proxy.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Package proxy contains all proxies used by V2Ray.
  2. package proxy
  3. import (
  4. "v2ray.com/core/common/alloc"
  5. v2net "v2ray.com/core/common/net"
  6. "v2ray.com/core/common/protocol"
  7. "v2ray.com/core/transport/internet"
  8. "v2ray.com/core/transport/ray"
  9. )
  10. type HandlerState int
  11. const (
  12. HandlerStateStopped = HandlerState(0)
  13. HandlerStateRunning = HandlerState(1)
  14. )
  15. type SessionInfo struct {
  16. Source v2net.Destination
  17. Destination v2net.Destination
  18. User *protocol.User
  19. }
  20. type InboundHandlerMeta struct {
  21. Tag string
  22. Address v2net.Address
  23. Port v2net.Port
  24. AllowPassiveConnection bool
  25. StreamSettings *internet.StreamConfig
  26. }
  27. type OutboundHandlerMeta struct {
  28. Tag string
  29. Address v2net.Address
  30. StreamSettings *internet.StreamConfig
  31. }
  32. // An InboundHandler handles inbound network connections to V2Ray.
  33. type InboundHandler interface {
  34. // Listen starts a InboundHandler.
  35. Start() error
  36. // Close stops the handler to accepting anymore inbound connections.
  37. Close()
  38. // Port returns the port that the handler is listening on.
  39. Port() v2net.Port
  40. }
  41. // An OutboundHandler handles outbound network connection for V2Ray.
  42. type OutboundHandler interface {
  43. // Dispatch sends one or more Packets to its destination.
  44. Dispatch(destination v2net.Destination, payload *alloc.Buffer, ray ray.OutboundRay) error
  45. }