Change the ECS prefix length from /48 to /56 for IPv6, per RFC 7871

This commit is contained in:
Star Brilliant
2018-08-14 09:06:13 +08:00
parent f40116b1f8
commit ffe5573552
7 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -85,7 +85,7 @@ records.
## EDNS0-Client-Subnet (GeoDNS) ## EDNS0-Client-Subnet (GeoDNS)
DNS-over-HTTPS supports EDNS0-Client-Subnet protocol, which submits part of the DNS-over-HTTPS supports EDNS0-Client-Subnet protocol, which submits part of the
client's IP address (/24 for IPv4, /48 for IPv6 by default) to the upstream client's IP address (/24 for IPv4, /56 for IPv6 by default) to the upstream
server. This is useful for GeoDNS and CDNs to work, and is exactly the same server. This is useful for GeoDNS and CDNs to work, and is exactly the same
configuration as most public DNS servers. configuration as most public DNS servers.
@@ -121,7 +121,7 @@ Currently supported features are:
- [X] IPv4 / IPv6 - [X] IPv4 / IPv6
- [X] EDNS0 large UDP packet (4 KiB by default) - [X] EDNS0 large UDP packet (4 KiB by default)
- [X] EDNS0-Client-Subnet (/24 for IPv4, /48 for IPv6 by default) - [X] EDNS0-Client-Subnet (/24 for IPv4, /56 for IPv6 by default)
## The name of the project ## The name of the project
+3 -3
View File
@@ -259,7 +259,7 @@ func (c *Client) tcpHandlerFunc(w dns.ResponseWriter, r *dns.Msg) {
var ( var (
ipv4Mask24 = net.IPMask{255, 255, 255, 0} ipv4Mask24 = net.IPMask{255, 255, 255, 0}
ipv6Mask48 = net.CIDRMask(48, 128) ipv6Mask56 = net.CIDRMask(56, 128)
) )
func (c *Client) findClientIP(w dns.ResponseWriter, r *dns.Msg) (ednsClientAddress net.IP, ednsClientNetmask uint8) { func (c *Client) findClientIP(w dns.ResponseWriter, r *dns.Msg) (ednsClientAddress net.IP, ednsClientNetmask uint8) {
@@ -286,8 +286,8 @@ func (c *Client) findClientIP(w dns.ResponseWriter, r *dns.Msg) (ednsClientAddre
ednsClientAddress = ipv4.Mask(ipv4Mask24) ednsClientAddress = ipv4.Mask(ipv4Mask24)
ednsClientNetmask = 24 ednsClientNetmask = 24
} else { } else {
ednsClientAddress = ip.Mask(ipv6Mask48) ednsClientAddress = ip.Mask(ipv6Mask56)
ednsClientNetmask = 48 ednsClientNetmask = 56
} }
} }
return return
+1 -1
View File
@@ -72,7 +72,7 @@ no_cookies = true
# Disable EDNS0-Client-Subnet (ECS) # Disable EDNS0-Client-Subnet (ECS)
# #
# DNS-over-HTTPS supports EDNS0-Client-Subnet protocol, which submits part of # DNS-over-HTTPS supports EDNS0-Client-Subnet protocol, which submits part of
# the client's IP address (/24 for IPv4, /48 for IPv6 by default) to the # the client's IP address (/24 for IPv4, /56 for IPv6 by default) to the
# upstream server. This is useful for GeoDNS and CDNs to work, and is exactly # upstream server. This is useful for GeoDNS and CDNs to work, and is exactly
# the same configuration as most public DNS servers. # the same configuration as most public DNS servers.
no_ecs = false no_ecs = false
+1 -1
View File
@@ -96,7 +96,7 @@ func (c *Client) generateRequestIETF(w dns.ResponseWriter, r *dns.Msg, isTCP boo
ednsClientNetmask = 24 ednsClientNetmask = 24
} else { } else {
ednsClientFamily = 2 ednsClientFamily = 2
ednsClientNetmask = 48 ednsClientNetmask = 56
} }
edns0Subnet = new(dns.EDNS0_SUBNET) edns0Subnet = new(dns.EDNS0_SUBNET)
edns0Subnet.Code = dns.EDNS0SUBNET edns0Subnet.Code = dns.EDNS0SUBNET
+2 -2
View File
@@ -104,7 +104,7 @@ func (s *Server) parseRequestGoogle(w http.ResponseWriter, r *http.Request) *DNS
ednsClientNetmask = 24 ednsClientNetmask = 24
} else { } else {
ednsClientFamily = 2 ednsClientFamily = 2
ednsClientNetmask = 48 ednsClientNetmask = 56
} }
} else { } else {
ednsClientAddress = net.ParseIP(ednsClientSubnet[:slash]) ednsClientAddress = net.ParseIP(ednsClientSubnet[:slash])
@@ -139,7 +139,7 @@ func (s *Server) parseRequestGoogle(w http.ResponseWriter, r *http.Request) *DNS
ednsClientNetmask = 24 ednsClientNetmask = 24
} else { } else {
ednsClientFamily = 2 ednsClientFamily = 2
ednsClientNetmask = 48 ednsClientNetmask = 56
} }
} }
+1 -1
View File
@@ -126,7 +126,7 @@ func (s *Server) parseRequestIETF(w http.ResponseWriter, r *http.Request) *DNSRe
ednsClientNetmask = 24 ednsClientNetmask = 24
} else { } else {
ednsClientFamily = 2 ednsClientFamily = 2
ednsClientNetmask = 48 ednsClientNetmask = 56
} }
edns0Subnet = new(dns.EDNS0_SUBNET) edns0Subnet = new(dns.EDNS0_SUBNET)
edns0Subnet.Code = dns.EDNS0SUBNET edns0Subnet.Code = dns.EDNS0SUBNET
+1 -1
View File
@@ -119,7 +119,7 @@ func Unmarshal(msg *dns.Msg, resp *Response, udpSize uint16, ednsClientNetmask u
if ednsClientFamily == 1 { if ednsClientFamily == 1 {
ednsClientNetmask = 24 ednsClientNetmask = 24
} else { } else {
ednsClientNetmask = 48 ednsClientNetmask = 56
} }
} }
edns0Subnet := new(dns.EDNS0_SUBNET) edns0Subnet := new(dns.EDNS0_SUBNET)