mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-05-24 19:35:23 +00:00
Add an option to disable IPv6, this option is available to client only
This commit is contained in:
+15
-6
@@ -131,13 +131,14 @@ func (c *Client) newHTTPClient() error {
|
|||||||
if c.httpTransport != nil {
|
if c.httpTransport != nil {
|
||||||
c.httpTransport.CloseIdleConnections()
|
c.httpTransport.CloseIdleConnections()
|
||||||
}
|
}
|
||||||
|
dialer := &net.Dialer{
|
||||||
|
Timeout: time.Duration(c.conf.Timeout) * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
DualStack: true,
|
||||||
|
Resolver: c.bootstrapResolver,
|
||||||
|
}
|
||||||
c.httpTransport = &http.Transport{
|
c.httpTransport = &http.Transport{
|
||||||
DialContext: (&net.Dialer{
|
DialContext: dialer.DialContext,
|
||||||
Timeout: time.Duration(c.conf.Timeout) * time.Second,
|
|
||||||
KeepAlive: 30 * time.Second,
|
|
||||||
DualStack: true,
|
|
||||||
Resolver: c.bootstrapResolver,
|
|
||||||
}).DialContext,
|
|
||||||
ExpectContinueTimeout: 1 * time.Second,
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
IdleConnTimeout: 90 * time.Second,
|
IdleConnTimeout: 90 * time.Second,
|
||||||
MaxIdleConns: 100,
|
MaxIdleConns: 100,
|
||||||
@@ -146,6 +147,14 @@ func (c *Client) newHTTPClient() error {
|
|||||||
ResponseHeaderTimeout: time.Duration(c.conf.Timeout) * time.Second,
|
ResponseHeaderTimeout: time.Duration(c.conf.Timeout) * time.Second,
|
||||||
TLSHandshakeTimeout: time.Duration(c.conf.Timeout) * time.Second,
|
TLSHandshakeTimeout: time.Duration(c.conf.Timeout) * time.Second,
|
||||||
}
|
}
|
||||||
|
if c.conf.NoIPv6 {
|
||||||
|
c.httpTransport.DialContext = func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
|
if strings.HasPrefix(network, "tcp") {
|
||||||
|
network = "tcp4"
|
||||||
|
}
|
||||||
|
return dialer.DialContext(ctx, network, address)
|
||||||
|
}
|
||||||
|
}
|
||||||
err := http2.ConfigureTransport(c.httpTransport)
|
err := http2.ConfigureTransport(c.httpTransport)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ type config struct {
|
|||||||
Timeout uint `toml:"timeout"`
|
Timeout uint `toml:"timeout"`
|
||||||
NoCookies bool `toml:"no_cookies"`
|
NoCookies bool `toml:"no_cookies"`
|
||||||
NoECS bool `toml:"no_ecs"`
|
NoECS bool `toml:"no_ecs"`
|
||||||
|
NoIPv6 bool `toml:"no_ipv6"`
|
||||||
Verbose bool `toml:"verbose"`
|
Verbose bool `toml:"verbose"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,5 +65,13 @@ no_cookies = false
|
|||||||
# the same configuration as most public DNS servers.
|
# the same configuration as most public DNS servers.
|
||||||
no_ecs = false
|
no_ecs = false
|
||||||
|
|
||||||
|
# Disable IPv6 when querying upstream
|
||||||
|
#
|
||||||
|
# Only enable this if you really have trouble connecting.
|
||||||
|
# Doh-client uses both IPv4 and IPv6 by default and should not have problems
|
||||||
|
# with an IPv4-only environment.
|
||||||
|
# Note that DNS listening and bootstrapping is not controlled by this option.
|
||||||
|
no_ipv6 = false
|
||||||
|
|
||||||
# Enable logging
|
# Enable logging
|
||||||
verbose = false
|
verbose = false
|
||||||
|
|||||||
Reference in New Issue
Block a user