forked from I2P_Developers/i2p.i2p
2005-11-27 jrandom
* Inlined the Syndie CSS to reduce the number of HTTP requests (and because firefox [and others?] delay rendering until they fetch the css). * Make sure we fire the shutdown tasks when regenerating a new identity (thanks picsou!) * Cleaned up some of the things I b0rked in the 'dynamic keys' mode * Don't drop SSU sessions if they're still transmitting data successfully, even if there are transmission failures * Adjusted the time summarization to display hours after 119m, not 90m * Further EepGet cleanup (grr)
This commit is contained in:
@ -63,6 +63,8 @@ public class ConfigStatsHandler extends FormHandler {
|
||||
|
||||
if (_explicitFilter) {
|
||||
_stats.clear();
|
||||
if (_explicitFilterValue == null)
|
||||
_explicitFilterValue = "";
|
||||
|
||||
if (_explicitFilterValue.indexOf(',') != -1) {
|
||||
StringTokenizer tok = new StringTokenizer(_explicitFilterValue, ",");
|
||||
|
@ -236,14 +236,14 @@ public class PacketHandler {
|
||||
}
|
||||
packet.releasePayload();
|
||||
} else {
|
||||
if (_log.shouldLog(Log.DEBUG) && !packet.isFlagSet(Packet.FLAG_SYNCHRONIZE))
|
||||
_log.debug("Packet received on an unknown stream (and not an ECHO or SYN): " + packet);
|
||||
//if (_log.shouldLog(Log.DEBUG) && !packet.isFlagSet(Packet.FLAG_SYNCHRONIZE))
|
||||
// _log.debug("Packet received on an unknown stream (and not an ECHO or SYN): " + packet);
|
||||
if (sendId <= 0) {
|
||||
Connection con = _manager.getConnectionByOutboundId(packet.getReceiveStreamId());
|
||||
if (con != null) {
|
||||
if ( (con.getHighestAckedThrough() <= 5) && (packet.getSequenceNum() <= 5) ) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Received additional packets before the syn on " + con + ": " + packet);
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("Received additional packets before the syn on " + con + ": " + packet);
|
||||
receiveKnownCon(con, packet);
|
||||
return;
|
||||
} else {
|
||||
|
@ -14,6 +14,7 @@ import net.i2p.data.*;
|
||||
import net.i2p.syndie.*;
|
||||
import net.i2p.syndie.data.*;
|
||||
import net.i2p.syndie.sml.*;
|
||||
import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
/**
|
||||
@ -75,7 +76,7 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
req.setCharacterEncoding("UTF-8");
|
||||
resp.setCharacterEncoding("UTF-8");
|
||||
resp.setContentType("text/html");
|
||||
resp.setContentType("text/html;charset=UTF-8");
|
||||
|
||||
User user = (User)req.getSession().getAttribute("user");
|
||||
String login = req.getParameter("login");
|
||||
@ -488,7 +489,27 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
protected void renderBegin(User user, HttpServletRequest req, PrintWriter out, ThreadIndex index) throws IOException {
|
||||
out.write("<html>\n<head><title>" + getTitle() + "</title>\n" + BEGIN_HTML);
|
||||
out.write("<html>\n<head><title>" + getTitle() + "</title>\n");
|
||||
out.write("<style>");
|
||||
out.write(STYLE_HTML);
|
||||
Reader css = null;
|
||||
try {
|
||||
InputStream in = req.getSession().getServletContext().getResourceAsStream("/syndie.css");
|
||||
if (in != null) {
|
||||
css = new InputStreamReader(in, "UTF-8");
|
||||
char buf[] = new char[1024];
|
||||
int read = 0;
|
||||
while ( (read = css.read(buf)) != -1)
|
||||
out.write(buf, 0, read);
|
||||
}
|
||||
} finally {
|
||||
if (css != null)
|
||||
css.close();
|
||||
}
|
||||
String content = FileUtil.readTextFile("./docs/syndie_standard.css", -1, true);
|
||||
if (content != null) out.write(content);
|
||||
out.write("</style>");
|
||||
out.write(BEGIN_HTML);
|
||||
}
|
||||
protected void renderNavBar(User user, HttpServletRequest req, PrintWriter out, ThreadIndex index) throws IOException {
|
||||
//out.write("<tr class=\"topNav\"><td class=\"topNav_user\" colspan=\"2\" nowrap=\"true\">\n");
|
||||
@ -899,8 +920,13 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
}
|
||||
}
|
||||
|
||||
private static final String BEGIN_HTML = "<style>\n" +
|
||||
".overallTable {\n" +
|
||||
private static final String BEGIN_HTML = "<link href=\"rss.jsp\" rel=\"alternate\" type=\"application/rss+xml\" >\n" +
|
||||
"</head>\n" +
|
||||
"<body>\n" +
|
||||
"<span style=\"display: none\"><a href=\"#bodySubject\">Jump to the beginning of the first post rendered, if any</a>\n" +
|
||||
"<a href=\"#threads\">Jump to the thread navigation</a>\n</span>\n" +
|
||||
"<table border=\"0\" width=\"100%\" class=\"overallTable\">\n";
|
||||
private static final String STYLE_HTML = ".overallTable {\n" +
|
||||
" border-spacing: 0px;\n" +
|
||||
" border-width: 0px;\n" +
|
||||
" border: 0px;\n" +
|
||||
@ -982,15 +1008,8 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
"}\n" +
|
||||
".postReplyOptions {\n" +
|
||||
" background-color: #BBBBFF;\n" +
|
||||
"}\n" +
|
||||
"</style>\n" +
|
||||
"<link href=\"style.jsp\" rel=\"stylesheet\" type=\"text/css\" >\n" +
|
||||
"<link href=\"rss.jsp\" rel=\"alternate\" type=\"application/rss+xml\" >\n" +
|
||||
"</head>\n" +
|
||||
"<body>\n" +
|
||||
"<span style=\"display: none\"><a href=\"#bodySubject\">Jump to the beginning of the first post rendered, if any</a>\n" +
|
||||
"<a href=\"#threads\">Jump to the thread navigation</a>\n</span>\n" +
|
||||
"<table border=\"0\" width=\"100%\" class=\"overallTable\">\n";
|
||||
"}\n";
|
||||
|
||||
|
||||
private static final String END_HTML = "</table>\n" +
|
||||
"</body>\n";
|
||||
|
@ -818,7 +818,7 @@ public class DataHelper {
|
||||
return ms + "ms";
|
||||
} else if (ms < 5 * 60 * 1000) {
|
||||
return (ms / 1000) + "s";
|
||||
} else if (ms < 90 * 60 * 1000) {
|
||||
} else if (ms < 120 * 60 * 1000) {
|
||||
return (ms / (60 * 1000)) + "m";
|
||||
} else if (ms < 3 * 24 * 60 * 60 * 1000) {
|
||||
return (ms / (60 * 60 * 1000)) + "h";
|
||||
|
@ -631,7 +631,8 @@ public class EepGet {
|
||||
buf.append(_alreadyTransferred);
|
||||
buf.append("-\r\n");
|
||||
}
|
||||
buf.append("Accept-Encoding: identity;q=1, *;q=0\r\n");
|
||||
buf.append("Accept-Encoding: \r\n");
|
||||
buf.append("X-Accept-Encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0\r\n");
|
||||
if (!_allowCaching) {
|
||||
buf.append("Cache-control: no-cache\r\n");
|
||||
buf.append("Pragma: no-cache\r\n");
|
||||
|
13
history.txt
13
history.txt
@ -1,4 +1,15 @@
|
||||
$Id: history.txt,v 1.333 2005/11/26 11:51:20 jrandom Exp $
|
||||
$Id: history.txt,v 1.334 2005/11/26 13:26:24 jrandom Exp $
|
||||
|
||||
2005-11-27 jrandom
|
||||
* Inlined the Syndie CSS to reduce the number of HTTP requests (and
|
||||
because firefox [and others?] delay rendering until they fetch the css).
|
||||
* Make sure we fire the shutdown tasks when regenerating a new identity
|
||||
(thanks picsou!)
|
||||
* Cleaned up some of the things I b0rked in the 'dynamic keys' mode
|
||||
* Don't drop SSU sessions if they're still transmitting data successfully,
|
||||
even if there are transmission failures
|
||||
* Adjusted the time summarization to display hours after 119m, not 90m
|
||||
* Further EepGet cleanup (grr)
|
||||
|
||||
* 2005-11-26 0.6.1.6 released
|
||||
|
||||
|
@ -38,8 +38,6 @@ import net.i2p.data.i2np.GarlicMessage;
|
||||
import net.i2p.router.message.GarlicMessageHandler;
|
||||
//import net.i2p.router.message.TunnelMessageHandler;
|
||||
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
|
||||
import net.i2p.router.transport.udp.UDPTransport;
|
||||
import net.i2p.router.transport.udp.UDPAddress;
|
||||
import net.i2p.router.startup.StartupJob;
|
||||
import net.i2p.stat.Rate;
|
||||
import net.i2p.stat.RateStat;
|
||||
@ -218,51 +216,6 @@ public class Router {
|
||||
_context.jobQueue().addJob(new PersistRouterInfoJob());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when our RouterInfo is loaded by LoadRouterInfoJob
|
||||
* to store our most recently known address to determine if
|
||||
* it has changed while we were down.
|
||||
*/
|
||||
public boolean updateExternalAddress(Collection addrs, boolean reboot) {
|
||||
if ("false".equalsIgnoreCase(_context.getProperty(Router.PROP_DYNAMIC_KEYS, "false")))
|
||||
return false; // no one cares. pretend it didn't change
|
||||
boolean ret = false;
|
||||
for (Iterator i = addrs.iterator(); i.hasNext(); ) {
|
||||
RouterAddress addr = (RouterAddress)i.next();
|
||||
if (UDPTransport.STYLE.equalsIgnoreCase(addr.getTransportStyle()))
|
||||
ret = updateExternalAddress(addr, reboot);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by TransportImpl.replaceAddress to notify the router of an
|
||||
* address change. It is the caller's responsibility to make sure this
|
||||
* really is a substantial change.
|
||||
*
|
||||
*/
|
||||
public boolean updateExternalAddress(RouterAddress addr, boolean rebootRouter) {
|
||||
String newExternal = null;
|
||||
// TCP is often incorrectly initialized to 83.246.74.28 for some
|
||||
// reason. Numerous hosts in the netdb report this address for TCP.
|
||||
// It is also easier to lie over the TCP transport. So only trust UDP.
|
||||
if (!UDPTransport.STYLE.equalsIgnoreCase(addr.getTransportStyle()))
|
||||
return false;
|
||||
|
||||
if ("false".equalsIgnoreCase(_context.getProperty(Router.PROP_DYNAMIC_KEYS, "false")))
|
||||
return false; // no one cares. pretend it didn't change
|
||||
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Rekeying and restarting due to " + addr.getTransportStyle()
|
||||
+ " address update. new address: " + addr);
|
||||
if (rebootRouter) {
|
||||
_context.router().rebuildNewIdentity();
|
||||
} else {
|
||||
_context.router().killKeys();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the router has tried to communicate with another router who is running a higher
|
||||
* incompatible protocol version.
|
||||
@ -459,6 +412,14 @@ public class Router {
|
||||
*/
|
||||
public void rebuildNewIdentity() {
|
||||
killKeys();
|
||||
try {
|
||||
for (Iterator iter = _shutdownTasks.iterator(); iter.hasNext(); ) {
|
||||
Runnable task = (Runnable)iter.next();
|
||||
task.run();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
_log.log(Log.CRIT, "Error running shutdown task", t);
|
||||
}
|
||||
// hard and ugly
|
||||
finalShutdown(EXIT_HARD_RESTART);
|
||||
}
|
||||
@ -870,6 +831,9 @@ public class Router {
|
||||
public void finalShutdown(int exitCode) {
|
||||
_log.log(Log.CRIT, "Shutdown(" + exitCode + ") complete", new Exception("Shutdown"));
|
||||
try { _context.logManager().shutdown(); } catch (Throwable t) { }
|
||||
if ("true".equalsIgnoreCase(_context.getProperty(PROP_DYNAMIC_KEYS, "false")))
|
||||
killKeys();
|
||||
|
||||
File f = new File(getPingFile());
|
||||
f.delete();
|
||||
if (_killVMOnEnd) {
|
||||
|
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
||||
*
|
||||
*/
|
||||
public class RouterVersion {
|
||||
public final static String ID = "$Revision: 1.301 $ $Date: 2005/11/26 11:51:19 $";
|
||||
public final static String ID = "$Revision: 1.302 $ $Date: 2005/11/26 13:26:23 $";
|
||||
public final static String VERSION = "0.6.1.6";
|
||||
public final static long BUILD = 0;
|
||||
public final static long BUILD = 1;
|
||||
public static void main(String args[]) {
|
||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||
System.out.println("Router ID: " + RouterVersion.ID);
|
||||
|
@ -11,8 +11,6 @@ package net.i2p.router.startup;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.PrivateKey;
|
||||
@ -78,7 +76,6 @@ public class LoadRouterInfoJob extends JobImpl {
|
||||
fis1 = new FileInputStream(rif);
|
||||
info = new RouterInfo();
|
||||
info.readBytes(fis1);
|
||||
getContext().router().updateExternalAddress(info.getAddresses(), false);
|
||||
_log.debug("Reading in routerInfo from " + rif.getAbsolutePath() + " and it has " + info.getAddresses().size() + " addresses");
|
||||
}
|
||||
|
||||
|
@ -763,7 +763,8 @@ public class EstablishmentManager {
|
||||
|
||||
Hash peer = outboundState.getRemoteIdentity().calculateHash();
|
||||
_context.shitlist().shitlistRouter(peer, err);
|
||||
_context.profileManager().commErrorOccurred(peer);
|
||||
_transport.dropPeer(peer);
|
||||
//_context.profileManager().commErrorOccurred(peer);
|
||||
} else {
|
||||
while (true) {
|
||||
OutNetMessage msg = outboundState.getNextQueuedMessage();
|
||||
|
@ -418,6 +418,11 @@ public class PeerState {
|
||||
}
|
||||
return _consecutiveFailedSends;
|
||||
}
|
||||
public long getInactivityTime() {
|
||||
long now = _context.clock().now();
|
||||
long lastActivity = Math.max(_lastReceiveTime, _lastSendFullyTime);
|
||||
return now - lastActivity;
|
||||
}
|
||||
|
||||
/** how fast we are sending *ack* packets */
|
||||
public int getSendACKBps() { return _sendACKBps; }
|
||||
|
@ -23,6 +23,7 @@ import net.i2p.data.i2np.DatabaseStoreMessage;
|
||||
import net.i2p.router.CommSystemFacade;
|
||||
import net.i2p.router.OutNetMessage;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.transport.Transport;
|
||||
import net.i2p.router.transport.TransportImpl;
|
||||
import net.i2p.router.transport.TransportBid;
|
||||
@ -526,8 +527,10 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
return super.getCurrentAddress();
|
||||
}
|
||||
|
||||
private void dropPeer(PeerState peer) {
|
||||
dropPeer(peer, true);
|
||||
void dropPeer(Hash peer) {
|
||||
PeerState state = getPeerState(peer);
|
||||
if (state != null)
|
||||
dropPeer(state, false);
|
||||
}
|
||||
private void dropPeer(PeerState peer, boolean shouldShitlist) {
|
||||
if (_log.shouldLog(Log.INFO)) {
|
||||
@ -827,15 +830,26 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
protected void replaceAddress(RouterAddress address, RouterAddress oldAddress) {
|
||||
replaceAddress(address);
|
||||
if (oldAddress != null) {
|
||||
// fire a router.updateExternalAddress only if the address /really/ changed.
|
||||
// updating the introducers doesn't require a real change, only updating the
|
||||
// IP or port does.
|
||||
UDPAddress old = new UDPAddress(oldAddress);
|
||||
InetAddress oldHost = old.getHostAddress();
|
||||
UDPAddress newAddr = new UDPAddress(address);
|
||||
InetAddress newHost = newAddr.getHostAddress();
|
||||
if ( (old.getPort() != newAddr.getPort()) || (!oldHost.equals(newHost)) )
|
||||
_context.router().updateExternalAddress(address, true);
|
||||
if ( (old.getPort() > 0) && (oldHost != null) && (isValid(oldHost.getAddress())) &&
|
||||
(newAddr.getPort() > 0) && (newHost != null) && (isValid(newHost.getAddress())) ) {
|
||||
if ( (old.getPort() != newAddr.getPort()) || (!oldHost.equals(newHost)) ) {
|
||||
// substantial data has changed, so if we are in 'dynamic keys' mode, restart the
|
||||
// router hard and regenerate a new identity
|
||||
if ("true".equalsIgnoreCase(_context.getProperty(Router.PROP_DYNAMIC_KEYS, "false"))) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("SSU address updated. new address: "
|
||||
+ newAddr.getHostAddress() + ":" + newAddr.getPort() + ", old address: "
|
||||
+ old.getHostAddress() + ":" + old.getPort());
|
||||
// shutdown itself checks the DYNAMIC_KEYS flag, and if its set to true, deletes
|
||||
// the keys
|
||||
_context.router().shutdown(Router.EXIT_HARD_RESTART);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -859,6 +873,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
private static final int DROP_INACTIVITY_TIME = 10*1000;
|
||||
|
||||
public void failed(OutboundMessageState msg) {
|
||||
if (msg == null) return;
|
||||
@ -875,7 +891,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
consecutive = msg.getPeer().incrementConsecutiveFailedSends();
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Consecutive failure #" + consecutive + " sending to " + msg.getPeer());
|
||||
if (consecutive > MAX_CONSECUTIVE_FAILED)
|
||||
if ( (consecutive > MAX_CONSECUTIVE_FAILED) && (msg.getPeer().getInactivityTime() > DROP_INACTIVITY_TIME))
|
||||
dropPeer(msg.getPeer(), false);
|
||||
}
|
||||
failed(msg.getMessage());
|
||||
|
Reference in New Issue
Block a user