Ported from Jetty5->6. Bumped version numbers.

This commit is contained in:
dev
2012-02-29 21:03:23 +00:00
parent 541d9ad5da
commit 9673965345
7 changed files with 55 additions and 58 deletions

View File

@ -10,7 +10,7 @@
<target name="plugin" depends="jar">
<!-- get version number -->
<buildnumber file="scripts/build.number" />
<property name="release.number" value="0.0.3" />
<property name="release.number" value="0.0.4" />
<!-- make the update xpi2p -->
<mkdir dir="plugin/lib"/>

View File

@ -6,4 +6,4 @@ author=hottuna
websiteURL=http://itoopie.i2p/
updateURL=http://itoopie.i2p/files/I2PControl-update.xpi2p
license=Apache 2.0
max-jetty-version=5.99999
max-jetty-version=6.99999

View File

@ -3,10 +3,10 @@
<classpathentry kind="src" path="java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/home/hottuna/Apps/i2p/lib/i2p.jar"/>
<classpathentry kind="lib" path="/home/hottuna/Apps/i2p/lib/org.mortbay.jetty.jar"/>
<classpathentry kind="lib" path="/home/hottuna/Apps/i2p/lib/javax.servlet.jar"/>
<classpathentry kind="lib" path="/home/hottuna/Apps/i2p/lib/commons-logging.jar"/>
<classpathentry kind="lib" path="/home/hottuna/Apps/i2p/lib/router.jar"/>
<classpathentry kind="lib" path="/home/hottuna/Apps/i2p/lib/wrapper.jar"/>
<classpathentry kind="lib" path="/home/hottuna/Downloads/jetty-6.1.26.jar"/>
<classpathentry kind="output" path="build/obj"/>
</classpath>

View File

@ -10,15 +10,16 @@
<pathelement location="${i2plib}/i2p.jar" />
<pathelement location="${i2plib}/router.jar" />
<pathelement location="${i2plib}/i2ptunnel.jar" />
<pathelement location="${i2plib}/org.mortbay.jetty.jar" />
<pathelement location="${i2plib}/org.mortbay.jetty.jar" />
<pathelement location="${ant.home}/lib/ant.jar"/>
<pathelement location="${jettylib}/org.mortbay.jetty.jar"/>
<pathelement location="${jettylib}/jetty-util-6.1.26.jar" />
<pathelement location="${jettylib}/jasper-compiler.jar" />
<pathelement location="${jettylib}/jasper-runtime.jar" />
<pathelement location="${jettylib}/javax.servlet.jar" />
<pathelement location="${jettylib}/commons-logging.jar" />
<pathelement location="${jettylib}/commons-el.jar" />
<pathelement location="${jettylib}/javax.servlet.jar" />
<pathelement location="${jettylib}/javax.servlet.jar" />
<pathelement location="${wrapperlib}/wrapper.jar" />
</path>

View File

