mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-14 20:39:36 +03:00
Chore: Refactor infra/conf.TestToCidrList() (#4017)
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user