mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-09 00:39:13 +00:00
support dest override in dns outbound
This commit is contained in:
7 files changed
+191
-16
No files matched your search
+16
-2
@@ -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
|
||||
}
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -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{
|
||||
|
||||
Reference in new issue
Block a user