proxy.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Package proxy contains all proxies used by V2Ray.
  2. //
  3. // To implement an inbound or outbound proxy, one needs to do the following:
  4. // 1. Implement the interface(s) below.
  5. // 2. Register a config creator through common.RegisterConfig.
  6. package proxy
  7. import (
  8. "context"
  9. "v2ray.com/core/app/dispatcher"
  10. "v2ray.com/core/common/net"
  11. "v2ray.com/core/transport/internet"
  12. "v2ray.com/core/transport/ray"
  13. )
  14. // An Inbound processes inbound connections.
  15. type Inbound interface {
  16. // Network returns a list of network that this inbound supports. Connections with not-supported networks will not be passed into Process().
  17. Network() net.NetworkList
  18. // Process processes a connection of given network. If necessary, the Inbound can dispatch the connection to an Outbound.
  19. Process(context.Context, net.Network, internet.Connection, dispatcher.Interface) error
  20. }
  21. // An Outbound process outbound connections.
  22. type Outbound interface {
  23. // Process processes the given connection. The given dialer may be used to dial a system outbound connection.
  24. Process(context.Context, ray.OutboundRay, Dialer) error
  25. }
  26. // Dialer is used by OutboundHandler for creating outbound connections.
  27. type Dialer interface {
  28. // Dial dials a system connection to the given destination.
  29. Dial(ctx context.Context, destination net.Destination) (internet.Connection, error)
  30. }