propagate from branch 'i2p.i2p' (head 96b4e09e85e0947d0b9df188f4861664073f07a6)

to branch 'i2p.i2p.zzz.jetty6' (head 4024ef4f6e6c5e4ca6a7803614dc769ca654ac5f)
This commit is contained in:
zzz
2012-01-10 04:06:23 +00:00
27 changed files with 457 additions and 248 deletions

View File

@ -140,7 +140,8 @@ public class ConfigNetHandler extends FormHandler {
if (!_ratesOnly) {
// IP Settings
String oldUdp = _context.getProperty(UDPTransport.PROP_SOURCES, UDPTransport.DEFAULT_SOURCES);
String oldUdp = _context.getProperty(UDPTransport.PROP_SOURCES,
_context.router().isHidden() ? "hidden" : UDPTransport.DEFAULT_SOURCES);
String oldUHost = _context.getProperty(UDPTransport.PROP_EXTERNAL_HOST, "");
if (_udpAutoIP != null) {
String uhost = "";

View File

@ -8,12 +8,9 @@ import net.i2p.apps.systray.UrlLauncher;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.startup.ClientAppConfig;
import net.i2p.util.Log;
import net.i2p.util.VersionComparator;
import org.tanukisoftware.wrapper.WrapperManager;
import org.tanukisoftware.wrapper.event.WrapperControlEvent;
import org.tanukisoftware.wrapper.event.WrapperEvent;
import org.tanukisoftware.wrapper.event.WrapperEventListener;
/**
* Handler to deal with form submissions from the service config form and act
@ -22,9 +19,9 @@ import org.tanukisoftware.wrapper.event.WrapperEventListener;
*/
public class ConfigServiceHandler extends FormHandler {
private static WrapperEventListener _signalHandler;
private static WrapperListener _wrapperListener;
private static final String PROP_GRACEFUL_HUP = "router.gracefulHUP";
private static final String LISTENER_AVAILABLE = "3.2.0";
/**
* Register two shutdown hooks, one to rekey and/or tell the wrapper we are stopping,
@ -137,16 +134,19 @@ public class ConfigServiceHandler extends FormHandler {
/**
* Register a handler for signals,
* so we can handle HUP from the wrapper (non-Windows only)
* so we can handle HUP from the wrapper (non-Windows only, wrapper 3.2.0 or higher)
*
* @since 0.8.13
*/
synchronized static void registerSignalHandler(RouterContext ctx) {
if (ctx.hasWrapper() && _signalHandler == null &&
if (ctx.hasWrapper() && _wrapperListener == null &&
!System.getProperty("os.name").startsWith("Win")) {
_signalHandler = new SignalHandler(ctx);
long mask = WrapperEventListener.EVENT_FLAG_CONTROL;
WrapperManager.addWrapperEventListener(_signalHandler, mask);
String wv = System.getProperty("wrapper.version");
if (wv != null && (new VersionComparator()).compare(wv, LISTENER_AVAILABLE) >= 0) {
try {
_wrapperListener = new WrapperListener(ctx);
} catch (Throwable t) {}
}
}
}
@ -156,55 +156,9 @@ public class ConfigServiceHandler extends FormHandler {
* @since 0.8.13
*/
public synchronized static void unregisterSignalHandler() {
if (_signalHandler != null) {
WrapperManager.removeWrapperEventListener(_signalHandler);
_signalHandler = null;
}
}
/**
* Catch signals.
* The wrapper will potentially forward HUP, USR1, and USR2.
* But USR1 and USR2 are used by the JVM GC and cannot be trapped.
* So we will only get HUP.
*
* @since 0.8.13
*/
private static class SignalHandler implements WrapperEventListener {
private final RouterContext _ctxt;
public SignalHandler(RouterContext ctx) {
_ctxt = ctx;
}
public void fired(WrapperEvent event) {
if (!(event instanceof WrapperControlEvent))
return;
WrapperControlEvent wce = (WrapperControlEvent) event;
Log log = _ctxt.logManager().getLog(ConfigServiceHandler.class);
if (log.shouldLog(Log.WARN))
log.warn("Got signal: " + wce.getControlEventName());
int sig = wce.getControlEvent();
switch (sig) {
case WrapperManager.WRAPPER_CTRL_HUP_EVENT:
if (_ctxt.getBooleanProperty(PROP_GRACEFUL_HUP)) {
wce.consume();
if (!(_ctxt.router().gracefulShutdownInProgress() ||
_ctxt.router().isFinalShutdownInProgress())) {
System.err.println("WARN: Graceful shutdown initiated by SIGHUP");
log.logAlways(Log.WARN, "Graceful shutdown initiated by SIGHUP");
registerWrapperNotifier(_ctxt, Router.EXIT_GRACEFUL, false);
_ctxt.router().shutdownGracefully();
}
} else {
log.log(Log.CRIT, "Hard shutdown initiated by SIGHUP");
// JVM will call ShutdownHook if we don't do it ourselves
//wce.consume();
//registerWrapperNotifier(_ctxt, Router.EXIT_HARD, false);
//_ctxt.router().shutdown(Router.EXIT_HARD);
}
break;
}
if (_wrapperListener != null) {
_wrapperListener.unregister();
_wrapperListener = null;
}
}

View File

@ -101,6 +101,8 @@ public class SummaryHelper extends HelperBase {
}
private String reachability() {
if (_context.commSystem().isDummy())
return "VM Comm System";
if (_context.router().getUptime() > 60*1000 && (!_context.router().gracefulShutdownInProgress()) &&
!_context.clientManager().isAlive())
return _("ERR-Client Manager I2CP Error - check logs"); // not a router problem but the user should know
@ -180,6 +182,7 @@ public class SummaryHelper extends HelperBase {
return _context != null &&
_context.netDb().isInitialized() &&
_context.router().getUptime() > 2*60*1000 &&
(!_context.commSystem().isDummy()) &&
_context.commSystem().countActivePeers() <= 0 &&
_context.netDb().getKnownRouters() > 5;
}

View File

@ -0,0 +1,89 @@
package net.i2p.router.web;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.util.Log;
import org.tanukisoftware.wrapper.WrapperManager;
import org.tanukisoftware.wrapper.event.WrapperControlEvent;
import org.tanukisoftware.wrapper.event.WrapperEvent;
import org.tanukisoftware.wrapper.event.WrapperEventListener;
/**
* Listen for events. Requires wrapper 3.2.0 or higher.
* Hides the actual listener so that
* ConfigServiceHandler can have a static field and not die on
* class not found error with wrapper 3.1.1.
*
* @since 0.8.13
*/
class WrapperListener {
private final RouterContext _context;
private final WrapperEventListener _listener;
private static final String PROP_GRACEFUL_HUP = "router.gracefulHUP";
/**
* Wrapper must be 3.2.0 or higher, or will throw class not found error.
* Registers with the wrapper in the constructor.
*/
public WrapperListener(RouterContext ctx) {
_context = ctx;
_listener = new SignalHandler(ctx);
long mask = WrapperEventListener.EVENT_FLAG_CONTROL;
WrapperManager.addWrapperEventListener(_listener, mask);
}
/**
* Unregister the handler for signals
*/
public void unregister() {
WrapperManager.removeWrapperEventListener(_listener);
}
/**
* Catch signals.
* The wrapper will potentially forward HUP, USR1, and USR2.
* But USR1 and USR2 are used by the JVM GC and cannot be trapped.
* So we will only get HUP.
*
* @since 0.8.13
*/
private static class SignalHandler implements WrapperEventListener {
private final RouterContext _ctxt;
public SignalHandler(RouterContext ctx) {
_ctxt = ctx;
}
public void fired(WrapperEvent event) {
if (!(event instanceof WrapperControlEvent))
return;
WrapperControlEvent wce = (WrapperControlEvent) event;
Log log = _ctxt.logManager().getLog(ConfigServiceHandler.class);
if (log.shouldLog(Log.WARN))
log.warn("Got signal: " + wce.getControlEventName());
int sig = wce.getControlEvent();
switch (sig) {
case WrapperManager.WRAPPER_CTRL_HUP_EVENT:
if (_ctxt.getBooleanPropertyDefaultTrue(PROP_GRACEFUL_HUP)) {
wce.consume();
if (!(_ctxt.router().gracefulShutdownInProgress() ||
_ctxt.router().isFinalShutdownInProgress())) {
System.err.println("WARN: Graceful shutdown initiated by SIGHUP");
log.logAlways(Log.WARN, "Graceful shutdown initiated by SIGHUP");
ConfigServiceHandler.registerWrapperNotifier(_ctxt, Router.EXIT_GRACEFUL, false);
_ctxt.router().shutdownGracefully();
}
} else {
log.log(Log.CRIT, "Hard shutdown initiated by SIGHUP");
// JVM will call ShutdownHook if we don't do it ourselves
//wce.consume();
//registerWrapperNotifier(_ctxt, Router.EXIT_HARD, false);
//_ctxt.router().shutdown(Router.EXIT_HARD);
}
break;
}
}
}
}

View File

@ -157,6 +157,7 @@
<%=intl._("The router is currently testing whether your UDP port is firewalled.")%>
<li class="tidylist"><b><%=intl._("Hidden")%></b> -
<%=intl._("The router is not configured to publish its address, therefore it does not expect incoming connections.")%>
<%=intl._("Hidden mode is automatically enabled for added protection in certain countries.")%>
<li class="tidylist"><b><%=intl._("WARN - Firewalled and Fast")%></b> -
<%=intl._("You have configured I2P to share more than 128KBps of bandwidth, but you are firewalled.")%>
<%=intl._("While I2P will work fine in this configuration, if you really have over 128KBps of bandwidth to share, it will be much more helpful to the network if you open your firewall.")%>

View File

@ -55,9 +55,14 @@
<p>
<b>I2P version:</b> <%=net.i2p.router.RouterVersion.FULL_VERSION%><br>
<b>Java version:</b> <%=System.getProperty("java.vendor")%> <%=System.getProperty("java.version")%> (<%=System.getProperty("java.runtime.name")%> <%=System.getProperty("java.runtime.version")%>)<br>
<b>Wrapper version:</b> <%=System.getProperty("wrapper.version", "none")%><br>
<jsp:useBean class="net.i2p.router.web.LogsHelper" id="logsHelper" scope="request" />
<jsp:setProperty name="logsHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<b>Server version:</b> <jsp:getProperty name="logsHelper" property="jettyVersion" /><br>
<b>Platform:</b> <%=System.getProperty("os.name")%> <%=System.getProperty("os.arch")%> <%=System.getProperty("os.version")%><br>
<b>Processor:</b> <%=net.i2p.util.NativeBigInteger.cpuModel()%> (<%=net.i2p.util.NativeBigInteger.cpuType()%>)<br>
<b>Jbigi:</b> <%=net.i2p.util.NativeBigInteger.loadStatus()%><br>
<b>Encoding:</b> <%=System.getProperty("file.encoding")%></p>
<b>Encoding:</b> <%=System.getProperty("file.encoding")%><br>
<b>Charset:</b> <%=java.nio.charset.Charset.defaultCharset().name()%></p>
<p><%=intl._("Note that system information, log timestamps, and log messages may provide clues to your location; please review everything you include in a bug report.")%></p>
</div></body></html>

View File

@ -10,9 +10,10 @@ TODO: Document generated folder structure
Linux-specific information:
===========================
Some linux distributions comes bundled with GMP.
Some linux distributions come bundled with GMP.
Try 'locate lib/libgmp.so' to see.
If so, install the the libgmp3-dev debian package to get the libgmp headers.
In Debian/Ubuntu, install the the libgmp3-dev package to get the libgmp headers.
Then export I2P=/path/to/your/i2p/install.
Then do 'build.sh dynamic'. This will do a quick build using your installed libgmp library
and then test it and the jbigi in your I2P installation to see which is faster.

View File

@ -17,63 +17,106 @@
# The resulting library is lib/libjbigi.so
#
mkdir -p lib/
mkdir -p bin/local
rm -rf bin/local
mkdir -p lib bin/local
# Use 4.3.2 32bit CPUs.
# Use 5.0.2 64bit CPUs.
VER=4.3.2
# If JAVA_HOME isn't set, try to figure it out on our own
[ -z $JAVA_HOME ] && . ./find-java-home
if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
echo "ERROR: Cannot find jni.h! Looked in \"$JAVA_HOME/include/jni.h\"" >&2
echo "Please set JAVA_HOME to a java home that has the JNI" >&2
exit 1
fi
# Abort script on uncaught errors
set -e
if [ "$1" != "dynamic" -a ! -d gmp-$VER ]
then
TAR=gmp-$VER.tar.bz2
if [ ! -f $TAR ]
then
echo "Downloading ftp://ftp.gmplib.org/pub/gmp-${VER}/gmp-${VER}.tar.bz2"
wget ftp://ftp.gmplib.org/pub/gmp-${VER}/gmp-${VER}.tar.bz2
fi
download_gmp ()
{
if [ $(which wget) ]; then
echo "Downloading ftp://ftp.gmplib.org/pub/gmp-${VER}/${TAR}"
wget -N --progress=dot ftp://ftp.gmplib.org/pub/gmp-${VER}/${TAR}
else
echo "ERROR: Cannot find wget." >&2
echo >&2
echo "Please download ftp://ftp.gmplib.org/pub/gmp-${VER}/${TAR}" >&2
echo "manually and rerun this script." >&2
exit 1
fi
}
echo "Building the jbigi library with GMP Version $VER"
extract_gmp ()
{
tar -xjf ${TAR} > /dev/null 2>&1|| (rm -f ${TAR} && download_gmp && extract_gmp || exit 1)
}
echo "Extracting GMP..."
tar -xjf gmp-$VER.tar.bz2
TAR=gmp-${VER}.tar.bz2
if [ "$1" != "dynamic" -a ! -d gmp-${VER} ]; then
if [ ! -f $TAR ]; then
download_gmp
fi
echo "Building the jbigi library with GMP Version ${VER}"
echo "Extracting GMP..."
extract_gmp
fi
cd bin/local
echo "Building..."
if [ "$1" != "dynamic" ]
then
case `uname -sr` in
Darwin*)
# --with-pic is required for static linking
../../gmp-$VER/configure --with-pic;;
*)
# and it's required for ASLR
../../gmp-$VER/configure --with-pic;;
esac
make
sh ../../build_jbigi.sh static
if [ "$1" != "dynamic" ]; then
case `uname -sr` in
Darwin*)
# --with-pic is required for static linking
../../gmp-${VER}/configure --with-pic;;
*)
# and it's required for ASLR
../../gmp-${VER}/configure --with-pic;;
esac
make
sh ../../build_jbigi.sh static
else
sh ../../build_jbigi.sh dynamic
shift
sh ../../build_jbigi.sh dynamic
fi
cp *jbigi???* ../../lib/
echo 'Library copied to lib/'
cd ../..
if [ ! -f $I2P/lib/i2p.jar ]
then
echo "I2P installation not found"
echo "We looked in '$I2P'"
echo "Not running tests against I2P installation without knowing where it is"
echo "Please set the environment variable I2P to the location of your I2P installation (so that \$I2P/lib/i2p.jar works)"
echo "If you do so, this script will run two tests to compare your installed jbigi with the one here you just compiled (to see if there is a marked improvement)"
exit 1
if [ "$1" != "notest" ]; then
if [ -z "$I2P" ]; then
if [ -r $HOME/i2p/lib/i2p.jar ]; then
I2P="$HOME/i2p"
elif [ -r /usr/share/i2p/lib/i2p.jar ]; then
I2P="/usr/share/i2p"
else
echo "Please set the environment variable \$I2P to run tests." >&2
fi
fi
if [ ! -f $I2P/lib/i2p.jar ]; then
echo "I2P installation not found" >&2
echo "We looked in $I2P" >&2
echo "Not running tests against I2P installation without knowing where it is." >&2
echo >&2
echo "Please set the environment variable I2P to the location of your"
echo "I2P installation (so that \$I2P/lib/i2p.jar works)." >&2
echo "If you do so, this script will run two tests to compare your" >&2
echo "installed jbigi with the one here you just compiled to see if" >&2
echo "there is a marked improvement." >&2
exit 1
fi
echo 'Running test with standard I2P installation...'
java -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger
echo
echo 'Running test with new libjbigi...'
java -Djava.library.path=lib/ -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger
echo 'If the second run shows better performance, please use the jbigi that you have compiled so that I2P will work better!'
echo "(You can do that just by copying lib/libjbigi.so over the existing libjbigi.so file in \$I2P)"
fi
echo 'Running test with standard I2P installation...'
java -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger
echo
echo 'Running test with new libjbigi...'
java -Djava.library.path=lib/ -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger
echo 'If the second is better performance, please use the jbigi you have compiled i2p will work better!'
echo '(You can do that just by copying lib/libjbigi.so over the existing libjbigi.so file in $I2P)'

View File

@ -1,61 +1,62 @@
#!/bin/sh
# When executed in Mingw: Produces an jbigi.dll
# When executed in Linux/FreeBSD: Produces an libjbigi.so
# Darwin produces libjbigi.jnilib, right?
# When executed in Mingw: Produces a jbigi.dll
# When executed in Linux/FreeBSD: Produces a libjbigi.so
# When executed in OSX: Produces a libjbigi.jnilib
CC="gcc"
case `uname -sr` in
MINGW*)
JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";;
CYGWIN*)
JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall -mno-cygwin"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";;
Darwin*)
JAVA_HOME="/Library/Java/Home"
COMPILEFLAGS="-Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include"
LINKFLAGS="-dynamiclib -framework JavaVM"
LIBFILE="libjbigi.jnilib";;
SunOS*)
COMPILEFLAGS="-fPIC -Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/solaris"
LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
LIBFILE="libjbigi.so";;
*)
COMPILEFLAGS="-fPIC -Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
LIBFILE="libjbigi.so";;
esac
# If JAVA_HOME isn't set we'll try to figure it out
[ -z $JAVA_HOME ] && . ./find-java-home
if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'"
echo "Please set JAVA_HOME to a java home that has the JNI"
exit 1
fi
#To link dynamically to GMP (use libgmp.so or gmp.lib), uncomment the first line below
#To link statically to GMP, uncomment the second line below
# Bug!!! Quote *BOTH* or neither! --Sponge
if test "$1" = "dynamic"
then
echo "Building jbigi lib that is dynamically linked to GMP"
LIBPATH="-L.libs"
INCLUDELIBS="-lgmp"
case `uname -s` in
MINGW*)
JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";;
CYGWIN*)
JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall -mno-cygwin"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";;
Darwin*)
JAVA_HOME=$(/usr/libexec/java_home)
COMPILEFLAGS="-fPIC -Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include"
LINKFLAGS="-dynamiclib -framework JavaVM"
LIBFILE="libjbigi.jnilib";;
SunOS*|OpenBSD*|NetBSD*|FreeBSD*|Linux*)
UNIXTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
if [ $UNIXTYPE = "sunos" ]; then
UNIXTYPE="solaris"
fi
COMPILEFLAGS="-fPIC -Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
LIBFILE="libjbigi.so";;
*)
echo "Unsupported system type."
exit 1;;
esac
if [ "$1" = "dynamic" ] ; then
echo "Building a jbigi lib that is dynamically linked to GMP"
LIBPATH="-L.libs"
INCLUDELIBS="-lgmp"
else
echo "Building jbigi lib that is statically linked to GMP"
STATICLIBS=".libs/libgmp.a"
echo "Building a jbigi lib that is statically linked to GMP"
STATICLIBS=".libs/libgmp.a"
fi
echo "Compiling C code..."
rm -f jbigi.o $LIBFILE
$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c
$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS
$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1
$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS || exit 1
exit 0

