i2ptunnel: Fix SSL wizard for split config (ticket #2610)

This commit is contained in:
zzz
2019-09-14 13:39:39 +00:00
parent f1b725a320
commit 65d0ea3f0b

View File

@ -285,7 +285,16 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
boolean addssl = ok && !isSSLEnabled && !action.equals("Disable");
boolean delssl = ok && isSSLEnabled && action.equals("Disable");
if (addssl || delssl) {
File f = new File(ctx.getConfigDir(), "clients.config");
String configfile = request.getParameter("clientConfigFile");
File f;
if (configfile == null || configfile.equals("clients.config")) {
f = new File(ctx.getConfigDir(), "clients.config");
} else if (configfile.contains("/") || configfile.contains("\\")) {
throw new IllegalArgumentException();
} else {
f = new File(ctx.getConfigDir(), "clients.config.d");
f = new File(f, configfile);
}
java.util.Properties p = new net.i2p.util.OrderedProperties();
try {
DataHelper.loadProps(p, f);
@ -578,15 +587,44 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
// Now try to find the Jetty server in clients.config
File configDir = ctx.getConfigDir();
File clientsConfig = new File(configDir, "clients.config");
boolean isSingleFile = clientsConfig.exists();
File[] configFiles;
if (!isSingleFile) {
File clientsConfigD = new File(configDir, "clients.config.d");
configFiles = clientsConfigD.listFiles();
} else {
configFiles = null;
}
java.util.Properties clientProps = new java.util.Properties();
try {
boolean foundClientConfig = false;
DataHelper.loadProps(clientProps, clientsConfig);
for (int i = 0; i < 100; i++) {
int i = -1;
int fileNum = 0;
while (true) {
if (isSingleFile) {
// next config in the file
i++;
if (i == 0)
DataHelper.loadProps(clientProps, clientsConfig);
} else {
if (configFiles == null)
break;
if (fileNum >= configFiles.length)
break;
// load the next file
clientProps.clear();
clientsConfig = configFiles[fileNum++];
DataHelper.loadProps(clientProps, clientsConfig);
// only look at client 0 in file
i = 0;
}
String prop = "clientApp." + i + ".main";
String cls = clientProps.getProperty(prop);
if (cls == null)
break;
if (cls == null) {
if (isSingleFile)
break;
continue;
}
if (!cls.equals("net.i2p.jetty.JettyStart"))
continue;
prop = "clientApp." + i + ".args";
@ -734,6 +772,7 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
%>
<tr><td colspan="4">
<input type="hidden" name="clientAppNumber" value="<%=i%>" />
<input type="hidden" name="clientConfigFile" value="<%=clientsConfig.getName()%>" />
<input type="hidden" name="isSSLEnabled" value="<%=isEnabled%>" />
<input type="hidden" name="nofilter_ksPath" value="<%=ksPath%>" />
<input type="hidden" name="nofilter_jettySSLFile" value="<%=jettySSLFile%>" />
@ -781,7 +820,7 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
<%
break;
} // canConfigure
} // for client
} // while (for each client or client file)
if (!foundClientConfig) {
%>
<tr><td colspan="4">Cannot configure, no Jetty server found in <a href="/configclients">client configurations</a> that matches this tunnel</td></tr>