i2ptunnel: More disabled options

This commit is contained in:
zzz
2020-05-08 22:29:09 +00:00
parent 69ef47e68c
commit 4ff234c110
3 changed files with 78 additions and 32 deletions

View File

@ -274,6 +274,13 @@ public class EditBean extends IndexBean {
return true; return true;
} }
/** @since 0.9.46 */
public boolean canChangePort(int tunnel) {
if (tunnel < 0)
return true;
return getTunnelStatus(tunnel) == GeneralHelper.NOT_RUNNING;
}
/** /**
* @param encType code * @param encType code
* @since 0.9.44 * @since 0.9.44

View File

@ -62,7 +62,16 @@
<%=intl._t("Automatically start tunnel when router starts")%></label> <%=intl._t("Automatically start tunnel when router starts")%></label>
</td> </td>
</tr><tr> </tr><tr>
<th colspan="2"> <%
String aStopFirst = intl._t("Tunnel and all other shared client tunnels must be stopped to change this configuration");
String bStopFirst = intl._t("Tunnel must be stopped to change this configuration");
String stopFirst = editBean.isSharedClient(curTunnel) ? aStopFirst : bStopFirst;
boolean canChangePort = editBean.canChangePort(curTunnel);
String tastopFirst = " title=\"" + aStopFirst + "\" ";
String tbstopFirst = " title=\"" + bStopFirst + "\" ";
String phdisabled = canChangePort ? "" : tbstopFirst;
%>
<th colspan="2" <%=phdisabled%>>
<% if ("streamrclient".equals(tunnelType)) { %> <% if ("streamrclient".equals(tunnelType)) { %>
<%=intl._t("Target")%> <%=intl._t("Target")%>
<% } else { %> <% } else { %>
@ -79,8 +88,11 @@
out.write(intl._t("required")); out.write(intl._t("required"));
out.write(")</font></span>"); out.write(")</font></span>");
} }
String phelp = intl._t("Specify the local port this service should be accessible from");
String ptext = canChangePort ? phelp : bStopFirst;
String pdisabled = canChangePort ? "" : " disabled=\"disabled\" ";
%> %>
<input type="text" size="6" maxlength="5" name="port" title="<%=intl._t("Specify the local port this service should be accessible from")%>" value="<%=editBean.getClientPort(curTunnel)%>" class="freetext port" placeholder="required" /> <input type="text" size="6" maxlength="5" name="port" title="<%=ptext%>" value="<%=editBean.getClientPort(curTunnel)%>" class="freetext port" placeholder="required" <%=pdisabled%>/>
</td> </td>
<% <%
if ("streamrclient".equals(tunnelType)) { if ("streamrclient".equals(tunnelType)) {
@ -99,10 +111,12 @@
</td> </td>
<% <%
} else { } else {
String ihelp = intl._t("Local interface (ip address) the client tunnel will be reachable from");
String itext = canChangePort ? ihelp : bStopFirst;
%> %>
<td> <td>
<b><%=intl._t("Reachable by")%>:</b> <b><%=intl._t("Reachable by")%>:</b>
<select id="reachableBy" name="reachableBy" title="<%=intl._t("Local interface (ip address) the client tunnel will be reachable from")%>" class="selectbox"> <select id="reachableBy" name="reachableBy" title="<%=itext%>" class="selectbox" <%=pdisabled%>>
<% <%
String clientInterface = editBean.getClientInterface(curTunnel); String clientInterface = editBean.getClientInterface(curTunnel);
for (String ifc : editBean.interfaceSet()) { for (String ifc : editBean.interfaceSet()) {
@ -494,9 +508,6 @@
int currentSigType = editBean.getSigType(curTunnel, tunnelType); int currentSigType = editBean.getSigType(curTunnel, tunnelType);
boolean canChangeSigType = editBean.canChangeSigType(curTunnel); boolean canChangeSigType = editBean.canChangeSigType(curTunnel);
String stopFirst = editBean.isSharedClient(curTunnel) ?
intl._t("Tunnel and all other shared client tunnels must be stopped to change this configuration") :
intl._t("Tunnel must be stopped to change this configuration");
String tstopFirst = " title=\"" + stopFirst + "\" "; String tstopFirst = " title=\"" + stopFirst + "\" ";
String shdisabled = canChangeSigType ? "" : tstopFirst; String shdisabled = canChangeSigType ? "" : tstopFirst;
String disabled = canChangeSigType ? "" : " disabled=\"disabled\" "; String disabled = canChangeSigType ? "" : " disabled=\"disabled\" ";

View File

@ -61,15 +61,27 @@
<%=intl._t("Automatically start tunnel when router starts")%></label> <%=intl._t("Automatically start tunnel when router starts")%></label>
</td> </td>
</tr><tr> </tr><tr>
<th colspan="2"> <%
<% if ("streamrserver".equals(tunnelType)) { %> String stopFirst = intl._t("Tunnel must be stopped to change this configuration");
String tstopFirst = " title=\"" + stopFirst + "\" ";
boolean canChangeDest = editBean.canChangePort(curTunnel);
boolean isStreamrServer = "streamrserver".equals(tunnelType);
boolean isBidirServer = "httpbidirserver".equals(tunnelType);
boolean canChangePort = canChangeDest || !(isStreamrServer || isBidirServer);
String phdisabled = canChangePort ? "" : tstopFirst;
%>
<th colspan="2" <%=phdisabled%>>
<%
if (isStreamrServer) { %>
<%=intl._t("Access Point")%> <%=intl._t("Access Point")%>
<% } else { %> <% } else { %>
<%=intl._t("Target")%> <%=intl._t("Target")%>
<% } %> <% } %>
</th> </th>
</tr><tr> </tr><tr>
<% if (!"streamrserver".equals(tunnelType)) { %> <%
if (!isStreamrServer) {
%>
<td> <td>
<b><%=intl._t("Host")%>:</b> <b><%=intl._t("Host")%>:</b>
<input type="text" size="20" name="targetHost" title="<%=intl._t("Hostname or IP address of the target server")%>" value="<%=editBean.getTargetHost(curTunnel)%>" class="freetext host" /> <input type="text" size="20" name="targetHost" title="<%=intl._t("Hostname or IP address of the target server")%>" value="<%=editBean.getTargetHost(curTunnel)%>" class="freetext host" />
@ -83,16 +95,20 @@
out.write(intl._t("required")); out.write(intl._t("required"));
out.write(")</font></span>"); out.write(")</font></span>");
} }
String asphelp = intl._t("Specify the local port this service should be accessible from");
String bsphelp = intl._t("Specify the port the server is running on");
String ptext = canChangePort ? (isStreamrServer ? asphelp : bsphelp) : stopFirst;
String pdisabled = canChangePort ? "" : " disabled=\"disabled\" ";
%> %>
<input type="text" size="6" maxlength="5" id="targetPort" name="targetPort" title="<%=intl._t("Specify the port the server is running on")%>" value="<%=editBean.getTargetPort(curTunnel)%>" class="freetext port" placeholder="required" /> <input type="text" size="6" maxlength="5" id="targetPort" name="targetPort" title="<%=ptext%>" value="<%=editBean.getTargetPort(curTunnel)%>" class="freetext port" placeholder="required" <%=pdisabled%>/>
<% if (!"streamrserver".equals(tunnelType)) { %> <% if (!isStreamrServer) { %>
<label title="<%=intl._t("To avoid traffic sniffing if connecting to a remote server, you can enable an SSL connection. Note that the target server must be configured to accept SSL connections.")%>"><input value="1" type="checkbox" name="useSSL"<%=(editBean.isSSLEnabled(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" /> <label title="<%=intl._t("To avoid traffic sniffing if connecting to a remote server, you can enable an SSL connection. Note that the target server must be configured to accept SSL connections.")%>"><input value="1" type="checkbox" name="useSSL"<%=(editBean.isSSLEnabled(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />
<%=intl._t("Use SSL to connect to target")%></label> <%=intl._t("Use SSL to connect to target")%></label>
<% } /* !streamrserver */ %> <% } /* !streamrserver */ %>
</td> </td>
<% if ("httpbidirserver".equals(tunnelType)) { %> <% if (isBidirServer) { %>
</tr><tr> </tr><tr>
<th colspan="2"> <th colspan="2" <%=phdisabled%>>
<%=intl._t("Access Point")%> <%=intl._t("Access Point")%>
</th> </th>
</tr><tr> </tr><tr>
@ -105,16 +121,21 @@
out.write(intl._t("required")); out.write(intl._t("required"));
out.write(")</font></span>"); out.write(")</font></span>");
} }
String csphelp = intl._t("Port required to access service (this can be a different port to the port the service is hosted on)");
String dsphelp = canChangePort ? csphelp : stopFirst;
%> %>
<input type="text" size="6" maxlength="5" name="port" title="<%=intl._t("Port required to access service (this can be a different port to the port the service is hosted on)")%>" value="<%=editBean.getClientPort(curTunnel)%>" class="freetext port" placeholder="required" /> <input type="text" size="6" maxlength="5" name="port" title="<%=dsphelp%>" value="<%=editBean.getClientPort(curTunnel)%>" class="freetext port" placeholder="required" <%=pdisabled%>/>
</td> </td>
<% } /* httpbidirserver */ <% } /* httpbidirserver */
if ("httpbidirserver".equals(tunnelType) || "streamrserver".equals(tunnelType)) { if (isBidirServer || isStreamrServer) {
%> %>
<td> <td>
<b><%=intl._t("Reachable by")%>:</b> <b><%=intl._t("Reachable by")%>:</b>
<%
<select id="reachableBy" name="reachableBy" title="<%=intl._t("Listening interface (IP address) for client access (normally 127.0.0.1)")%>" class="selectbox"> String esphelp = intl._t("Listening interface (IP address) for client access (normally 127.0.0.1)");
String fsphelp = canChangePort ? esphelp : stopFirst;
%>
<select id="reachableBy" name="reachableBy" title="<%=fsphelp%>" class="selectbox" <%=pdisabled%>>
<% <%
String clientInterface = editBean.getClientInterface(curTunnel); String clientInterface = editBean.getClientInterface(curTunnel);
for (String ifc : editBean.interfaceSet()) { for (String ifc : editBean.interfaceSet()) {
@ -132,7 +153,7 @@
</td> </td>
<% } /* httpbidirserver || streamrserver */ %> <% } /* httpbidirserver || streamrserver */ %>
</tr> </tr>
<% if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) { <% if ("httpserver".equals(tunnelType) || isBidirServer) {
%> %>
<tr> <tr>
<th> <th>
@ -150,26 +171,33 @@
<tr> <tr>
<th> <th>
<%=intl._t("Local destination")%> <%=intl._t("Local destination")%>
</th><th class="excludeBackgroundImage"> <%
String dhdisable = canChangeDest ? "" : tstopFirst;
%>
</th><th class="excludeBackgroundImage" <%=dhdisable%>>
<%=intl._t("Private key file")%> <%=intl._t("Private key file")%>
</th> </th>
</tr><tr> </tr><tr>
<td> <td>
<div class="displayText" title="<%=intl._t("Read Only: Local Destination (if known)")%>" tabindex="0" onblur="resetScrollLeft(this)"><%=editBean.getDestinationBase64(curTunnel)%></div> <div class="displayText" title="<%=intl._t("Read Only: Local Destination (if known)")%>" tabindex="0" onblur="resetScrollLeft(this)"><%=editBean.getDestinationBase64(curTunnel)%></div>
</td><td> </td><td>
<% String value3 = editBean.getPrivateKeyFile(curTunnel); <%
String value3 = editBean.getPrivateKeyFile(curTunnel);
if (value3 == null || "".equals(value3.trim())) { if (value3 == null || "".equals(value3.trim())) {
out.write(" <span class=\"required\"><font color=\"red\">("); out.write(" <span class=\"required\"><font color=\"red\">(");
out.write(intl._t("required")); out.write(intl._t("required"));
out.write(")</font></span>"); out.write(")</font></span>");
} }
%> String htext = intl._t("Path to Private Key File");
<input type="text" size="30" id="privKeyFile" name="privKeyFile" title="<%=intl._t("Path to Private Key File")%>" value="<%=editBean.getPrivateKeyFile(curTunnel)%>" class="freetext" placeholder="required" /> String dtext = canChangeDest ? htext : stopFirst;
String ddisabled = canChangeDest ? "" : " disabled=\"disabled\" ";
%>
<input type="text" size="30" id="privKeyFile" name="privKeyFile" title="<%=dtext%>" value="<%=editBean.getPrivateKeyFile(curTunnel)%>" class="freetext" placeholder="required" <%=ddisabled%>/>
</td> </td>
</tr> </tr>
<% <%
/****** /******
if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) { if ("httpserver".equals(tunnelType) || isBidirServer) {
String sig = editBean.getNameSignature(curTunnel); String sig = editBean.getNameSignature(curTunnel);
if (sig.length() > 0) { if (sig.length() > 0) {
%><div id="sigField" class="rowItem"> %><div id="sigField" class="rowItem">
@ -212,7 +240,7 @@
%> %>
<a class="control" title="<%=intl._t("Register, unregister or change details for hostname")%>" href="register?tunnel=<%=curTunnel%>"><%=intl._t("Registration Authentication")%></a> <a class="control" title="<%=intl._t("Register, unregister or change details for hostname")%>" href="register?tunnel=<%=curTunnel%>"><%=intl._t("Registration Authentication")%></a>
<% <%
if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) { if ("httpserver".equals(tunnelType) || isBidirServer) {
%> %>
<a class="control" title="<%=intl._t("HTTPS configuration")%>" href="ssl?tunnel=<%=curTunnel%>"><%=intl._t("SSL Wizard")%></a> <a class="control" title="<%=intl._t("HTTPS configuration")%>" href="ssl?tunnel=<%=curTunnel%>"><%=intl._t("SSL Wizard")%></a>
<% <%
@ -407,8 +435,6 @@
%> %>
<% <%
boolean canChangeEncType = editBean.canChangeEncType(curTunnel); boolean canChangeEncType = editBean.canChangeEncType(curTunnel);
String stopFirst = intl._t("Tunnel must be stopped to change this configuration");
String tstopFirst = " title=\"" + stopFirst + "\" ";
String ehdisabled = canChangeEncType ? "" : tstopFirst; String ehdisabled = canChangeEncType ? "" : tstopFirst;
// TODO, encrypted + offline is unimplemented // TODO, encrypted + offline is unimplemented
@ -499,8 +525,10 @@
<td> <td>
<% <%
if (allowBlinding /* && editBean.isAdvanced() */) { if (allowBlinding /* && editBean.isAdvanced() */) {
String pwTitle = "title=\"" + intl._t("Set password required to access this service") + String pwTitle = "title=\"" +
(canChangeEncType ? "" : (" - " + stopFirst)) + '"'; (canChangeEncType ?
intl._t("Set password required to access this service") :
stopFirst) + '"';
%> %>
<input type="password" name="nofilter_blindedPassword" <%=pwTitle%> value="<%=editBean.getBlindedPassword(curTunnel)%>" class="freetext password" <%=bdisabled%>/> <input type="password" name="nofilter_blindedPassword" <%=pwTitle%> value="<%=editBean.getBlindedPassword(curTunnel)%>" class="freetext password" <%=bdisabled%>/>
<% <%
@ -687,7 +715,7 @@
<% <%
/* alternate dest, only if current dest is set and is DSA_SHA1 */ /* alternate dest, only if current dest is set and is DSA_SHA1 */
if (currentSigType == 0 && !"".equals(b64) && !"streamrserver".equals(tunnelType)) { if (currentSigType == 0 && !"".equals(b64) && !isStreamrServer) {
%> %>
<tr> <tr>
<th colspan="2"> <th colspan="2">
@ -794,7 +822,7 @@
</th> </th>
</tr> </tr>
<% <%
if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) { if ("httpserver".equals(tunnelType) || isBidirServer) {
%> %>
<tr> <tr>
<td> <td>
@ -831,7 +859,7 @@
</th> </th>
</tr> </tr>
<% <%
if (!"streamrserver".equals(tunnelType)) { if (!isStreamrServer) {
%> %>
<tr> <tr>
<th colspan="5"> <th colspan="5">
@ -871,7 +899,7 @@
</td> </td>
</tr> </tr>
<% <%
if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) { if ("httpserver".equals(tunnelType) || isBidirServer) {
%> %>
<tr> <tr>
<th colspan="8"> <th colspan="8">