2005-04-17 zzz

* Added new user-editable eepproxy error page templates.
2005-04-17  jrandom
    * Revamp the tunnel building throttles, fixing a situation where the
      rebuild may not recover, and defaulting it to unthrottled (users with
      slow CPUs may want to set "router.tunnel.shouldThrottle=true" in their
      advanced router config)
This commit is contained in:
jrandom
2005-04-17 23:23:20 +00:00
committed by zzz
parent 39343ce957
commit addab1fa2a
10 changed files with 202 additions and 13 deletions

View File

@ -23,6 +23,7 @@ import net.i2p.client.streaming.I2PSocketOptions;
import net.i2p.data.DataFormatException;
import net.i2p.data.Destination;
import net.i2p.util.EventDispatcher;
import net.i2p.util.FileUtil;
import net.i2p.util.Log;
/**
@ -70,7 +71,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
"wrong BASE64 I2P Destination or the link you are following is "+
"bad. The host (or the WWW proxy, if you're using one) could also "+
"be temporarily offline. You may want to <b>retry</b>. "+
"Could not find the following Destination:<BR><BR>")
"Could not find the following Destination:<BR><BR><div>")
.getBytes();
private final static byte[] ERR_TIMEOUT =
@ -190,6 +191,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream(), "ISO-8859-1"));
String line, method = null, protocol = null, host = null, destination = null;
StringBuffer newRequest = new StringBuffer();
int ahelper = 0;
while ((line = br.readLine()) != null) {
if (_log.shouldLog(Log.DEBUG))
_log.debug(getPrefix(requestId) + "Line=[" + line + "]");
@ -282,6 +284,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
if (addressHelper != null) {
destination = addressHelper;
host = getHostName(destination);
ahelper = 1;
}
}
line = method + " " + request.substring(pos);
@ -403,7 +406,19 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
l.log("Could not resolve " + destination + ".");
if (_log.shouldLog(Log.WARN))
_log.warn("Unable to resolve " + destination + " (proxy? " + usingWWWProxy + ", request: " + targetRequest);
writeErrorMessage(ERR_DESTINATION_UNKNOWN, out, targetRequest, usingWWWProxy, destination);
String str;
byte[] header;
if (usingWWWProxy)
str = FileUtil.readTextFile("docs/dnfp-header.ht", 100, true);
else if(ahelper != 0)
str = FileUtil.readTextFile("docs/dnfb-header.ht", 100, true);
else
str = FileUtil.readTextFile("docs/dnf-header.ht", 100, true);
if (str != null)
header = str.getBytes();
else
header = ERR_DESTINATION_UNKNOWN;
writeErrorMessage(header, out, targetRequest, usingWWWProxy, destination);
s.close();
return;
}
@ -476,10 +491,16 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
if (out != null) {
out.write(errMessage);
if (targetRequest != null) {
out.write(targetRequest.getBytes());
int protopos = targetRequest.indexOf(" ");
String uri = targetRequest.substring(0, protopos);
out.write("<a href=\"http://".getBytes());
out.write(uri.getBytes());
out.write("\">http://".getBytes());
out.write(uri.getBytes());
out.write("</a>".getBytes());
if (usingWWWProxy) out.write(("<br>WWW proxy: " + wwwProxy).getBytes());
}
out.write("<p /><i>Generated on: ".getBytes());
out.write("</div><p><i>I2P HTTP Proxy Server<br>Generated on: ".getBytes());
out.write(new Date().toString().getBytes());
out.write("</i></body></html>\n".getBytes());
out.flush();
@ -493,7 +514,17 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
_log.warn(getPrefix(requestId) + "Error sending to " + wwwProxy + " (proxy? " + usingWWWProxy + ", request: " + targetRequest, ex);
if (out != null) {
try {
writeErrorMessage(ERR_DESTINATION_UNKNOWN, out, targetRequest, usingWWWProxy, wwwProxy);
String str;
byte[] header;
if (usingWWWProxy)
str = FileUtil.readTextFile("docs/dnfp-header.ht", 100, true);
else
str = FileUtil.readTextFile("docs/dnf-header.ht", 100, true);
if (str != null)
header = str.getBytes();
else
header = ERR_DESTINATION_UNKNOWN;
writeErrorMessage(header, out, targetRequest, usingWWWProxy, wwwProxy);
} catch (IOException ioe) {
_log.warn(getPrefix(requestId) + "Error writing out the 'destination was unknown' " + "message", ioe);
}

View File

@ -228,6 +228,9 @@
<copy file="installer/resources/start.ico" todir="pkg-temp/docs/" />
<copy file="installer/resources/console.ico" todir="pkg-temp/docs/" />
<copy file="installer/resources/uninstall.ico" todir="pkg-temp/docs/" />
<copy file="installer/resources/dnf-header.ht" todir="pkg-temp/docs/" />
<copy file="installer/resources/dnfp-header.ht" todir="pkg-temp/docs/" />
<copy file="installer/resources/dnfb-header.ht" todir="pkg-temp/docs/" />
<mkdir dir="pkg-temp/eepsite" />
<mkdir dir="pkg-temp/eepsite/webapps" />
<mkdir dir="pkg-temp/eepsite/logs" />
@ -274,6 +277,9 @@
<copy file="history.txt" todir="pkg-temp/" />
<mkdir dir="pkg-temp/docs/" />
<copy file="news.xml" todir="pkg-temp/docs/" />
<copy file="installer/resources/dnf-header.ht" todir="pkg-temp/docs/" />
<copy file="installer/resources/dnfp-header.ht" todir="pkg-temp/docs/" />
<copy file="installer/resources/dnfb-header.ht" todir="pkg-temp/docs/" />
<!-- the addressbook handles this for updates -->
<!-- <copy file="hosts.txt" todir="pkg-temp/" /> -->
<mkdir dir="pkg-temp/eepsite" />

View File

@ -1,4 +1,13 @@
$Id: history.txt,v 1.192 2005/04/12 10:22:11 jrandom Exp $
$Id: history.txt,v 1.193 2005/04/16 19:59:51 jrandom Exp $
2005-04-17 zzz
* Added new user-editable eepproxy error page templates.
2005-04-17 jrandom
* Revamp the tunnel building throttles, fixing a situation where the
rebuild may not recover, and defaulting it to unthrottled (users with
slow CPUs may want to set "router.tunnel.shouldThrottle=true" in their
advanced router config)
2005-04-16 jrandom
* Migrated to Bouncycastle's SHA256 and HMAC implementations for efficiency

View File

@ -0,0 +1,41 @@
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=iso-8859-1
Cache-control: no-cache
<html><head>
<title>Eepsite not reachable</title>
<style type='text/css'>
div.warning {
margin: 0em 1em 1em 224px;
padding: .5em 1em;
background-color: #ffefef;
border: medium solid #ffafaf;
text-align: left;
color: inherit;
}
div.logo {
float: left;
width: 200px;
left: 1em;
top: 1em;
margin: 0em;
padding: .5em;
text-align: left;
border: medium solid #efefff;
background-color: #fafaff;
color: inherit;
}
</style>
</head>
<body>
<div class=logo>
<a href="http://localhost:7657/index.jsp">Router Console</a><br />
[<a href="http://localhost:7657/config.jsp">configuration</a> | <a href="http://localhost:7657/help.jsp">help</a>]
</div>
<div class=warning id=warning>
The eepsite was not reachable. Perhaps
the link you are following is
bad. The eepsite could also
be temporarily offline. You may want to
<a href="javascript: window.location.reload()">retry</a>.
<BR><BR>Could not find the following destination:<BR><BR>

View File

@ -0,0 +1,42 @@
HTTP/1.1 400 Destination Not Found
Content-Type: text/html; charset=iso-8859-1
Cache-control: no-cache
<html><head>
<title>Invalid eepsite destination</title>
<style type='text/css'>
div.warning {
margin: 0em 1em 1em 224px;
padding: .5em 1em;
background-color: #ffefef;
border: medium solid #ffafaf;
text-align: left;
color: inherit;
}
div.logo {
float: left;
width: 200px;
left: 1em;
top: 1em;
margin: 0em;
padding: .5em;
text-align: left;
border: medium solid #efefff;
background-color: #fafaff;
color: inherit;
}
</style>
</head>
<body>
<div class=logo>
<a href="http://localhost:7657/index.jsp">Router Console</a><br />
[<a href="http://localhost:7657/config.jsp">configuration</a> | <a href="http://localhost:7657/help.jsp">help</a>]
</div>
<div class=warning id=warning>
The eepsite destination specified was not valid, or was
otherwise unreachable. Perhaps you pasted in the
wrong BASE64 string or the link you are following is
bad. The I2P host could also
be temporarily offline. You may want to
<a href="javascript: window.location.reload()">retry</a>.
<BR><BR>Could not find the following destination:<BR><BR>

View File

@ -0,0 +1,46 @@
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=iso-8859-1
Cache-control: no-cache
<html><head>
<title>Outproxy Not Found</title>
<style type='text/css'>
div.warning {
margin: 0em 1em 1em 224px;
padding: .5em 1em;
background-color: #ffefef;
border: medium solid #ffafaf;
text-align: left;
color: inherit;
}
div.logo {
float: left;
width: 200px;
left: 1em;
top: 1em;
margin: 0em;
padding: .5em;
text-align: left;
border: medium solid #efefff;
background-color: #fafaff;
color: inherit;
}
</style>
</head>
<body>
<div class=logo>
<a href="http://localhost:7657/index.jsp">Router Console</a><br />
[<a href="http://localhost:7657/config.jsp">configuration</a> | <a href="http://localhost:7657/help.jsp">help</a>]
</div>
<div class=warning id=warning>
The WWW Outproxy was not found.
It could
be temporarily offline. You may want to
<a href="javascript: parent.window.location.reload()">retry</a>
as this will randomly reselect an outproxy from the pool you have defined
<a href="http://localhost:7657/i2ptunnel/index.jsp">here</a>
(if you have more than one configured).
If you continue to have trouble you may want to edit your outproxy list
<a href="http://localhost:7657/i2ptunnel/edit.jsp?tunnel=0">here</a>.
<BR><BR>Could not find the following destination:<BR><BR>

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.184 $ $Date: 2005/04/12 10:22:12 $";
public final static String ID = "$Revision: 1.185 $ $Date: 2005/04/16 19:59:51 $";
public final static String VERSION = "0.5.0.6";
public final static long BUILD = 2;
public final static long BUILD = 3;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -38,7 +38,7 @@ public class TunnelBuilder {
return;
}
OnCreatedJob onCreated = new OnCreatedJob(ctx, pool, cfg);
RetryJob onFailed= (zeroHop ? null : new RetryJob(ctx, pool));
RetryJob onFailed= new RetryJob(ctx, pool);
// queue up a job to request the endpoint to join the tunnel, which then
// requeues up another job for earlier hops, etc, until it reaches the
// gateway. after the gateway is confirmed, onCreated is fired

View File

@ -41,7 +41,7 @@ public class TunnelPool {
* etc. On overflow, the necessary additional tunnels are built by the
* RefreshJob
*/
private static final int MAX_BUILDS_PER_MINUTE = 5;
private static final int MAX_BUILDS_PER_MINUTE = 10;
public TunnelPool(RouterContext ctx, TunnelPoolManager mgr, TunnelPoolSettings settings, TunnelPeerSelector sel, TunnelBuilder builder) {
_context = ctx;

View File

@ -41,6 +41,12 @@ public class TunnelPoolManager implements TunnelManagerFacade {
/** max # of concurrent build requests */
private int _maxOutstandingBuilds;
private static final String PROP_MAX_OUTSTANDING_BUILDS = "router.tunnel.maxConcurrentBuilds";
private static final int DEFAULT_MAX_OUTSTANDING_BUILDS = 20;
private static final String PROP_THROTTLE_CONCURRENT_TUNNELS = "router.tunnel.shouldThrottle";
private static final boolean DEFAULT_THROTTLE_CONCURRENT_TUNNELS = false;
public TunnelPoolManager(RouterContext ctx) {
_context = ctx;
_log = ctx.logManager().getLog(TunnelPoolManager.class);
@ -54,13 +60,13 @@ public class TunnelPoolManager implements TunnelManagerFacade {
_clientInboundPools = new HashMap(4);
_clientOutboundPools = new HashMap(4);
_outstandingBuilds = 0;
_maxOutstandingBuilds = 20;
String max = ctx.getProperty("router.tunnel.maxConcurrentBuilds", "20");
_maxOutstandingBuilds = DEFAULT_MAX_OUTSTANDING_BUILDS;
String max = ctx.getProperty(PROP_MAX_OUTSTANDING_BUILDS, String.valueOf(DEFAULT_MAX_OUTSTANDING_BUILDS));
if (max != null) {
try {
_maxOutstandingBuilds = Integer.parseInt(max);
} catch (NumberFormatException nfe) {
_maxOutstandingBuilds = 20;
_maxOutstandingBuilds = DEFAULT_MAX_OUTSTANDING_BUILDS;
}
}
@ -266,6 +272,9 @@ public class TunnelPoolManager implements TunnelManagerFacade {
* @return how many are allowed to be built
*/
int allocateBuilds(int wanted) {
boolean shouldThrottle = shouldThrottleTunnels();
if (!shouldThrottle) return wanted;
synchronized (this) {
if (_outstandingBuilds >= _maxOutstandingBuilds) {
// ok, as a failsafe, always let one through
@ -284,6 +293,11 @@ public class TunnelPoolManager implements TunnelManagerFacade {
}
}
}
private boolean shouldThrottleTunnels() {
Boolean rv = Boolean.valueOf(_context.getProperty(PROP_THROTTLE_CONCURRENT_TUNNELS, ""+DEFAULT_THROTTLE_CONCURRENT_TUNNELS));
return rv.booleanValue();
}
void buildComplete() {
synchronized (this) {