View File

@ -0,0 +1,24 @@
UNIXTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
if [ $UNIXTYPE = "freebsd" ]; then
if [ -d /usr/local/openjdk6 ]; then
JAVA_HOME="/usr/local/openjdk6"
elif [ -d /usr/local/openjdk7 ]; then
JAVA_HOME="/usr/local/openjdk7"
fi
elif [ $UNIXTYPE = "openbsd" ]; then
if [ -d /usr/local/jdk-1.7.0 ]; then
JAVA_HOME="/usr/local/jdk-1.7.0"
fi
elif [ $UNIXTYPE = "netbsd" ]; then
if [ -d /usr/pkg/java/openjdk7 ]; then
JAVA_HOME="/usr/pkg/java/openjdk7"
fi
elif [ $UNIXTYPE = "linux" ] && [ -e /etc/debian_version ]; then
if [ -d /usr/lib/jvm/default-java ]; then
JAVA_HOME="/usr/lib/jvm/default-java"
fi
elif [ $UNIXTYPE = "darwin" ]; then
JAVA_HOME=$(/usr/libexec/java_home)
fi
export JAVA_HOME

View File

@ -154,7 +154,7 @@ esac
make_static () {
$ECHO "Attempting .${4} creation for ${3}${5}${2}"
../../mbuild_jbigi.sh static || return 1
../../build_jbigi.sh static || return 1
cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4}
return 0
}

