github.com/kelleygo/clashcore@v1.0.2/common/net/packet/ref_sing.go (about) 1 package packet 2 3 import ( 4 "runtime" 5 6 "github.com/sagernet/sing/common/buf" 7 M "github.com/sagernet/sing/common/metadata" 8 N "github.com/sagernet/sing/common/network" 9 ) 10 11 type refSingPacketConn struct { 12 *refPacketConn 13 singPacketConn SingPacketConn 14 } 15 16 var _ N.NetPacketConn = (*refSingPacketConn)(nil) 17 18 func (c *refSingPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error { 19 defer runtime.KeepAlive(c.ref) 20 return c.singPacketConn.WritePacket(buffer, destination) 21 } 22 23 func (c *refSingPacketConn) ReadPacket(buffer *buf.Buffer) (destination M.Socksaddr, err error) { 24 defer runtime.KeepAlive(c.ref) 25 return c.singPacketConn.ReadPacket(buffer) 26 }