Skip to content
Commits on Source (1)
  • Eugene Burkov's avatar
    Pull request: upd golibs · 6c8d917b
    Eugene Burkov authored
    Merge in DNS/dnsproxy from upd-golibs to master
    
    Squashed commit of the following:
    
    commit 0785c0e3131114a9c36ab28e7d8894c4f9b33902
    Author: Eugene Burkov <E.Burkov@AdGuard.COM>
    Date:   Wed Mar 23 15:31:40 2022 +0300
    
        vendor: fix inconsistency
    
    commit c11a450918a2af026b169188f2099d18eb101a3c
    Merge: 5ade968 f5c11d40
    Author: Eugene Burkov <E.Burkov@AdGuard.COM>
    Date:   Wed Mar 23 15:28:10 2022 +0300
    
        Merge branch 'master' into upd-golibs
    
    commit 5ade96816352f81f6ec7a5d2cbdfcb00748c4b8f
    Author: Eugene Burkov <E.Burkov@AdGuard.COM>
    Date:   Thu Mar 17 20:22:41 2022 +0300
    
        proxy: fix func call
    
    commit e462a1b42507648a4319081357cd05e46e1760dc
    Author: Eugene Burkov <E.Burkov@AdGuard.COM>
    Date:   Thu Mar 17 20:14:29 2022 +0300
    
        all: upd golibs, use helper
    6c8d917b
......@@ -3,7 +3,7 @@ module github.com/AdguardTeam/dnsproxy
go 1.17
require (
github.com/AdguardTeam/golibs v0.10.6
github.com/AdguardTeam/golibs v0.10.8
github.com/ameshkov/dnscrypt/v2 v2.2.3
github.com/ameshkov/dnsstamps v1.0.3
github.com/beefsack/go-rate v0.0.0-20200827232406-6cde80facd47
......
......@@ -155,55 +155,3 @@ func setECS(m *dns.Msg, ip net.IP, scope uint8) (subnet *net.IPNet) {
return subnet
}
// isPublicIP returns true if ip is within public Internet IP range.
//
// TODO(e.burkov, a.garipov): Add an interface-based subnet detector to the
// netutil.
//
// nolint (gocyclo)
func isPublicIP(ip net.IP) (ok bool) {
if ip = ip.To4(); ip == nil {
return !ip.IsLoopback() && !ip.IsLinkLocalMulticast() && !ip.IsLinkLocalUnicast()
}
switch ip[0] {
case 0, 10, 127:
// Software, private network, loopback.
return false
case 169:
// Link-local.
return ip[1] != 254
case 172:
// Private network.
return ip[1] < 16 || ip[1] > 31
case 192:
switch ip[1] {
case 0:
// Private network, documentation.
return ip[2] != 0 && ip[2] != 2
case 88:
// Reserved.
return ip[2] != 99
case 168:
// Private network.
return false
default:
return true
}
case 198:
// Private network, documentation.
return (ip[1] != 18 && ip[2] != 19) && (ip[1] != 51 && ip[2] != 100)
case 203:
// Documentation.
return ip[1] != 0 || ip[2] != 113
case 224:
// Multicast.
return ip[1] != 0 || ip[2] != 0
case 255:
// Broadcast.
return ip[1] != 255 || ip[2] != 255 || ip[3] != 255
default:
return true
}
}
......@@ -525,7 +525,7 @@ func (dctx *DNSContext) processECS(cliIP net.IP) {
}
}
if isPublicIP(cliIP) {
if !netutil.IsSpecialPurpose(cliIP) {
// A Stub Resolver MUST set SCOPE PREFIX-LENGTH to 0. See RFC 7871
// Section 6.
dctx.ReqECS = setECS(dctx.Req, cliIP, 0)
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.