View File

@ -1,72 +0,0 @@
#!/bin/sh
# When executed in Mingw: Produces a jbigi.dll
# When executed in Linux/FreeBSD: Produces a libjbigi.so
# When executed in OSX: Produces a libjbigi.jnilib
CC="gcc"
case `uname -s` in
MINGW*)
JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";;
CYGWIN*)
JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall -mno-cygwin"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";;
Darwin*)
JAVA_HOME=$(/usr/libexec/java_home)
COMPILEFLAGS="-fPIC -Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include"
LINKFLAGS="-dynamiclib -framework JavaVM"
LIBFILE="libjbigi.jnilib";;
SunOS*|OpenBSD*|NetBSD*|FreeBSD*|Linux*)
UNIXTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
if [ $UNIXTYPE = "sunos" ]; then
UNIXTYPE="solaris"
elif [ $UNIXTYPE = "freebsd" ]; then
if [ -d /usr/local/openjdk6 ]; then
JAVA_HOME="/usr/local/openjdk6"
elif [ -d /usr/local/openjdk7 ]; then
JAVA_HOME="/usr/local/openjdk7"
fi
elif [ $UNIXTYPE = "openbsd" ]; then
if [ -d /usr/local/jdk-1.7.0 ]; then
JAVA_HOME="/usr/local/jdk-1.7.0"
fi
elif [ $UNIXTYPE = "netbsd" ]; then
if [ -d /usr/pkg/java/openjdk7 ]; then
JAVA_HOME="/usr/pkg/java/openjdk7"
fi
elif [ $UNIXTYPE = "linux" ] && [ -e /etc/debian_version ]; then
if [ -d /usr/lib/jvm/default-java ]; then
JAVA_HOME="/usr/lib/jvm/default-java"
fi
fi
COMPILEFLAGS="-fPIC -Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
LIBFILE="libjbigi.so";;
*)
echo "Unsupported system type."
exit 1;;
esac
if [ "$1" = "dynamic" ] ; then
echo "Building a jbigi lib that is dynamically linked to GMP"
LIBPATH="-L.libs"
INCLUDELIBS="-lgmp"
else
echo "Building a jbigi lib that is statically linked to GMP"
STATICLIBS=".libs/libgmp.a"
fi
echo "Compiling C code..."
rm -f jbigi.o $LIBFILE
$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1
$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS || exit 1
exit 0

