proxy.go 1.1 KB

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