context.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package routing
  2. import (
  3. "github.com/xtls/xray-core/common/net"
  4. )
  5. // Context is a feature to store connection information for routing.
  6. //
  7. // xray:api:stable
  8. type Context interface {
  9. // GetInboundTag returns the tag of the inbound the connection was from.
  10. GetInboundTag() string
  11. // GetSourcesIPs returns the source IPs bound to the connection.
  12. GetSourceIPs() []net.IP
  13. // GetSourcePort returns the source port of the connection.
  14. GetSourcePort() net.Port
  15. // GetTargetIPs returns the target IP of the connection or resolved IPs of target domain.
  16. GetTargetIPs() []net.IP
  17. // GetTargetPort returns the target port of the connection.
  18. GetTargetPort() net.Port
  19. // GetTargetDomain returns the target domain of the connection, if exists.
  20. GetTargetDomain() string
  21. // GetNetwork returns the network type of the connection.
  22. GetNetwork() net.Network
  23. // GetProtocol returns the protocol from the connection content, if sniffed out.
  24. GetProtocol() string
  25. // GetUser returns the user email from the connection content, if exists.
  26. GetUser() string
  27. // GetAttributes returns extra attributes from the conneciont content.
  28. GetAttributes() map[string]string
  29. // GetSkipDNSResolve returns a flag switch for weather skip dns resolve during route pick.
  30. GetSkipDNSResolve() bool
  31. }