mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-03-30 16:25:39 +00:00
Add an option no_user_agent
This commit is contained in:
@@ -53,6 +53,7 @@ type others struct {
|
||||
NoCookies bool `toml:"no_cookies"`
|
||||
NoECS bool `toml:"no_ecs"`
|
||||
NoIPv6 bool `toml:"no_ipv6"`
|
||||
NoUserAgent bool `toml:"no_user_agent"`
|
||||
Verbose bool `toml:"verbose"`
|
||||
DebugHTTPHeaders []string `toml:"debug_http_headers"`
|
||||
}
|
||||
|
||||
@@ -119,5 +119,16 @@ no_ecs = false
|
||||
# Note that DNS listening and bootstrapping is not controlled by this option.
|
||||
no_ipv6 = false
|
||||
|
||||
# Disable submitting User-Agent
|
||||
#
|
||||
# It is generally not recommended to disable submitting User-Agent because it
|
||||
# is still possible to probe client version according to behavior differences,
|
||||
# such as TLS handshaking, handling of malformed packets, and specific bugs.
|
||||
# Additionally, User-Agent is an important way for the server to distinguish
|
||||
# buggy, old, or insecure clients, and to workaround specific bugs.
|
||||
# (e.g. doh-server can detect and workaround certain issues of DNSCrypt-Proxy
|
||||
# and older Firefox.)
|
||||
no_user_agent = false
|
||||
|
||||
# Enable logging
|
||||
verbose = false
|
||||
|
||||
@@ -86,7 +86,11 @@ func (c *Client) generateRequestGoogle(ctx context.Context, w dns.ResponseWriter
|
||||
}
|
||||
|
||||
req.Header.Set("Accept", "application/json, application/dns-message, application/dns-udpwireformat")
|
||||
req.Header.Set("User-Agent", USER_AGENT)
|
||||
if !c.conf.NoUserAgent {
|
||||
req.Header.Set("User-Agent", USER_AGENT)
|
||||
} else {
|
||||
req.Header.Set("User-Agent", "")
|
||||
}
|
||||
req = req.WithContext(ctx)
|
||||
|
||||
c.httpClientMux.RLock()
|
||||
|
||||
@@ -128,7 +128,11 @@ func (c *Client) generateRequestIETF(ctx context.Context, w dns.ResponseWriter,
|
||||
req.Header.Set("Content-Type", "application/dns-message")
|
||||
}
|
||||
req.Header.Set("Accept", "application/dns-message, application/dns-udpwireformat, application/json")
|
||||
req.Header.Set("User-Agent", USER_AGENT)
|
||||
if !c.conf.NoUserAgent {
|
||||
req.Header.Set("User-Agent", USER_AGENT)
|
||||
} else {
|
||||
req.Header.Set("User-Agent", "")
|
||||
}
|
||||
req = req.WithContext(ctx)
|
||||
c.httpClientMux.RLock()
|
||||
resp, err := c.httpClient.Do(req)
|
||||
|
||||
Reference in New Issue
Block a user