mirror of https://github.com/v2ray/v2ray-core
move connhandler to proxy
parent
54ce82fbfa
commit
0780db7999
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue