move v4 configure support to own directory

This commit is contained in:
Shelikhoo 2021-06-19 13:45:43 +01:00
parent c86ac3aca6
commit add375390e
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
42 changed files with 76 additions and 76 deletions

View File

@ -3,11 +3,11 @@ package serial
import (
"bytes"
"encoding/json"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"io"
core "github.com/v2fly/v2ray-core/v4"
"github.com/v2fly/v2ray-core/v4/common/errors"
"github.com/v2fly/v2ray-core/v4/infra/conf"
json_reader "github.com/v2fly/v2ray-core/v4/infra/conf/json"
)
@ -40,8 +40,8 @@ func findOffset(b []byte, o int) *offset {
// DecodeJSONConfig reads from reader and decode the config into *conf.Config
// syntax error could be detected.
func DecodeJSONConfig(reader io.Reader) (*conf.Config, error) {
jsonConfig := &conf.Config{}
func DecodeJSONConfig(reader io.Reader) (*v4.Config, error) {
jsonConfig := &v4.Config{}
err := DecodeJSON(reader, jsonConfig)
if err != nil {
return nil, err

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"strings"

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/json"

View File

@ -1,18 +1,18 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/v2fly/v2ray-core/v4/common/serial"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/blackhole"
)
func TestHTTPResponseJSON(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(BlackholeConfig)
return new(v4.BlackholeConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"strings"

View File

@ -1,3 +1,3 @@
package conf
package v4
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

View File

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

View File

@ -1,18 +1,18 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/v2fly/v2ray-core/v4/common/net"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/dns"
)
func TestDnsProxyConfig(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(DNSOutboundConfig)
return new(v4.DNSOutboundConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{

View File

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

View File

@ -1,18 +1,18 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/v2fly/v2ray-core/v4/common/net"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/dokodemo"
)
func TestDokodemoConfig(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(DokodemoConfig)
return new(v4.DokodemoConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{

View File

@ -1,4 +1,4 @@
package conf
package v4
import "github.com/v2fly/v2ray-core/v4/common/errors"

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/json"

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"net"

View File

@ -1,19 +1,19 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/common/protocol"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/freedom"
)
func TestFreedomConfig(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(FreedomConfig)
return new(v4.FreedomConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{

View File

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

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/json"

View File

@ -1,17 +1,17 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/http"
)
func TestHTTPServerConfig(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(HTTPServerConfig)
return new(v4.HTTPServerConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{

View File

@ -1,4 +1,4 @@
package conf
package v4
func init() {
RegisterConfigureFilePostProcessingStage("FakeDNS", &FakeDNSPostProcessingStage{})

View File

@ -1,4 +1,4 @@
package conf
package v4
type ConfigureFilePostProcessingStage interface {
Process(conf *Config) error

View File

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

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/json"

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"github.com/v2fly/v2ray-core/v4/app/policy"

View File

@ -1,10 +1,10 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/v2fly/v2ray-core/v4/common"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
)
func TestBufferSize(t *testing.T) {
@ -28,7 +28,7 @@ func TestBufferSize(t *testing.T) {
for _, c := range cases {
bs := c.Input
pConf := Policy{
pConf := v4.Policy{
BufferSize: &bs,
}
p, err := pConf.Build()

View File

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

View File

@ -1,17 +1,17 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/v2fly/v2ray-core/v4/app/reverse"
"github.com/v2fly/v2ray-core/v4/infra/conf"
)
func TestReverseConfig(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(conf.ReverseConfig)
return new(v4.ReverseConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/json"

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"strings"

View File

@ -1,20 +1,20 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/common/protocol"
"github.com/v2fly/v2ray-core/v4/common/serial"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/shadowsocks"
)
func TestShadowsocksServerConfigParsing(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(ShadowsocksServerConfig)
return new(v4.ShadowsocksServerConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/json"

View File

@ -1,20 +1,20 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/common/protocol"
"github.com/v2fly/v2ray-core/v4/common/serial"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/socks"
)
func TestSocksInboundConfig(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(SocksServerConfig)
return new(v4.SocksServerConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{
@ -53,7 +53,7 @@ func TestSocksInboundConfig(t *testing.T) {
func TestSocksOutboundConfig(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(SocksClientConfig)
return new(v4.SocksClientConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"github.com/v2fly/v2ray-core/v4/common/serial"

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"sort"

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/base64"

View File

@ -1,15 +1,15 @@
package conf_test
package v4_test
import (
"encoding/json"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/golang/protobuf/proto"
"github.com/v2fly/v2ray-core/v4/common/protocol"
"github.com/v2fly/v2ray-core/v4/common/serial"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/transport"
"github.com/v2fly/v2ray-core/v4/transport/internet"
"github.com/v2fly/v2ray-core/v4/transport/internet/headers/http"
@ -24,7 +24,7 @@ import (
func TestSocketConfig(t *testing.T) {
createParser := func() func(string) (proto.Message, error) {
return func(s string) (proto.Message, error) {
config := new(SocketConfig)
config := new(v4.SocketConfig)
if err := json.Unmarshal([]byte(s), config); err != nil {
return nil, err
}
@ -50,7 +50,7 @@ func TestSocketConfig(t *testing.T) {
func TestTransportConfig(t *testing.T) {
createParser := func() func(string) (proto.Message, error) {
return func(s string) (proto.Message, error) {
config := new(TransportConfig)
config := new(v4.TransportConfig)
if err := json.Unmarshal([]byte(s), config); err != nil {
return nil, err
}

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/json"

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/json"

View File

@ -1,8 +1,9 @@
package conf_test
package v4_test
import (
"encoding/json"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"reflect"
"testing"
@ -18,7 +19,6 @@ import (
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/common/protocol"
"github.com/v2fly/v2ray-core/v4/common/serial"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/blackhole"
dns_proxy "github.com/v2fly/v2ray-core/v4/proxy/dns"
"github.com/v2fly/v2ray-core/v4/proxy/freedom"
@ -33,7 +33,7 @@ import (
func TestV2RayConfig(t *testing.T) {
createParser := func() func(string) (proto.Message, error) {
return func(s string) (proto.Message, error) {
config := new(Config)
config := new(v4.Config)
if err := json.Unmarshal([]byte(s), config); err != nil {
return nil, err
}
@ -363,7 +363,7 @@ func TestMuxConfig_Build(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := &MuxConfig{}
m := &v4.MuxConfig{}
common.Must(json.Unmarshal([]byte(tt.fields), m))
if got := m.Build(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("MuxConfig.Build() = %v, want %v", got, tt.want)

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/json"

View File

@ -1,14 +1,14 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/common/protocol"
"github.com/v2fly/v2ray-core/v4/common/serial"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/vless"
"github.com/v2fly/v2ray-core/v4/proxy/vless/inbound"
"github.com/v2fly/v2ray-core/v4/proxy/vless/outbound"
@ -16,7 +16,7 @@ import (
func TestVLessOutbound(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(VLessOutboundConfig)
return new(v4.VLessOutboundConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{
@ -62,7 +62,7 @@ func TestVLessOutbound(t *testing.T) {
func TestVLessInbound(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(VLessInboundConfig)
return new(v4.VLessInboundConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{

View File

@ -1,4 +1,4 @@
package conf
package v4
import (
"encoding/json"

View File

@ -1,14 +1,14 @@
package conf_test
package v4_test
import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"testing"
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/common/protocol"
"github.com/v2fly/v2ray-core/v4/common/serial"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/vmess"
"github.com/v2fly/v2ray-core/v4/proxy/vmess/inbound"
"github.com/v2fly/v2ray-core/v4/proxy/vmess/outbound"
@ -16,7 +16,7 @@ import (
func TestVMessOutbound(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(VMessOutboundConfig)
return new(v4.VMessOutboundConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{
@ -66,7 +66,7 @@ func TestVMessOutbound(t *testing.T) {
func TestVMessInbound(t *testing.T) {
creator := func() cfgcommon.Buildable {
return new(VMessInboundConfig)
return new(v4.VMessInboundConfig)
}
testassist.RunMultiTestCase(t, []testassist.TestCase{

View File

@ -2,9 +2,9 @@ package helpers
import (
"bytes"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"os"
"github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/infra/conf/merge"
"github.com/v2fly/v2ray-core/v4/infra/conf/mergers"
"github.com/v2fly/v2ray-core/v4/infra/conf/serial"
@ -13,7 +13,7 @@ import (
// LoadConfig load config files to *conf.Config, it will:
// - resolve folder to files
// - try to read stdin if no file specified
func LoadConfig(files []string, format string, recursively bool) (*conf.Config, error) {
func LoadConfig(files []string, format string, recursively bool) (*v4.Config, error) {
m, err := LoadConfigToMap(files, format, recursively)
if err != nil {
return nil, err