forked from I2P_Developers/i2p.i2p
Console:
- Move multipart form support from susimail to jetty-i2p.jar so console can use it - Add multipart form support to formhandler.jsi and FormHandler.java Reseed: - Fix zip magic number - Finish manual reseed from local file package.html files for jetty-i2p.jar
This commit is contained in:
@ -277,8 +277,6 @@
|
||||
<target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
|
||||
<!-- set if unset -->
|
||||
<property name="workspace.changes.tr" value="" />
|
||||
<!-- old jetty 5 classes blow up the build if you forgot to do distclean -->
|
||||
<delete dir="build/obj/org" />
|
||||
<copy todir="build/obj" file="resources/log4j.properties" />
|
||||
<jar destfile="./jettylib/jetty-i2p.jar" basedir="./build/obj" includes="**/*.class log4j.properties" >
|
||||
<manifest>
|
||||
|
7
apps/jetty/java/src/net/i2p/jetty/package.html
Normal file
7
apps/jetty/java/src/net/i2p/jetty/package.html
Normal file
@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Classes for starting Jetty, logging requests, and debug logging to the I2P router log.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
@ -21,7 +21,7 @@
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
*/
|
||||
package i2p.susi.webmail;
|
||||
package net.i2p.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -48,13 +48,15 @@ import org.mortbay.servlet.MultiPartRequest;
|
||||
*
|
||||
* The filter would have been added in web.xml,
|
||||
* see that file, where it's commented out.
|
||||
* Filter isn't supported until Tomcat 7 (Servlet 3.0)
|
||||
*
|
||||
* @author user
|
||||
* @author user
|
||||
* @since 0.9.19 moved from susimail so it may be used by routerconsole too
|
||||
*/
|
||||
class RequestWrapper {
|
||||
public class RequestWrapper {
|
||||
|
||||
private final HttpServletRequest httpRequest;
|
||||
private MultiPartRequest multiPartRequest;
|
||||
private final MultiPartRequest multiPartRequest;
|
||||
private final Hashtable<String, String> cache;
|
||||
private Hashtable<String, Integer> cachedParameterNames;
|
||||
|
||||
@ -65,14 +67,16 @@ class RequestWrapper {
|
||||
cache = new Hashtable<String, String>();
|
||||
this.httpRequest = httpRequest;
|
||||
String contentType = httpRequest.getContentType();
|
||||
MultiPartRequest mpr = null;
|
||||
if( contentType != null && contentType.toLowerCase(Locale.US).startsWith( "multipart/form-data" ) ) {
|
||||
try {
|
||||
multiPartRequest = new MultiPartRequest( httpRequest );
|
||||
mpr = new MultiPartRequest( httpRequest );
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
multiPartRequest = mpr;
|
||||
}
|
||||
|
||||
/**
|
7
apps/jetty/java/src/net/i2p/servlet/filters/package.html
Normal file
7
apps/jetty/java/src/net/i2p/servlet/filters/package.html
Normal file
@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
XSS filter, since 0.9.14.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
11
apps/jetty/java/src/net/i2p/servlet/package.html
Normal file
11
apps/jetty/java/src/net/i2p/servlet/package.html
Normal file
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
RequestWrapper was a susimail class,
|
||||
moved from susimail to jetty-i2p.jar when we needed them in the router console also.
|
||||
As of 0.9.19.
|
||||
Requires org.mortbay classes also in this jar.
|
||||
Will be maintained as a public API until we move to Tomcat 7 (servlet 3.0).
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
@ -263,7 +263,7 @@ public class MultiPartRequest
|
||||
{
|
||||
// Get first boundary
|
||||
String line = _in.readLine();
|
||||
if (!line.equals(_boundary))
|
||||
if (line == null || !line.equals(_boundary))
|
||||
{
|
||||
//log.warn(line);
|
||||
throw new IOException("Missing initial multi part boundary");
|
11
apps/jetty/java/src/org/mortbay/servlet/package.html
Normal file
11
apps/jetty/java/src/org/mortbay/servlet/package.html
Normal file
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Old Jetty 5 classes for multipart form requests, moved to susimail and modded when we moved to Jetty 6,
|
||||
then moved from susimail to jetty-i2p.jar when we needed them in the router console also.
|
||||
As of 0.9.19.
|
||||
Not a public API, not for direct use.
|
||||
These are requirements for net.i2p.servlet.RequestWrapper.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
11
apps/jetty/java/src/org/mortbay/util/package.html
Normal file
11
apps/jetty/java/src/org/mortbay/util/package.html
Normal file
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Old Jetty 5 classes for multipart form requests, moved to susimail and modded when we moved to Jetty 6,
|
||||
then moved from susimail to jetty-i2p.jar when we needed them in the router console also.
|
||||
As of 0.9.19.
|
||||
Not a public API, not for direct use.
|
||||
These are requirements for net.i2p.servlet.RequestWrapper.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,5 @@
|
||||
package net.i2p.router.web;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
@ -10,7 +9,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.networkdb.reseed.Reseeder;
|
||||
|
||||
/**
|
||||
@ -76,15 +74,14 @@ public class ConfigReseedHandler extends FormHandler {
|
||||
addFormError(_("Bad URL {0}", val) + " - " + iae.getMessage());
|
||||
}
|
||||
} else if (_action.equals(_("Reseed from file"))) {
|
||||
//////// FIXME multipart
|
||||
String val = getJettyString("file");
|
||||
if (val == null || val.length() == 0) {
|
||||
addFormError(_("You must enter a file"));
|
||||
return;
|
||||
}
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(DataHelper.getASCII(val));
|
||||
InputStream in = _requestWrapper.getInputStream("file");
|
||||
try {
|
||||
int count = _context.netDb().reseedChecker().requestReseed(bais);
|
||||
// non-null but zero bytes if no file entered, don't know why
|
||||
if (in == null || in.available() <= 0) {
|
||||
addFormError(_("You must enter a file"));
|
||||
return;
|
||||
}
|
||||
int count = _context.netDb().reseedChecker().requestReseed(in);
|
||||
if (count <= 0) {
|
||||
addFormError(_("Reseed from file failed"));
|
||||
} else {
|
||||
@ -94,6 +91,10 @@ public class ConfigReseedHandler extends FormHandler {
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
addFormError(_("Reseed from file failed") + " - " + ioe);
|
||||
} finally {
|
||||
// it's really a ByteArrayInputStream but we'll play along...
|
||||
if (in != null)
|
||||
try { in.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
} else if (_action.equals(_("Save changes"))) {
|
||||
saveChanges();
|
||||
|
@ -7,6 +7,7 @@ import java.util.Map;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.servlet.RequestWrapper;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
/**
|
||||
@ -21,7 +22,10 @@ import net.i2p.util.Log;
|
||||
public abstract class FormHandler {
|
||||
protected RouterContext _context;
|
||||
protected Log _log;
|
||||
/** Not for multipart/form-data, will be null */
|
||||
protected Map _settings;
|
||||
/** Only for multipart/form-data. Warning, parameters are NOT XSS filtered */
|
||||
protected RequestWrapper _requestWrapper;
|
||||
private String _nonce, _nonce1, _nonce2;
|
||||
protected String _action;
|
||||
protected String _method;
|
||||
@ -61,6 +65,15 @@ public abstract class FormHandler {
|
||||
*/
|
||||
public void setSettings(Map settings) { _settings = new HashMap(settings); }
|
||||
|
||||
/**
|
||||
* Only set by formhandler.jsi for multipart/form-data
|
||||
*
|
||||
* @since 0.9.19
|
||||
*/
|
||||
public void setRequestWrapper(RequestWrapper rw) {
|
||||
_requestWrapper = rw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as HelperBase
|
||||
* @since 0.9.14.1
|
||||
|
@ -29,12 +29,31 @@
|
||||
// nonce1 will be null, removed in setAttibute below
|
||||
}
|
||||
|
||||
// Put all the params in the map, some handlers use this instead of individual setters
|
||||
// We also call all of the setters below.
|
||||
formhandler.setSettings(request.getParameterMap());
|
||||
|
||||
String contentType = request.getContentType();
|
||||
if (contentType != null && contentType.toLowerCase(java.util.Locale.US).startsWith( "multipart/form-data")) {
|
||||
// For multipart/form-data, we must decode things enough to get the action and nonce
|
||||
// so FormHandler will validate.
|
||||
// The handler must get everything else through the wrapper. No other properties will be set.
|
||||
// All parameters other than nonce and action must be retrieved through the wrapper.
|
||||
// Warning, parameters are NOT XSS filtered.
|
||||
net.i2p.servlet.RequestWrapper requestWrapper = new net.i2p.servlet.RequestWrapper(request);
|
||||
String action = requestWrapper.getParameter("action");
|
||||
if (action != null)
|
||||
formhandler.setAction(action);
|
||||
String nonce = requestWrapper.getParameter("nonce");
|
||||
if (nonce != null)
|
||||
formhandler.setNonce(nonce);
|
||||
formhandler.setRequestWrapper(requestWrapper);
|
||||
} else {
|
||||
// Put all the params in the map, some handlers use this instead of individual setters
|
||||
// We also call all of the setters below.
|
||||
formhandler.setSettings(request.getParameterMap());
|
||||
%>
|
||||
<jsp:setProperty name="formhandler" property="*" />
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<jsp:getProperty name="formhandler" property="allMessages" />
|
||||
<%
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
<!-- Depend on classes instead of jars where available -->
|
||||
<classpath>
|
||||
<pathelement location="../../core/java/build/obj" />
|
||||
<pathelement location="../jetty/jettylib/javax.servlet.jar" />
|
||||
<pathelement location="../jetty/jettylib/jetty-i2p.jar" />
|
||||
</classpath>
|
||||
</depend>
|
||||
</target>
|
||||
@ -38,6 +40,7 @@
|
||||
<compilerarg line="${javac.compilerargs}" />
|
||||
<classpath>
|
||||
<pathelement location="../jetty/jettylib/javax.servlet.jar" />
|
||||
<pathelement location="../jetty/jettylib/jetty-i2p.jar" />
|
||||
<pathelement location="../../core/java/build/i2p.jar" />
|
||||
</classpath>
|
||||
</javac>
|
||||
|
@ -69,6 +69,7 @@ import javax.servlet.http.HttpSessionBindingListener;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.servlet.RequestWrapper;
|
||||
|
||||
/**
|
||||
* @author susi23
|
||||
|
@ -690,11 +690,11 @@
|
||||
<group title="I2PSnark Application" packages="org.klomp.snark:org.klomp.snark.*" />
|
||||
<group title="I2PTunnel Application" packages="net.i2p.i2ptunnel:net.i2p.i2ptunnel.*" />
|
||||
<group title="Installer Utilities" packages="net.i2p.installer" />
|
||||
<group title="Jetty Starter and Logging" packages="net.i2p.jetty:net.i2p.servlet:net.i2p.servlet.*" />
|
||||
<group title="Jetty Utilities" packages="net.i2p.jetty:net.i2p.servlet:net.i2p.servlet.*:org.mortbay.servlet:org.mortbay.util" />
|
||||
<group title="SAM Bridge" packages="net.i2p.sam" />
|
||||
<group title="SAM Demos" packages="net.i2p.sam.client" />
|
||||
<group title="SusiDNS Application" packages="i2p.susi.dns" />
|
||||
<group title="SusiMail Application" packages="i2p.susi.webmail:i2p.susi.webmail.*:i2p.susi.debug:i2p.susi.util:org.mortbay.servlet:org.mortbay.util" />
|
||||
<group title="SusiMail Application" packages="i2p.susi.webmail:i2p.susi.webmail.*:i2p.susi.debug:i2p.susi.util" />
|
||||
<group title="Systray Application" packages="net.i2p.apps.systray" />
|
||||
<sourcepath>
|
||||
<pathelement location="core/java/src" />
|
||||
|
@ -1,3 +1,9 @@
|
||||
2015-03-20 zzz
|
||||
* Reseed:
|
||||
- Move multipart form support from susimail to jetty-i2p.jar
|
||||
so console can use it
|
||||
- Finish manual reseed from local file
|
||||
|
||||
2015-03-19 zzz
|
||||
* Reseed:
|
||||
- Add form to manually reseed from zip or su3 URL
|
||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 7;
|
||||
public final static long BUILD = 8;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
Reference in New Issue
Block a user