outbound.go 626 B

12345678910111213141516171819202122232425
  1. package adapter
  2. import (
  3. "context"
  4. "net"
  5. tun "github.com/sagernet/sing-tun"
  6. N "github.com/sagernet/sing/common/network"
  7. )
  8. // Note: for proxy protocols, outbound creates early connections by default.
  9. type Outbound interface {
  10. Type() string
  11. Tag() string
  12. Network() []string
  13. N.Dialer
  14. NewConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
  15. NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
  16. }
  17. type IPOutbound interface {
  18. Outbound
  19. NewIPConnection(ctx context.Context, conn tun.RouteContext, metadata InboundContext) (tun.DirectDestination, error)
  20. }