@ -18,27 +18,27 @@ package net.i2p.i2pcontrol;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Calendar;
import java.util.logging.LogManager;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.security.SslSocketConnector;
import org.mortbay.jetty.servlet.ServletHandler;
import net.i2p.I2PAppContext;
import net.i2p.i2pcontrol.router.RouterManager;
import net.i2p.i2pcontrol.security.KeyStoreFactory;
import net.i2p.i2pcontrol.security.KeyStoreInitializer;
import net.i2p.i2pcontrol.security.SecurityManager;
import net.i2p.i2pcontrol.servlets.JSONRPC2Servlet;
import net.i2p.i2pcontrol.servlets.configuration.ConfigurationManager;
import net.i2p.i2pcontrol.util.IsJar;
import net.i2p.util.Log;
import org.mortbay.http.HttpListener;
import org.mortbay.http.SslListener;
import org.mortbay.http.handler.AbstractHttpHandler;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.ServletHttpContext;
import org.mortbay.util.InetAddrPort;
//import org.mortbay.http.SslListener;
//import org.mortbay.http.handler.AbstractHttpHandler;
//import org.mortbay.jetty.Server;
//import org.mortbay.jetty.servlet.ServletHttpContext;
//import org.mortbay.util.InetAddrPort;
//import org.mortbay.servlet.jetty.*;
/**
* This handles the starting and stopping of an eepsite tunnel and jetty
@ -118,12 +118,13 @@ public class I2PControlController{
public static Server buildServer() throws UnknownHostException, Exception, InstantiationException, IllegalAccessException{
Server server = new Server();
SslListener ssl = buildSslListener(_conf.getConf("i2pcontrol.listen.address", "127.0.0.1"),
SslSocketConnector ssl = buildSslListener(_conf.getConf("i2pcontrol.listen.address", "127.0.0.1"),
_conf.getConf("i2pcontrol.listen.port", 7650));
server.addListener(ssl);
_server.addConnector(ssl);
ServletHttpContext context = (ServletHttpContext) server.getContext("/");
context.addServlet("/jsonrpc", "net.i2p.i2pcontrol.servlets.JSONRPC2Servlet");
ServletHandler sh = new ServletHandler();
sh.addServletWithMapping(net.i2p.i2pcontrol.servlets.JSONRPC2Servlet.class, "/");
server.getServer().setHandler(sh);
server.start();
return server;
@ -137,15 +138,15 @@ public class I2PControlController{
* @return - Newly created listener
* @throws UnknownHostException
*/
public static SslListener buildSslListener(String address, int port) throws UnknownHostException{
public static SslSocketConnector buildSslListener(String address, int port) throws UnknownHostException{
int listeners = 0;
if (_server != null){
listeners = _server.getListeners().length;
listeners = _server.getConnectors().length;
}
SslListener ssl = new SslListener();
SslSocketConnector ssl = new SslSocketConnector();
ssl.setProvider(_secMan.getSecurityProvider());
ssl.setCipherSuites(_secMan.getSupprtedSSLCipherSuites());
//ssl.setCipherSuites(_secMan.getSupprtedSSLCipherSuites()); Removed in Jetty 5->6 port.
ssl.setHost(address);
ssl.setPort(port);
ssl.setWantClientAuth(false); // Don't care about client authentication.
@ -163,10 +164,10 @@ public class I2PControlController{
* @param listener
* @throws Exception
*/
public static void addListener(HttpListener listener) throws Exception{
public static void addListener(Connector listener) throws Exception{
if (_server != null){
listener.start();
_server.addListener(listener);
_server.addConnector(listener);
}
}
@ -174,9 +175,9 @@ public class I2PControlController{
* Remove a listener from the server.
* @param listener
*/
public static void removeListener(HttpListener listener){
public static void removeListener(Connector listener){
if (_server != null){
_server.removeListener(listener);
_server.removeConnector(listener);
}
}
@ -188,11 +189,11 @@ public class I2PControlController{
* @param listener
* @throws Exception
*/
public static void replaceListener(HttpListener listener) throws Exception{
public static void replaceListener(Connector listener) throws Exception{
if (_server != null){
for (HttpListener currentListener : _server.getListeners()){
for (Connector currentListener : _server.getConnectors()){
if (currentListener.getPort() == listener.getPort()){
_server.removeListener(currentListener);
_server.removeConnector(currentListener);
try {
currentListener.stop();
} catch (InterruptedException e) {
@ -201,7 +202,7 @@ public class I2PControlController{
}
}
listener.start();
_server.addListener(listener);
_server.addConnector(listener);
}
}
@ -209,11 +210,11 @@ public class I2PControlController{
* Get all listeners of the server.
* @return
*/
public static HttpListener[] getListeners(){
public static Connector[] getListeners(){
if (_server != null){
return _server.getListeners();
return _server.getConnectors();
}
return new HttpListener[0];
return new Connector[0];
}
/**
@ -221,8 +222,8 @@ public class I2PControlController{
*/
public static void clearListeners(){
if (_server != null){
for (HttpListener listen : getListeners()){
_server.removeListener(listen);
for (Connector listen : getListeners()){
_server.removeConnector(listen);
}
}
}
@ -241,7 +242,9 @@ public class I2PControlController{
try {
_server.stop();
_server = server;
} catch (InterruptedException e) {}
} catch (InterruptedException e) {} catch (Exception e) {
//e.printStackTrace();
}
}
}
}).start();
@ -255,13 +258,13 @@ public class I2PControlController{
try {
if (_server != null){
_server.stop();
for (HttpListener listener : _server.getListeners()){
for (Connector listener : _server.getConnectors()){
listener.stop();
}
_server.destroy();
_server = null;
}
} catch (InterruptedException e) {
} catch (Exception e) {
_log.error("Stopping server" + e);
}
// Get and stop all running threads

View File

@ -6,7 +6,7 @@ import java.util.Set;
public class I2PControlVersion {
/** The current version of I2PControl */
public final static String VERSION = "0.0.2";
public final static String VERSION = "0.0.4";
/** The current version of the I2PControl API being primarily being implemented */
public final static int API_VERSION = 1;

View File

@ -5,26 +5,17 @@ import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import org.mortbay.http.SslListener;
import org.mortbay.jetty.Server;
import org.mortbay.util.InetAddrPort;
import org.mortbay.jetty.security.SslSocketConnector;
import net.i2p.I2PAppContext;
import net.i2p.data.RouterInfo;
import net.i2p.i2pcontrol.I2PControlController;
import net.i2p.i2pcontrol.router.RouterManager;
import net.i2p.i2pcontrol.security.SecurityManager;
import net.i2p.i2pcontrol.servlets.configuration.ConfigurationManager;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.transport.CommSystemFacadeImpl;
import net.i2p.router.transport.FIFOBandwidthRefiller;
import net.i2p.router.transport.TransportManager;
import net.i2p.router.transport.udp.UDPTransport;
import net.i2p.util.Log;
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error;
import com.thetransactioncompany.jsonrpc2.JSONRPC2ParamsType;
import com.thetransactioncompany.jsonrpc2.JSONRPC2Request;
import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.server.MessageContext;
@ -114,9 +105,10 @@ public class I2PControlHandler implements RequestHandler {
req.getID());
}
try {
SslListener ssl = I2PControlController.buildSslListener(_conf.getConf("i2pcontrol.listen.address", "127.0.0.1"), newPort);
SslSocketConnector ssl = I2PControlController.buildSslListener(_conf.getConf("i2pcontrol.listen.address", "127.0.0.1"), newPort);
I2PControlController.clearListeners();
I2PControlController.replaceListener(ssl);
_conf.setConf("i2pcontrol.listen.port", newPort);
@ -126,7 +118,7 @@ public class I2PControlHandler implements RequestHandler {
} catch (Exception e) {
try {
_conf.setConf("i2pcontrol.listen.port", oldPort);
SslListener ssl = I2PControlController.buildSslListener(_conf.getConf("i2pcontrol.listen.address", "127.0.0.1"), newPort);
SslSocketConnector ssl = I2PControlController.buildSslListener(_conf.getConf("i2pcontrol.listen.address", "127.0.0.1"), newPort);
I2PControlController.clearListeners();
I2PControlController.replaceListener(ssl);
} catch (Exception e2){
@ -158,9 +150,10 @@ public class I2PControlHandler implements RequestHandler {
if ((inParam = (String) inParams.get("i2pcontrol.address")) != null){
if ((oldAddress == null || !inParam.equals(oldAddress.toString()) &&
(inParam.equals("0.0.0.0") || inParam.equals("127.0.0.1")))){
InetAddrPort newAddress;
InetAddress[] newAddress;
try {
newAddress = new InetAddrPort(inParam ,1000);
newAddress = InetAddress.getAllByName(inParam);
} catch (UnknownHostException e){
return new JSONRPC2Response(
new JSONRPC2Error(JSONRPC2Error.INVALID_PARAMS.getCode(),
@ -168,7 +161,7 @@ public class I2PControlHandler implements RequestHandler {
req.getID());
}
try {
SslListener ssl = I2PControlController.buildSslListener(inParam, _conf.getConf("i2pcontrol.listen.port", 7650));
SslSocketConnector ssl = I2PControlController.buildSslListener(inParam, _conf.getConf("i2pcontrol.listen.port", 7650));
I2PControlController.clearListeners();
I2PControlController.replaceListener(ssl);
_conf.setConf("i2pcontrol.listen.address", inParam);
@ -179,13 +172,13 @@ public class I2PControlHandler implements RequestHandler {
} catch (Exception e) {
_conf.setConf("i2pcontrol.listen.address", oldAddress);
try {
SslListener ssl = I2PControlController.buildSslListener(inParam, _conf.getConf("i2pcontrol.listen.port", 7650));
SslSocketConnector ssl = I2PControlController.buildSslListener(inParam, _conf.getConf("i2pcontrol.listen.port", 7650));
I2PControlController.clearListeners();
I2PControlController.replaceListener(ssl);
} catch (Exception e2){
_log.log(Log.CRIT, "Unable to resume server on previous listening ip." );
}
_log.error("Client tried to set listen address to, " + newAddress + " which isn't valid.", e);
_log.error("Client tried to set listen address to, " + newAddress.toString() + " which isn't valid.", e);
return new JSONRPC2Response(
new JSONRPC2Error(JSONRPC2Error.INVALID_PARAMS.getCode(),
"\"i2pcontrol.address\" has been set to an invalid address, reverting. "), req.getID());