proxy.go 1.3 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/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. AllowPassiveConnection bool
  19. StreamSettings *internet.StreamSettings
  20. }
  21. type OutboundHandlerMeta struct {
  22. Tag string
  23. Address v2net.Address
  24. StreamSettings *internet.StreamSettings
  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. }