proxy.go 985 B

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