outbound.go 981 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package adapter
  2. import (
  3. "context"
  4. "net/netip"
  5. "github.com/sagernet/sing-box/log"
  6. "github.com/sagernet/sing-box/option"
  7. N "github.com/sagernet/sing/common/network"
  8. )
  9. // Note: for proxy protocols, outbound creates early connections by default.
  10. type Outbound interface {
  11. Type() string
  12. Tag() string
  13. Network() []string
  14. Dependencies() []string
  15. N.Dialer
  16. }
  17. type OutboundWithPreferredRoutes interface {
  18. PreferredDomain(domain string) bool
  19. PreferredAddress(address netip.Addr) bool
  20. }
  21. type OutboundRegistry interface {
  22. option.OutboundOptionsRegistry
  23. CreateOutbound(ctx context.Context, router Router, logger log.ContextLogger, tag string, outboundType string, options any) (Outbound, error)
  24. }
  25. type OutboundManager interface {
  26. Lifecycle
  27. Outbounds() []Outbound
  28. Outbound(tag string) (Outbound, bool)
  29. Default() Outbound
  30. Remove(tag string) error
  31. Create(ctx context.Context, router Router, logger log.ContextLogger, tag string, outboundType string, options any) error
  32. }