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

Restrict the set of resolvers used from a remote source

This commit is contained in:
Frank Denis 2018-01-14 00:08:46 +01:00
parent 13e30ade2b
commit 1b7b6418f1
2 changed files with 19 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"errors"
"flag"
"fmt"
"strings"
"time"
"github.com/BurntSushi/toml"
@ -112,12 +113,18 @@ func ConfigLoad(proxy *Proxy, config_file string) error {
dlog.Criticalf("Unable use source [%s]: [%s]", sourceName, err)
continue
}
proxy.registeredServers = append(proxy.registeredServers, registeredServers...)
for _, registeredServer := range registeredServers {
if !includesName(config.ServerNames, registeredServer.name) {
continue
}
dlog.Infof("Adding [%s] to the set of wanted resolvers", registeredServer.name)
proxy.registeredServers = append(proxy.registeredServers, registeredServer)
}
}
for _, serverName := range config.ServerNames {
serverConfig, ok := config.ServersConfig[serverName]
if !ok {
return fmt.Errorf("No definitions found for server [%v]", serverName)
continue
}
var stamp ServerStamp
var err error
@ -137,3 +144,12 @@ func ConfigLoad(proxy *Proxy, config_file string) error {
}
return nil
}
func includesName(names []string, name string) bool {
for _, found := range names {
if strings.EqualFold(found, name) {
return true
}
}
return false
}

View File

@ -11,7 +11,7 @@
## List of servers to use
## If this line is commented, all registered servers will be used
server_names = ["dnscrypt.org-fr"]
server_names = ["dnscrypt.org-fr", "adguard-dns"]
## List of local addresses and ports to listen to. Can be IPv4 and/or IPv6.