diff --git a/plugin/geodns/filter.go b/plugin/geodns/filter.go index dc3ac1e50c5..a9424db872d 100644 --- a/plugin/geodns/filter.go +++ b/plugin/geodns/filter.go @@ -56,6 +56,11 @@ func (r *ResponseFilter) WriteMsg(res *dns.Msg) error { return r.ResponseWriter.WriteMsg(res) } + if len(res.Answer) == 0 { + log.Debugf("answer is empty, nothing to do") + return r.ResponseWriter.WriteMsg(res) + } + clientInf := r.filter.db.IPInfo(r.client) if clientInf.IsEmpty() { log.Warningf(formErrMessage(r.client)) @@ -66,6 +71,9 @@ func (r *ResponseFilter) WriteMsg(res *dns.Msg) error { } healthy := r.filterHealthy(res.Answer) + if len(healthy) == 0 { + log.Warning("no healthy answer servers") + } distances := make([]serverInfo, len(healthy)) for i, rec := range healthy { diff --git a/plugin/geodns/health.go b/plugin/geodns/health.go index 3e09a0acb25..c3205f91301 100644 --- a/plugin/geodns/health.go +++ b/plugin/geodns/health.go @@ -1,6 +1,7 @@ package geodns import ( + "net" "net/http" "sync" "time" @@ -21,8 +22,8 @@ func newHealthChecker() *checker { client: &http.Client{ Timeout: 2 * time.Second, }, - schema: "https://", - port: ":443", + schema: "http://", + port: "80", } } @@ -54,11 +55,12 @@ func (c *checker) check(endpoints []string) []bool { } func (c *checker) checkOne(endpoint string) bool { - response, err := c.client.Get(c.schema + endpoint + c.port) + response, err := c.client.Get(c.schema + net.JoinHostPort(endpoint, c.port)) if err != nil { + log.Debugf(err.Error()) return false } _ = response.Body.Close() - return response.StatusCode == http.StatusOK + return response.StatusCode < http.StatusInternalServerError }