Files
tun2socks/internal/adapter/adapter.go
xjasonlyu e1e96c8cfb v2
2020-11-05 18:41:15 +08:00

32 lines
803 B
Go

package adapter
import "net"
type TCPConn interface {
net.Conn
Metadata() *Metadata
}
type UDPPacket interface {
// Data get the payload of UDP Packet.
Data() []byte
// Drop call after packet is used, could release resources in this function.
Drop()
// LocalAddr returns the source IP/Port of packet.
LocalAddr() net.Addr
// Metadata returns the metadata of packet.
Metadata() *Metadata
// RemoteAddr returns the destination IP/Port of packet.
RemoteAddr() net.Addr
// WriteBack writes the payload with source IP/Port equals addr
// - variable source IP/Port is important to STUN
// - if addr is not provided, WriteBack will write out UDP packet with SourceIP/Port equals to original Target,
// this is important when using Fake-IP.
WriteBack([]byte, net.Addr) (int, error)
}