View File

@ -43,4 +43,8 @@ public interface AMDCPUInfo extends CPUInfo {
* @return true if the CPU present in the machine is at least an 'k8' CPU (Atlhon 64, Opteron etc. and better)
*/
public boolean IsBobcatCompatible();
/**
* @return true if the CPU present in the machine is at least a 'bulldozer' CPU
*/
public boolean IsBulldozerCompatible();
}

View File

@ -13,6 +13,7 @@ class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
protected static boolean isAthlonCompatible = false;
protected static boolean isAthlon64Compatible = false;
protected static boolean isBobcatCompatible = false;
protected static boolean isBulldozerCompatible = false;
// If modelString != null, the cpu is considered correctly identified.
protected static String modelString = null;
@ -31,6 +32,8 @@ class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
public boolean IsBobcatCompatible(){ return isBobcatCompatible; }
public boolean IsBulldozerCompatible(){ return isBulldozerCompatible; }
static
{
identifyCPU();
@ -349,6 +352,22 @@ class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
break;
}
}
//Bulldozer
if(CPUID.getCPUFamily() + CPUID.getCPUExtendedFamily() == 21){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
isAthlon64Compatible = true;
isBobcatCompatible = true;
isBulldozerCompatible = true;
isX64 = true;
switch(CPUID.getCPUModel() + CPUID.getCPUExtendedModel()){
case 1:
modelString = "Bulldozer FX-6***/FX-8***";
break;
}
}
}
public boolean hasX64()

