1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-01 03:25:23 +00:00

move buildable to cfg common

This commit is contained in:
Shelikhoo 2021-06-19 13:04:50 +01:00
parent b61d55c6a7
commit 41b54ff61e
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
16 changed files with 34 additions and 23 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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