mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-03-31 14:05:38 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb166ececa | ||
|
|
f557e4aa29 | ||
|
|
967faec56c | ||
|
|
2aa7370aaf |
@@ -4,6 +4,11 @@ This Changelog records major changes between versions.
|
|||||||
|
|
||||||
Not all changes are recorded. Please check git log for details.
|
Not all changes are recorded. Please check git log for details.
|
||||||
|
|
||||||
|
## Version 2.2.4
|
||||||
|
|
||||||
|
- Add options to configure ECS netmask length
|
||||||
|
- Add an option to disable TLS verification (Note: dangerous)
|
||||||
|
|
||||||
## Version 2.2.3
|
## Version 2.2.3
|
||||||
|
|
||||||
- Use the library ipTree to determine whether an IP is global routable, improving the performance
|
- Use the library ipTree to determine whether an IP is global routable, improving the performance
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@@ -247,6 +248,7 @@ func (c *Client) newHTTPClient() error {
|
|||||||
MaxIdleConnsPerHost: 10,
|
MaxIdleConnsPerHost: 10,
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
TLSHandshakeTimeout: time.Duration(c.conf.Other.Timeout) * time.Second,
|
TLSHandshakeTimeout: time.Duration(c.conf.Other.Timeout) * time.Second,
|
||||||
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: c.conf.Other.TLSInsecureSkipVerify},
|
||||||
}
|
}
|
||||||
if c.conf.Other.NoIPv6 {
|
if c.conf.Other.NoIPv6 {
|
||||||
c.httpTransport.DialContext = func(ctx context.Context, network, address string) (net.Conn, error) {
|
c.httpTransport.DialContext = func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ type others struct {
|
|||||||
NoUserAgent bool `toml:"no_user_agent"`
|
NoUserAgent bool `toml:"no_user_agent"`
|
||||||
Verbose bool `toml:"verbose"`
|
Verbose bool `toml:"verbose"`
|
||||||
DebugHTTPHeaders []string `toml:"debug_http_headers"`
|
DebugHTTPHeaders []string `toml:"debug_http_headers"`
|
||||||
|
TLSInsecureSkipVerify bool `toml:"insecure_tls_skip_verify"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
|||||||
@@ -132,3 +132,9 @@ no_user_agent = false
|
|||||||
|
|
||||||
# Enable logging
|
# Enable logging
|
||||||
verbose = false
|
verbose = false
|
||||||
|
|
||||||
|
# insecure_tls_skip_verification will disable necessary TLS security verification.
|
||||||
|
# This option is designed for testing or development purposes,
|
||||||
|
# turning on this option on public Internet may cause your connection
|
||||||
|
# vulnerable to MITM attack.
|
||||||
|
insecure_tls_skip_verify = false
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/m13253/dns-over-https/doh-client/selector"
|
"github.com/m13253/dns-over-https/doh-client/selector"
|
||||||
"github.com/m13253/dns-over-https/json-dns"
|
jsondns "github.com/m13253/dns-over-https/json-dns"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "2.2.3"
|
VERSION = "2.2.4"
|
||||||
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ type config struct {
|
|||||||
Verbose bool `toml:"verbose"`
|
Verbose bool `toml:"verbose"`
|
||||||
DebugHTTPHeaders []string `toml:"debug_http_headers"`
|
DebugHTTPHeaders []string `toml:"debug_http_headers"`
|
||||||
LogGuessedIP bool `toml:"log_guessed_client_ip"`
|
LogGuessedIP bool `toml:"log_guessed_client_ip"`
|
||||||
|
LocalIPFilter bool `toml:"ecs_allow_non_global_ip"`
|
||||||
|
ECSFullSubnet bool `toml:"ecs_use_precise_ip"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig(path string) (*config, error) {
|
func loadConfig(path string) (*config, error) {
|
||||||
|
|||||||
@@ -51,3 +51,21 @@ verbose = false
|
|||||||
# Enable log IP from HTTPS-reverse proxy header: X-Forwarded-For or X-Real-IP
|
# Enable log IP from HTTPS-reverse proxy header: X-Forwarded-For or X-Real-IP
|
||||||
# Note: http uri/useragent log cannot be controlled by this config
|
# Note: http uri/useragent log cannot be controlled by this config
|
||||||
log_guessed_client_ip = false
|
log_guessed_client_ip = 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;
|
||||||
|
# 2. the upstream server unable to provide geographically near results,
|
||||||
|
# or even fail to provide any result.
|
||||||
|
# However, if you are deploying a split tunnel corporation network environment,
|
||||||
|
# or for any other reason you want to inhibit this behavior, change the following
|
||||||
|
# option to "true".
|
||||||
|
ecs_allow_non_global_ip = false
|
||||||
|
|
||||||
|
# If ECS is added to the request, let the full IP address or
|
||||||
|
# cap it to 24 or 128 mask. This option is to be used only on private
|
||||||
|
# networks where knwoledge of the terminal endpoint may be required for
|
||||||
|
# security purposes (eg. DNS Firewalling). Not a good option on the
|
||||||
|
# internet where IP address may be used to identify the user and
|
||||||
|
# not only the approximate location.
|
||||||
|
ecs_use_precise_ip = false
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/m13253/dns-over-https/json-dns"
|
jsondns "github.com/m13253/dns-over-https/json-dns"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"golang.org/x/net/idna"
|
"golang.org/x/net/idna"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ func (s *Server) parseRequestIETF(ctx context.Context, w http.ResponseWriter, r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
isTailored := edns0Subnet == nil
|
isTailored := edns0Subnet == nil
|
||||||
|
|
||||||
if edns0Subnet == nil {
|
if edns0Subnet == nil {
|
||||||
ednsClientFamily := uint16(0)
|
ednsClientFamily := uint16(0)
|
||||||
ednsClientAddress := s.findClientIP(r)
|
ednsClientAddress := s.findClientIP(r)
|
||||||
@@ -133,10 +134,20 @@ func (s *Server) parseRequestIETF(ctx context.Context, w http.ResponseWriter, r
|
|||||||
if ipv4 := ednsClientAddress.To4(); ipv4 != nil {
|
if ipv4 := ednsClientAddress.To4(); ipv4 != nil {
|
||||||
ednsClientFamily = 1
|
ednsClientFamily = 1
|
||||||
ednsClientAddress = ipv4
|
ednsClientAddress = ipv4
|
||||||
|
if s.conf.ECSFullSubnet {
|
||||||
|
ednsClientNetmask = 32
|
||||||
|
} else {
|
||||||
ednsClientNetmask = 24
|
ednsClientNetmask = 24
|
||||||
|
ednsClientAddress = ednsClientAddress.Mask(net.CIDRMask(24, 32))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ednsClientFamily = 2
|
ednsClientFamily = 2
|
||||||
|
if s.conf.ECSFullSubnet {
|
||||||
|
ednsClientNetmask = 128
|
||||||
|
} else {
|
||||||
ednsClientNetmask = 56
|
ednsClientNetmask = 56
|
||||||
|
ednsClientAddress = ednsClientAddress.Mask(net.CIDRMask(56, 128))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
edns0Subnet = new(dns.EDNS0_SUBNET)
|
edns0Subnet = new(dns.EDNS0_SUBNET)
|
||||||
edns0Subnet.Code = dns.EDNS0SUBNET
|
edns0Subnet.Code = dns.EDNS0SUBNET
|
||||||
|
|||||||
@@ -265,17 +265,22 @@ func (s *Server) findClientIP(r *http.Request) net.IP {
|
|||||||
if XRealIP != "" {
|
if XRealIP != "" {
|
||||||
addr := strings.TrimSpace(XRealIP)
|
addr := strings.TrimSpace(XRealIP)
|
||||||
ip := net.ParseIP(addr)
|
ip := net.ParseIP(addr)
|
||||||
if jsondns.IsGlobalIP(ip) {
|
if !s.conf.LocalIPFilter || jsondns.IsGlobalIP(ip) {
|
||||||
return ip
|
return ip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteAddr, err := net.ResolveTCPAddr("tcp", r.RemoteAddr)
|
remoteAddr, err := net.ResolveTCPAddr("tcp", r.RemoteAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if !s.conf.LocalIPFilter {
|
||||||
|
return remoteAddr.IP
|
||||||
|
}
|
||||||
if ip := remoteAddr.IP; jsondns.IsGlobalIP(ip) {
|
if ip := remoteAddr.IP; jsondns.IsGlobalIP(ip) {
|
||||||
return ip
|
return ip
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "2.2.3"
|
VERSION = "2.2.4"
|
||||||
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user