Improve: UDP relay refactor (#441)
Co-authored-by: Dreamacro <Dreamacro@vip.qq.com>
This commit is contained in:
@ -109,3 +109,21 @@ func (at AdapterType) String() string {
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// UDPPacket contains the data of UDP packet, and offers control/info of UDP packet's source
|
||||
type UDPPacket interface {
|
||||
// Data get the payload of UDP Packet
|
||||
Data() []byte
|
||||
|
||||
// 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 wirte out UDP packet with SourceIP/Prot equals to origional Target,
|
||||
// this is important when using Fake-IP.
|
||||
WriteBack(b []byte, addr net.Addr) (n int, err error)
|
||||
|
||||
// Close closes the underlaying connection.
|
||||
Close() error
|
||||
|
||||
// LocalAddr returns the source IP/Port of packet
|
||||
LocalAddr() net.Addr
|
||||
}
|
||||
|
Reference in New Issue
Block a user