View File

@ -238,9 +238,15 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
case 10:
modelString = "Core i7/i5 (32nm)";
break;
case 11:
modelString = "Core i7/i5 (32nm)";
break;
case 12:
modelString = "Core i7 (32nm)";
break;
case 13:
modelString = "Core i7 Extreme Edition (32nm)";
break;
case 14:
modelString = "Xeon MP (45nm)";
break;

View File

@ -105,7 +105,7 @@ Debian wrapper.config to try to prevent confusion.
# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
wrapper.java.additional.auto_bits=TRUE
@@ -69,7 +61,7 @@
@@ -71,7 +63,7 @@
wrapper.java.additional.1=-DloggerFilenameOverride=logs/log-router-@.txt
wrapper.java.additional.2=-Dorg.mortbay.http.Version.paranoid=true
wrapper.java.additional.3=-Dorg.mortbay.xml.XmlParser.NotValidating=true
@ -114,7 +114,7 @@ Debian wrapper.config to try to prevent confusion.
wrapper.java.additional.4.stripquotes=TRUE
# On some IPv6 enabled systems, I2P and other network-enabled java applications
@@ -139,11 +131,7 @@
@@ -141,11 +133,7 @@
# tell the router where to find the wrapper log
# (change X to the next available number)
# wrapper.java.additional.X=-Dwrapper.logfile=/path/to/wrapper.log
@ -127,7 +127,7 @@ Debian wrapper.config to try to prevent confusion.
# Format of output for the log file.
# The format consists of the tokens 'L' for log level, 'P' for prefix, 'D' for thread,
@@ -205,10 +193,7 @@
@@ -211,10 +199,7 @@
# you should copy this file, change the location or file name,
# and edit the i2prouter script to change the WRAPPER_CONF setting
# to point to the new wrapper.config location.
@ -139,7 +139,7 @@ Debian wrapper.config to try to prevent confusion.
# pid file for the service monitoring the JVM
#
# From i2prouter:
@@ -219,10 +204,7 @@
@@ -225,10 +210,7 @@
#
# This means i2prouter looks for './i2p.pid'.
# See comments above for wrapper.java.pidfile
@ -151,7 +151,7 @@ Debian wrapper.config to try to prevent confusion.
#********************************************************************
# Wrapper General Properties
@@ -239,30 +221,3 @@
@@ -245,30 +227,3 @@
wrapper.umask=0022
wrapper.java.umask=0022
wrapper.logfile.umask=077

