router.go 631 B

12345678910111213141516171819202122232425262728
  1. package adapter
  2. import (
  3. "context"
  4. "net"
  5. N "github.com/sagernet/sing/common/network"
  6. "github.com/sagernet/sing-box/common/geoip"
  7. "github.com/sagernet/sing-box/common/geosite"
  8. )
  9. type Router interface {
  10. Service
  11. Outbound(tag string) (Outbound, bool)
  12. RouteConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
  13. RoutePacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
  14. GeoIPReader() *geoip.Reader
  15. GeositeReader() *geosite.Reader
  16. }
  17. type Rule interface {
  18. Service
  19. UpdateGeosite() error
  20. Match(metadata *InboundContext) bool
  21. Outbound() string
  22. String() string
  23. }