I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit a70a7a7e authored by zzz's avatar zzz
Browse files

Imagegen:

- Return 403 if no code specified in QR or RA
- Mode parameter for html or text in RA
- Set RA text-mode character encoding
- Fix up test page
parent 2fb1ad03
No related branches found
No related tags found
No related merge requests found
......@@ -69,10 +69,8 @@ public class QRServlet extends HttpServlet {
String codeParam = request.getParameter(PARAM_IDENTICON_CODE_SHORT);
boolean codeSpecified = codeParam != null && codeParam.length() > 0;
if (!codeSpecified) {
// TODO 404
codeParam="http://stats.i2p/?i2paddresshelper=Okd5sN9hFWx-sr0HH8EFaxkeIMi6PC5eGTcjM1KB7uQ0ffCUJ2nVKzcsKZFHQc7pLONjOs2LmG5H-2SheVH504EfLZnoB7vxoamhOMENnDABkIRGGoRisc5AcJXQ759LraLRdiGSR0WTHQ0O1TU0hAz7vAv3SOaDp9OwNDr9u902qFzzTKjUTG5vMTayjTkLo2kOwi6NVchDeEj9M7mjj5ySgySbD48QpzBgcqw1R27oIoHQmjgbtbmV2sBL-2Tpyh3lRe1Vip0-K0Sf4D-Zv78MzSh8ibdxNcZACmZiVODpgMj2ejWJHxAEz41RsfBpazPV0d38Mfg4wzaS95R5hBBo6SdAM4h5vcZ5ESRiheLxJbW0vBpLRd4mNvtKOrcEtyCvtvsP3FpA-6IKVswyZpHgr3wn6ndDHiVCiLAQZws4MsIUE1nkfxKpKtAnFZtPrrB8eh7QO9CkH2JBhj7bG0ED6mV5~X5iqi52UpsZ8gnjZTgyG5pOF8RcFrk86kHxAAAA";
//response.setStatus(403);
//return;
response.setStatus(403);
return;
}
String sizeParam = request.getParameter(PARAM_IDENTICON_SIZE_SHORT);
......
......@@ -24,6 +24,7 @@ public class RandomArtServlet extends HttpServlet {
private static final long serialVersionUID = -3507466186902317988L;
private static final String PARAM_IDENTICON_CODE_SHORT = "c";
private static final String PARAM_IDENTICON_MODE_SHORT = "m";
private static final long DEFAULT_IDENTICON_EXPIRES_IN_MILLIS = 24 * 60 * 60 * 1000;
private int version = 1;
private long identiconExpiresInMillis = DEFAULT_IDENTICON_EXPIRES_IN_MILLIS;
......@@ -34,8 +35,12 @@ public class RandomArtServlet extends HttpServlet {
String codeParam = request.getParameter(PARAM_IDENTICON_CODE_SHORT);
boolean codeSpecified = codeParam != null && codeParam.length() > 0;
if (!codeSpecified)
codeParam="stats.i2p";
if (!codeSpecified) {
response.setStatus(403);
return;
}
String modeParam = request.getParameter(PARAM_IDENTICON_MODE_SHORT);
boolean html = modeParam == null || modeParam.startsWith("h");
String identiconETag = IdenticonUtil.getIdenticonETag(codeParam.hashCode(), 0,
version);
String requestETag = request.getHeader("If-None-Match");
......@@ -47,13 +52,13 @@ public class RandomArtServlet extends HttpServlet {
if (h == null) {
response.setStatus(403);
} else {
boolean html = true;
StringBuilder buf = new StringBuilder(512);
if (html) {
response.setContentType("text/html");
buf.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>");
} else {
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
}
buf.append(RandomArt.gnutls_key_fingerprint_randomart(h.getData(), "SHA", 256, "", true, html));
if (html)
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Identicon Canvas Test</title>
<title>Image Generator Webapp</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h2>Server-side ID</h2>
<h2>Image Generator Webapp</h2>
<p>This is the webapp that creates identification images.</p>
<h2>Identicon Test</h2>
<img src="id?c=-2044886870&amp;s=15" width=15 height=15>
<img src="id?c=-2044886870&amp;s=21" width=21 height=21>
<img src="id?c=-2044886870&amp;s=30" width=30 height=30>
......@@ -16,8 +18,16 @@
<img src="id?c=-2044886870&amp;s=64" width=64 height=64>
<img src="id?c=-2044886870&amp;s=128" width=128 height=128>
<h2>Server-side QR</h2>
<img src="qr?c=https%3a%2f%2fgeti2p.net%2f&amp;s=128" width=128 height=128>
<h2>QR Test</h2>
<img src="qr?c=https%3a%2f%2fgeti2p.net%2f&amp;s=128" width=128 height=128>
<img src="qr?c=https%3a%2f%2fgeti2p.net%2f&amp;s=256" width=256 height=256>
<h2>Random Art Test</h2>
<iframe src="ra?c=i2p-projekt.i2p&amp;m=html" width=180 height=200>
<a href="ra?c=i2p-projekt.i2p&amp;m=html">HTML test</a>
</iframe>
<iframe src="ra?c=i2p-projekt.i2p&amp;m=text" width=180 height=200>
<a href="ra?c=i2p-projekt.i2p&amp;m=text">UTF-8 text test</a>
</iframe>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment