proxy.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/internet"
  7. "github.com/v2ray/v2ray-core/transport/ray"
  8. )
  9. type HandlerState int
  10. const (
  11. HandlerStateStopped = HandlerState(0)
  12. HandlerStateRunning = HandlerState(1)
  13. )
  14. type InboundHandlerMeta struct {
  15. Tag string
  16. Address v2net.Address
  17. Port v2net.Port
  18. StreamSettings *internet.StreamSettings
  19. }
  20. type OutboundHandlerMeta struct {
  21. Tag string
  22. Address v2net.Address
  23. StreamSettings *internet.StreamSettings
  24. }
  25. // An InboundHandler handles inbound network connections to V2Ray.
  26. type InboundHandler interface {
  27. // Listen starts a InboundHandler.
  28. Start() error
  29. // Close stops the handler to accepting anymore inbound connections.
  30. Close()
  31. // Port returns the port that the handler is listening on.
  32. Port() v2net.Port
  33. }
  34. // An OutboundHandler handles outbound network connection for V2Ray.
  35. type OutboundHandler interface {
  36. // Dispatch sends one or more Packets to its destination.
  37. Dispatch(destination v2net.Destination, payload *alloc.Buffer, ray ray.OutboundRay) error
  38. }