Add identicons to i2ptunnel address helper conflict page.

Clean up text on the conflict page for readability.
This commit is contained in:
zzz
2016-01-22 22:26:46 +00:00
parent d16db7b56c
commit 726adaf2bb
2 changed files with 47 additions and 4 deletions

View File

@ -34,6 +34,7 @@ import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.data.Hash;
import net.i2p.i2ptunnel.localServer.LocalHTTPServer;
import net.i2p.util.ConvertToHash;
import net.i2p.util.EventDispatcher;
import net.i2p.util.Log;
import net.i2p.util.PortMapper;
@ -706,9 +707,51 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
String conflictURL = conflictURI.toASCIIString();
String header = getErrorPage("ahelper-conflict", ERR_AHELPER_CONFLICT);
out.write(header.getBytes("UTF-8"));
out.write(_t("To visit the destination in your host database, click <a href=\"{0}\">here</a>. To visit the conflicting addresshelper destination, click <a href=\"{1}\">here</a>.",
out.write("<p>".getBytes("UTF-8"));
out.write(_t("To visit the destination in your address book, click <a href=\"{0}\">here</a>. To visit the conflicting addresshelper destination, click <a href=\"{1}\">here</a>.",
trustedURL, conflictURL).getBytes("UTF-8"));
out.write("</p></div>".getBytes("UTF-8"));
out.write("</p>".getBytes("UTF-8"));
Hash h1 = ConvertToHash.getHash(requestURI.getHost());
Hash h2 = ConvertToHash.getHash(ahelperKey);
if (h1 != null && h2 != null) {
// Do we need to replace http://127.0.0.1:7657
// Get the registered host and port from the PortMapper.
final String unset = "*unset*";
final String httpHost = _context.portMapper().getActualHost(PortMapper.SVC_CONSOLE, unset);
final String httpsHost = _context.portMapper().getActualHost(PortMapper.SVC_HTTPS_CONSOLE, unset);
final int httpPort = _context.portMapper().getPort(PortMapper.SVC_CONSOLE, 7657);
final int httpsPort = _context.portMapper().getPort(PortMapper.SVC_HTTPS_CONSOLE, -1);
final boolean httpsOnly = httpsPort > 0 && httpHost.equals(unset) && !httpsHost.equals(unset);
final int cport = httpsOnly ? httpsPort : httpPort;
String chost = httpsOnly ? httpsHost : httpHost;
if (chost.equals(unset))
chost = "127.0.0.1";
String chostport;
if (httpsOnly || cport != 7657 || !chost.equals("127.0.0.1"))
chostport = (httpsOnly ? "https://" : "http://") + chost + ':' + cport;
else
chostport = "http://127.0.0.1:7657";
out.write(("\n<table class=\"conflict\"><tr><th align=\"center\">" +
"<a href=\"" + trustedURL + "\">").getBytes("UTF-8"));
out.write(_t("Destination for {0} in address book", requestURI.getHost()).getBytes("UTF-8"));
out.write(("</a></th>\n<th align=\"center\">" +
"<a href=\"" + conflictURL + "\">").getBytes("UTF-8"));
out.write(_t("Conflicting address helper destination").getBytes("UTF-8"));
out.write(("</a></th></tr>\n<tr><td align=\"center\">" +
"<a href=\"" + trustedURL + "\">" +
"<img src=\"" +
chostport + "/imagegen/id?s=160&amp;c=" +
h1.toBase64().replace("=", "%3d") +
"\" width=\"160\" height=\"160\"></a>\n").getBytes("UTF-8"));
out.write(("</td>\n<td align=\"center\">" +
"<a href=\"" + conflictURL + "\">" +
"<img src=\"" +
chostport + "/imagegen/id?s=160&amp;c=" +
h2.toBase64().replace("=", "%3d") +
"\" width=\"160\" height=\"160\"></a>\n").getBytes("UTF-8"));
out.write("</td></tr></table>".getBytes("UTF-8"));
}
out.write("</div>".getBytes("UTF-8"));
writeFooter(out);
}
reader.drain();