1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-03 20:45:23 +00:00
v2fly/tools/conf/dns_test.go

30 lines
665 B
Go
Raw Normal View History

2016-10-17 12:35:13 +00:00
package conf_test
2016-05-16 16:19:55 +00:00
import (
"encoding/json"
"testing"
2016-08-20 18:55:45 +00:00
v2net "v2ray.com/core/common/net"
"v2ray.com/core/testing/assert"
2016-10-17 12:35:13 +00:00
. "v2ray.com/core/tools/conf"
2016-05-16 16:19:55 +00:00
)
2016-10-17 12:35:13 +00:00
func TestDnsConfigParsing(t *testing.T) {
2016-05-24 19:55:46 +00:00
assert := assert.On(t)
2016-05-16 16:19:55 +00:00
rawJson := `{
"servers": ["8.8.8.8"]
}`
2016-10-17 12:35:13 +00:00
jsonConfig := new(DnsConfig)
err := json.Unmarshal([]byte(rawJson), jsonConfig)
2016-05-16 16:19:55 +00:00
assert.Error(err).IsNil()
2016-10-17 12:35:13 +00:00
config := jsonConfig.Build()
2016-05-16 16:19:55 +00:00
assert.Int(len(config.NameServers)).Equals(1)
2016-09-20 14:05:35 +00:00
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))
2016-05-16 16:19:55 +00:00
}