From 838f2919ab16d539861b8ad4e7dd3c1060c0f39b Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Tue, 23 Oct 2018 12:21:12 +0200 Subject: [PATCH] move mux to common --- app/proxyman/inbound/always.go | 2 +- app/proxyman/inbound/dynamic.go | 2 +- app/proxyman/outbound/handler.go | 4 ++-- .../mux/errors.generated.go | 0 {app/proxyman => common}/mux/frame.go | 0 {app/proxyman => common}/mux/mux.go | 21 +++++++++---------- {app/proxyman => common}/mux/mux_test.go | 2 +- {app/proxyman => common}/mux/reader.go | 0 {app/proxyman => common}/mux/session.go | 0 {app/proxyman => common}/mux/session_test.go | 2 +- {app/proxyman => common}/mux/writer.go | 0 11 files changed, 16 insertions(+), 17 deletions(-) rename {app/proxyman => common}/mux/errors.generated.go (100%) rename {app/proxyman => common}/mux/frame.go (100%) rename {app/proxyman => common}/mux/mux.go (97%) rename {app/proxyman => common}/mux/mux_test.go (99%) rename {app/proxyman => common}/mux/reader.go (100%) rename {app/proxyman => common}/mux/session.go (100%) rename {app/proxyman => common}/mux/session_test.go (94%) rename {app/proxyman => common}/mux/writer.go (100%) diff --git a/app/proxyman/inbound/always.go b/app/proxyman/inbound/always.go index 1ee2371c..67d5ec54 100644 --- a/app/proxyman/inbound/always.go +++ b/app/proxyman/inbound/always.go @@ -5,9 +5,9 @@ import ( "v2ray.com/core" "v2ray.com/core/app/proxyman" - "v2ray.com/core/app/proxyman/mux" "v2ray.com/core/common" "v2ray.com/core/common/dice" + "v2ray.com/core/common/mux" "v2ray.com/core/common/net" "v2ray.com/core/common/serial" "v2ray.com/core/features/policy" diff --git a/app/proxyman/inbound/dynamic.go b/app/proxyman/inbound/dynamic.go index 1ff48872..6941c77d 100644 --- a/app/proxyman/inbound/dynamic.go +++ b/app/proxyman/inbound/dynamic.go @@ -7,8 +7,8 @@ import ( "v2ray.com/core" "v2ray.com/core/app/proxyman" - "v2ray.com/core/app/proxyman/mux" "v2ray.com/core/common/dice" + "v2ray.com/core/common/mux" "v2ray.com/core/common/net" "v2ray.com/core/common/task" "v2ray.com/core/proxy" diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 58d21c59..bdbc4f21 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -5,8 +5,8 @@ import ( "v2ray.com/core" "v2ray.com/core/app/proxyman" - "v2ray.com/core/app/proxyman/mux" "v2ray.com/core/common" + "v2ray.com/core/common/mux" "v2ray.com/core/common/net" "v2ray.com/core/common/session" "v2ray.com/core/common/vio" @@ -72,7 +72,7 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbou if config.Concurrency < 1 || config.Concurrency > 1024 { return nil, newError("invalid mux concurrency: ", config.Concurrency).AtWarning() } - h.mux = mux.NewClientManager(proxyHandler, h, config) + h.mux = mux.NewClientManager(proxyHandler, h, config.Concurrency) } h.proxy = proxyHandler diff --git a/app/proxyman/mux/errors.generated.go b/common/mux/errors.generated.go similarity index 100% rename from app/proxyman/mux/errors.generated.go rename to common/mux/errors.generated.go diff --git a/app/proxyman/mux/frame.go b/common/mux/frame.go similarity index 100% rename from app/proxyman/mux/frame.go rename to common/mux/frame.go diff --git a/app/proxyman/mux/mux.go b/common/mux/mux.go similarity index 97% rename from app/proxyman/mux/mux.go rename to common/mux/mux.go index 6c595754..59440877 100644 --- a/app/proxyman/mux/mux.go +++ b/common/mux/mux.go @@ -9,7 +9,6 @@ import ( "time" "v2ray.com/core" - "v2ray.com/core/app/proxyman" "v2ray.com/core/common" "v2ray.com/core/common/buf" "v2ray.com/core/common/errors" @@ -30,18 +29,18 @@ const ( ) type ClientManager struct { - access sync.Mutex - clients []*Client - proxy proxy.Outbound - dialer internet.Dialer - config *proxyman.MultiplexingConfig + access sync.Mutex + clients []*Client + proxy proxy.Outbound + dialer internet.Dialer + concurrency uint32 } -func NewClientManager(p proxy.Outbound, d internet.Dialer, c *proxyman.MultiplexingConfig) *ClientManager { +func NewClientManager(p proxy.Outbound, d internet.Dialer, c uint32) *ClientManager { return &ClientManager{ - proxy: p, - dialer: d, - config: c, + proxy: p, + dialer: d, + concurrency: c, } } @@ -108,7 +107,7 @@ func NewClient(pctx context.Context, p proxy.Outbound, dialer internet.Dialer, m }, done: done.New(), manager: m, - concurrency: m.config.Concurrency, + concurrency: m.concurrency, } go func() { diff --git a/app/proxyman/mux/mux_test.go b/common/mux/mux_test.go similarity index 99% rename from app/proxyman/mux/mux_test.go rename to common/mux/mux_test.go index 1c96298c..43918908 100644 --- a/app/proxyman/mux/mux_test.go +++ b/common/mux/mux_test.go @@ -4,8 +4,8 @@ import ( "io" "testing" - . "v2ray.com/core/app/proxyman/mux" "v2ray.com/core/common/buf" + . "v2ray.com/core/common/mux" "v2ray.com/core/common/net" "v2ray.com/core/common/protocol" "v2ray.com/core/transport/pipe" diff --git a/app/proxyman/mux/reader.go b/common/mux/reader.go similarity index 100% rename from app/proxyman/mux/reader.go rename to common/mux/reader.go diff --git a/app/proxyman/mux/session.go b/common/mux/session.go similarity index 100% rename from app/proxyman/mux/session.go rename to common/mux/session.go diff --git a/app/proxyman/mux/session_test.go b/common/mux/session_test.go similarity index 94% rename from app/proxyman/mux/session_test.go rename to common/mux/session_test.go index 4acffd8f..01557e12 100644 --- a/app/proxyman/mux/session_test.go +++ b/common/mux/session_test.go @@ -3,7 +3,7 @@ package mux_test import ( "testing" - . "v2ray.com/core/app/proxyman/mux" + . "v2ray.com/core/common/mux" . "v2ray.com/ext/assert" ) diff --git a/app/proxyman/mux/writer.go b/common/mux/writer.go similarity index 100% rename from app/proxyman/mux/writer.go rename to common/mux/writer.go