diff --git a/app/proxyman/config.go b/app/proxyman/config.go index 6a4140634..9c5ac6bdf 100644 --- a/app/proxyman/config.go +++ b/app/proxyman/config.go @@ -21,7 +21,7 @@ func (s *AllocationStrategy) GetRefreshValue() uint32 { return s.Refresh.Value } -func (c *OutboundHandlerConfig) GetProxyHandler(ctx context.Context) (proxy.OutboundHandler, error) { +func (c *OutboundHandlerConfig) GetProxyHandler(ctx context.Context) (proxy.Outbound, error) { if c == nil { return nil, errors.New("Proxyman: OutboundHandlerConfig is nil.") } diff --git a/app/proxyman/inbound/always.go b/app/proxyman/inbound/always.go index 8eace8529..34f1512c8 100644 --- a/app/proxyman/inbound/always.go +++ b/app/proxyman/inbound/always.go @@ -11,7 +11,7 @@ import ( ) type AlwaysOnInboundHandler struct { - proxy proxy.InboundHandler + proxy proxy.Inbound workers []worker } @@ -72,7 +72,7 @@ func (h *AlwaysOnInboundHandler) Close() { } } -func (h *AlwaysOnInboundHandler) GetRandomInboundProxy() (proxy.InboundHandler, net.Port, int) { +func (h *AlwaysOnInboundHandler) GetRandomInboundProxy() (proxy.Inbound, net.Port, int) { w := h.workers[dice.Roll(len(h.workers))] return w.Proxy(), w.Port(), 9999 } diff --git a/app/proxyman/inbound/dynamic.go b/app/proxyman/inbound/dynamic.go index 64c913968..47af6a625 100644 --- a/app/proxyman/inbound/dynamic.go +++ b/app/proxyman/inbound/dynamic.go @@ -136,7 +136,7 @@ func (h *DynamicInboundHandler) Close() { h.cancel() } -func (h *DynamicInboundHandler) GetRandomInboundProxy() (proxy.InboundHandler, v2net.Port, int) { +func (h *DynamicInboundHandler) GetRandomInboundProxy() (proxy.Inbound, v2net.Port, int) { w := h.worker[dice.Roll(len(h.worker))] expire := h.receiverConfig.AllocationStrategy.GetRefreshValue() - uint32(time.Since(h.lastRefresh)/time.Minute) return w.Proxy(), w.Port(), int(expire) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 1820554ae..892550fea 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -21,13 +21,13 @@ type worker interface { Start() error Close() Port() v2net.Port - Proxy() proxy.InboundHandler + Proxy() proxy.Inbound } type tcpWorker struct { address v2net.Address port v2net.Port - proxy proxy.InboundHandler + proxy proxy.Inbound stream *internet.StreamConfig recvOrigDest bool tag string @@ -56,7 +56,7 @@ func (w *tcpWorker) callback(conn internet.Connection) { conn.Close() } -func (w *tcpWorker) Proxy() proxy.InboundHandler { +func (w *tcpWorker) Proxy() proxy.Inbound { return w.proxy } @@ -148,7 +148,7 @@ func (*udpConn) SetReusable(bool) {} type udpWorker struct { sync.RWMutex - proxy proxy.InboundHandler + proxy proxy.Inbound hub *udp.Hub address v2net.Address port v2net.Port @@ -264,6 +264,6 @@ func (w *udpWorker) Port() v2net.Port { return w.port } -func (w *udpWorker) Proxy() proxy.InboundHandler { +func (w *udpWorker) Proxy() proxy.Inbound { return w.proxy } diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 3caca46fc..625d1c908 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -20,7 +20,7 @@ import ( type Handler struct { config *proxyman.OutboundHandlerConfig senderSettings *proxyman.SenderConfig - proxy proxy.OutboundHandler + proxy proxy.Outbound outboundManager proxyman.OutboundHandlerManager } diff --git a/app/proxyman/proxyman.go b/app/proxyman/proxyman.go index f6dde91d0..b323d404f 100644 --- a/app/proxyman/proxyman.go +++ b/app/proxyman/proxyman.go @@ -22,7 +22,7 @@ type InboundHandler interface { Close() // For migration - GetRandomInboundProxy() (proxy.InboundHandler, net.Port, int) + GetRandomInboundProxy() (proxy.Inbound, net.Port, int) } type OutboundHandlerManager interface { diff --git a/proxy/handler_cache.go b/proxy/handler_cache.go index 5c4bc1552..3878332b3 100644 --- a/proxy/handler_cache.go +++ b/proxy/handler_cache.go @@ -7,26 +7,26 @@ import ( "v2ray.com/core/common/errors" ) -func CreateInboundHandler(ctx context.Context, config interface{}) (InboundHandler, error) { +func CreateInboundHandler(ctx context.Context, config interface{}) (Inbound, error) { handler, err := common.CreateObject(ctx, config) if err != nil { return nil, err } switch h := handler.(type) { - case InboundHandler: + case Inbound: return h, nil default: return nil, errors.New("Proxy: Not a InboundHandler.") } } -func CreateOutboundHandler(ctx context.Context, config interface{}) (OutboundHandler, error) { +func CreateOutboundHandler(ctx context.Context, config interface{}) (Outbound, error) { handler, err := common.CreateObject(ctx, config) if err != nil { return nil, err } switch h := handler.(type) { - case OutboundHandler: + case Outbound: return h, nil default: return nil, errors.New("Proxy: Not a OutboundHandler.") diff --git a/proxy/proxy.go b/proxy/proxy.go index 71c226760..ddcea305e 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -9,15 +9,15 @@ import ( "v2ray.com/core/transport/ray" ) -// An InboundHandler handles inbound network connections to V2Ray. -type InboundHandler interface { +// An Inbound processes inbound connections. +type Inbound interface { Network() net.NetworkList Process(context.Context, net.Network, internet.Connection) error } -// An OutboundHandler handles outbound network connection for V2Ray. -type OutboundHandler interface { +// An Outbound process outbound connections. +type Outbound interface { Process(context.Context, ray.OutboundRay) error }