Selaa lähdekoodia

move buildable to cfg common

Shelikhoo 4 vuotta sitten
vanhempi
commit
41b54ff61e

+ 2 - 1
infra/conf/blackhole.go

@@ -2,6 +2,7 @@ package conf
 
 import (
 	"encoding/json"
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 
 	"github.com/golang/protobuf/proto"
 
@@ -32,7 +33,7 @@ func (v *BlackholeConfig) Build() (proto.Message, error) {
 		if err != nil {
 			return nil, newError("Config: Failed to parse Blackhole response config.").Base(err)
 		}
-		responseSettings, err := response.(Buildable).Build()
+		responseSettings, err := response.(cfgcommon.Buildable).Build()
 		if err != nil {
 			return nil, err
 		}

+ 2 - 1
infra/conf/blackhole_test.go

@@ -1,6 +1,7 @@
 package conf_test
 
 import (
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	"github.com/v2fly/v2ray-core/v4/common/serial"
@@ -9,7 +10,7 @@ import (
 )
 
 func TestHTTPResponseJSON(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(BlackholeConfig)
 	}
 

+ 1 - 1
infra/conf/buildable.go → infra/conf/cfgcommon/buildable.go

@@ -1,4 +1,4 @@
-package conf
+package cfgcommon
 
 import "github.com/golang/protobuf/proto"
 

+ 2 - 1
infra/conf/dns_proxy_test.go

@@ -1,6 +1,7 @@
 package conf_test
 
 import (
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	"github.com/v2fly/v2ray-core/v4/common/net"
@@ -9,7 +10,7 @@ import (
 )
 
 func TestDnsProxyConfig(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(DNSOutboundConfig)
 	}
 

+ 2 - 1
infra/conf/dokodemo_test.go

@@ -1,6 +1,7 @@
 package conf_test
 
 import (
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	"github.com/v2fly/v2ray-core/v4/common/net"
@@ -9,7 +10,7 @@ import (
 )
 
 func TestDokodemoConfig(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(DokodemoConfig)
 	}
 

+ 2 - 1
infra/conf/freedom_test.go

@@ -1,6 +1,7 @@
 package conf_test
 
 import (
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	"github.com/v2fly/v2ray-core/v4/common/net"
@@ -10,7 +11,7 @@ import (
 )
 
 func TestFreedomConfig(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(FreedomConfig)
 	}
 

+ 2 - 2
infra/conf/general_test.go

@@ -2,15 +2,15 @@ package conf_test
 
 import (
 	"encoding/json"
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	"github.com/golang/protobuf/proto"
 
 	"github.com/v2fly/v2ray-core/v4/common"
-	. "github.com/v2fly/v2ray-core/v4/infra/conf"
 )
 
-func loadJSON(creator func() Buildable) func(string) (proto.Message, error) {
+func loadJSON(creator func() cfgcommon.Buildable) func(string) (proto.Message, error) {
 	return func(s string) (proto.Message, error) {
 		instance := creator()
 		if err := json.Unmarshal([]byte(s), instance); err != nil {

+ 2 - 1
infra/conf/http_test.go

@@ -1,6 +1,7 @@
 package conf_test
 
 import (
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	. "github.com/v2fly/v2ray-core/v4/infra/conf"
@@ -8,7 +9,7 @@ import (
 )
 
 func TestHTTPServerConfig(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(HTTPServerConfig)
 	}
 

+ 2 - 1
infra/conf/reverse_test.go

@@ -1,6 +1,7 @@
 package conf_test
 
 import (
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	"github.com/v2fly/v2ray-core/v4/app/reverse"
@@ -8,7 +9,7 @@ import (
 )
 
 func TestReverseConfig(t *testing.T) {
-	creator := func() conf.Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(conf.ReverseConfig)
 	}
 

+ 1 - 1
infra/conf/router.go

@@ -64,7 +64,7 @@ func (r *BalancingRule) Build() (*router.BalancingRule, error) {
 		return nil, newError("failed to parse to strategy config.").Base(err)
 	}
 	var ts proto.Message
-	if builder, ok := rawConfig.(Buildable); ok {
+	if builder, ok := rawConfig.(cfgcommon.Buildable); ok {
 		ts, err = builder.Build()
 		if err != nil {
 			return nil, err

+ 2 - 1
infra/conf/shadowsocks_test.go

@@ -1,6 +1,7 @@
 package conf_test
 
 import (
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	"github.com/v2fly/v2ray-core/v4/common/net"
@@ -11,7 +12,7 @@ import (
 )
 
 func TestShadowsocksServerConfigParsing(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(ShadowsocksServerConfig)
 	}
 

+ 3 - 2
infra/conf/socks_test.go

@@ -1,6 +1,7 @@
 package conf_test
 
 import (
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	"github.com/v2fly/v2ray-core/v4/common/net"
@@ -11,7 +12,7 @@ import (
 )
 
 func TestSocksInboundConfig(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(SocksServerConfig)
 	}
 
@@ -50,7 +51,7 @@ func TestSocksInboundConfig(t *testing.T) {
 }
 
 func TestSocksOutboundConfig(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(SocksClientConfig)
 	}
 

+ 3 - 3
infra/conf/transport_internet.go

@@ -98,7 +98,7 @@ func (c *KCPConfig) Build() (proto.Message, error) {
 		if err != nil {
 			return nil, newError("invalid mKCP header config.").Base(err).AtError()
 		}
-		ts, err := headerConfig.(Buildable).Build()
+		ts, err := headerConfig.(cfgcommon.Buildable).Build()
 		if err != nil {
 			return nil, newError("invalid mKCP header config").Base(err).AtError()
 		}
@@ -125,7 +125,7 @@ func (c *TCPConfig) Build() (proto.Message, error) {
 		if err != nil {
 			return nil, newError("invalid TCP header config").Base(err).AtError()
 		}
-		ts, err := headerConfig.(Buildable).Build()
+		ts, err := headerConfig.(cfgcommon.Buildable).Build()
 		if err != nil {
 			return nil, newError("invalid TCP header config").Base(err).AtError()
 		}
@@ -221,7 +221,7 @@ func (c *QUICConfig) Build() (proto.Message, error) {
 		if err != nil {
 			return nil, newError("invalid QUIC header config.").Base(err).AtError()
 		}
-		ts, err := headerConfig.(Buildable).Build()
+		ts, err := headerConfig.(cfgcommon.Buildable).Build()
 		if err != nil {
 			return nil, newError("invalid QUIC header config").Base(err).AtError()
 		}

+ 2 - 2
infra/conf/v2ray.go

@@ -235,7 +235,7 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) {
 	if dokodemoConfig, ok := rawConfig.(*DokodemoConfig); ok {
 		receiverSettings.ReceiveOriginalDestination = dokodemoConfig.Redirect
 	}
-	ts, err := rawConfig.(Buildable).Build()
+	ts, err := rawConfig.(cfgcommon.Buildable).Build()
 	if err != nil {
 		return nil, err
 	}
@@ -297,7 +297,7 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) {
 	if err != nil {
 		return nil, newError("failed to parse to outbound detour config.").Base(err)
 	}
-	ts, err := rawConfig.(Buildable).Build()
+	ts, err := rawConfig.(cfgcommon.Buildable).Build()
 	if err != nil {
 		return nil, err
 	}

+ 3 - 2
infra/conf/vless_test.go

@@ -1,6 +1,7 @@
 package conf_test
 
 import (
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	"github.com/v2fly/v2ray-core/v4/common/net"
@@ -13,7 +14,7 @@ import (
 )
 
 func TestVLessOutbound(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(VLessOutboundConfig)
 	}
 
@@ -59,7 +60,7 @@ func TestVLessOutbound(t *testing.T) {
 }
 
 func TestVLessInbound(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(VLessInboundConfig)
 	}
 

+ 3 - 2
infra/conf/vmess_test.go

@@ -1,6 +1,7 @@
 package conf_test
 
 import (
+	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
 	"testing"
 
 	"github.com/v2fly/v2ray-core/v4/common/net"
@@ -13,7 +14,7 @@ import (
 )
 
 func TestVMessOutbound(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(VMessOutboundConfig)
 	}
 
@@ -63,7 +64,7 @@ func TestVMessOutbound(t *testing.T) {
 }
 
 func TestVMessInbound(t *testing.T) {
-	creator := func() Buildable {
+	creator := func() cfgcommon.Buildable {
 		return new(VMessInboundConfig)
 	}