View File

@ -2,18 +2,18 @@ From: Kill Your TV <killyourtv@i2pmail.org>
Date: Wed, 11 May 2011 00:12:04 +0000
Subject: jbigi soname
The purpose of this patch is to change the path that mbuild_jbigi.sh
The purpose of this patch is to change the path that build_jbigi.sh
expects to find the source files at. At the same time I'm specifying
a soname to shut lintian up.
---
core/c/jbigi/mbuild_jbigi.sh | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
core/c/jbigi/build_jbigi.sh | 4 +++---
1 files changed, 2 insertions(+), 2 deletions(-)
--- a/core/c/jbigi/mbuild_jbigi.sh
+++ b/core/c/jbigi/mbuild_jbigi.sh
@@ -47,7 +47,7 @@
fi
--- a/core/c/jbigi/build_jbigi.sh
+++ b/core/c/jbigi/build_jbigi.sh
@@ -37,7 +37,7 @@
UNIXTYPE="solaris"
fi
COMPILEFLAGS="-fPIC -Wall"
- INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include -I$JAVA_HOME/include/${UNIXTYPE}"
@ -21,12 +21,12 @@ a soname to shut lintian up.
LINKFLAGS="-shared -Wl,-soname,libjbigi.so"
LIBFILE="libjbigi.so";;
*)
@@ -66,7 +66,7 @@
@@ -56,7 +56,7 @@
echo "Compiling C code..."
rm -f jbigi.o $LIBFILE
-$CC -c $COMPILEFLAGS $INCLUDES ../../jbigi/src/jbigi.c || exit 1
+$CC -c $COMPILEFLAGS $INCLUDES ./jbigi/src/jbigi.c || exit 1
$CC $LINKFLAGS $INCLUDES $INCLUDELIBS -o $LIBFILE jbigi.o $STATICLIBS || exit 1
$CC $LINKFLAGS $INCLUDES -o $LIBFILE jbigi.o $INCLUDELIBS $STATICLIBS || exit 1
exit 0

