From 0780db79995bc790f10d266ab9e632518f3dd321 Mon Sep 17 00:00:00 2001 From: v2ray Date: Sat, 2 Jan 2016 23:32:18 +0100 Subject: [PATCH] move connhandler to proxy --- app/handlers.go | 4 ++-- app/internal/handlers.go | 6 +++--- proxy/blackhole/blackhole.go | 4 ++-- proxy/common/connhandler/inbound_connection.go | 12 ------------ .../common/connhandler/outbound_connection.go | 12 ------------ proxy/dokodemo/dokodemo_factory.go | 4 ++-- proxy/freedom/freedom_test.go | 4 ++-- proxy/freedom/freedomfactory.go | 4 ++-- proxy/http/http_factory.go | 4 ++-- proxy/internal/creator.go | 6 +++--- proxy/internal/handler_cache.go | 6 +++--- proxy/proxy.go | 18 +++++++++++------- proxy/repo/repo.go | 15 +++++++++++++++ proxy/socks/socks_test.go | 12 ++++++------ proxy/socks/socksfactory.go | 4 ++-- proxy/testing/mocks/outboundhandler.go | 4 ++-- proxy/vmess/inbound/inbound.go | 4 ++-- proxy/vmess/outbound/outbound.go | 6 +++--- proxy/vmess/vmess_test.go | 6 +++--- shell/point/inbound_detour.go | 6 +++--- shell/point/point.go | 16 ++++++++-------- 21 files changed, 76 insertions(+), 81 deletions(-) delete mode 100644 proxy/common/connhandler/inbound_connection.go delete mode 100644 proxy/common/connhandler/outbound_connection.go create mode 100644 proxy/repo/repo.go diff --git a/app/handlers.go b/app/handlers.go index e6baa4a9d..9a3d14add 100644 --- a/app/handlers.go +++ b/app/handlers.go @@ -1,9 +1,9 @@ package app import ( - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" ) type InboundHandlerManager interface { - GetHandler(tag string) (connhandler.InboundConnectionHandler, int) + GetHandler(tag string) (proxy.InboundConnectionHandler, int) } diff --git a/app/internal/handlers.go b/app/internal/handlers.go index c1e60e5e5..ae0812694 100644 --- a/app/internal/handlers.go +++ b/app/internal/handlers.go @@ -2,11 +2,11 @@ package internal import ( "github.com/v2ray/v2ray-core/app" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" ) type InboundHandlerManagerWithContext interface { - GetHandler(context app.Context, tag string) (connhandler.InboundConnectionHandler, int) + GetHandler(context app.Context, tag string) (proxy.InboundConnectionHandler, int) } type inboundHandlerManagerWithContext struct { @@ -14,6 +14,6 @@ type inboundHandlerManagerWithContext struct { manager InboundHandlerManagerWithContext } -func (this *inboundHandlerManagerWithContext) GetHandler(tag string) (connhandler.InboundConnectionHandler, int) { +func (this *inboundHandlerManagerWithContext) GetHandler(tag string) (proxy.InboundConnectionHandler, int) { return this.manager.GetHandler(this.context, tag) } diff --git a/proxy/blackhole/blackhole.go b/proxy/blackhole/blackhole.go index f753c59c7..a5c0483e3 100644 --- a/proxy/blackhole/blackhole.go +++ b/proxy/blackhole/blackhole.go @@ -5,7 +5,7 @@ import ( "github.com/v2ray/v2ray-core/app" v2net "github.com/v2ray/v2ray-core/common/net" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy/internal" "github.com/v2ray/v2ray-core/transport/ray" ) @@ -31,7 +31,7 @@ func (this *BlackHole) Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) e } func init() { - if err := internal.RegisterOutboundConnectionHandlerFactory("blackhole", func(space app.Space, config interface{}) (connhandler.OutboundConnectionHandler, error) { + if err := internal.RegisterOutboundConnectionHandlerFactory("blackhole", func(space app.Space, config interface{}) (proxy.OutboundConnectionHandler, error) { return NewBlackHole(), nil }); err != nil { panic(err) diff --git a/proxy/common/connhandler/inbound_connection.go b/proxy/common/connhandler/inbound_connection.go deleted file mode 100644 index 99ffc0fe4..000000000 --- a/proxy/common/connhandler/inbound_connection.go +++ /dev/null @@ -1,12 +0,0 @@ -package connhandler - -import ( - v2net "github.com/v2ray/v2ray-core/common/net" -) - -// A InboundConnectionHandler handles inbound network connections to V2Ray. -type InboundConnectionHandler interface { - // Listen starts a InboundConnectionHandler by listen on a specific port. This method is called - // exactly once during runtime. - Listen(port v2net.Port) error -} diff --git a/proxy/common/connhandler/outbound_connection.go b/proxy/common/connhandler/outbound_connection.go deleted file mode 100644 index 88ca5eff0..000000000 --- a/proxy/common/connhandler/outbound_connection.go +++ /dev/null @@ -1,12 +0,0 @@ -package connhandler - -import ( - v2net "github.com/v2ray/v2ray-core/common/net" - "github.com/v2ray/v2ray-core/transport/ray" -) - -// An OutboundConnectionHandler handles outbound network connection for V2Ray. -type OutboundConnectionHandler interface { - // Dispatch sends one or more Packets to its destination. - Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error -} diff --git a/proxy/dokodemo/dokodemo_factory.go b/proxy/dokodemo/dokodemo_factory.go index b352e3567..32c8426f8 100644 --- a/proxy/dokodemo/dokodemo_factory.go +++ b/proxy/dokodemo/dokodemo_factory.go @@ -2,12 +2,12 @@ package dokodemo import ( "github.com/v2ray/v2ray-core/app" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy/internal" ) func init() { - if err := internal.RegisterInboundConnectionHandlerFactory("dokodemo-door", func(space app.Space, rawConfig interface{}) (connhandler.InboundConnectionHandler, error) { + if err := internal.RegisterInboundConnectionHandlerFactory("dokodemo-door", func(space app.Space, rawConfig interface{}) (proxy.InboundConnectionHandler, error) { config := rawConfig.(Config) return NewDokodemoDoor(space, config), nil }); err != nil { diff --git a/proxy/freedom/freedom_test.go b/proxy/freedom/freedom_test.go index aaee2169d..47081ab68 100644 --- a/proxy/freedom/freedom_test.go +++ b/proxy/freedom/freedom_test.go @@ -12,7 +12,7 @@ import ( "github.com/v2ray/v2ray-core/common/alloc" v2net "github.com/v2ray/v2ray-core/common/net" v2nettesting "github.com/v2ray/v2ray-core/common/net/testing" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + v2proxy "github.com/v2ray/v2ray-core/proxy" _ "github.com/v2ray/v2ray-core/proxy/socks" _ "github.com/v2ray/v2ray-core/proxy/socks/json" proxytesting "github.com/v2ray/v2ray-core/proxy/testing" @@ -49,7 +49,7 @@ func TestUDPSend(t *testing.T) { ConnOutput: connOutput, } - protocol, err := proxytesting.RegisterInboundConnectionHandlerCreator("mock_ich", func(space app.Space, config interface{}) (connhandler.InboundConnectionHandler, error) { + protocol, err := proxytesting.RegisterInboundConnectionHandlerCreator("mock_ich", func(space app.Space, config interface{}) (v2proxy.InboundConnectionHandler, error) { ich.Space = space return ich, nil }) diff --git a/proxy/freedom/freedomfactory.go b/proxy/freedom/freedomfactory.go index 1f1843bfc..d44464604 100644 --- a/proxy/freedom/freedomfactory.go +++ b/proxy/freedom/freedomfactory.go @@ -2,12 +2,12 @@ package freedom import ( "github.com/v2ray/v2ray-core/app" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy/internal" ) func init() { - if err := internal.RegisterOutboundConnectionHandlerFactory("freedom", func(space app.Space, config interface{}) (connhandler.OutboundConnectionHandler, error) { + if err := internal.RegisterOutboundConnectionHandlerFactory("freedom", func(space app.Space, config interface{}) (proxy.OutboundConnectionHandler, error) { return &FreedomConnection{space: space}, nil }); err != nil { panic(err) diff --git a/proxy/http/http_factory.go b/proxy/http/http_factory.go index da3d9d78b..d5e96734d 100644 --- a/proxy/http/http_factory.go +++ b/proxy/http/http_factory.go @@ -2,12 +2,12 @@ package http import ( "github.com/v2ray/v2ray-core/app" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy/internal" ) func init() { - if err := internal.RegisterInboundConnectionHandlerFactory("http", func(space app.Space, rawConfig interface{}) (connhandler.InboundConnectionHandler, error) { + if err := internal.RegisterInboundConnectionHandlerFactory("http", func(space app.Space, rawConfig interface{}) (proxy.InboundConnectionHandler, error) { return NewHttpProxyServer(space, rawConfig.(Config)), nil }); err != nil { panic(err) diff --git a/proxy/internal/creator.go b/proxy/internal/creator.go index cf56eca88..8b085fc9c 100644 --- a/proxy/internal/creator.go +++ b/proxy/internal/creator.go @@ -2,8 +2,8 @@ package internal import ( "github.com/v2ray/v2ray-core/app" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" ) -type InboundConnectionHandlerCreator func(space app.Space, config interface{}) (connhandler.InboundConnectionHandler, error) -type OutboundConnectionHandlerCreator func(space app.Space, config interface{}) (connhandler.OutboundConnectionHandler, error) +type InboundConnectionHandlerCreator func(space app.Space, config interface{}) (proxy.InboundConnectionHandler, error) +type OutboundConnectionHandlerCreator func(space app.Space, config interface{}) (proxy.OutboundConnectionHandler, error) diff --git a/proxy/internal/handler_cache.go b/proxy/internal/handler_cache.go index 87ff131de..3d4352ffa 100644 --- a/proxy/internal/handler_cache.go +++ b/proxy/internal/handler_cache.go @@ -4,7 +4,7 @@ import ( "errors" "github.com/v2ray/v2ray-core/app" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy/internal/config" ) @@ -33,7 +33,7 @@ func RegisterOutboundConnectionHandlerFactory(name string, creator OutboundConne return nil } -func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []byte) (connhandler.InboundConnectionHandler, error) { +func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.InboundConnectionHandler, error) { creator, found := inboundFactories[name] if !found { return nil, ErrorProxyNotFound @@ -48,7 +48,7 @@ func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []by return creator(space, nil) } -func CreateOutboundConnectionHandler(name string, space app.Space, rawConfig []byte) (connhandler.OutboundConnectionHandler, error) { +func CreateOutboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.OutboundConnectionHandler, error) { creator, found := outboundFactories[name] if !found { return nil, ErrorNameExists diff --git a/proxy/proxy.go b/proxy/proxy.go index b29f6d4f2..e3f9beb4a 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -3,15 +3,19 @@ package proxy import ( - "github.com/v2ray/v2ray-core/app" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" - "github.com/v2ray/v2ray-core/proxy/internal" + v2net "github.com/v2ray/v2ray-core/common/net" + "github.com/v2ray/v2ray-core/transport/ray" ) -func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []byte) (connhandler.InboundConnectionHandler, error) { - return internal.CreateInboundConnectionHandler(name, space, rawConfig) +// A InboundConnectionHandler handles inbound network connections to V2Ray. +type InboundConnectionHandler interface { + // Listen starts a InboundConnectionHandler by listen on a specific port. This method is called + // exactly once during runtime. + Listen(port v2net.Port) error } -func CreateOutboundConnectionHandler(name string, space app.Space, rawConfig []byte) (connhandler.OutboundConnectionHandler, error) { - return internal.CreateOutboundConnectionHandler(name, space, rawConfig) +// An OutboundConnectionHandler handles outbound network connection for V2Ray. +type OutboundConnectionHandler interface { + // Dispatch sends one or more Packets to its destination. + Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error } diff --git a/proxy/repo/repo.go b/proxy/repo/repo.go new file mode 100644 index 000000000..509a0222f --- /dev/null +++ b/proxy/repo/repo.go @@ -0,0 +1,15 @@ +package repo + +import ( + "github.com/v2ray/v2ray-core/app" + "github.com/v2ray/v2ray-core/proxy" + "github.com/v2ray/v2ray-core/proxy/internal" +) + +func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.InboundConnectionHandler, error) { + return internal.CreateInboundConnectionHandler(name, space, rawConfig) +} + +func CreateOutboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.OutboundConnectionHandler, error) { + return internal.CreateOutboundConnectionHandler(name, space, rawConfig) +} diff --git a/proxy/socks/socks_test.go b/proxy/socks/socks_test.go index 2f69a3b6c..92fe275a7 100644 --- a/proxy/socks/socks_test.go +++ b/proxy/socks/socks_test.go @@ -11,7 +11,7 @@ import ( "github.com/v2ray/v2ray-core/app" v2nettesting "github.com/v2ray/v2ray-core/common/net/testing" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + v2proxy "github.com/v2ray/v2ray-core/proxy" _ "github.com/v2ray/v2ray-core/proxy/socks/json" proxytesting "github.com/v2ray/v2ray-core/proxy/testing" proxymocks "github.com/v2ray/v2ray-core/proxy/testing/mocks" @@ -32,7 +32,7 @@ func TestSocksTcpConnect(t *testing.T) { ConnInput: bytes.NewReader(connInput), } - protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (connhandler.OutboundConnectionHandler, error) { + protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundConnectionHandler, error) { return och, nil }) assert.Error(err).IsNil() @@ -91,7 +91,7 @@ func TestSocksTcpConnectWithUserPass(t *testing.T) { ConnOutput: connOutput, } - protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (connhandler.OutboundConnectionHandler, error) { + protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundConnectionHandler, error) { return och, nil }) assert.Error(err).IsNil() @@ -153,7 +153,7 @@ func TestSocksTcpConnectWithWrongUserPass(t *testing.T) { ConnOutput: connOutput, } - protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (connhandler.OutboundConnectionHandler, error) { + protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundConnectionHandler, error) { return och, nil }) assert.Error(err).IsNil() @@ -201,7 +201,7 @@ func TestSocksTcpConnectWithWrongAuthMethod(t *testing.T) { ConnOutput: connOutput, } - protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (connhandler.OutboundConnectionHandler, error) { + protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundConnectionHandler, error) { return och, nil }) assert.Error(err).IsNil() @@ -249,7 +249,7 @@ func TestSocksUdpSend(t *testing.T) { ConnOutput: connOutput, } - protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (connhandler.OutboundConnectionHandler, error) { + protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundConnectionHandler, error) { return och, nil }) assert.Error(err).IsNil() diff --git a/proxy/socks/socksfactory.go b/proxy/socks/socksfactory.go index 3ab8be45c..08f2e5a52 100644 --- a/proxy/socks/socksfactory.go +++ b/proxy/socks/socksfactory.go @@ -2,12 +2,12 @@ package socks import ( "github.com/v2ray/v2ray-core/app" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy/internal" ) func init() { - if err := internal.RegisterInboundConnectionHandlerFactory("socks", func(space app.Space, rawConfig interface{}) (connhandler.InboundConnectionHandler, error) { + if err := internal.RegisterInboundConnectionHandlerFactory("socks", func(space app.Space, rawConfig interface{}) (proxy.InboundConnectionHandler, error) { return NewSocksServer(space, rawConfig.(Config)), nil }); err != nil { panic(err) diff --git a/proxy/testing/mocks/outboundhandler.go b/proxy/testing/mocks/outboundhandler.go index 22c79f8c1..09d1e1e41 100644 --- a/proxy/testing/mocks/outboundhandler.go +++ b/proxy/testing/mocks/outboundhandler.go @@ -6,7 +6,7 @@ import ( "github.com/v2ray/v2ray-core/app" v2net "github.com/v2ray/v2ray-core/common/net" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/transport/ray" ) @@ -45,6 +45,6 @@ func (this *OutboundConnectionHandler) Dispatch(packet v2net.Packet, ray ray.Out return nil } -func (this *OutboundConnectionHandler) Create(space app.Space, config interface{}) (connhandler.OutboundConnectionHandler, error) { +func (this *OutboundConnectionHandler) Create(space app.Space, config interface{}) (proxy.OutboundConnectionHandler, error) { return this, nil } diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index 91913ebe2..70b1712e8 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -12,7 +12,7 @@ import ( "github.com/v2ray/v2ray-core/common/log" v2net "github.com/v2ray/v2ray-core/common/net" "github.com/v2ray/v2ray-core/common/retry" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy/internal" "github.com/v2ray/v2ray-core/proxy/vmess" "github.com/v2ray/v2ray-core/proxy/vmess/protocol" @@ -141,7 +141,7 @@ func handleOutput(request *protocol.VMessRequest, writer io.Writer, output <-cha } func init() { - if err := internal.RegisterInboundConnectionHandlerFactory("vmess", func(space app.Space, rawConfig interface{}) (connhandler.InboundConnectionHandler, error) { + if err := internal.RegisterInboundConnectionHandlerFactory("vmess", func(space app.Space, rawConfig interface{}) (proxy.InboundConnectionHandler, error) { config := rawConfig.(Config) allowedClients := user.NewTimedUserSet() diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index 905526526..1aa060879 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -11,7 +11,7 @@ import ( v2crypto "github.com/v2ray/v2ray-core/common/crypto" "github.com/v2ray/v2ray-core/common/log" v2net "github.com/v2ray/v2ray-core/common/net" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy/internal" "github.com/v2ray/v2ray-core/proxy/vmess/protocol" "github.com/v2ray/v2ray-core/proxy/vmess/protocol/user" @@ -188,7 +188,7 @@ func handleResponse(conn net.Conn, request *protocol.VMessRequest, output chan<- type VMessOutboundHandlerFactory struct { } -func (this *VMessOutboundHandlerFactory) Create(space app.Space, rawConfig interface{}) (connhandler.OutboundConnectionHandler, error) { +func (this *VMessOutboundHandlerFactory) Create(space app.Space, rawConfig interface{}) (proxy.OutboundConnectionHandler, error) { vOutConfig := rawConfig.(Config) return &VMessOutboundHandler{ space: space, @@ -197,7 +197,7 @@ func (this *VMessOutboundHandlerFactory) Create(space app.Space, rawConfig inter } func init() { - if err := internal.RegisterOutboundConnectionHandlerFactory("vmess", func(space app.Space, rawConfig interface{}) (connhandler.OutboundConnectionHandler, error) { + if err := internal.RegisterOutboundConnectionHandlerFactory("vmess", func(space app.Space, rawConfig interface{}) (proxy.OutboundConnectionHandler, error) { vOutConfig := rawConfig.(Config) return &VMessOutboundHandler{ space: space, diff --git a/proxy/vmess/vmess_test.go b/proxy/vmess/vmess_test.go index caeef1aad..296588a55 100644 --- a/proxy/vmess/vmess_test.go +++ b/proxy/vmess/vmess_test.go @@ -8,7 +8,7 @@ import ( v2net "github.com/v2ray/v2ray-core/common/net" v2nettesting "github.com/v2ray/v2ray-core/common/net/testing" "github.com/v2ray/v2ray-core/common/uuid" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + "github.com/v2ray/v2ray-core/proxy" proxytesting "github.com/v2ray/v2ray-core/proxy/testing" proxymocks "github.com/v2ray/v2ray-core/proxy/testing/mocks" vmess "github.com/v2ray/v2ray-core/proxy/vmess" @@ -40,7 +40,7 @@ func TestVMessInAndOut(t *testing.T) { ConnOutput: ichConnOutput, } - protocol, err := proxytesting.RegisterInboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (connhandler.InboundConnectionHandler, error) { + protocol, err := proxytesting.RegisterInboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (proxy.InboundConnectionHandler, error) { ich.Space = space return ich, nil }) @@ -81,7 +81,7 @@ func TestVMessInAndOut(t *testing.T) { ConnOutput: ochConnOutput, } - protocol, err = proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (connhandler.OutboundConnectionHandler, error) { + protocol, err = proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (proxy.OutboundConnectionHandler, error) { return och, nil }) assert.Error(err).IsNil() diff --git a/shell/point/inbound_detour.go b/shell/point/inbound_detour.go index 87edd6be8..912dec687 100644 --- a/shell/point/inbound_detour.go +++ b/shell/point/inbound_detour.go @@ -6,12 +6,12 @@ import ( v2net "github.com/v2ray/v2ray-core/common/net" "github.com/v2ray/v2ray-core/common/retry" "github.com/v2ray/v2ray-core/proxy" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + proxyrepo "github.com/v2ray/v2ray-core/proxy/repo" ) type InboundConnectionHandlerWithPort struct { port v2net.Port - handler connhandler.InboundConnectionHandler + handler proxy.InboundConnectionHandler } // Handler for inbound detour connections. @@ -26,7 +26,7 @@ func (this *InboundDetourHandler) Initialize() error { this.ich = make([]*InboundConnectionHandlerWithPort, 0, ports.To()-ports.From()+1) for i := ports.From(); i <= ports.To(); i++ { ichConfig := this.config.Settings() - ich, err := proxy.CreateInboundConnectionHandler(this.config.Protocol(), this.space, ichConfig) + ich, err := proxyrepo.CreateInboundConnectionHandler(this.config.Protocol(), this.space, ichConfig) if err != nil { log.Error("Failed to create inbound connection handler: %v", err) return err diff --git a/shell/point/point.go b/shell/point/point.go index 4bc65320a..ed4ceffda 100644 --- a/shell/point/point.go +++ b/shell/point/point.go @@ -12,17 +12,17 @@ import ( v2net "github.com/v2ray/v2ray-core/common/net" "github.com/v2ray/v2ray-core/common/retry" "github.com/v2ray/v2ray-core/proxy" - "github.com/v2ray/v2ray-core/proxy/common/connhandler" + proxyrepo "github.com/v2ray/v2ray-core/proxy/repo" "github.com/v2ray/v2ray-core/transport/ray" ) // Point shell of V2Ray. type Point struct { port v2net.Port - ich connhandler.InboundConnectionHandler - och connhandler.OutboundConnectionHandler + ich proxy.InboundConnectionHandler + och proxy.OutboundConnectionHandler idh []*InboundDetourHandler - odh map[string]connhandler.OutboundConnectionHandler + odh map[string]proxy.OutboundConnectionHandler router router.Router space *controller.SpaceController } @@ -56,7 +56,7 @@ func NewPoint(pConfig PointConfig) (*Point, error) { vpoint.space.Bind(vpoint) ichConfig := pConfig.InboundConfig().Settings() - ich, err := proxy.CreateInboundConnectionHandler(pConfig.InboundConfig().Protocol(), vpoint.space.ForContext("vpoint-default-inbound"), ichConfig) + ich, err := proxyrepo.CreateInboundConnectionHandler(pConfig.InboundConfig().Protocol(), vpoint.space.ForContext("vpoint-default-inbound"), ichConfig) if err != nil { log.Error("Failed to create inbound connection handler: %v", err) return nil, err @@ -64,7 +64,7 @@ func NewPoint(pConfig PointConfig) (*Point, error) { vpoint.ich = ich ochConfig := pConfig.OutboundConfig().Settings() - och, err := proxy.CreateOutboundConnectionHandler(pConfig.OutboundConfig().Protocol(), vpoint.space.ForContext("vpoint-default-outbound"), ochConfig) + och, err := proxyrepo.CreateOutboundConnectionHandler(pConfig.OutboundConfig().Protocol(), vpoint.space.ForContext("vpoint-default-outbound"), ochConfig) if err != nil { log.Error("Failed to create outbound connection handler: %v", err) return nil, err @@ -89,9 +89,9 @@ func NewPoint(pConfig PointConfig) (*Point, error) { outboundDetours := pConfig.OutboundDetours() if len(outboundDetours) > 0 { - vpoint.odh = make(map[string]connhandler.OutboundConnectionHandler) + vpoint.odh = make(map[string]proxy.OutboundConnectionHandler) for _, detourConfig := range outboundDetours { - detourHandler, err := proxy.CreateOutboundConnectionHandler(detourConfig.Protocol(), vpoint.space.ForContext(detourConfig.Tag()), detourConfig.Settings()) + detourHandler, err := proxyrepo.CreateOutboundConnectionHandler(detourConfig.Protocol(), vpoint.space.ForContext(detourConfig.Tag()), detourConfig.Settings()) if err != nil { log.Error("Failed to create detour outbound connection handler: %v", err) return nil, err