proxy.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. //go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg proxy -path Proxy
  8. import (
  9. "context"
  10. "v2ray.com/core/app/dispatcher"
  11. "v2ray.com/core/common/net"
  12. "v2ray.com/core/transport/internet"
  13. "v2ray.com/core/transport/ray"
  14. )
  15. // An Inbound processes inbound connections.
  16. type Inbound interface {
  17. // Network returns a list of network that this inbound supports. Connections with not-supported networks will not be passed into Process().
  18. Network() net.NetworkList
  19. // Process processes a connection of given network. If necessary, the Inbound can dispatch the connection to an Outbound.
  20. Process(context.Context, net.Network, internet.Connection, dispatcher.Interface) error
  21. }
  22. // An Outbound process outbound connections.
  23. type Outbound interface {
  24. // Process processes the given connection. The given dialer may be used to dial a system outbound connection.
  25. Process(context.Context, ray.OutboundRay, Dialer) error
  26. }
  27. // Dialer is used by OutboundHandler for creating outbound connections.
  28. type Dialer interface {
  29. // Dial dials a system connection to the given destination.
  30. Dial(ctx context.Context, destination net.Destination) (internet.Connection, error)
  31. }