diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java
index feee19258..74c6f0a95 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java
@@ -46,6 +46,8 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
private static final String SERVER_HEADER = "Server";
private static final String[] SERVER_SKIPHEADERS = {SERVER_HEADER};
private static final long HEADER_TIMEOUT = 60*1000;
+ private static final long START_INTERVAL = (60 * 1000) * 3;
+ private long _startedOn = 0L;
private final static byte[] ERR_UNAVAILABLE =
("HTTP/1.1 503 Service Unavailable\r\n"+
@@ -81,6 +83,14 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
getTunnel().getContext().statManager().createRateStat("i2ptunnel.httpNullWorkaround", "How often an http server works around a streaming lib or i2ptunnel bug", "I2PTunnel.HTTPServer", new long[] { 60*1000, 10*60*1000 });
}
+ @Override
+ public void startRunning() {
+ super.startRunning();
+ _startedOn = getTunnel().getContext().clock().now();
+ // Would be better if this was set when the inbound tunnel becomes alive.
+ }
+
+
/**
* Called by the thread pool of I2PSocket handlers
*
@@ -168,8 +178,10 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
try {
socket.close();
} catch (IOException ioe) {}
- if (_log.shouldLog(Log.ERROR))
- _log.error("Error connecting to HTTP server " + remoteHost + ':' + remotePort, ex);
+ // Don't complain too early, Jetty may not be ready.
+ int level = getTunnel().getContext().clock().now() - _startedOn > START_INTERVAL ? Log.ERROR : Log.WARN;
+ if (_log.shouldLog(level))
+ _log.log(level, "Error connecting to HTTP server " + remoteHost + ':' + remotePort, ex);
} catch (IOException ex) {
try {
socket.close();
diff --git a/build.xml b/build.xml
index 1fda686e8..71ae4cb11 100644
--- a/build.xml
+++ b/build.xml
@@ -274,7 +274,7 @@
-
+
@@ -462,7 +462,7 @@
-
+
diff --git a/core/c/jbigi/mbuild-all.sh b/core/c/jbigi/mbuild-all.sh
index a108dffe0..c257278ca 100755
--- a/core/c/jbigi/mbuild-all.sh
+++ b/core/c/jbigi/mbuild-all.sh
@@ -1,12 +1,4 @@
-#!/usr/bin/env bash
-
-if [ -z "$BASH_VERSION" ]; then
- echo "This script needs to be run with Bash."
- echo
- echo "Please install bash and then run this script with"
- echo "bash $0"
- exit 1
-fi
+#!/bin/sh
#FIXME What platforms for MacOS?
MISC_DARWIN_PLATFORMS="powerpc powerpc64 powerpc64le powerpcle"
@@ -50,6 +42,17 @@ X86_PLATFORMS="pentium pentiummmx pentium2 pentium3 pentiumm k6 k62 k63 athlon g
# You should not need to edit anything below this comment.
#
+# The built-in echo in /bin/sh (the real bourne shell) on BSD systems supports -e.
+# The built-in echo in dash (the default /bin/sh on Debian) does not support -e
+# but /bin/echo always supports -e in Linux; therefore, let's set echo to /bin/echo
+# whenever we're on Linux and use the shell's built-in "echo" on everything else.
+
+if [ $(uname -s |tr "[A-Z]" "[a-z]") = "linux" ]; then
+ ECHO="/bin/echo"
+else
+ ECHO="echo"
+fi
+
MINGW_PLATFORMS="${X86_PLATFORMS} ${MISC_MINGW_PLATFORMS}"
LINUX_PLATFORMS="${X86_PLATFORMS} ${MISC_LINUX_PLATFORMS}"
FREEBSD_PLATFORMS="${X86_PLATFORMS} ${MISC_FREEBSD_PLATFORMS}"
@@ -60,146 +63,144 @@ OPENBSD_PLATFORM="${X86_PLATFORMS} ${MISC_OPENBSD_PLATFORMS}"
# FIXME Is this all?
DARWIN_PLATFORMS="core2 corei"
-# Set the version to 5.0.2 for OSX because
-# 1) it doesn't have the -r parameter as an option for sed
-# 2) AFAIK there are only 64bit capable CPUs for the Intel Macs
+# Set the version to 5.0.2 for OSX because AFAIK there are only 64bit capable CPUs for the Intel Macs
if [ `uname -s |grep Darwin` ]; then
- VER=5.0.2
+ VER=5.0.2
else
- VER=$(echo gmp-*.tar.bz2 | sed -re "s/(.*-)(.*)(.*.tar.bz2)$/\2/" | tail -n 1)
+ VER=$($ECHO gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1)
fi
if [ "$VER" = "" ] ; then
- echo "ERROR! Can't find gmp source tarball."
- exit 1
+ $ECHO "ERROR! Can't find gmp source tarball."
+ exit 1
fi
-case `uname -sr` in
+case `uname -s` in
MINGW*)
- PLATFORM_LIST="${MINGW_PLATFORMS}"
- NAME="jbigi"
- TYPE="dll"
- TARGET="-windows-"
- echo "Building windows .dlls for all architectures";;
+ PLATFORM_LIST="${MINGW_PLATFORMS}"
+ NAME="jbigi"
+ TYPE="dll"
+ TARGET="-windows-"
+ $ECHO "Building windows .dlls for all architectures";;
Darwin*)
- PLATFORM_LIST="${DARWIN_PLATFORMS}"
- NAME="libjbigi"
- TYPE="jnilib"
- TARGET="-osx-"
- echo "Building ${TARGET} .jnilibs for all architectures";;
+ PLATFORM_LIST="${DARWIN_PLATFORMS}"
+ NAME="libjbigi"
+ TYPE="jnilib"
+ TARGET="-osx-"
+ $ECHO "Building ${TARGET} .jnilibs for all architectures";;
Linux*)
- NAME="libjbigi"
- TYPE="so"
- PLATFORM_LIST=""
- TARGET="-linux-"
- arch=$(uname -m | cut -f1 -d" ")
- case ${arch} in
- i[3-6]86)
- arch="x86";;
- esac
- case ${arch} in
- x86_64 | amd64)
- PLATFORM_LIST="${X86_64_PLATFORMS}"
- TARGET="-linux-X86_64-";;
- ia64)
- PLATFORM_LIST="${X86_64_PLATFORMS}"
- TARGET="-linux-ia64-";;
- x86)
- PLATFORM_LIST="${X86_PLATFORMS}"
- TARGET="-linux-x86-";;
- *)
- PLATFORM_LIST="${LINUX_PLATFORMS}";;
- esac
- echo "Building ${TARGET} .so's for ${arch}";;
+ NAME="libjbigi"
+ TYPE="so"
+ PLATFORM_LIST=""
+ TARGET="-linux-"
+ arch=$(uname -m | cut -f1 -d" ")
+ case ${arch} in
+ i[3-6]86)
+ arch="x86";;
+ esac
+ case ${arch} in
+ x86_64 | amd64)
+ PLATFORM_LIST="${X86_64_PLATFORMS}"
+ TARGET="-linux-X86_64-";;
+ ia64)
+ PLATFORM_LIST="${X86_64_PLATFORMS}"
+ TARGET="-linux-ia64-";;
+ x86)
+ PLATFORM_LIST="${X86_PLATFORMS}"
+ TARGET="-linux-x86-";;
+ *)
+ PLATFORM_LIST="${LINUX_PLATFORMS}";;
+ esac
+ $ECHO "Building ${TARGET} .sos for ${arch}";;
NetBSD*|FreeBSD*|OpenBSD*)
- NAME="libjbigi"
- TYPE="so"
- PLATFORM_LIST=""
- BSDTYPE="`uname -s | tr [A-Z] [a-z]`"
- arch=$(uname -m | cut -f1 -d" ")
- case ${arch} in
- i[3-6]86)
- arch="x86";;
- esac
- case ${arch} in
- x86_64|amd64)
- PLATFORM_LIST="${X86_64_PLATFORMS}"
- TARGET="-${BSDTYPE}-X86_64-";;
- ia64)
- PLATFORM_LIST="${X86_64_PLATFORMS}"
- TARGET="-${BSDTYPE}-ia64-";;
- x86)
- PLATFORM_LIST="${X86_PLATFORMS}"
- TARGET="-${BSDTYPE}-x86-";;
- *)
- case ${BSDTYPE} in
- netbsd)
- PLATFORM_LIST="${NETBSD_PLATFORMS}";;
- openbsd)
- PLATFORM_LIST="${OPENBSD_PLATFORMS}";;
- freebsd)
- PLATFORM_LIST="${FREEBSD_PLATFORMS}";;
- *)
- echo "Unsupported build environment"
- exit 1;;
- esac
- esac
- echo "Building ${BSDTYPE} .so's for ${arch}";;
+ NAME="libjbigi"
+ TYPE="so"
+ PLATFORM_LIST=""
+ BSDTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
+ arch=$(uname -m | cut -f1 -d" ")
+ case ${arch} in
+ i[3-6]86)
+ arch="x86";;
+ esac
+ case ${arch} in
+ x86_64|amd64)
+ PLATFORM_LIST="${X86_64_PLATFORMS}"
+ TARGET="-${BSDTYPE}-X86_64-";;
+ ia64)
+ PLATFORM_LIST="${X86_64_PLATFORMS}"
+ TARGET="-${BSDTYPE}-ia64-";;
+ x86)
+ PLATFORM_LIST="${X86_PLATFORMS}"
+ TARGET="-${BSDTYPE}-x86-";;
+ *)
+ case ${BSDTYPE} in
+ netbsd)
+ PLATFORM_LIST="${NETBSD_PLATFORMS}";;
+ openbsd)
+ PLATFORM_LIST="${OPENBSD_PLATFORMS}";;
+ freebsd)
+ PLATFORM_LIST="${FREEBSD_PLATFORMS}";;
+ *)
+ $ECHO "Unsupported build environment"
+ exit 1;;
+ esac
+ esac
+ $ECHO "Building ${BSDTYPE} .sos for ${arch}";;
*)
- echo "Unsupported build environment"
- exit;;
+ $ECHO "Unsupported build environment"
+ exit;;
esac
-function make_static {
- echo "Attempting .${4} creation for ${3}${5}${2}"
- ../../mbuild_jbigi.sh static || return 1
- cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4}
- return 0
+make_static () {
+ $ECHO "Attempting .${4} creation for ${3}${5}${2}"
+ ../../mbuild_jbigi.sh static || return 1
+ cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4}
+ return 0
}
-function make_file {
- # Nonfatal bail out on Failed build.
- echo "Attempting build for ${3}${5}${2}"
- make && return 0
- cd ..
- rm -R "$2"
- echo -e "\n\nFAILED! ${3}${5}${2} not made.\a"
- sleep 10
- return 1
+make_file () {
+ # Nonfatal bail out on Failed build.
+ $ECHO "Attempting build for ${3}${5}${2}"
+ make && return 0
+ cd ..
+ rm -R "$2"
+ $ECHO -e "\n\nFAILED! ${3}${5}${2} not made.\a"
+ sleep 10
+ return 1
}
-function configure_file {
- echo -e "\n\n\nAttempting configure for ${3}${5}${2}\n\n\n"
- sleep 10
- # Nonfatal bail out on unsupported platform.
- if [ `uname -s |grep Darwin` ]; then
- ../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0
- else
- ../../gmp-${1}/configure --build=${2} --with-pic && return 0
- fi
- cd ..
- rm -R "$2"
- echo -e "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a"
- sleep 10
- return 1
+configure_file () {
+ $ECHO -e "\n\n\nAttempting configure for ${3}${5}${2}\n\n\n"
+ sleep 10
+ # Nonfatal bail out on unsupported platform.
+ if [ `uname -s |grep Darwin` ]; then
+ ../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0
+ else
+ ../../gmp-${1}/configure --build=${2} --with-pic && return 0
+ fi
+ cd ..
+ rm -R "$2"
+ $ECHO -e "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a"
+ sleep 10
+ return 1
}
-function build_file {
- configure_file "$1" "$2" "$3" "$4" "$5" && make_file "$1" "$2" "$3" "$4" "$5" && make_static "$1" "$2" "$3" "$4" "$5" && return 0
- echo -e "\n\n\nError building static!\n\n\a"
- sleep 10
- return 1
+build_file () {
+ configure_file "$1" "$2" "$3" "$4" "$5" && make_file "$1" "$2" "$3" "$4" "$5" && make_static "$1" "$2" "$3" "$4" "$5" && return 0
+ $ECHO -e "\n\n\nError building static!\n\n\a"
+ sleep 10
+ return 1
}
-echo "Extracting GMP Version $VER ..."
-tar -xjf gmp-$VER.tar.bz2 || ( echo "Error in tarball file!" ; exit 1 )
+$ECHO "Extracting GMP Version $VER ..."
+tar -xjf gmp-$VER.tar.bz2 || ( $ECHO "Error in tarball file!" ; exit 1 )
if [ ! -d bin ]; then
- mkdir bin
+ mkdir bin
fi
if [ ! -d lib/net/i2p/util ]; then
- mkdir -p lib/net/i2p/util
+ mkdir -p lib/net/i2p/util
fi
# Don't touch this one.
@@ -207,18 +208,18 @@ NO_PLATFORM=none
for x in $NO_PLATFORM $PLATFORM_LIST
do
- (
- if [ ! -d bin/$x ]; then
- mkdir bin/$x
- cd bin/$x
- else
- cd bin/$x
- rm -Rf *
- fi
+ (
+ if [ ! -d bin/$x ]; then
+ mkdir bin/$x
+ cd bin/$x
+ else
+ cd bin/$x
+ rm -Rf *
+ fi
- build_file "$VER" "$x" "$NAME" "$TYPE" "$TARGET"
- )
+ build_file "$VER" "$x" "$NAME" "$TYPE" "$TARGET"
+ )
done
-echo "Success!"
+$ECHO "Success!"
exit 0
diff --git a/core/c/jbigi/mbuild_jbigi.sh b/core/c/jbigi/mbuild_jbigi.sh
index 4b505d1e1..545128aeb 100755
--- a/core/c/jbigi/mbuild_jbigi.sh
+++ b/core/c/jbigi/mbuild_jbigi.sh
@@ -1,30 +1,30 @@
-#!/usr/bin/env bash
+#!/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 -sr` in
+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";;
+ 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";;
+ 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)
+ 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]`"
+ UNIXTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
if [ $UNIXTYPE = "sunos" ]; then
UNIXTYPE="solaris"
elif [ $UNIXTYPE = "freebsd" ]; then
@@ -37,31 +37,31 @@ SunOS*|OpenBSD*|NetBSD*|FreeBSD*|Linux*)
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" -a -e /etc/debian_version ]; then
- if [ -d /usr/lib/jvm/default-java ]; then
- JAVA_HOME="/usr/lib/jvm/default-java"
- 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;;
+ 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"
+ 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"
+ echo "Building a jbigi lib that is statically linked to GMP"
+ STATICLIBS=".libs/libgmp.a"
fi
echo "Compiling C code..."
diff --git a/history.txt b/history.txt
index 0f149f742..0c0e00c50 100644
--- a/history.txt
+++ b/history.txt
@@ -1,3 +1,6 @@
+2011-12-11 sponge
+ * HTTP server tunnel, use log.WARN for 3 first minutes. (closes #460)
+
2011-12-10 kytv
* Replace eepget's whitelist of accepted characters with the
blacklist from i2psnark. (closes #562)