2022-07-01 11:34:02 +00:00
|
|
|
package adapter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/sagernet/sing/common/buf"
|
|
|
|
E "github.com/sagernet/sing/common/exceptions"
|
|
|
|
N "github.com/sagernet/sing/common/network"
|
|
|
|
)
|
|
|
|
|
2022-07-05 05:23:47 +00:00
|
|
|
type ConnectionHandler interface {
|
|
|
|
NewConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
|
2022-07-01 11:34:02 +00:00
|
|
|
}
|
|
|
|
|
2022-07-05 05:23:47 +00:00
|
|
|
type PacketHandler interface {
|
|
|
|
NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, metadata InboundContext) error
|
2022-07-01 11:34:02 +00:00
|
|
|
}
|
|
|
|
|
2022-07-15 00:42:02 +00:00
|
|
|
type OOBPacketHandler interface {
|
|
|
|
NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, oob []byte, metadata InboundContext) error
|
|
|
|
}
|
|
|
|
|
2022-07-05 05:23:47 +00:00
|
|
|
type PacketConnectionHandler interface {
|
|
|
|
NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
|
2022-07-01 11:34:02 +00:00
|
|
|
}
|
|
|
|
|
2022-07-05 05:23:47 +00:00
|
|
|
type UpstreamHandlerAdapter interface {
|
|
|
|
N.TCPConnectionHandler
|
|
|
|
N.UDPConnectionHandler
|
|
|
|
E.Handler
|
2022-07-01 11:34:02 +00:00
|
|
|
}
|