+ dns: use per-client filtering settings
This commit is contained in:
parent
8f7aff93d7
commit
3f89335ed2
23
dns.go
23
dns.go
|
@ -70,9 +70,32 @@ func generateServerConfig() dnsforward.ServerConfig {
|
|||
newconfig.Upstreams = upstreamConfig.Upstreams
|
||||
newconfig.DomainsReservedUpstreams = upstreamConfig.DomainReservedUpstreams
|
||||
newconfig.AllServers = config.DNS.AllServers
|
||||
newconfig.FilterHandler = applyClientSettings
|
||||
return newconfig
|
||||
}
|
||||
|
||||
// If a client has his own settings, apply them
|
||||
func applyClientSettings(clientAddr string, setts *dnsfilter.RequestFilteringSettings) {
|
||||
c, ok := clientFind(clientAddr)
|
||||
if !ok || !c.UseOwnSettings {
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug("Using settings for client with IP %s", clientAddr)
|
||||
if !c.FilteringEnabled {
|
||||
setts.FilteringEnabled = false
|
||||
}
|
||||
if !c.SafeSearchEnabled {
|
||||
setts.SafeSearchEnabled = false
|
||||
}
|
||||
if !c.SafeBrowsingEnabled {
|
||||
setts.SafeBrowsingEnabled = false
|
||||
}
|
||||
if !c.ParentalEnabled {
|
||||
setts.ParentalEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
func startDNSServer() error {
|
||||
if isRunning() {
|
||||
return fmt.Errorf("unable to start forwarding DNS server: Already running")
|
||||
|
|
Loading…
Reference in New Issue