Changeset a0b2f57


Ignore:
Timestamp:
Mar 25, 2017 11:29:14 AM (3 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
cff8eaf
Parents:
b335ded1
Message:

i2ptunnel: Allow alt priv key file to be added without restarting I2P
Display message requiring tunnel restart if tunnel is running

File:
1 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java

    rb335ded1 ra0b2f57  
    160160        _messages = new ArrayList<String>(4);
    161161        boolean keyOK = true;
    162         if (createKey && (getType().endsWith("server") || getPersistentClientKey())) {
     162        if (createKey && (!isClient() || getPersistentClientKey())) {
    163163            keyOK = createPrivateKey();
    164             if (keyOK && getType().endsWith("server") && !getType().equals(TYPE_STREAMR_SERVER)) {
     164            if (keyOK && !isClient() && !getType().equals(TYPE_STREAMR_SERVER)) {
    165165                // check rv?
    166166                createAltPrivateKey();
     
    381381        // Config options may have changed since instantiation, so do this again.
    382382        // Or should we take it out of the constructor completely?
    383         if (type.endsWith("server") || getPersistentClientKey()) {
     383        if (!isClient() || getPersistentClientKey()) {
    384384            boolean ok = createPrivateKey();
    385385            if (!ok) {
     
    387387                log("Failed to start tunnel " + getName() + " as the private key file could not be created");
    388388                return;
     389            }
     390            if (!isClient() && !getType().equals(TYPE_STREAMR_SERVER)) {
     391                // check rv?
     392                createAltPrivateKey();
    389393            }
    390394        }
     
    755759            }
    756760        }
     761        Properties oldConfig = _config;
    757762        _config = props;
    758763
     
    799804            }
    800805        }
     806
     807        if (oldConfig != null) {
     808            if (configChanged(_config, oldConfig, PROP_FILE) ||
     809                configChanged(_config, oldConfig, OPT_ALT_PKF) ||
     810                configChanged(_config, oldConfig, OPT_SIG_TYPE)) {
     811                log("Tunnel must be stopped and restarted for private key file changes to take effect");
     812            }
     813        }
     814
    801815        // Running, so check sessions
    802816        Collection<I2PSession> sessions = getAllSessions();
     
    816830            }
    817831        }
     832    }
     833
     834    /**
     835     *  Is property p different in p1 and p2?
     836     *  @since 0.9.30
     837     */
     838    private static boolean configChanged(Properties p1, Properties p2, String p) {
     839        String s1 = p1.getProperty(p);
     840        String s2 = p2.getProperty(p);
     841        return (s1 != null && !s1.equals(s2)) ||
     842               (s1 == null && s2 != null);
    818843    }
    819844
Note: See TracChangeset for help on using the changeset viewer.