support dest override in dns outbound

This commit is contained in:
Darien Raymond committed 2019-02-12 22:34:43 +01:00
1 parent 6c31049295
commit 114ec4c74b
7 files changed
+191 -16

No files matched your search

+16 -2
View File
@@ -2,11 +2,25 @@ package conf
import (
"github.com/golang/protobuf/proto"
"v2ray.com/core/common/net"
"v2ray.com/core/proxy/dns"
)
type DnsOutboundConfig struct{}
type DnsOutboundConfig struct {
Network Network `json:network`
Address *Address `json:address`
Port uint16 `json:port`
}
func (c *DnsOutboundConfig) Build() (proto.Message, error) {
return new(dns.Config), nil
config := &dns.Config{
Server: &net.Endpoint{
Network: c.Network.Build(),
Port: uint32(c.Port),
},
}
if c.Address != nil {
config.Server.Address = c.Address.Build()
}
return config, nil
}
+33
View File
@@ -0,0 +1,33 @@
package conf_test
import (
"testing"
"v2ray.com/core/common/net"
. "v2ray.com/core/infra/conf"
"v2ray.com/core/proxy/dns"
)
func TestDnsProxyConfig(t *testing.T) {
creator := func() Buildable {
return new(DnsOutboundConfig)
}
runMultiTestCase(t, []TestCase{
{
Input: `{
"address": "8.8.8.8",
"port": 53,
"network": "tcp"
}`,
Parser: loadJSON(creator),
Output: &dns.Config{
Server: &net.Endpoint{
Network: net.Network_TCP,
Address: net.NewIPOrDomain(net.IPAddress([]byte{8, 8, 8, 8})),
Port: 53,
},
},
},
})
}
+3 -1
View File
@@ -221,7 +221,9 @@ func TestV2RayConfig(t *testing.T) {
},
},
}),
ProxySettings: serial.ToTypedMessage(&dns_proxy.Config{}),
ProxySettings: serial.ToTypedMessage(&dns_proxy.Config{
Server: &net.Endpoint{},
}),
},
},
Inbound: []*core.InboundHandlerConfig{