mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
improvement: use IsLinkLocalUnicast in IsLocal
Looking at the code, this commit appears to change behavior, because `IsLocal` will now return `true` for IPv6 link-local unicast addresses.
This commit is contained in:
parent
387096b2a1
commit
f65f1d850f
1 changed files with 4 additions and 4 deletions
|
@ -60,15 +60,15 @@ func IsLocal(ip net.IP) bool {
|
||||||
if ip.IsPrivate() {
|
if ip.IsPrivate() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// Dynamic Configuration as per https://tools.ietf.org/htm/rfc3927
|
||||||
|
if ip.IsLinkLocalUnicast() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
if ip4 := ip.To4(); ip4 != nil {
|
if ip4 := ip.To4(); ip4 != nil {
|
||||||
// Carrier-Grade NAT as per https://tools.ietf.org/htm/rfc6598
|
// Carrier-Grade NAT as per https://tools.ietf.org/htm/rfc6598
|
||||||
if ip4[0] == 100 && ip4[1]&0xc0 == 64 {
|
if ip4[0] == 100 && ip4[1]&0xc0 == 64 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Dynamic Configuration as per https://tools.ietf.org/htm/rfc3927
|
|
||||||
if ip4[0] == 169 && ip4[1] == 254 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue