proxy.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. Inbound *InboundHandlerMeta
  20. }
  21. type InboundHandlerMeta struct {
  22. Tag string
  23. Address v2net.Address
  24. Port v2net.Port
  25. AllowPassiveConnection bool
  26. StreamSettings *internet.StreamConfig
  27. }
  28. type OutboundHandlerMeta struct {
  29. Tag string
  30. Address v2net.Address
  31. StreamSettings *internet.StreamConfig
  32. ProxySettings *internet.ProxyConfig
  33. }
  34. func (this *OutboundHandlerMeta) GetDialerOptions() internet.DialerOptions {
  35. return internet.DialerOptions{
  36. Stream: this.StreamSettings,
  37. Proxy: this.ProxySettings,
  38. }
  39. }
  40. // An InboundHandler handles inbound network connections to V2Ray.
  41. type InboundHandler interface {
  42. // Listen starts a InboundHandler.
  43. Start() error
  44. // Close stops the handler to accepting anymore inbound connections.
  45. Close()
  46. // Port returns the port that the handler is listening on.
  47. Port() v2net.Port
  48. }
  49. // An OutboundHandler handles outbound network connection for V2Ray.
  50. type OutboundHandler interface {
  51. // Dispatch sends one or more Packets to its destination.
  52. Dispatch(destination v2net.Destination, payload *alloc.Buffer, ray ray.OutboundRay) error
  53. }