github.com/inazumav/sing-box@v0.0.0-20230926072359-ab51429a14f1/adapter/handler.go (about) 1 package adapter 2 3 import ( 4 "context" 5 "net" 6 7 "github.com/sagernet/sing/common/buf" 8 E "github.com/sagernet/sing/common/exceptions" 9 N "github.com/sagernet/sing/common/network" 10 ) 11 12 type ConnectionHandler interface { 13 NewConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error 14 } 15 16 type PacketHandler interface { 17 NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, metadata InboundContext) error 18 } 19 20 type OOBPacketHandler interface { 21 NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, oob []byte, metadata InboundContext) error 22 } 23 24 type PacketConnectionHandler interface { 25 NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error 26 } 27 28 type UpstreamHandlerAdapter interface { 29 N.TCPConnectionHandler 30 N.UDPConnectionHandler 31 E.Handler 32 }