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;
|
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 getIsRunning() { return _state == TunnelState.RUNNING; }
|
||||||
public boolean getIsStarting() { return _state == TunnelState.START_ON_LOAD || _state == TunnelState.STARTING; }
|
public boolean getIsStarting() { return _state == TunnelState.START_ON_LOAD || _state == TunnelState.STARTING; }
|
||||||
|
|
||||||
|
@ -447,6 +447,26 @@ public class GeneralHelper {
|
|||||||
return null;
|
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) {
|
public boolean shouldStartAutomatically(int tunnel) {
|
||||||
TunnelController tun = getController(tunnel);
|
TunnelController tun = getController(tunnel);
|
||||||
return tun != null ? tun.getStartOnLoad() : false;
|
return tun != null ? tun.getStartOnLoad() : false;
|
||||||
|
@ -608,6 +608,15 @@ public class IndexBean {
|
|||||||
return d.toBase32();
|
return d.toBase32();
|
||||||
return "";
|
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
|
* For index.jsp
|
||||||
|
@ -432,7 +432,9 @@
|
|||||||
<%=intl._t("Encrypted")%></label></span>
|
<%=intl._t("Encrypted")%></label></span>
|
||||||
<%
|
<%
|
||||||
int curSigType = editBean.getSigType(curTunnel, tunnelType);
|
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" />
|
<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>
|
<%=intl._t("Blinded")%></label></span>
|
||||||
@ -452,7 +454,7 @@
|
|||||||
<%=intl._t("Blinded with lookup password and per-user key")%></label></span>
|
<%=intl._t("Blinded with lookup password and per-user key")%></label></span>
|
||||||
<%
|
<%
|
||||||
} // isAdvanced()
|
} // isAdvanced()
|
||||||
} // curSigType
|
} // allowBlinding
|
||||||
%>
|
%>
|
||||||
</td>
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
@ -469,7 +471,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<%
|
<%
|
||||||
if (curSigType == 7 || curSigType == 11) {
|
if (allowBlinding) {
|
||||||
%>
|
%>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@ -478,7 +480,7 @@
|
|||||||
</td><td> </td>
|
</td><td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<%
|
<%
|
||||||
} // curSigType
|
} // allowBlinding
|
||||||
%>
|
%>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2">
|
<th colspan="2">
|
||||||
|
@ -627,6 +627,12 @@ public class PrivateKeyFile {
|
|||||||
* @since 0.9.38
|
* @since 0.9.38
|
||||||
*/
|
*/
|
||||||
public boolean isOffline() {
|
public boolean isOffline() {
|
||||||
|
try {
|
||||||
|
// call this to force initialization
|
||||||
|
getDestination();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return _offlineSignature != null;
|
return _offlineSignature != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user