mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-08 10:10:12 +08:00
32 lines
803 B
Go
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)
|
|
}
|