Transport: Don't use HE addresses for GeoIP

Limit max MTU for HE addresses
This commit is contained in:
zzz
2022-03-15 14:30:04 -04:00
parent 587409daa7
commit e8afbc5b92
2 changed files with 17 additions and 0 deletions

View File

@@ -782,6 +782,11 @@ public class GeoIP {
* @param ip IPv4 or IPv6
*/
public void add(byte ip[]) {
// skip he.net tunnel 2001:470:: so we will get correct geoip from IPv4
if (ip.length == 16 &&
ip[0] == 0x20 && ip[1] == 0x01 &&
ip[2] == 0x04 && ip[3] == 0x70)
return;
add(toLong(ip));
}
@@ -815,6 +820,11 @@ public class GeoIP {
* @return lower-case code, generally two letters, or null.
*/
String get(byte ip[]) {
// skip he.net tunnel 2001:470:: so we will get correct geoip from IPv4
if (ip.length == 16 &&
ip[0] == 0x20 && ip[1] == 0x01 &&
ip[2] == 0x04 && ip[3] == 0x70)
return null;
return get(toLong(ip));
}

View File

@@ -86,6 +86,13 @@ public class MTU {
log.logAlways(Log.WARN, "Unusually low MTU " + mtu + " for interface " + ia +
", consider disabling");
}
// fix for he.net tunnels with too big MTU
if (isIPv6 && mtu > 1472) {
byte[] ip = addr.getAddress();
if (ip[0] == 0x20 && ip[1] == 0x01 &&
ip[2] == 0x04 && ip[3] == 0x70)
return 1472;
}
return rectify(isIPv6, mtu);
} catch (SocketException se) {
// ignore