Chore: Refactor infra/conf.TestToCidrList() (#4017)

This commit is contained in:
zonescape 2024-11-14 19:04:17 +03:00 committed by GitHub
parent 17825b25f2
commit ec1fd008c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 30 deletions

View file

@ -2,35 +2,15 @@ package conf_test
import (
"encoding/json"
"os"
"path/filepath"
"testing"
"github.com/xtls/xray-core/app/dns"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/platform"
"github.com/xtls/xray-core/common/platform/filesystem"
. "github.com/xtls/xray-core/infra/conf"
"google.golang.org/protobuf/proto"
)
func init() {
wd, err := os.Getwd()
common.Must(err)
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) {
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "resources", "geoip.dat")))
}
os.Setenv("xray.location.asset", wd)
}
func TestDNSConfigParsing(t *testing.T) {
defer func() {
os.Unsetenv("xray.location.asset")
}()
parserCreator := func() func(string) (proto.Message, error) {
return func(s string) (proto.Message, error) {
config := new(DNSConfig)