2021-08-01 00:35:37 +08:00
|
|
|
package constant
|
|
|
|
|
2022-11-11 22:44:44 +08:00
|
|
|
import "net"
|
|
|
|
|
2021-08-01 00:35:37 +08:00
|
|
|
type Listener interface {
|
|
|
|
RawAddress() string
|
|
|
|
Address() string
|
|
|
|
Close() error
|
|
|
|
}
|
2022-11-11 22:44:44 +08:00
|
|
|
|
|
|
|
type AdvanceListener interface {
|
|
|
|
Close()
|
|
|
|
Config() string
|
|
|
|
HandleConn(conn net.Conn, in chan<- ConnContext)
|
|
|
|
}
|
2022-12-04 13:37:14 +08:00
|
|
|
|
|
|
|
type NewListener interface {
|
|
|
|
Name() string
|
|
|
|
ReCreate(tcpIn chan<- ConnContext,udpIn chan<-*PacketAdapter) error
|
|
|
|
Close() error
|
|
|
|
Address() string
|
|
|
|
RawAddress() string
|
|
|
|
}
|
|
|
|
|
|
|
|
// PacketAdapter is a UDP Packet adapter for socks/redir/tun
|
|
|
|
type PacketAdapter struct {
|
|
|
|
UDPPacket
|
|
|
|
metadata *Metadata
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPacketAdapter(udppacket UDPPacket,metadata *Metadata)*PacketAdapter{
|
|
|
|
return &PacketAdapter{
|
|
|
|
udppacket,
|
|
|
|
metadata,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Metadata returns destination metadata
|
|
|
|
func (s *PacketAdapter) Metadata() *Metadata {
|
|
|
|
return s.metadata
|
|
|
|
}
|