sing-box/adapter/handler.go

62 lines
1.6 KiB
Go
Raw Normal View History

2022-07-01 19:34:02 +08:00
package adapter
import (
"context"
"net"
"github.com/sagernet/sing/common/buf"
E "github.com/sagernet/sing/common/exceptions"
2024-10-21 23:38:34 +08:00
M "github.com/sagernet/sing/common/metadata"
2022-07-01 19:34:02 +08:00
N "github.com/sagernet/sing/common/network"
)
2024-10-21 23:38:34 +08:00
// Deprecated
2022-07-05 13:23:47 +08:00
type ConnectionHandler interface {
NewConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
2022-07-01 19:34:02 +08:00
}
2024-10-21 23:38:34 +08:00
type ConnectionHandlerEx interface {
NewConnectionEx(ctx context.Context, conn net.Conn, metadata InboundContext, onClose N.CloseHandlerFunc)
}
// Deprecated: use PacketHandlerEx instead
2022-07-05 13:23:47 +08:00
type PacketHandler interface {
NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, metadata InboundContext) error
2022-07-01 19:34:02 +08:00
}
2024-10-21 23:38:34 +08:00
type PacketHandlerEx interface {
NewPacketEx(buffer *buf.Buffer, source M.Socksaddr)
}
// Deprecated: use OOBPacketHandlerEx instead
2022-07-15 08:42:02 +08:00
type OOBPacketHandler interface {
NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, oob []byte, metadata InboundContext) error
}
2024-10-21 23:38:34 +08:00
type OOBPacketHandlerEx interface {
NewPacketEx(buffer *buf.Buffer, oob []byte, source M.Socksaddr)
}
// Deprecated
2022-07-05 13:23:47 +08:00
type PacketConnectionHandler interface {
NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
2022-07-01 19:34:02 +08:00
}
2024-10-21 23:38:34 +08:00
type PacketConnectionHandlerEx interface {
NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, metadata InboundContext, onClose N.CloseHandlerFunc)
}
2024-11-23 22:34:02 +08:00
// Deprecated: use TCPConnectionHandlerEx instead
//
//nolint:staticcheck
2022-07-05 13:23:47 +08:00
type UpstreamHandlerAdapter interface {
N.TCPConnectionHandler
N.UDPConnectionHandler
E.Handler
2022-07-01 19:34:02 +08:00
}
2024-10-21 23:38:34 +08:00
type UpstreamHandlerAdapterEx interface {
N.TCPConnectionHandlerEx
N.UDPConnectionHandlerEx
}