Changeset 82d812c


Ignore:
Timestamp:
Feb 4, 2017 3:38:49 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
6306799
Parents:
890ad25
Message:

NTP: Enable IPv6 support (ticket #1896)

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/util/Addresses.java

    r890ad25 r82d812c  
    5757        // not as good as using a Java DBus implementation to talk to NetworkManager...
    5858        return !getAddresses(true, false, false).isEmpty();
     59    }
     60
     61    /**
     62     *  Do we have any non-loop, non-wildcard IPv6 address at all?
     63     *  @since 0.9.29
     64     */
     65    public static boolean isConnectedIPv6() {
     66        // not as good as using a Java DBus implementation to talk to NetworkManager...
     67        for (String ip : getAddresses(false, true)) {
     68            if (ip.contains(":"))
     69                return true;
     70        }
     71        return false;
    5972    }
    6073
     
    600613            System.out.println(buf.toString());
    601614        }
    602         System.out.println("\nIs connected? " + isConnected());
     615        System.out.println("\nIs connected? " + isConnected() +
     616                           "\nHas IPv6?     " + isConnectedIPv6());
    603617    }
    604618}
  • history.txt

    r890ad25 r82d812c  
     12017-02-04 zzz
     2 * NTP: Enable IPv6 support (ticket #1896)
     3
     42017-01-30 zzz
     5 * Router: Run shutdown tasks in parallel,
     6   increase max time for shutdown tasks (ticket #1893)
     7   i2psnark: Remove most delay between announces at shutdown
     8
     92017-01-29 zzz
     10 * i2ptunnel CONNECT proxy:
     11   - Add support for outproxy plugin (tickets #1364, #1895)
     12   - Add support for ports
     13
     142017-01-28 zzz
     15 * Utils: Detect when running as service on Gentoo
     16
    1172017-01-26 zzz
    218 * Build: Set up translations for man pages
     
    4258   - Verify source address and port
    4359   - Add to command line
    44    - Add KoD support (ticket #1896)
    45    - Add initial IPv6 support (ticket #1897)
     60   - Add KoD support (ticket #1897)
     61   - Add initial IPv6 support (ticket #1896)
    4662
    47632016-12-20 zzz
  • router/java/src/net/i2p/router/RouterVersion.java

    r890ad25 r82d812c  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 4;
     21    public final static long BUILD = 5;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/time/RouterTimestamper.java

    r890ad25 r82d812c  
    99import net.i2p.I2PAppContext;
    1010import net.i2p.time.Timestamper;
     11import net.i2p.util.Addresses;
    1112import net.i2p.util.I2PThread;
    1213import net.i2p.util.Log;
     
    174175                // NOTE: _log is null the first time through, to prevent problems and stack overflows
    175176                updateConfig();
     177                boolean preferIPv6 = Addresses.isConnectedIPv6();
    176178                if (!_disabled) {
    177179                    // first the servers for our country and continent, we know what country we're in...
     
    181183                                _log.debug("Querying servers " + servers);
    182184                            try {
    183                                 lastFailed = !queryTime(servers.toArray(new String[servers.size()]), SHORT_TIMEOUT);
     185                                lastFailed = !queryTime(servers.toArray(new String[servers.size()]), SHORT_TIMEOUT, preferIPv6);
    184186                            } catch (IllegalArgumentException iae) {
    185187                                if (!lastFailed && _log != null && _log.shouldWarn())
     
    196198                            _log.debug("Querying servers " + _servers);
    197199                        try {
    198                             lastFailed = !queryTime(_servers.toArray(new String[_servers.size()]), DEFAULT_TIMEOUT);
     200                            // If we failed, maybe it's because IPv6 is blocked, so try IPv4 only
     201                            // also first time through, and randomly
     202                            boolean prefIPv6 = preferIPv6 && !lastFailed && _log != null && _context.random().nextInt(4) != 0;
     203                            lastFailed = !queryTime(_servers.toArray(new String[_servers.size()]), DEFAULT_TIMEOUT, prefIPv6);
    199204                        } catch (IllegalArgumentException iae) {
    200205                            lastFailed = true;
     
    263268     * True if the time was queried successfully, false if it couldn't be
    264269     */
    265     private boolean queryTime(String serverList[], int perServerTimeout) throws IllegalArgumentException {
     270    private boolean queryTime(String serverList[], int perServerTimeout, boolean preferIPv6) throws IllegalArgumentException {
    266271        long found[] = new long[_concurringServers];
    267272        long now = -1;
     
    274279            //    try { Thread.sleep(2*1000); } catch (InterruptedException ie) {}
    275280            //}
    276             // IPv6 arg TODO
    277             long[] timeAndStratum = NtpClient.currentTimeAndStratum(serverList, perServerTimeout, false, _log);
     281            long[] timeAndStratum = NtpClient.currentTimeAndStratum(serverList, perServerTimeout, preferIPv6, _log);
    278282            now = timeAndStratum[0];
    279283            stratum = (int) timeAndStratum[1];
Note: See TracChangeset for help on using the changeset viewer.