mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 01:27:03 -05:00
move v4 configure support to own directory
This commit is contained in:
parent
c86ac3aca6
commit
add375390e
@ -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
|
||||
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"strings"
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -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{
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"strings"
|
@ -1,3 +1,3 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
@ -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{
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
@ -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{
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import "github.com/v2fly/v2ray-core/v4/common/errors"
|
||||
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"net"
|
@ -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{
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -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{
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
func init() {
|
||||
RegisterConfigureFilePostProcessingStage("FakeDNS", &FakeDNSPostProcessingStage{})
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
type ConfigureFilePostProcessingStage interface {
|
||||
Process(conf *Config) error
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"github.com/v2fly/v2ray-core/v4/app/policy"
|
@ -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()
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
@ -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{
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"strings"
|
@ -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{
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -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{
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"github.com/v2fly/v2ray-core/v4/common/serial"
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"sort"
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
@ -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
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -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)
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -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{
|
@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package v4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -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{
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user