i2ptunnel: Disallow encrypted LS for offline keys

This commit is contained in:
zzz
2019-04-11 15:38:03 +00:00
parent b5a4f1626f
commit f4d7a6d0d4
5 changed files with 56 additions and 4 deletions

View File

@@ -1080,6 +1080,21 @@ public class TunnelController implements Logging {
return null;
}
/**
* Returns false if not running.
* @return true if offline keys or not running
* @since 0.9.40
*/
public boolean getIsOfflineKeys() {
if (_tunnel != null) {
List<I2PSession> sessions = _tunnel.getSessions();
if (!sessions.isEmpty())
return sessions.get(0).isOffline();
}
return false;
}
// TODO synch
public boolean getIsRunning() { return _state == TunnelState.RUNNING; }
public boolean getIsStarting() { return _state == TunnelState.START_ON_LOAD || _state == TunnelState.STARTING; }

View File

@@ -447,6 +447,26 @@ public class GeneralHelper {
return null;
}
/**
* Works even if tunnel is not running.
* @return true if offline keys
* @since 0.9.40
*/
public boolean isOfflineKeys(int tunnel) {
TunnelController tun = getController(tunnel);
if (tun != null) {
if (tun.getIsRunning())
return tun.getIsOfflineKeys();
// do this the hard way
File keyFile = tun.getPrivateKeyFile();
if (keyFile != null) {
PrivateKeyFile pkf = new PrivateKeyFile(keyFile);
return pkf.isOffline();
}
}
return false;
}
public boolean shouldStartAutomatically(int tunnel) {
TunnelController tun = getController(tunnel);
return tun != null ? tun.getStartOnLoad() : false;

View File

@@ -608,6 +608,15 @@ public class IndexBean {
return d.toBase32();
return "";
}
/**
* Works even if tunnel is not running.
* @return true if offline keys
* @since 0.9.40
*/
public boolean getIsOfflineKeys(int tunnel) {
return _helper.isOfflineKeys(tunnel);
}
/**
* For index.jsp