i2ptunnel: B32 auth form improvements

This commit is contained in:
zzz
2019-09-17 13:18:47 +00:00
parent 62914d7678
commit 69638caa7b
2 changed files with 42 additions and 14 deletions

View File

@@ -1497,22 +1497,21 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
if(outs == null) if(outs == null)
return; return;
Writer out = new BufferedWriter(new OutputStreamWriter(outs, "UTF-8")); Writer out = new BufferedWriter(new OutputStreamWriter(outs, "UTF-8"));
String header = getErrorPage("b32", ERR_DESTINATION_UNKNOWN); String header = getErrorPage("b32-auth", ERR_DESTINATION_UNKNOWN);
out.write(header); out.write(header);
out.write("<table id=\"proxyNewHost\">\n<tr><td align=\"right\">" + _t("Host") + out.write("<table id=\"proxyNewHost\">\n" +
"</td><td>" + destination + "</td></tr>\n"); "<tr><td align=\"right\">" + _t("Base 32") + "</td>" +
out.write("<tr><td align=\"right\">" + _t("Base 32") + "</td>" + "<td>" + destination + "</td></tr>" +
"<td><a href=\"http://" + destination + "/\">" + destination + "</a></td></tr>"); "\n</table>\n" + "<hr>");
out.write("\n</table>\n" + "<hr>");
String msg; String msg;
if (code == LookupResult.RESULT_SECRET_REQUIRED) if (code == LookupResult.RESULT_SECRET_REQUIRED)
msg = _t("b32 address requires lookup password"); msg = _t("Base 32 address requires lookup password");
else if (code == LookupResult.RESULT_KEY_REQUIRED) else if (code == LookupResult.RESULT_KEY_REQUIRED)
msg = _t("b32 address requires encryption key"); msg = _t("Base 32 address requires encryption key");
else if (code == LookupResult.RESULT_SECRET_AND_KEY_REQUIRED) else if (code == LookupResult.RESULT_SECRET_AND_KEY_REQUIRED)
msg = _t("b32 address requires encryption key and lookup password"); msg = _t("Base 32 address requires encryption key and lookup password");
else if (code == LookupResult.RESULT_DECRYPTION_FAILURE) else if (code == LookupResult.RESULT_DECRYPTION_FAILURE)
msg = _t("b32 address decryption failure, check encryption key"); msg = _t("Base 32 address decryption failure, check encryption key");
else else
msg = "lookup failure code " + code; msg = "lookup failure code " + code;
out.write("<p><b>" + msg + "</b></p>"); out.write("<p><b>" + msg + "</b></p>");
@@ -1529,20 +1528,26 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
' ' + _t("Ask the server operator for help.") + ' ' + _t("Ask the server operator for help.") +
"</p>\n" + "</p>\n" +
"<input type=\"text\" size=\"55\" name=\"privkey\" value=\"\"></p>\n" + "<p>" + _t("Enter PSK encryption key") +
"</p>\n" +
"<input type=\"text\" size=\"55\" name=\"privkey\" value=\"\">\n" +
"<p>" + _t("Generate new DH encryption key") + "<p>" + _t("Generate new DH encryption key") +
"<button type=\"submit\" class=\"accept\" name=\"action\" value=\"newdh\">" + label + "</button>\n"); "<div class=\"formaction\">" +
"<button type=\"submit\" class=\"accept\" name=\"action\" value=\"newdh\">" + label +
"</button></div>\n");
//"<p>" + _t("Generate new PSK encryption key") + //"<p>" + _t("Generate new PSK encryption key") +
//"<button type=\"submit\" class=\"accept\" name=\"action\" value=\"newpsk\">" + label + "</button>\n"); //"<button type=\"submit\" class=\"accept\" name=\"action\" value=\"newpsk\">" + label + "</button>\n");
} }
if (code == LookupResult.RESULT_SECRET_REQUIRED || code == LookupResult.RESULT_SECRET_AND_KEY_REQUIRED) { if (code == LookupResult.RESULT_SECRET_REQUIRED || code == LookupResult.RESULT_SECRET_AND_KEY_REQUIRED) {
out.write("<h4>" + _t("Lookup password") + "</h4>\n<p>" + out.write("<h4>" + _t("Lookup password") + "</h4>\n<p>" +
"<input type=\"text\" size=\"55\" name=\"secret\" value=\"\"></p>\n"); "<p>" + _t("You must enter the password provided by the server operator.") +
"</p>\n" +
"<input type=\"text\" size=\"55\" name=\"secret\" value=\"\">\n");
} }
// FIXME wasn't escaped // FIXME wasn't escaped
String label = _t("Save & continue").replace("&", "&amp;"); String label = _t("Save & continue").replace("&", "&amp;");
out.write("<div class=\"formaction\"><button type=\"submit\" class=\"accept\" name=\"action\" value=\"save\">" + out.write("<p><div class=\"formaction\"><button type=\"submit\" class=\"accept\" name=\"action\" value=\"save\">" +
label + "</button></div>\n" + label + "</button></div>\n" +
"</form>\n</div>\n"); "</form>\n</div>\n");
writeFooter(out); writeFooter(out);

View File

@@ -0,0 +1,23 @@
HTTP/1.1 400 Destination Not Found
Content-Type: text/html; charset=UTF-8
Cache-Control: no-cache
Connection: close
Proxy-Connection: close
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>_("Website Unreachable")</title>
<noscript><style type="text/css">.script {display: none;}</style></noscript>
<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="logo">
<a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
<a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
</div>
<div class="warning" id="warning">
<h3>_("Warning: Authorization Required")</h3>
<p>
<p><b>_("Could not find the following destination:")</b>
</p>