11
debian/patches/0004-oom-listener.patch vendored Normal file
View File

@ -0,0 +1,11 @@
--- a/router/java/src/net/i2p/router/tasks/OOMListener.java
+++ b/router/java/src/net/i2p/router/tasks/OOMListener.java
@@ -33,7 +33,7 @@
// gobble
}
}
- log.log(Log.CRIT, "To prevent future shutdowns, increase wrapper.java.maxmemory in $I2P/wrapper.config");
+ log.log(Log.CRIT, "To prevent future shutdowns, increase wrapper.java.maxmemory in /etc/i2p/wrapper.config");
_context.router().shutdown(Router.EXIT_OOM);
}
}

View File

@ -1,5 +1,6 @@
0001-path-substitution.patch
0002-jbigi-soname.patch
0003-renaming-jcpuid.patch
0004-oom-listener.patch
#debian-version.patch
0004-jetty6.patch

View File

@ -1,3 +1,14 @@
2012-01-10 zzz
* Console:
- Add info to error 500 page
- Add indication on summary bar when in VM comm system
- Make graceful the default for HUP (ticket #580)
- Fix class error on wrapper 3.1.1
* i2prouter: Don't attempt to translate strings from script
* Router:
- Auto-hidden mode for bad countries
- Don't put addresses in our RouterInfo when hidden
2012-01-08 zzz
* Plugins:
- Enforce min and max Jetty versions at plugin installation

View File

@ -461,10 +461,13 @@ fi
gettext() {
"$WRAPPER_CMD" --translate "$1" "$WRAPPER_CONF" 2>/dev/null
if [ $? != 0 ] ; then
# TODO provide translations and call external gettext.
# For now, don't attempt to translate via the wrapper,
# it probably isn't supported in the community edition.
#"$WRAPPER_CMD" --translate "$1" "$WRAPPER_CONF" 2>/dev/null
#if [ $? != 0 ] ; then
echo "$1"
fi
#fi
}
outputFile() {
@ -1099,7 +1102,7 @@ graceful() {
# Running so try to stop it.
# This sends HUP. router.gracefulHUP must be set in router.config,
# or else this will do the same as stop.
kill $pid
kill -HUP $pid
if [ $? -ne 0 ]
then
# An explanation for the failure should have been given

View File

@ -61,14 +61,22 @@ public abstract class CommSystemFacade implements Service {
public boolean isEstablished(Hash dest) { return false; }
public byte[] getIP(Hash dest) { return null; }
public void queueLookup(byte[] ip) {}
/** @since 0.8.11 */
public String getOurCountry() { return null; }
/** @since 0.8.13 */
public boolean isInBadCountry() { return false; }
public String getCountry(Hash peer) { return null; }
public String getCountryName(String code) { return code; }
public String renderPeerHTML(Hash peer) {
return peer.toBase64().substring(0, 4);
}
/** @since 0.8.13 */
public boolean isDummy() { return true; }
/**
* Tell other transports our address changed
*/

View File

@ -241,8 +241,6 @@ public class Router implements RouterClock.ClockShiftListener {
String now = Long.toString(System.currentTimeMillis());
_config.put("router.firstInstalled", now);
_config.put("router.updateLastInstalled", now);
// only compatible with new i2prouter script
_config.put("router.gracefulHUP", "true");
saveConfig();
}
// ********* Start no threads before here ********* //
@ -592,14 +590,22 @@ public class Router implements RouterClock.ClockShiftListener {
RouterInfo ri = _routerInfo;
if ( (ri != null) && (ri.isHidden()) )
return true;
return _context.getBooleanProperty(PROP_HIDDEN_HIDDEN);
String h = _context.getProperty(PROP_HIDDEN_HIDDEN);
if (h != null)
return Boolean.valueOf(h).booleanValue();
return _context.commSystem().isInBadCountry();
}
/**
* Only called at startup via LoadRouterInfoJob and RebuildRouterInfoJob.
* Not called by periodic RepublishLocalRouterInfoJob.
* We don't want to change the cert on the fly as it changes the router hash.
* RouterInfo.isHidden() checks the capability, but RouterIdentity.isHidden() checks the cert.
* There's no reason to ever add a hidden cert?
* @return the certificate for a new RouterInfo - probably a null cert.
*/
public Certificate createCertificate() {
if (isHidden())
if (_context.getBooleanProperty(PROP_HIDDEN))
return new Certificate(Certificate.CERTIFICATE_TYPE_HIDDEN, null);
return Certificate.NULL_CERT;
}

View File

@ -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 = 1;
public final static long BUILD = 2;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -0,0 +1,65 @@
package net.i2p.router.transport;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
/**
* Maintain a list of bad places.
* @since 0.8.13
*/
abstract class BadCountries {
private static final Set<String> _countries;
// zzz.i2p/topics/969
// List created based on the Press Freedom Index. Those countries with a score of higher than 50 are included:
// http://en.wikipedia.org/wiki/Press_Freedom_Index
// Except:
// I don't really think that is usage of I2P is dangerous in countries from CIS
// General situation is really bad (like in Russia) but people here doesn't have problems with Ecnryption usage.
static {
String[] c = {
/* Afghanistan */ "AF",
/* Bahrain */ "BH",
/* Brunei */ "BN",
/* Burma */ "MM",
/* China */ "CN",
/* Colombia */ "CO",
/* Cuba */ "CU",
/* Democratic Republic of the Congo */ "CD",
/* Equatorial Guinea */ "GQ",
/* Eritrea */ "ER",
/* Fiji */ "FJ",
/* Honduras */ "HN",
/* Iran */ "IR",
/* Laos */ "LA",
/* Libya */ "LY",
/* Malaysia */ "MY",
/* Nigeria */ "NG",
/* North Korea */ "KP",
/* Pakistan */ "PK",
/* Palestinian Territories */ "PS",
/* Philippines */ "PH",
/* Rwanda */ "RW",
/* Saudi Arabia */ "SA",
/* Somalia */ "SO",
/* Sri Lanka */ "LK",
/* Sudan */ "SD",
/* Swaziland */ "SZ",
/* Syria */ "SY",
/* Thailand */ "TH",
/* Tunisia */ "TN",
/* Vietnam */ "VN",
/* Yemen */ "YE"
};
_countries = new HashSet(Arrays.asList(c));
}
/** @param country non-null, two letter code, case-independent */
public static boolean contains(String country) {
return _countries.contains(country.toUpperCase(Locale.US));
}
}

View File

@ -176,8 +176,11 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
_manager.renderStatusHTML(out, urlBase, sortFlags);
}
/** @return non-null, possibly empty */
@Override
public Set<RouterAddress> createAddresses() {
if (_context.router().isHidden())
return Collections.EMPTY_SET;
Map<String, RouterAddress> addresses = null;
boolean newCreated = false;
@ -450,6 +453,15 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
return _context.getProperty(GeoIP.PROP_IP_COUNTRY);
}
/**
* Are we in a bad place
* @since 0.8.13
*/
public boolean isInBadCountry() {
String us = getOurCountry();
return us != null && (BadCountries.contains(us) || _context.getBooleanProperty("router.forceBadCountry"));
}
/**
* Uses the transport IP first because that lookup is fast,
* then the SSU IP from the netDb.
@ -517,6 +529,10 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
return buf.toString();
}
/** @since 0.8.13 */
@Override
public boolean isDummy() { return false; }
/**
* Translate
*/

View File

@ -21,6 +21,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper;
import net.i2p.data.Hash;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.util.ConcurrentHashSet;
import net.i2p.util.Log;
@ -283,6 +284,14 @@ class GeoIP {
if (country != null && !country.equals(oldCountry)) {
_context.router().setConfigSetting(PROP_IP_COUNTRY, country);
_context.router().saveConfig();
if (_context.commSystem().isInBadCountry() && _context.getProperty(Router.PROP_HIDDEN_HIDDEN) == null) {
String name = fullName(country);
if (name == null)
name = country;
_log.logAlways(Log.WARN, "Setting hidden mode to protect you in " + name +
", you may override on the network configuration page");
_context.router().rebuildRouterInfo();
}
}
/****/
}