forked from I2P_Developers/i2p.i2p
i2ptunnel: Disallow encrypted LS for offline keys
This commit is contained in:
@ -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; }
|
||||
|
||||
|
@ -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;
|
||||
|
@ -609,6 +609,15 @@ public class IndexBean {
|
||||
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
|
||||
* @return true if the plugin is enabled, installed, and running
|
||||
|
@ -432,7 +432,9 @@
|
||||
<%=intl._t("Encrypted")%></label></span>
|
||||
<%
|
||||
int curSigType = editBean.getSigType(curTunnel, tunnelType);
|
||||
if (curSigType == 7 || curSigType == 11) {
|
||||
// TODO, encrypted + offline is unimplemented
|
||||
boolean allowBlinding = (curSigType == 7 || curSigType == 11) && !editBean.getIsOfflineKeys(curTunnel);
|
||||
if (allowBlinding) {
|
||||
%>
|
||||
<span class="multiOption"><label title="<%=intl._t("Prevents server discovery by floodfills")%>"><input value="2" type="radio" name="encryptMode"<%=(curEncryptMode.equals("2") ? " checked=\"checked\"" : "")%> class="tickbox" />
|
||||
<%=intl._t("Blinded")%></label></span>
|
||||
@ -452,7 +454,7 @@
|
||||
<%=intl._t("Blinded with lookup password and per-user key")%></label></span>
|
||||
<%
|
||||
} // isAdvanced()
|
||||
} // curSigType
|
||||
} // allowBlinding
|
||||
%>
|
||||
</td>
|
||||
</tr><tr>
|
||||
@ -469,7 +471,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<%
|
||||
if (curSigType == 7 || curSigType == 11) {
|
||||
if (allowBlinding) {
|
||||
%>
|
||||
<tr>
|
||||
<td>
|
||||
@ -478,7 +480,7 @@
|
||||
</td><td> </td>
|
||||
</tr>
|
||||
<%
|
||||
} // curSigType
|
||||
} // allowBlinding
|
||||
%>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
|
@ -627,6 +627,12 @@ public class PrivateKeyFile {
|
||||
* @since 0.9.38
|
||||
*/
|
||||
public boolean isOffline() {
|
||||
try {
|
||||
// call this to force initialization
|
||||
getDestination();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return _offlineSignature != null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user