mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-11-13 00:37:52 +00:00
Modify HTTP status codes to affect the error
This commit is contained in:
1 parent
c4412e2993
commit
f49b5a3a0b
2 files changed
+5
-2
No files matched your search
@@ -194,7 +194,7 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) {
|
||||
return
|
||||
}
|
||||
if resp.StatusCode != 200 {
|
||||
log.Printf("Server returned error: %s\n", resp.Status)
|
||||
log.Printf("HTTP error: %s\n", resp.Status)
|
||||
reply.Rcode = dns.RcodeServerFailure
|
||||
w.WriteMsg(reply)
|
||||
return
|
||||
|
||||
@@ -205,7 +205,7 @@ func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
resp, err := s.doDNSQuery(msg)
|
||||
if err != nil {
|
||||
jsonDNS.FormatError(w, fmt.Sprintf("DNS query failure (%s)", err.Error()), 503)
|
||||
jsonDNS.FormatError(w, fmt.Sprintf("DNS query failure (%s)", err.Error()), 502)
|
||||
return
|
||||
}
|
||||
respJson := jsonDNS.Marshal(resp)
|
||||
@@ -223,6 +223,9 @@ func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
w.Header().Set("Expires", respJson.EarliestExpires.Format(time.RFC1123))
|
||||
}
|
||||
if respJson.Status == dns.RcodeServerFailure {
|
||||
w.WriteHeader(503)
|
||||
}
|
||||
w.Write(respStr)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user