forked from I2P_Developers/i2p.i2p
Transports: Prefer IPv6 temporary addresses if the kernel does
This helps us pick the right address at startup, so we don't switch after peer testing.
This commit is contained in:
@@ -898,17 +898,15 @@ public abstract class Addresses {
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4941
|
||||
* @since 0.9.34
|
||||
* @return "true", "false", or "unknown"
|
||||
* @since 0.9.50
|
||||
*/
|
||||
private static String getPrivacyStatus() {
|
||||
public static String useIPv6TempAddresses() {
|
||||
// Windows: netsh interface ipv6 show privacy
|
||||
// Mac: sysctl net.inet6.ip6.use_tempaddr (1 is enabled)
|
||||
if (SystemVersion.isMac() || SystemVersion.isWindows())
|
||||
return "unknown";
|
||||
long t = getLong("/proc/sys/net/ipv6/conf/all/use_tempaddr");
|
||||
if (t < 0)
|
||||
return "unknown";
|
||||
String rv;
|
||||
if (t == 0)
|
||||
rv = "false";
|
||||
@@ -916,7 +914,16 @@ public abstract class Addresses {
|
||||
rv = "true";
|
||||
else
|
||||
rv = "unknown";
|
||||
if (t == 2) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4941
|
||||
* @since 0.9.34
|
||||
*/
|
||||
private static String getPrivacyStatus() {
|
||||
String rv = useIPv6TempAddresses();
|
||||
if (Boolean.valueOf(rv)) {
|
||||
long pref = getLong("/proc/sys/net/ipv6/conf/all/temp_prefered_lft");
|
||||
if (pref > 0)
|
||||
rv += ", preferred lifetime " + DataHelper.formatDuration(pref * 1000);
|
||||
|
||||
@@ -326,10 +326,10 @@ public class TransportManager implements TransportEventListener {
|
||||
Set<String> ipset = Addresses.getAddresses(_context.getBooleanProperty("i2np.allowLocal"), false, true);
|
||||
String lastv4 = _context.getProperty(UDPTransport.PROP_IP);
|
||||
String lastv6 = _context.getProperty(UDPTransport.PROP_IPV6);
|
||||
boolean preferTemp = _context.getBooleanProperty(UDPTransport.PROP_LAPTOP_MODE);
|
||||
boolean preferTemp = Boolean.valueOf(Addresses.useIPv6TempAddresses());
|
||||
//
|
||||
// Avoid IPv6 temporary addresses if we have a non-temporary one,
|
||||
// unless laptop mode
|
||||
// unless the kernel prefers them
|
||||
//
|
||||
boolean hasPreferredV6Address = false;
|
||||
List<InetAddress> addresses = new ArrayList<InetAddress>(4);
|
||||
|
||||
Reference in New Issue
Block a user