github.com/igoogolx/clash@v1.19.8/listener/tunnel/packet.go (about) 1 package tunnel 2 3 import ( 4 "net" 5 6 "github.com/igoogolx/clash/common/pool" 7 ) 8 9 type packet struct { 10 pc net.PacketConn 11 rAddr net.Addr 12 payload []byte 13 } 14 15 func (c *packet) Data() []byte { 16 return c.payload 17 } 18 19 // WriteBack write UDP packet with source(ip, port) = `addr` 20 func (c *packet) WriteBack(b []byte, addr net.Addr) (n int, err error) { 21 return c.pc.WriteTo(b, c.rAddr) 22 } 23 24 // LocalAddr returns the source IP/Port of UDP Packet 25 func (c *packet) LocalAddr() net.Addr { 26 return c.rAddr 27 } 28 29 func (c *packet) Drop() { 30 pool.Put(c.payload) 31 }