mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
665 B
30 lines
665 B
8 years ago
|
package conf_test
|
||
9 years ago
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"testing"
|
||
|
|
||
8 years ago
|
v2net "v2ray.com/core/common/net"
|
||
|
"v2ray.com/core/testing/assert"
|
||
8 years ago
|
. "v2ray.com/core/tools/conf"
|
||
9 years ago
|
)
|
||
|
|
||
8 years ago
|
func TestDnsConfigParsing(t *testing.T) {
|
||
9 years ago
|
assert := assert.On(t)
|
||
9 years ago
|
|
||
|
rawJson := `{
|
||
|
"servers": ["8.8.8.8"]
|
||
|
}`
|
||
|
|
||
8 years ago
|
jsonConfig := new(DnsConfig)
|
||
|
err := json.Unmarshal([]byte(rawJson), jsonConfig)
|
||
9 years ago
|
assert.Error(err).IsNil()
|
||
8 years ago
|
|
||
|
config := jsonConfig.Build()
|
||
9 years ago
|
assert.Int(len(config.NameServers)).Equals(1)
|
||
8 years ago
|
dest := config.NameServers[0].AsDestination()
|
||
|
assert.Destination(dest).IsUDP()
|
||
|
assert.Address(dest.Address).Equals(v2net.IPAddress([]byte{8, 8, 8, 8}))
|
||
|
assert.Port(dest.Port).Equals(v2net.Port(53))
|
||
9 years ago
|
}
|