Browse Source

isolate dns settings synthesis

Shelikhoo 4 years ago
parent
commit
b37755d111
3 changed files with 10 additions and 6 deletions
  1. 3 1
      infra/conf/synthetic/dns/dns.go
  2. 5 4
      infra/conf/synthetic/dns/dns_test.go
  3. 2 1
      infra/conf/v2ray.go

+ 3 - 1
infra/conf/dns.go → infra/conf/synthetic/dns/dns.go

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

+ 5 - 4
infra/conf/dns_test.go → infra/conf/synthetic/dns/dns_test.go

@@ -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
 			}

+ 2 - 1
infra/conf/v2ray.go

@@ -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"`