diff --git a/doh-server/config.go b/doh-server/config.go index 767069b..73998aa 100644 --- a/doh-server/config.go +++ b/doh-server/config.go @@ -43,6 +43,7 @@ type config struct { Tries uint `toml:"tries"` Verbose bool `toml:"verbose"` LogGuessedIP bool `toml:"log_guessed_client_ip"` + ECSDisable bool `toml:"ecs_disable"` ECSAllowNonGlobalIP bool `toml:"ecs_allow_non_global_ip"` ECSUsePreciseIP bool `toml:"ecs_use_precise_ip"` TLSClientAuth bool `toml:"tls_client_auth"` diff --git a/doh-server/doh-server.conf b/doh-server/doh-server.conf index dcdaa84..1cfaa21 100644 --- a/doh-server/doh-server.conf +++ b/doh-server/doh-server.conf @@ -52,6 +52,10 @@ verbose = false # Note: http uri/useragent log cannot be controlled by this config log_guessed_client_ip = false +# Disable ECS +# If this item is set to true, edns will not work. +ecs_disable = false; + # By default, non global IP addresses are never forwarded to upstream servers. # This is to prevent two things from happening: # 1. the upstream server knowing your private LAN addresses; diff --git a/doh-server/server.go b/doh-server/server.go index 8efd584..a384e5b 100644 --- a/doh-server/server.go +++ b/doh-server/server.go @@ -284,6 +284,10 @@ func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) { } func (s *Server) findClientIP(r *http.Request) net.IP { + if s.conf.ECSDisable { + return nil + } + noEcs := r.URL.Query().Get("no_ecs") if strings.EqualFold(noEcs, "true") { return nil