Merge pull request #61 from m13253/feature/no_ecs_arg

Allow client opt-out of EDNS0 Client Subnet
This commit is contained in:
Star Brilliant
2019-11-11 12:21:41 +08:00
committed by GitHub

View File

@@ -234,6 +234,11 @@ func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) {
}
func (s *Server) findClientIP(r *http.Request) net.IP {
noEcs := r.URL.Query().Get("no_ecs")
if strings.ToLower(noEcs) == "true" {
return nil
}
XForwardedFor := r.Header.Get("X-Forwarded-For")
if XForwardedFor != "" {
for _, addr := range strings.Split(XForwardedFor, ",") {