From 26ebd8dde91fd48befdb7a611f2e890c533542f7 Mon Sep 17 00:00:00 2001 From: v2ray Date: Tue, 26 Apr 2016 00:35:42 +0200 Subject: [PATCH] refactor --- proxy/socks/server.go | 14 ++++++++++++++ proxy/socks/{udp.go => server_udp.go} | 0 proxy/socks/socksfactory.go | 20 -------------------- 3 files changed, 14 insertions(+), 20 deletions(-) rename proxy/socks/{udp.go => server_udp.go} (100%) delete mode 100644 proxy/socks/socksfactory.go diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 2fa38e95a..26657d4d9 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -6,11 +6,13 @@ import ( "sync" "time" + "github.com/v2ray/v2ray-core/app" "github.com/v2ray/v2ray-core/app/dispatcher" v2io "github.com/v2ray/v2ray-core/common/io" "github.com/v2ray/v2ray-core/common/log" v2net "github.com/v2ray/v2ray-core/common/net" "github.com/v2ray/v2ray-core/proxy" + "github.com/v2ray/v2ray-core/proxy/internal" "github.com/v2ray/v2ray-core/proxy/socks/protocol" "github.com/v2ray/v2ray-core/transport/hub" ) @@ -292,3 +294,15 @@ func (this *Server) transport(reader io.Reader, writer io.Writer, destination v2 }() outputFinish.Lock() } + +func init() { + internal.MustRegisterInboundHandlerCreator("socks", + func(space app.Space, rawConfig interface{}) (proxy.InboundHandler, error) { + if !space.HasApp(dispatcher.APP_ID) { + return nil, internal.ErrorBadConfiguration + } + return NewServer( + rawConfig.(*Config), + space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher)), nil + }) +} diff --git a/proxy/socks/udp.go b/proxy/socks/server_udp.go similarity index 100% rename from proxy/socks/udp.go rename to proxy/socks/server_udp.go diff --git a/proxy/socks/socksfactory.go b/proxy/socks/socksfactory.go deleted file mode 100644 index 8aab84152..000000000 --- a/proxy/socks/socksfactory.go +++ /dev/null @@ -1,20 +0,0 @@ -package socks - -import ( - "github.com/v2ray/v2ray-core/app" - "github.com/v2ray/v2ray-core/app/dispatcher" - "github.com/v2ray/v2ray-core/proxy" - "github.com/v2ray/v2ray-core/proxy/internal" -) - -func init() { - internal.MustRegisterInboundHandlerCreator("socks", - func(space app.Space, rawConfig interface{}) (proxy.InboundHandler, error) { - if !space.HasApp(dispatcher.APP_ID) { - return nil, internal.ErrorBadConfiguration - } - return NewServer( - rawConfig.(*Config), - space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher)), nil - }) -}