Ignore:
Timestamp:
2015-04-30T22:53:20+02:00 (11 years ago)
Author:
stoecker
Message:

see #8562 - move IPv6 detection to main class instead of preferences

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r8295 r8296  
    1717import java.lang.annotation.RetentionPolicy;
    1818import java.lang.reflect.Field;
    19 import java.net.InetAddress;
    20 import java.net.Inet6Address;
    2119import java.nio.charset.StandardCharsets;
    2220import java.nio.file.Files;
     
    927925            }
    928926        }
    929         if("auto".equals(get("prefer.ipv6", "auto"))) {
    930              new Thread(new Runnable() { /* this may take some time (DNS, Connect) */
    931                 public void run() {
    932                     boolean hasv6 = false;
    933                     try {
    934                         /* Use the check result from last run of the software, as after the test value
    935                            changes have no effect anymore */
    936                         if(getBoolean("validated.ipv6", false)) {
    937                             Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true");
    938                         }
    939                         for(InetAddress a : InetAddress.getAllByName("josm.openstreetmap.de")) {
    940                             if(a instanceof Inet6Address) {
    941                                 if(a.isReachable(1000)) {
    942                                     Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true");
    943                                     if(!getBoolean("validated.ipv6", false)) {
    944                                         Main.info(tr("Automatics detected useable IPv6 network, prefering IPv6 over IPv4 after next restart."));
    945                                     } else {
    946                                         Main.info(tr("Automatics detected useable IPv6 network, prefering IPv6 over IPv4."));
    947                                     }
    948                                     hasv6 = true;
    949                                 }
    950                                 break; /* we're done */
    951                             }
    952                         }
    953                     } catch (Exception e) {
    954                     }
    955                     put("validated.ipv6", hasv6);
    956                 }
    957             }).start();
    958         }
    959927    }
    960928
     
    14071375        if("true".equals(get("prefer.ipv6", "auto"))) {
    14081376            // never set this to false, only true!
    1409             Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true");
     1377            if(!"true".equals(Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true"))) {
     1378                Main.info(tr("Try enabling IPv6 network, prefering IPv4 over IPv6 (only works on early startup)."));
     1379            }
    14101380        }
    14111381        Utils.updateSystemProperty("http.agent", Version.getInstance().getAgentString());
Note: See TracChangeset for help on using the changeset viewer.