Changeset 686742a


Ignore:
Timestamp:
Nov 28, 2005 4:02:38 PM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c66e325
Parents:
cdf9429
git-author:
jrandom <jrandom> (11/28/05 16:02:38)
git-committer:
zzz <zzz@…> (11/28/05 16:02:38)
Message:

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)
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java

    rcdf9429 r686742a  
    6464        if (_explicitFilter) {
    6565            _stats.clear();
     66            if (_explicitFilterValue == null)
     67                _explicitFilterValue = "";
    6668           
    6769            if (_explicitFilterValue.indexOf(',') != -1) {
  • apps/streaming/java/src/net/i2p/client/streaming/PacketHandler.java

    rcdf9429 r686742a  
    237237            packet.releasePayload();
    238238        } else {
    239             if (_log.shouldLog(Log.DEBUG) && !packet.isFlagSet(Packet.FLAG_SYNCHRONIZE))
    240                 _log.debug("Packet received on an unknown stream (and not an ECHO or SYN): " + packet);
     239            //if (_log.shouldLog(Log.DEBUG) && !packet.isFlagSet(Packet.FLAG_SYNCHRONIZE))
     240            //    _log.debug("Packet received on an unknown stream (and not an ECHO or SYN): " + packet);
    241241            if (sendId <= 0) {
    242242                Connection con = _manager.getConnectionByOutboundId(packet.getReceiveStreamId());
    243243                if (con != null) {
    244244                    if ( (con.getHighestAckedThrough() <= 5) && (packet.getSequenceNum() <= 5) ) {
    245                         if (_log.shouldLog(Log.DEBUG))
    246                             _log.debug("Received additional packets before the syn on " + con + ": " + packet);
     245                        //if (_log.shouldLog(Log.DEBUG))
     246                        //    _log.debug("Received additional packets before the syn on " + con + ": " + packet);
    247247                        receiveKnownCon(con, packet);
    248248                        return;
  • apps/syndie/java/src/net/i2p/syndie/web/BaseServlet.java

    rcdf9429 r686742a  
    1515import net.i2p.syndie.data.*;
    1616import net.i2p.syndie.sml.*;
     17import net.i2p.util.FileUtil;
    1718import net.i2p.util.Log;
    1819
     
    7677        req.setCharacterEncoding("UTF-8");
    7778        resp.setCharacterEncoding("UTF-8");
    78         resp.setContentType("text/html");
     79        resp.setContentType("text/html;charset=UTF-8");
    7980       
    8081        User user = (User)req.getSession().getAttribute("user");
     
    489490   
    490491    protected void renderBegin(User user, HttpServletRequest req, PrintWriter out, ThreadIndex index) throws IOException {
    491         out.write("<html>\n<head><title>" + getTitle() + "</title>\n" + BEGIN_HTML);
     492        out.write("<html>\n<head><title>" + getTitle() + "</title>\n");
     493        out.write("<style>");
     494        out.write(STYLE_HTML);
     495        Reader css = null;
     496        try {
     497            InputStream in = req.getSession().getServletContext().getResourceAsStream("/syndie.css");
     498            if (in != null) {
     499                css = new InputStreamReader(in, "UTF-8");
     500                char buf[] = new char[1024];
     501                int read = 0;
     502                while ( (read = css.read(buf)) != -1)
     503                    out.write(buf, 0, read);
     504            }
     505        } finally {
     506            if (css != null)
     507                css.close();
     508        }
     509        String content = FileUtil.readTextFile("./docs/syndie_standard.css", -1, true);
     510        if (content != null) out.write(content);
     511        out.write("</style>");
     512        out.write(BEGIN_HTML);
    492513    }
    493514    protected void renderNavBar(User user, HttpServletRequest req, PrintWriter out, ThreadIndex index) throws IOException {
     
    900921    }
    901922   
    902     private static final String BEGIN_HTML = "<style>\n" +
    903 ".overallTable {\n" +
     923    private static final String BEGIN_HTML = "<link href=\"rss.jsp\" rel=\"alternate\" type=\"application/rss+xml\" >\n" +
     924"</head>\n" +
     925"<body>\n" +
     926"<span style=\"display: none\"><a href=\"#bodySubject\">Jump to the beginning of the first post rendered, if any</a>\n" +
     927"<a href=\"#threads\">Jump to the thread navigation</a>\n</span>\n" +
     928"<table border=\"0\" width=\"100%\" class=\"overallTable\">\n";
     929    private static final String STYLE_HTML = ".overallTable {\n" +
    904930"       border-spacing: 0px;\n" +
    905931"       border-width: 0px;\n" +
     
    9831009".postReplyOptions {\n" +
    9841010"       background-color: #BBBBFF;\n" +
    985 "}\n" +
    986 "</style>\n" +
    987 "<link href=\"style.jsp\" rel=\"stylesheet\" type=\"text/css\" >\n" +
    988 "<link href=\"rss.jsp\" rel=\"alternate\" type=\"application/rss+xml\" >\n" +
    989 "</head>\n" +
    990 "<body>\n" +
    991 "<span style=\"display: none\"><a href=\"#bodySubject\">Jump to the beginning of the first post rendered, if any</a>\n" +
    992 "<a href=\"#threads\">Jump to the thread navigation</a>\n</span>\n" +
    993 "<table border=\"0\" width=\"100%\" class=\"overallTable\">\n";
     1011"}\n";
     1012
    9941013   
    9951014    private static final String END_HTML = "</table>\n" +
  • core/java/src/net/i2p/data/DataHelper.java

    rcdf9429 r686742a  
    819819        } else if (ms < 5 * 60 * 1000) {
    820820            return (ms / 1000) + "s";
    821         } else if (ms < 90 * 60 * 1000) {
     821        } else if (ms < 120 * 60 * 1000) {
    822822            return (ms / (60 * 1000)) + "m";
    823823        } else if (ms < 3 * 24 * 60 * 60 * 1000) {
  • core/java/src/net/i2p/util/EepGet.java

    rcdf9429 r686742a  
    632632            buf.append("-\r\n");
    633633        }
    634         buf.append("Accept-Encoding: identity;q=1, *;q=0\r\n");
     634        buf.append("Accept-Encoding: \r\n");
     635        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");
    635636        if (!_allowCaching) {
    636637            buf.append("Cache-control: no-cache\r\n");
  • history.txt

    rcdf9429 r686742a  
    1 $Id: history.txt,v 1.333 2005/11/26 11:51:20 jrandom Exp $
     1$Id: history.txt,v 1.334 2005/11/26 13:26:24 jrandom Exp $
     2
     32005-11-27  jrandom
     4    * Inlined the Syndie CSS to reduce the number of HTTP requests (and
     5      because firefox [and others?] delay rendering until they fetch the css).
     6    * Make sure we fire the shutdown tasks when regenerating a new identity
     7      (thanks picsou!)
     8    * Cleaned up some of the things I b0rked in the 'dynamic keys' mode
     9    * Don't drop SSU sessions if they're still transmitting data successfully,
     10      even if there are transmission failures
     11    * Adjusted the time summarization to display hours after 119m, not 90m
     12    * Further EepGet cleanup (grr)
    213
    314* 2005-11-26 0.6.1.6 released
  • router/java/src/net/i2p/router/Router.java

    rcdf9429 r686742a  
    3939//import net.i2p.router.message.TunnelMessageHandler;
    4040import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
    41 import net.i2p.router.transport.udp.UDPTransport;
    42 import net.i2p.router.transport.udp.UDPAddress;
    4341import net.i2p.router.startup.StartupJob;
    4442import net.i2p.stat.Rate;
     
    220218
    221219    /**
    222      * Called when our RouterInfo is loaded by LoadRouterInfoJob
    223      * to store our most recently known address to determine if
    224      * it has changed while we were down.
    225      */
    226     public boolean updateExternalAddress(Collection addrs, boolean reboot) {
    227         if ("false".equalsIgnoreCase(_context.getProperty(Router.PROP_DYNAMIC_KEYS, "false")))
    228             return false; // no one cares. pretend it didn't change
    229         boolean ret = false;
    230         for (Iterator i = addrs.iterator(); i.hasNext(); ) {
    231             RouterAddress addr = (RouterAddress)i.next();
    232             if (UDPTransport.STYLE.equalsIgnoreCase(addr.getTransportStyle()))
    233                 ret = updateExternalAddress(addr, reboot);
    234         }
    235         return ret;
    236     }
    237 
    238     /**
    239      * Called by TransportImpl.replaceAddress to notify the router of an
    240      * address change.  It is the caller's responsibility to make sure this
    241      * really is a substantial change.
    242      *
    243      */
    244     public boolean updateExternalAddress(RouterAddress addr, boolean rebootRouter) {
    245         String newExternal = null;
    246         // TCP is often incorrectly initialized to 83.246.74.28 for some
    247         // reason. Numerous hosts in the netdb report this address for TCP.
    248         // It is also easier to lie over the TCP transport. So only trust UDP.
    249         if (!UDPTransport.STYLE.equalsIgnoreCase(addr.getTransportStyle()))
    250             return false;
    251 
    252         if ("false".equalsIgnoreCase(_context.getProperty(Router.PROP_DYNAMIC_KEYS, "false")))
    253             return false; // no one cares. pretend it didn't change
    254 
    255         if (_log.shouldLog(Log.WARN))
    256             _log.warn("Rekeying and restarting due to " + addr.getTransportStyle()
    257                       + " address update. new address: " + addr);
    258         if (rebootRouter) {
    259             _context.router().rebuildNewIdentity();
    260         } else {
    261             _context.router().killKeys();
    262         }
    263         return true;
    264     }
    265    
    266     /**
    267220     * True if the router has tried to communicate with another router who is running a higher
    268221     * incompatible protocol version. 
     
    460413    public void rebuildNewIdentity() {
    461414        killKeys();
     415        try {
     416            for (Iterator iter = _shutdownTasks.iterator(); iter.hasNext(); ) {
     417                Runnable task = (Runnable)iter.next();
     418                task.run();
     419            }
     420        } catch (Throwable t) {
     421            _log.log(Log.CRIT, "Error running shutdown task", t);
     422        }
    462423        // hard and ugly
    463424        finalShutdown(EXIT_HARD_RESTART);
     
    871832        _log.log(Log.CRIT, "Shutdown(" + exitCode + ") complete", new Exception("Shutdown"));
    872833        try { _context.logManager().shutdown(); } catch (Throwable t) { }
     834        if ("true".equalsIgnoreCase(_context.getProperty(PROP_DYNAMIC_KEYS, "false")))
     835            killKeys();
     836
    873837        File f = new File(getPingFile());
    874838        f.delete();
  • router/java/src/net/i2p/router/RouterVersion.java

    rcdf9429 r686742a  
    1616 */
    1717public class RouterVersion {
    18     public final static String ID = "$Revision: 1.301 $ $Date: 2005/11/26 11:51:19 $";
     18    public final static String ID = "$Revision: 1.302 $ $Date: 2005/11/26 13:26:23 $";
    1919    public final static String VERSION = "0.6.1.6";
    20     public final static long BUILD = 0;
     20    public final static long BUILD = 1;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
  • router/java/src/net/i2p/router/startup/LoadRouterInfoJob.java

    rcdf9429 r686742a  
    1212import java.io.FileInputStream;
    1313import java.io.IOException;
    14 import java.util.Collection;
    15 import java.util.Set;
    1614
    1715import net.i2p.data.DataFormatException;
     
    7977                info = new RouterInfo();
    8078                info.readBytes(fis1);
    81                 getContext().router().updateExternalAddress(info.getAddresses(), false);
    8279                _log.debug("Reading in routerInfo from " + rif.getAbsolutePath() + " and it has " + info.getAddresses().size() + " addresses");
    8380            }
  • router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java

    rcdf9429 r686742a  
    764764                    Hash peer = outboundState.getRemoteIdentity().calculateHash();
    765765                    _context.shitlist().shitlistRouter(peer, err);
    766                     _context.profileManager().commErrorOccurred(peer);
     766                    _transport.dropPeer(peer);
     767                    //_context.profileManager().commErrorOccurred(peer);
    767768                } else {
    768769                    while (true) {
  • router/java/src/net/i2p/router/transport/udp/PeerState.java

    rcdf9429 r686742a  
    419419        return _consecutiveFailedSends;
    420420    }
     421    public long getInactivityTime() {
     422        long now = _context.clock().now();
     423        long lastActivity = Math.max(_lastReceiveTime, _lastSendFullyTime);
     424        return now - lastActivity;
     425    }
    421426   
    422427    /** how fast we are sending *ack* packets */
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    rcdf9429 r686742a  
    2424import net.i2p.router.OutNetMessage;
    2525import net.i2p.router.RouterContext;
     26import net.i2p.router.Router;
    2627import net.i2p.router.transport.Transport;
    2728import net.i2p.router.transport.TransportImpl;
     
    527528    }
    528529   
    529     private void dropPeer(PeerState peer) {
    530         dropPeer(peer, true);
     530    void dropPeer(Hash peer) {
     531        PeerState state = getPeerState(peer);
     532        if (state != null)
     533            dropPeer(state, false);
    531534    }
    532535    private void dropPeer(PeerState peer, boolean shouldShitlist) {
     
    828831        replaceAddress(address);
    829832        if (oldAddress != null) {
    830             // fire a router.updateExternalAddress only if the address /really/ changed.
    831             // updating the introducers doesn't require a real change, only updating the
    832             // IP or port does.
    833833            UDPAddress old = new UDPAddress(oldAddress);
    834834            InetAddress oldHost = old.getHostAddress();
    835835            UDPAddress newAddr = new UDPAddress(address);
    836836            InetAddress newHost = newAddr.getHostAddress();
    837             if ( (old.getPort() != newAddr.getPort()) || (!oldHost.equals(newHost)) )
    838                 _context.router().updateExternalAddress(address, true);
     837            if ( (old.getPort() > 0) && (oldHost != null) && (isValid(oldHost.getAddress())) &&
     838                 (newAddr.getPort() > 0) && (newHost != null) && (isValid(newHost.getAddress())) ) {
     839                if ( (old.getPort() != newAddr.getPort()) || (!oldHost.equals(newHost)) ) {
     840                    // substantial data has changed, so if we are in 'dynamic keys' mode, restart the
     841                    // router hard and regenerate a new identity
     842                    if ("true".equalsIgnoreCase(_context.getProperty(Router.PROP_DYNAMIC_KEYS, "false"))) {
     843                        if (_log.shouldLog(Log.ERROR))
     844                            _log.error("SSU address updated. new address: "
     845                                       + newAddr.getHostAddress() + ":" + newAddr.getPort() + ", old address: "
     846                                       + old.getHostAddress() + ":" + old.getPort());
     847                        // shutdown itself checks the DYNAMIC_KEYS flag, and if its set to true, deletes
     848                        // the keys
     849                        _context.router().shutdown(Router.EXIT_HARD_RESTART);             
     850                    }
     851                }
     852            }
    839853        }
    840854    }
     
    860874            return "";
    861875    }
     876
     877    private static final int DROP_INACTIVITY_TIME = 10*1000;
    862878   
    863879    public void failed(OutboundMessageState msg) {
     
    876892            if (_log.shouldLog(Log.WARN))
    877893                _log.warn("Consecutive failure #" + consecutive + " sending to " + msg.getPeer());
    878             if (consecutive > MAX_CONSECUTIVE_FAILED)
     894            if ( (consecutive > MAX_CONSECUTIVE_FAILED) && (msg.getPeer().getInactivityTime() > DROP_INACTIVITY_TIME))
    879895                dropPeer(msg.getPeer(), false);
    880896        }
Note: See TracChangeset for help on using the changeset viewer.