proxy.go 913 B

123456789101112131415161718192021222324252627282930
  1. // Package proxy contains all proxies used by V2Ray.
  2. package proxy // import "github.com/v2ray/v2ray-core/proxy"
  3. import (
  4. v2net "github.com/v2ray/v2ray-core/common/net"
  5. "github.com/v2ray/v2ray-core/transport/ray"
  6. )
  7. type HandlerState int
  8. const (
  9. HandlerStateStopped = HandlerState(0)
  10. HandlerStateRunning = HandlerState(1)
  11. )
  12. // An InboundHandler handles inbound network connections to V2Ray.
  13. type InboundHandler interface {
  14. // Listen starts a InboundHandler by listen on a specific port.
  15. Listen(port v2net.Port) error
  16. // Close stops the handler to accepting anymore inbound connections.
  17. Close()
  18. // Port returns the port that the handler is listening on.
  19. Port() v2net.Port
  20. }
  21. // An OutboundHandler handles outbound network connection for V2Ray.
  22. type OutboundHandler interface {
  23. // Dispatch sends one or more Packets to its destination.
  24. Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error
  25. }