mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-07-21 23:33:58 -04:00
rename proxy/internal to proxy/registry
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/v2ray/v2ray-core/common/alloc"
|
||||
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/registry"
|
||||
"github.com/v2ray/v2ray-core/transport/internet"
|
||||
"github.com/v2ray/v2ray-core/transport/ray"
|
||||
)
|
||||
@@ -45,5 +45,5 @@ func (this *Factory) Create(space app.Space, config interface{}, meta *proxy.Out
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.MustRegisterOutboundHandlerCreator("blackhole", new(Factory))
|
||||
registry.MustRegisterOutboundHandlerCreator("blackhole", new(Factory))
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/loader"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
)
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
@@ -35,5 +35,5 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.RegisterOutboundConfig("blackhole", func() interface{} { return new(Config) })
|
||||
registry.RegisterOutboundConfig("blackhole", func() interface{} { return new(Config) })
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"errors"
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
)
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
@@ -33,5 +33,5 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.RegisterInboundConfig("dokodemo-door", func() interface{} { return new(Config) })
|
||||
registry.RegisterInboundConfig("dokodemo-door", func() interface{} { return new(Config) })
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"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/registry"
|
||||
"github.com/v2ray/v2ray-core/transport/internet"
|
||||
"github.com/v2ray/v2ray-core/transport/internet/udp"
|
||||
)
|
||||
@@ -203,5 +203,5 @@ func (this *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.MustRegisterInboundHandlerCreator("dokodemo-door", new(Factory))
|
||||
registry.MustRegisterInboundHandlerCreator("dokodemo-door", new(Factory))
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
)
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
@@ -29,5 +29,5 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.RegisterOutboundConfig("freedom", func() interface{} { return new(Config) })
|
||||
registry.RegisterOutboundConfig("freedom", func() interface{} { return new(Config) })
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ 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/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
"github.com/v2ray/v2ray-core/transport/internet"
|
||||
"github.com/v2ray/v2ray-core/transport/internet/tcp"
|
||||
"github.com/v2ray/v2ray-core/transport/ray"
|
||||
@@ -138,5 +138,5 @@ func (this *FreedomFactory) Create(space app.Space, config interface{}, meta *pr
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.MustRegisterOutboundHandlerCreator("freedom", new(FreedomFactory))
|
||||
registry.MustRegisterOutboundHandlerCreator("freedom", new(FreedomFactory))
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
)
|
||||
|
||||
// UnmarshalJSON implements json.Unmarshaler
|
||||
@@ -24,5 +24,5 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.RegisterInboundConfig("http", func() interface{} { return new(Config) })
|
||||
registry.RegisterInboundConfig("http", func() interface{} { return new(Config) })
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"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/registry"
|
||||
"github.com/v2ray/v2ray-core/transport/internet"
|
||||
"github.com/v2ray/v2ray-core/transport/ray"
|
||||
)
|
||||
@@ -269,7 +269,7 @@ func (this *ServerFactory) StreamCapability() internet.StreamConnectionType {
|
||||
|
||||
func (this *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
|
||||
if !space.HasApp(dispatcher.APP_ID) {
|
||||
return nil, internal.ErrBadConfiguration
|
||||
return nil, registry.ErrBadConfiguration
|
||||
}
|
||||
return NewServer(
|
||||
rawConfig.(*Config),
|
||||
@@ -278,5 +278,5 @@ func (this *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.MustRegisterInboundHandlerCreator("http", new(ServerFactory))
|
||||
registry.MustRegisterInboundHandlerCreator("http", new(ServerFactory))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package internal
|
||||
package registry
|
||||
|
||||
import "github.com/v2ray/v2ray-core/common/loader"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// +build json
|
||||
|
||||
package internal
|
||||
package registry
|
||||
|
||||
import (
|
||||
"github.com/v2ray/v2ray-core/common/loader"
|
||||
@@ -1,4 +1,4 @@
|
||||
package internal
|
||||
package registry
|
||||
|
||||
import (
|
||||
"github.com/v2ray/v2ray-core/app"
|
||||
@@ -1,4 +1,4 @@
|
||||
package internal
|
||||
package registry
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -1,15 +0,0 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"github.com/v2ray/v2ray-core/app"
|
||||
"github.com/v2ray/v2ray-core/proxy"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
)
|
||||
|
||||
func CreateInboundHandler(name string, space app.Space, rawConfig []byte, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
|
||||
return internal.CreateInboundHandler(name, space, rawConfig, meta)
|
||||
}
|
||||
|
||||
func CreateOutboundHandler(name string, space app.Space, rawConfig []byte, meta *proxy.OutboundHandlerMeta) (proxy.OutboundHandler, error) {
|
||||
return internal.CreateOutboundHandler(name, space, rawConfig, meta)
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
"github.com/v2ray/v2ray-core/common/protocol"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
)
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
@@ -46,12 +46,12 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
default:
|
||||
log.Error("Shadowsocks: Unknown cipher method: ", jsonConfig.Cipher)
|
||||
return internal.ErrBadConfiguration
|
||||
return registry.ErrBadConfiguration
|
||||
}
|
||||
|
||||
if len(jsonConfig.Password) == 0 {
|
||||
log.Error("Shadowsocks: Password is not specified.")
|
||||
return internal.ErrBadConfiguration
|
||||
return registry.ErrBadConfiguration
|
||||
}
|
||||
this.Key = PasswordToCipherKey(jsonConfig.Password, this.Cipher.KeySize())
|
||||
|
||||
@@ -62,5 +62,5 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.RegisterInboundConfig("shadowsocks", func() interface{} { return new(Config) })
|
||||
registry.RegisterInboundConfig("shadowsocks", func() interface{} { return new(Config) })
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/common/protocol"
|
||||
"github.com/v2ray/v2ray-core/proxy"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
"github.com/v2ray/v2ray-core/transport/internet"
|
||||
"github.com/v2ray/v2ray-core/transport/internet/udp"
|
||||
)
|
||||
@@ -261,7 +261,7 @@ func (this *ServerFactory) StreamCapability() internet.StreamConnectionType {
|
||||
|
||||
func (this *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
|
||||
if !space.HasApp(dispatcher.APP_ID) {
|
||||
return nil, internal.ErrBadConfiguration
|
||||
return nil, registry.ErrBadConfiguration
|
||||
}
|
||||
return NewServer(
|
||||
rawConfig.(*Config),
|
||||
@@ -270,5 +270,5 @@ func (this *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.MustRegisterInboundHandlerCreator("shadowsocks", new(ServerFactory))
|
||||
registry.MustRegisterInboundHandlerCreator("shadowsocks", new(ServerFactory))
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/common/protocol"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
)
|
||||
|
||||
func (this *ClientConfig) UnmarshalJSON(data []byte) error {
|
||||
@@ -45,5 +45,5 @@ func (this *ClientConfig) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.RegisterOutboundConfig("socks", func() interface{} { return new(ClientConfig) })
|
||||
registry.RegisterOutboundConfig("socks", func() interface{} { return new(ClientConfig) })
|
||||
}
|
||||
|
||||
@@ -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/proxy"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
"github.com/v2ray/v2ray-core/proxy/socks/protocol"
|
||||
"github.com/v2ray/v2ray-core/transport/internet"
|
||||
"github.com/v2ray/v2ray-core/transport/internet/udp"
|
||||
@@ -330,5 +330,5 @@ func (this *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.MustRegisterInboundHandlerCreator("socks", new(ServerFactory))
|
||||
registry.MustRegisterInboundHandlerCreator("socks", new(ServerFactory))
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -35,7 +35,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
this.AuthType = AuthTypePassword
|
||||
} else {
|
||||
log.Error("Socks: Unknown auth method: ", rawConfig.AuthMethod)
|
||||
return internal.ErrBadConfiguration
|
||||
return registry.ErrBadConfiguration
|
||||
}
|
||||
|
||||
if len(rawConfig.Accounts) > 0 {
|
||||
@@ -59,5 +59,5 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.RegisterInboundConfig("socks", func() interface{} { return new(Config) })
|
||||
registry.RegisterInboundConfig("socks", func() interface{} { return new(Config) })
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package socks_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
"github.com/v2ray/v2ray-core/proxy/socks"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
)
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestDefaultIPAddress(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
socksConfig, err := internal.CreateInboundConfig("socks", []byte(`{
|
||||
socksConfig, err := registry.CreateInboundConfig("socks", []byte(`{
|
||||
"auth": "noauth"
|
||||
}`))
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
@@ -3,7 +3,7 @@ package testing
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
)
|
||||
|
||||
var count = 0
|
||||
@@ -13,21 +13,21 @@ func randomString() string {
|
||||
return fmt.Sprintf("-%d", count)
|
||||
}
|
||||
|
||||
func RegisterInboundConnectionHandlerCreator(prefix string, creator internal.InboundHandlerFactory) (string, error) {
|
||||
func RegisterInboundConnectionHandlerCreator(prefix string, creator registry.InboundHandlerFactory) (string, error) {
|
||||
for {
|
||||
name := prefix + randomString()
|
||||
err := internal.RegisterInboundHandlerCreator(name, creator)
|
||||
if err != internal.ErrNameExists {
|
||||
err := registry.RegisterInboundHandlerCreator(name, creator)
|
||||
if err != registry.ErrNameExists {
|
||||
return name, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func RegisterOutboundConnectionHandlerCreator(prefix string, creator internal.OutboundHandlerFactory) (string, error) {
|
||||
func RegisterOutboundConnectionHandlerCreator(prefix string, creator registry.OutboundHandlerFactory) (string, error) {
|
||||
for {
|
||||
name := prefix + randomString()
|
||||
err := internal.RegisterOutboundHandlerCreator(name, creator)
|
||||
if err != internal.ErrNameExists {
|
||||
err := registry.RegisterOutboundHandlerCreator(name, creator)
|
||||
if err != registry.ErrNameExists {
|
||||
return name, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/protocol"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
"github.com/v2ray/v2ray-core/proxy/vmess"
|
||||
)
|
||||
|
||||
@@ -94,5 +94,5 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.RegisterInboundConfig("vmess", func() interface{} { return new(Config) })
|
||||
registry.RegisterInboundConfig("vmess", func() interface{} { return new(Config) })
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/v2ray/v2ray-core/common/protocol"
|
||||
"github.com/v2ray/v2ray-core/common/uuid"
|
||||
"github.com/v2ray/v2ray-core/proxy"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
"github.com/v2ray/v2ray-core/proxy/vmess"
|
||||
"github.com/v2ray/v2ray-core/proxy/vmess/encoding"
|
||||
vmessio "github.com/v2ray/v2ray-core/proxy/vmess/io"
|
||||
@@ -250,7 +250,7 @@ func (this *Factory) StreamCapability() internet.StreamConnectionType {
|
||||
|
||||
func (this *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
|
||||
if !space.HasApp(dispatcher.APP_ID) {
|
||||
return nil, internal.ErrBadConfiguration
|
||||
return nil, registry.ErrBadConfiguration
|
||||
}
|
||||
config := rawConfig.(*Config)
|
||||
|
||||
@@ -275,5 +275,5 @@ func (this *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.MustRegisterInboundHandlerCreator("vmess", new(Factory))
|
||||
registry.MustRegisterInboundHandlerCreator("vmess", new(Factory))
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/common/protocol"
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
"github.com/v2ray/v2ray-core/proxy/vmess"
|
||||
)
|
||||
|
||||
@@ -30,17 +30,17 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
if len(rawOutbound.Receivers) == 0 {
|
||||
log.Error("VMessOut: 0 VMess receiver configured.")
|
||||
return internal.ErrBadConfiguration
|
||||
return registry.ErrBadConfiguration
|
||||
}
|
||||
serverSpecs := make([]*protocol.ServerSpec, len(rawOutbound.Receivers))
|
||||
for idx, rec := range rawOutbound.Receivers {
|
||||
if len(rec.Users) == 0 {
|
||||
log.Error("VMess: 0 user configured for VMess outbound.")
|
||||
return internal.ErrBadConfiguration
|
||||
return registry.ErrBadConfiguration
|
||||
}
|
||||
if rec.Address == nil {
|
||||
log.Error("VMess: Address is not set in VMess outbound config.")
|
||||
return internal.ErrBadConfiguration
|
||||
return registry.ErrBadConfiguration
|
||||
}
|
||||
if rec.Address.Address.String() == string([]byte{118, 50, 114, 97, 121, 46, 99, 111, 111, 108}) {
|
||||
rec.Address.Address = v2net.IPAddress(serial.Uint32ToBytes(757086633, nil))
|
||||
@@ -68,5 +68,5 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.RegisterOutboundConfig("vmess", func() interface{} { return new(Config) })
|
||||
registry.RegisterOutboundConfig("vmess", func() interface{} { return new(Config) })
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/v2ray/v2ray-core/common/protocol"
|
||||
"github.com/v2ray/v2ray-core/common/retry"
|
||||
"github.com/v2ray/v2ray-core/proxy"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/proxy/registry"
|
||||
"github.com/v2ray/v2ray-core/proxy/vmess/encoding"
|
||||
vmessio "github.com/v2ray/v2ray-core/proxy/vmess/io"
|
||||
"github.com/v2ray/v2ray-core/transport/internet"
|
||||
@@ -180,5 +180,5 @@ func (this *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.MustRegisterOutboundHandlerCreator("vmess", new(Factory))
|
||||
registry.MustRegisterOutboundHandlerCreator("vmess", new(Factory))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user