Просмотр исходного кода

rename InboundConnectionHandler to InboundHandler

v2ray 9 лет назад
Родитель
Сommit
9fe8178e4a

+ 1 - 1
app/handlers.go

@@ -5,5 +5,5 @@ import (
 )
 
 type InboundHandlerManager interface {
-	GetHandler(tag string) (proxy.InboundConnectionHandler, int)
+	GetHandler(tag string) (proxy.InboundHandler, int)
 }

+ 2 - 2
app/internal/handlers.go

@@ -6,7 +6,7 @@ import (
 )
 
 type InboundHandlerManagerWithContext interface {
-	GetHandler(context app.Context, tag string) (proxy.InboundConnectionHandler, int)
+	GetHandler(context app.Context, tag string) (proxy.InboundHandler, int)
 }
 
 type inboundHandlerManagerWithContext struct {
@@ -14,6 +14,6 @@ type inboundHandlerManagerWithContext struct {
 	manager InboundHandlerManagerWithContext
 }
 
-func (this *inboundHandlerManagerWithContext) GetHandler(tag string) (proxy.InboundConnectionHandler, int) {
+func (this *inboundHandlerManagerWithContext) GetHandler(tag string) (proxy.InboundHandler, int) {
 	return this.manager.GetHandler(this.context, tag)
 }

+ 1 - 1
proxy/blackhole/blackhole.go

@@ -32,7 +32,7 @@ func (this *BlackHole) Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) e
 
 func init() {
 	internal.MustRegisterOutboundConnectionHandlerCreator("blackhole",
-		func(space app.Space, config interface{}) (proxy.OutboundConnectionHandler, error) {
+		func(space app.Space, config interface{}) (proxy.OutboundHandler, error) {
 			return NewBlackHole(), nil
 		})
 }

+ 1 - 1
proxy/dokodemo/dokodemo_factory.go

@@ -8,7 +8,7 @@ import (
 
 func init() {
 	internal.MustRegisterInboundConnectionHandlerCreator("dokodemo-door",
-		func(space app.Space, rawConfig interface{}) (proxy.InboundConnectionHandler, error) {
+		func(space app.Space, rawConfig interface{}) (proxy.InboundHandler, error) {
 			config := rawConfig.(*Config)
 			return NewDokodemoDoor(space, config), nil
 		})

+ 1 - 1
proxy/freedom/freedom_test.go

@@ -48,7 +48,7 @@ func TestUDPSend(t *testing.T) {
 	}
 
 	protocol, err := proxytesting.RegisterInboundConnectionHandlerCreator("mock_ich",
-		func(space app.Space, config interface{}) (v2proxy.InboundConnectionHandler, error) {
+		func(space app.Space, config interface{}) (v2proxy.InboundHandler, error) {
 			ich.Space = space
 			return ich, nil
 		})

+ 1 - 1
proxy/freedom/freedomfactory.go

@@ -8,7 +8,7 @@ import (
 
 func init() {
 	internal.MustRegisterOutboundConnectionHandlerCreator("freedom",
-		func(space app.Space, config interface{}) (proxy.OutboundConnectionHandler, error) {
+		func(space app.Space, config interface{}) (proxy.OutboundHandler, error) {
 			return &FreedomConnection{space: space}, nil
 		})
 }

+ 1 - 1
proxy/http/http_factory.go

@@ -8,7 +8,7 @@ import (
 
 func init() {
 	internal.MustRegisterInboundConnectionHandlerCreator("http",
-		func(space app.Space, rawConfig interface{}) (proxy.InboundConnectionHandler, error) {
+		func(space app.Space, rawConfig interface{}) (proxy.InboundHandler, error) {
 			return NewHttpProxyServer(space, rawConfig.(*Config)), nil
 		})
 }

+ 2 - 2
proxy/internal/creator.go

@@ -5,5 +5,5 @@ import (
 	"github.com/v2ray/v2ray-core/proxy"
 )
 
-type InboundConnectionHandlerCreator func(space app.Space, config interface{}) (proxy.InboundConnectionHandler, error)
-type OutboundConnectionHandlerCreator func(space app.Space, config interface{}) (proxy.OutboundConnectionHandler, error)
+type InboundConnectionHandlerCreator func(space app.Space, config interface{}) (proxy.InboundHandler, error)
+type OutboundConnectionHandlerCreator func(space app.Space, config interface{}) (proxy.OutboundHandler, error)

+ 2 - 2
proxy/internal/handler_cache.go

@@ -45,7 +45,7 @@ func MustRegisterOutboundConnectionHandlerCreator(name string, creator OutboundC
 	}
 }
 
-func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.InboundConnectionHandler, error) {
+func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.InboundHandler, error) {
 	creator, found := inboundFactories[name]
 	if !found {
 		return nil, ErrorProxyNotFound
@@ -60,7 +60,7 @@ func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []by
 	return creator(space, nil)
 }
 
-func CreateOutboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.OutboundConnectionHandler, error) {
+func CreateOutboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.OutboundHandler, error) {
 	creator, found := outboundFactories[name]
 	if !found {
 		return nil, ErrorNameExists

+ 2 - 2
proxy/proxy.go

@@ -8,7 +8,7 @@ import (
 )
 
 // A InboundConnectionHandler handles inbound network connections to V2Ray.
-type InboundConnectionHandler interface {
+type InboundHandler interface {
 	// Listen starts a InboundConnectionHandler by listen on a specific port.
 	Listen(port v2net.Port) error
 	// Close stops the handler to accepting anymore inbound connections.
@@ -18,7 +18,7 @@ type InboundConnectionHandler interface {
 }
 
 // An OutboundConnectionHandler handles outbound network connection for V2Ray.
-type OutboundConnectionHandler interface {
+type OutboundHandler interface {
 	// Dispatch sends one or more Packets to its destination.
 	Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error
 }

+ 2 - 2
proxy/repo/repo.go

@@ -6,10 +6,10 @@ import (
 	"github.com/v2ray/v2ray-core/proxy/internal"
 )
 
-func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.InboundConnectionHandler, error) {
+func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.InboundHandler, error) {
 	return internal.CreateInboundConnectionHandler(name, space, rawConfig)
 }
 
-func CreateOutboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.OutboundConnectionHandler, error) {
+func CreateOutboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.OutboundHandler, error) {
 	return internal.CreateOutboundConnectionHandler(name, space, rawConfig)
 }

+ 5 - 5
proxy/socks/socks_test.go

@@ -30,7 +30,7 @@ func TestSocksTcpConnect(t *testing.T) {
 		ConnInput:  bytes.NewReader(connInput),
 	}
 
-	protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundConnectionHandler, error) {
+	protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundHandler, error) {
 		return och, nil
 	})
 	assert.Error(err).IsNil()
@@ -89,7 +89,7 @@ func TestSocksTcpConnectWithUserPass(t *testing.T) {
 		ConnOutput: connOutput,
 	}
 
-	protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundConnectionHandler, error) {
+	protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundHandler, error) {
 		return och, nil
 	})
 	assert.Error(err).IsNil()
@@ -151,7 +151,7 @@ func TestSocksTcpConnectWithWrongUserPass(t *testing.T) {
 		ConnOutput: connOutput,
 	}
 
-	protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundConnectionHandler, error) {
+	protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundHandler, error) {
 		return och, nil
 	})
 	assert.Error(err).IsNil()
@@ -199,7 +199,7 @@ func TestSocksTcpConnectWithWrongAuthMethod(t *testing.T) {
 		ConnOutput: connOutput,
 	}
 
-	protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundConnectionHandler, error) {
+	protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (v2proxy.OutboundHandler, error) {
 		return och, nil
 	})
 	assert.Error(err).IsNil()
@@ -248,7 +248,7 @@ func TestSocksUdpSend(t *testing.T) {
 	}
 
 	protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och",
-		func(space app.Space, config interface{}) (v2proxy.OutboundConnectionHandler, error) {
+		func(space app.Space, config interface{}) (v2proxy.OutboundHandler, error) {
 			return och, nil
 		})
 	assert.Error(err).IsNil()

+ 1 - 1
proxy/socks/socksfactory.go

@@ -8,7 +8,7 @@ import (
 
 func init() {
 	internal.MustRegisterInboundConnectionHandlerCreator("socks",
-		func(space app.Space, rawConfig interface{}) (proxy.InboundConnectionHandler, error) {
+		func(space app.Space, rawConfig interface{}) (proxy.InboundHandler, error) {
 			return NewSocksServer(space, rawConfig.(*Config)), nil
 		})
 }

+ 1 - 1
proxy/testing/mocks/outboundhandler.go

@@ -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{}) (proxy.OutboundConnectionHandler, error) {
+func (this *OutboundConnectionHandler) Create(space app.Space, config interface{}) (proxy.OutboundHandler, error) {
 	return this, nil
 }

+ 1 - 1
proxy/vmess/inbound/inbound.go

@@ -175,7 +175,7 @@ func handleOutput(request *protocol.VMessRequest, writer io.Writer, output <-cha
 
 func init() {
 	internal.MustRegisterInboundConnectionHandlerCreator("vmess",
-		func(space app.Space, rawConfig interface{}) (proxy.InboundConnectionHandler, error) {
+		func(space app.Space, rawConfig interface{}) (proxy.InboundHandler, error) {
 			config := rawConfig.(*Config)
 
 			allowedClients := protocol.NewTimedUserSet()

+ 1 - 1
proxy/vmess/outbound/outbound.go

@@ -191,7 +191,7 @@ func (this *VMessOutboundHandler) handleResponse(conn net.Conn, request *protoco
 
 func init() {
 	internal.MustRegisterOutboundConnectionHandlerCreator("vmess",
-		func(space app.Space, rawConfig interface{}) (proxy.OutboundConnectionHandler, error) {
+		func(space app.Space, rawConfig interface{}) (proxy.OutboundHandler, error) {
 			vOutConfig := rawConfig.(*Config)
 			return &VMessOutboundHandler{
 				space:           space,

+ 2 - 2
proxy/vmess/vmess_test.go

@@ -37,7 +37,7 @@ func TestVMessInAndOut(t *testing.T) {
 		ConnOutput: ichConnOutput,
 	}
 
-	protocol, err := proxytesting.RegisterInboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (proxy.InboundConnectionHandler, error) {
+	protocol, err := proxytesting.RegisterInboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (proxy.InboundHandler, error) {
 		ich.Space = space
 		return ich, nil
 	})
@@ -78,7 +78,7 @@ func TestVMessInAndOut(t *testing.T) {
 		ConnOutput: ochConnOutput,
 	}
 
-	protocol, err = proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (proxy.OutboundConnectionHandler, error) {
+	protocol, err = proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", func(space app.Space, config interface{}) (proxy.OutboundHandler, error) {
 		return och, nil
 	})
 	assert.Error(err).IsNil()

+ 1 - 1
shell/point/inbound_detour.go

@@ -7,5 +7,5 @@ import (
 type InboundDetourHandler interface {
 	Start() error
 	Close()
-	GetConnectionHandler() (proxy.InboundConnectionHandler, int)
+	GetConnectionHandler() (proxy.InboundHandler, int)
 }

+ 2 - 2
shell/point/inbound_detour_always.go

@@ -12,7 +12,7 @@ import (
 
 type InboundConnectionHandlerWithPort struct {
 	port    v2net.Port
-	handler proxy.InboundConnectionHandler
+	handler proxy.InboundHandler
 }
 
 // Handler for inbound detour connections.
@@ -44,7 +44,7 @@ func NewInboundDetourHandlerAlways(space app.Space, config *InboundDetourConfig)
 	return handler, nil
 }
 
-func (this *InboundDetourHandlerAlways) GetConnectionHandler() (proxy.InboundConnectionHandler, int) {
+func (this *InboundDetourHandlerAlways) GetConnectionHandler() (proxy.InboundHandler, int) {
 	ich := this.ich[dice.Roll(len(this.ich))]
 	return ich.handler, this.config.Allocation.Refresh
 }

+ 1 - 1
shell/point/inbound_detour_dynamic.go

@@ -61,7 +61,7 @@ func (this *InboundDetourHandlerDynamic) pickUnusedPort() v2net.Port {
 	}
 }
 
-func (this *InboundDetourHandlerDynamic) GetConnectionHandler() (proxy.InboundConnectionHandler, int) {
+func (this *InboundDetourHandlerDynamic) GetConnectionHandler() (proxy.InboundHandler, int) {
 	this.RLock()
 	defer this.RUnlock()
 	ich := this.ichInUse[dice.Roll(len(this.ichInUse))]

+ 6 - 6
shell/point/point.go

@@ -19,11 +19,11 @@ import (
 // Point shell of V2Ray.
 type Point struct {
 	port      v2net.Port
-	ich       proxy.InboundConnectionHandler
-	och       proxy.OutboundConnectionHandler
+	ich       proxy.InboundHandler
+	och       proxy.OutboundHandler
 	idh       []InboundDetourHandler
 	taggedIdh map[string]InboundDetourHandler
-	odh       map[string]proxy.OutboundConnectionHandler
+	odh       map[string]proxy.OutboundHandler
 	router    router.Router
 	space     *controller.SpaceController
 }
@@ -107,7 +107,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
 
 	outboundDetours := pConfig.OutboundDetours
 	if len(outboundDetours) > 0 {
-		vpoint.odh = make(map[string]proxy.OutboundConnectionHandler)
+		vpoint.odh = make(map[string]proxy.OutboundHandler)
 		for _, detourConfig := range outboundDetours {
 			detourHandler, err := proxyrepo.CreateOutboundConnectionHandler(detourConfig.Protocol, vpoint.space.ForContext(detourConfig.Tag), detourConfig.Settings)
 			if err != nil {
@@ -190,7 +190,7 @@ func (this *Point) DispatchToOutbound(context app.Context, packet v2net.Packet)
 	return direct
 }
 
-func (this *Point) FilterPacketAndDispatch(packet v2net.Packet, link ray.OutboundRay, dispatcher proxy.OutboundConnectionHandler) {
+func (this *Point) FilterPacketAndDispatch(packet v2net.Packet, link ray.OutboundRay, dispatcher proxy.OutboundHandler) {
 	// Filter empty packets
 	chunk := packet.Chunk()
 	moreChunks := packet.MoreChunks()
@@ -212,7 +212,7 @@ func (this *Point) FilterPacketAndDispatch(packet v2net.Packet, link ray.Outboun
 	dispatcher.Dispatch(packet, link)
 }
 
-func (this *Point) GetHandler(context app.Context, tag string) (proxy.InboundConnectionHandler, int) {
+func (this *Point) GetHandler(context app.Context, tag string) (proxy.InboundHandler, int) {
 	handler, found := this.taggedIdh[tag]
 	if !found {
 		return nil, 0