* minor fixes
This commit is contained in:
parent
9b8cccdfcf
commit
f579c23bc9
@ -64,7 +64,7 @@ func processIPCIDRArray(dst *map[string]bool, dstIPNet *[]net.IPNet, src []strin
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return TRUE if this client should be blocked
|
// IsBlockedIP - return TRUE if this client should be blocked
|
||||||
func (a *accessCtx) IsBlockedIP(ip string) bool {
|
func (a *accessCtx) IsBlockedIP(ip string) bool {
|
||||||
a.lock.Lock()
|
a.lock.Lock()
|
||||||
defer a.lock.Unlock()
|
defer a.lock.Unlock()
|
||||||
@ -104,7 +104,7 @@ func (a *accessCtx) IsBlockedIP(ip string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return TRUE if this domain should be blocked
|
// IsBlockedDomain - return TRUE if this domain should be blocked
|
||||||
func (a *accessCtx) IsBlockedDomain(host string) bool {
|
func (a *accessCtx) IsBlockedDomain(host string) bool {
|
||||||
a.lock.Lock()
|
a.lock.Lock()
|
||||||
_, ok := a.blockedHosts[host]
|
_, ok := a.blockedHosts[host]
|
||||||
|
@ -113,10 +113,6 @@ type FilteringConfig struct {
|
|||||||
ParentalBlockHost string `yaml:"parental_block_host"`
|
ParentalBlockHost string `yaml:"parental_block_host"`
|
||||||
SafeBrowsingBlockHost string `yaml:"safebrowsing_block_host"`
|
SafeBrowsingBlockHost string `yaml:"safebrowsing_block_host"`
|
||||||
|
|
||||||
// Names of services to block (globally).
|
|
||||||
// Per-client settings can override this configuration.
|
|
||||||
BlockedServices []string `yaml:"blocked_services"`
|
|
||||||
|
|
||||||
CacheSize uint `yaml:"cache_size"` // DNS cache size (in bytes)
|
CacheSize uint `yaml:"cache_size"` // DNS cache size (in bytes)
|
||||||
UpstreamDNS []string `yaml:"upstream_dns"`
|
UpstreamDNS []string `yaml:"upstream_dns"`
|
||||||
}
|
}
|
||||||
@ -282,13 +278,8 @@ func (s *Server) IsRunning() bool {
|
|||||||
return isRunning
|
return isRunning
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure2 - safely apply and write new configuration and restart
|
// Restart - restart server
|
||||||
func (s *Server) Reconfigure2(newconf FilteringConfig) error {
|
func (s *Server) Restart() error {
|
||||||
s.Lock()
|
|
||||||
s.conf.FilteringConfig = newconf
|
|
||||||
s.Unlock()
|
|
||||||
s.conf.ConfigModified()
|
|
||||||
|
|
||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
log.Print("Start reconfiguring the server")
|
log.Print("Start reconfiguring the server")
|
||||||
|
@ -63,7 +63,15 @@ func (s *Server) handleSetUpstreamConfig(w http.ResponseWriter, r *http.Request)
|
|||||||
newconf.BootstrapDNS = req.BootstrapDNS
|
newconf.BootstrapDNS = req.BootstrapDNS
|
||||||
|
|
||||||
newconf.AllServers = req.AllServers
|
newconf.AllServers = req.AllServers
|
||||||
err = s.Reconfigure2(newconf)
|
|
||||||
|
s.Lock()
|
||||||
|
s.conf.UpstreamDNS = newconf.UpstreamDNS
|
||||||
|
s.conf.BootstrapDNS = newconf.BootstrapDNS
|
||||||
|
s.conf.AllServers = newconf.AllServers
|
||||||
|
s.Unlock()
|
||||||
|
s.conf.ConfigModified()
|
||||||
|
|
||||||
|
err = s.Restart()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpError(r, w, http.StatusInternalServerError, "%s", err)
|
httpError(r, w, http.StatusInternalServerError, "%s", err)
|
||||||
return
|
return
|
||||||
|
@ -186,6 +186,8 @@ func handleBlockedServicesSet(w http.ResponseWriter, r *http.Request) {
|
|||||||
httpError(w, http.StatusBadRequest, "%s", err)
|
httpError(w, http.StatusBadRequest, "%s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
httpOK(r, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterBlockedServicesHandlers - register HTTP handlers
|
// RegisterBlockedServicesHandlers - register HTTP handlers
|
||||||
|
@ -112,6 +112,10 @@ type dnsConfig struct {
|
|||||||
FilteringEnabled bool `yaml:"filtering_enabled"` // whether or not use filter lists
|
FilteringEnabled bool `yaml:"filtering_enabled"` // whether or not use filter lists
|
||||||
FiltersUpdateIntervalHours uint32 `yaml:"filters_update_interval"` // time period to update filters (in hours)
|
FiltersUpdateIntervalHours uint32 `yaml:"filters_update_interval"` // time period to update filters (in hours)
|
||||||
DnsfilterConf dnsfilter.Config `yaml:",inline"`
|
DnsfilterConf dnsfilter.Config `yaml:",inline"`
|
||||||
|
|
||||||
|
// Names of services to block (globally).
|
||||||
|
// Per-client settings can override this configuration.
|
||||||
|
BlockedServices []string `yaml:"blocked_services"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type tlsConfigSettings struct {
|
type tlsConfigSettings struct {
|
||||||
|
@ -21,6 +21,9 @@ func returnOK(w http.ResponseWriter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func httpOK(r *http.Request, w http.ResponseWriter) {
|
||||||
|
}
|
||||||
|
|
||||||
func httpError(w http.ResponseWriter, code int, format string, args ...interface{}) {
|
func httpError(w http.ResponseWriter, code int, format string, args ...interface{}) {
|
||||||
text := fmt.Sprintf(format, args...)
|
text := fmt.Sprintf(format, args...)
|
||||||
log.Info(text)
|
log.Info(text)
|
||||||
|
Loading…
Reference in New Issue
Block a user