proxy.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. type InboundHandlerMeta struct {
  14. Tag string
  15. Address v2net.Address
  16. Port v2net.Port
  17. //Whether this proxy support KCP connections
  18. KcpSupported bool
  19. }
  20. type OutboundHandlerMeta struct {
  21. Tag string
  22. Address v2net.Address
  23. //Whether this proxy support KCP connections
  24. KcpSupported bool
  25. }
  26. // An InboundHandler handles inbound network connections to V2Ray.
  27. type InboundHandler interface {
  28. // Listen starts a InboundHandler.
  29. Start() error
  30. // Close stops the handler to accepting anymore inbound connections.
  31. Close()
  32. // Port returns the port that the handler is listening on.
  33. Port() v2net.Port
  34. }
  35. // An OutboundHandler handles outbound network connection for V2Ray.
  36. type OutboundHandler interface {
  37. // Dispatch sends one or more Packets to its destination.
  38. Dispatch(destination v2net.Destination, payload *alloc.Buffer, ray ray.OutboundRay) error
  39. }