proxy.go 1.6 KB

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