1
0
mirror of https://github.com/DNSCrypt/dnscrypt-proxy.git synced 2024-12-27 00:12:31 +01:00

plugin_forward: parse more conventions for IPv6 addresses

This commit is contained in:
Frank Denis 2023-08-30 21:29:09 +02:00
parent 5ae83c1592
commit f531c8fffb

View File

@ -49,9 +49,16 @@ func (plugin *PluginForward) Init(proxy *Proxy) error {
var servers []string
for _, server := range strings.Split(serversStr, ",") {
server = strings.TrimSpace(server)
if net.ParseIP(server) != nil {
server = fmt.Sprintf("%s:%d", server, 53)
server = strings.TrimPrefix(server, "[")
server = strings.TrimSuffix(server, "]")
if ip := net.ParseIP(server); ip != nil {
if ip.To4() != nil {
server = fmt.Sprintf("%s:%d", server, 53)
} else {
server = fmt.Sprintf("[%s]:%d", server, 53)
}
}
dlog.Infof("Forwarding [%s] to %s", domain, server)
servers = append(servers, server)
}
if len(servers) == 0 {