Fix review comments
This commit is contained in:
parent
b477b67428
commit
a40ddb094b
|
@ -20,7 +20,8 @@
|
||||||
"DisableAll": false,
|
"DisableAll": false,
|
||||||
"Disable": [
|
"Disable": [
|
||||||
"maligned",
|
"maligned",
|
||||||
"goconst"
|
"goconst",
|
||||||
|
"vetshadow"
|
||||||
],
|
],
|
||||||
|
|
||||||
"Cyclo": 20,
|
"Cyclo": 20,
|
||||||
|
|
|
@ -198,7 +198,7 @@ func handleStatsTop(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// handleStatsReset resets the stats caches
|
// handleStatsReset resets the stats caches
|
||||||
func handleStatsReset(w http.ResponseWriter, r *http.Request) {
|
func handleStatsReset(w http.ResponseWriter, r *http.Request) {
|
||||||
dnsServer.ResetStats()
|
dnsServer.PurgeStats()
|
||||||
_, err := fmt.Fprintf(w, "OK\n")
|
_, err := fmt.Fprintf(w, "OK\n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorText := fmt.Sprintf("Couldn't write body: %s", err)
|
errorText := fmt.Sprintf("Couldn't write body: %s", err)
|
||||||
|
|
4
dhcp.go
4
dhcp.go
|
@ -85,8 +85,8 @@ func handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) {
|
||||||
// this interface doesn't support broadcast, skip it
|
// this interface doesn't support broadcast, skip it
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
addrs, e := iface.Addrs()
|
addrs, err := iface.Addrs()
|
||||||
if e != nil {
|
if err != nil {
|
||||||
httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %s: %s", iface.Name, err)
|
httpError(w, http.StatusInternalServerError, "Failed to get addresses for interface %s: %s", iface.Name, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,14 @@ func (s *Server) startInternal(config *ServerConfig) error {
|
||||||
return errors.New("DNS server is already started")
|
return errors.New("DNS server is already started")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.queryLog == nil {
|
||||||
|
s.queryLog = newQueryLog(".")
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.stats == nil {
|
||||||
|
s.stats = newStats()
|
||||||
|
}
|
||||||
|
|
||||||
err := s.initDNSFilter()
|
err := s.initDNSFilter()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -200,7 +208,7 @@ func (s *Server) stopInternal() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// flush remainder to file
|
// flush remainder to file
|
||||||
return s.queryLog.clearLogBuffer()
|
return s.queryLog.flushLogBuffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsRunning returns true if the DNS server is running
|
// IsRunning returns true if the DNS server is running
|
||||||
|
@ -242,8 +250,8 @@ func (s *Server) GetStatsTop() *StatsTop {
|
||||||
return s.queryLog.runningTop.getStatsTop()
|
return s.queryLog.runningTop.getStatsTop()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetStats purges current server stats
|
// PurgeStats purges current server stats
|
||||||
func (s *Server) ResetStats() {
|
func (s *Server) PurgeStats() {
|
||||||
// TODO: Locks?
|
// TODO: Locks?
|
||||||
s.stats.purgeStats()
|
s.stats.purgeStats()
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ var (
|
||||||
|
|
||||||
const enableGzip = false
|
const enableGzip = false
|
||||||
|
|
||||||
// clearLogBuffer flushes the current buffer to file and resets the current buffer
|
// flushLogBuffer flushes the current buffer to file and resets the current buffer
|
||||||
func (l *queryLog) clearLogBuffer() error {
|
func (l *queryLog) flushLogBuffer() error {
|
||||||
// flush remainder to file
|
// flush remainder to file
|
||||||
l.logBufferLock.Lock()
|
l.logBufferLock.Lock()
|
||||||
flushBuffer := l.logBuffer
|
flushBuffer := l.logBuffer
|
||||||
|
|
|
@ -95,13 +95,10 @@ func refreshFiltersIfNecessary(force bool) int {
|
||||||
filter.ID = assignUniqueFilterID()
|
filter.ID = assignUniqueFilterID()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-load it from the disk before updating
|
|
||||||
if len(filter.Rules) == 0 {
|
if len(filter.Rules) == 0 {
|
||||||
err := filter.load()
|
// Try reloading filter from the disk before updating
|
||||||
if err != nil {
|
// This is useful for the case when we simply enable a previously downloaded filter
|
||||||
log.Printf("Failed to reload filter %s: %s", filter.URL, err)
|
_ = filter.load()
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updated, err := filter.update(force)
|
updated, err := filter.update(force)
|
||||||
|
|
Loading…
Reference in New Issue