1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

isolate dns settings synthesis

This commit is contained in:
Shelikhoo 2021-06-19 13:41:32 +01:00
parent 3510ddb464
commit b37755d111
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
3 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,6 @@
package conf
package dns
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
import (
"context"

View File

@ -1,4 +1,4 @@
package conf_test
package dns_test
import (
"encoding/json"
@ -15,8 +15,9 @@ import (
"github.com/v2fly/v2ray-core/v4/common"
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/common/platform/filesystem"
"github.com/v2fly/v2ray-core/v4/infra/conf"
_ "github.com/v2fly/v2ray-core/v4/infra/conf/geodata/standard"
dns2 "github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/dns"
)
func init() {
@ -28,7 +29,7 @@ func init() {
wd, err := os.Getwd()
common.Must(err)
tempPath := filepath.Join(wd, "..", "..", "testing", "temp")
tempPath := filepath.Join(wd, "..", "..", "..", "..", "testing", "temp")
geoipPath := filepath.Join(tempPath, "geoip.dat")
geositePath := filepath.Join(tempPath, "geosite.dat")
@ -51,7 +52,7 @@ func init() {
func TestDNSConfigParsing(t *testing.T) {
parserCreator := func() func(string) (protoiface.MessageV1, error) {
return func(s string) (protoiface.MessageV1, error) {
config := new(conf.DNSConfig)
config := new(dns2.DNSConfig)
if err := json.Unmarshal([]byte(s), config); err != nil {
return nil, err
}

View File

@ -3,6 +3,7 @@ package conf
import (
"encoding/json"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/loader"
"github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/dns"
"github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/log"
"github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/router"
"strings"
@ -343,7 +344,7 @@ type Config struct {
LogConfig *log.LogConfig `json:"log"`
RouterConfig *router.RouterConfig `json:"routing"`
DNSConfig *DNSConfig `json:"dns"`
DNSConfig *dns.DNSConfig `json:"dns"`
InboundConfigs []InboundDetourConfig `json:"inbounds"`
OutboundConfigs []OutboundDetourConfig `json:"outbounds"`
Transport *TransportConfig `json:"transport"`