Changeset 6c00bb2


Ignore:
Timestamp:
Nov 11, 2009 8:28:13 PM (10 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ab2e211
Parents:
573ac35
Message:
  • Console: Some colon cleansing
  • Shitlist: Move HTML renderer to router console, add cause parameter for ease of translation, tag all causes
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/bmsg.sh

    r573ac35 r6c00bb2  
    3636ROUTERFILES="\
    3737   ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \
    38    ../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java"
    39 JPATHS="src ../jsp/WEB-INF strings $JFILE $ROUTERFILES"
     38   ../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java \
     39   ../../../router/java/src/net/i2p/router/transport/TransportManager.java \
     40   ../../../router/java/src/net/i2p/router/transport/GetBidsJob.java \
     41   ../../../router/java/src/net/i2p/router/Blocklist.java \
     42   ../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java"
    4043for i in ../locale/messages_*.po
    4144do
  • apps/routerconsole/java/bundle-messages.sh

    r573ac35 r6c00bb2  
    2525ROUTERFILES="\
    2626   ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \
    27    ../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java"
     27   ../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java \
     28   ../../../router/java/src/net/i2p/router/transport/TransportManager.java \
     29   ../../../router/java/src/net/i2p/router/transport/GetBidsJob.java \
     30   ../../../router/java/src/net/i2p/router/Blocklist.java \
     31   ../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java"
     32
    2833JPATHS="src ../jsp/WEB-INF strings $JFILE $ROUTERFILES"
    2934for i in ../locale/messages_*.po
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigPeerHandler.java

    r573ac35 r6c00bb2  
    2121            Hash h = getHash();
    2222            if (h != null) {
    23                 _context.shitlist().shitlistRouterForever(h, "Manually banned via <a href=\"configpeer.jsp\">configpeer.jsp</a>");
     23                _context.shitlist().shitlistRouterForever(h, _("Manually banned via {0}"), "<a href=\"configpeer.jsp\">configpeer.jsp</a>");
    2424                addFormNotice(_("Peer") + " " + _peer + " " + _("banned until restart") );
    2525                return;
  • apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java

    r573ac35 r6c00bb2  
    277277        for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) {
    278278            RouterAddress addr = (RouterAddress)iter.next();
    279             buf.append("<b>").append(DataHelper.stripHTML(addr.getTransportStyle())).append("</b>: ");
     279            buf.append("<b>").append(DataHelper.stripHTML(addr.getTransportStyle())).append(":</b> ");
    280280            for (Iterator optIter = addr.getOptions().keySet().iterator(); optIter.hasNext(); ) {
    281281                String name = (String)optIter.next();
  • apps/routerconsole/java/src/net/i2p/router/web/ProfileOrganizerRenderer.java

    r573ac35 r6c00bb2  
    235235        buf.append("</table>");
    236236
    237         buf.append("<h3>").append(_("Thresholds:")).append("</h3>");
     237        buf.append("<h3>").append(_("Thresholds")).append("</h3>");
    238238        buf.append("<p><b>").append(_("Speed")).append(":</b> ").append(num(_organizer.getSpeedThreshold()))
    239239           .append(" (").append(fast).append(' ').append(_("fast peers")).append(")<br>");
     
    242242        buf.append("<b>").append(_("Integration")).append(":</b> ").append(num(_organizer.getIntegrationThreshold()))
    243243           .append(" (").append(integrated).append(' ').append(_(" well integrated peers")).append(")</p>");
    244         buf.append("<h3>").append(_("Definitions")).append(":</h3><ul>");
     244        buf.append("<h3>").append(_("Definitions")).append("</h3><ul>");
    245245        buf.append("<li><b>").append(_("groups")).append("</b>: ").append(_("as determined by the profile organizer")).append("</li>");
    246246        buf.append("<li><b>").append(_("caps")).append("</b>: ").append(_("capabilities in the netDb, not used to determine profiles")).append("</li>");
  • apps/routerconsole/java/src/net/i2p/router/web/ProfilesHelper.java

    r573ac35 r6c00bb2  
    2121    public String getShitlistSummary() {
    2222        try {
    23             _context.shitlist().renderStatusHTML(_out);
     23            ShitlistRenderer rend = new ShitlistRenderer(_context);
     24            rend.renderStatusHTML(_out);
    2425        } catch (IOException ioe) {
    2526            ioe.printStackTrace();
  • apps/routerconsole/java/src/net/i2p/router/web/TunnelRenderer.java

    r573ac35 r6c00bb2  
    3838   
    3939    public void renderStatusHTML(Writer out) throws IOException {
    40         out.write("<div class=\"wideload\"><h2><a name=\"exploratory\" ></a>" + _("Exploratory tunnels") + " (<a href=\"/configtunnels.jsp#exploratory\">" + _("config") + "</a>):</h2>\n");
     40        out.write("<div class=\"wideload\"><h2><a name=\"exploratory\" ></a>" + _("Exploratory tunnels") + " (<a href=\"/configtunnels.jsp#exploratory\">" + _("configure") + "</a>)</h2>\n");
    4141        renderPool(out, _context.tunnelManager().getInboundExploratoryPool(), _context.tunnelManager().getOutboundExploratoryPool());
    4242       
     
    6060                      + "\" ></a>" + _("Client tunnels for") + ' ' + _(name));
    6161            if (_context.clientManager().isLocal(client))
    62                 out.write(" (<a href=\"/configtunnels.jsp#" + client.toBase64().substring(0,4) +"\">" + _("config") + "</a>):</h2>\n");
    63             else
    64                 out.write(" (dead):</h2>\n");
     62                out.write(" (<a href=\"/configtunnels.jsp#" + client.toBase64().substring(0,4) +"\">" + _("configure") + "</a>)</h2>\n");
     63            else
     64                out.write(" (" + _("dead") + ")</h2>\n");
    6565            renderPool(out, in, outPool);
    6666        }
     
    6868        List participating = _context.tunnelDispatcher().listParticipatingTunnels();
    6969        Collections.sort(participating, new TunnelComparator());
    70         out.write("<h2><a name=\"participating\"></a>" + _("Participating tunnels") + ":</h2><table>\n");
     70        out.write("<h2><a name=\"participating\"></a>" + _("Participating tunnels") + "</h2><table>\n");
    7171        out.write("<tr><th>" + _("Receive on") + "</th><th>" + _("From") + "</th><th>"
    7272                  + _("Send on") + "</th><th>" + _("To") + "</th><th>" + _("Expiration") + "</th>"
     
    105105                out.write(" <td class=\"cells\" align=\"center\">" + DataHelper.formatDuration(timeLeft) + "</td>");
    106106            else
    107                 out.write(" <td class=\"cells\" align=\"center\">(grace period)</td>");
     107                out.write(" <td class=\"cells\" align=\"center\">(" + _("grace period") + ")</td>");
    108108            out.write(" <td class=\"cells\" align=\"center\">" + cfg.getProcessedMessagesCount() + "KB</td>");
    109109            int lifetime = (int) ((_context.clock().now() - cfg.getCreation()) / 1000);
     
    232232        Collections.sort(peerList, new HashComparator());
    233233
    234         out.write("<h2><a name=\"peers\"></a>" + _("Tunnel Counts By Peer") + ":</h2>\n");
     234        out.write("<h2><a name=\"peers\"></a>" + _("Tunnel Counts By Peer") + "</h2>\n");
    235235        out.write("<table><tr><th>" + _("Peer") + "</th><th>" + _("Expl. + Client") + "</th><th>" + _("% of total") + "</th><th>" + _("Part. from + to") + "</th><th>" + _("% of total") + "</th></tr>\n");
    236236        for (Hash h : peerList) {
  • history.txt

    r573ac35 r6c00bb2  
     12009-11-11 zzz
     2    * Console: Some colon cleansing
     3    * FloodfillPeerSelector: Adjustments
     4    * Shitlist: Move HTML renderer to router console,
     5      add cause parameter for ease of translation,
     6      tag all causes
     7
    182009-11-11 zzz
    29    * Addressbook, NamingService: Allow 516 byte dests
  • router/java/src/net/i2p/router/Blocklist.java

    r573ac35 r6c00bb2  
    112112            for (Iterator iter = _peerBlocklist.keySet().iterator(); iter.hasNext(); ) {
    113113                Hash peer = (Hash) iter.next();
    114                 String reason = "Banned by router hash";
     114                String reason;
    115115                String comment = (String) _peerBlocklist.get(peer);
    116116                if (comment != null)
    117                     reason = reason + ": " + comment;
    118                 _context.shitlist().shitlistRouterForever(peer, reason);
     117                    reason = _x("Banned by router hash: {0}");
     118                else
     119                    reason = _x("Banned by router hash");
     120                _context.shitlist().shitlistRouterForever(peer, reason, comment);
    119121            }
    120122            _peerBlocklist = null;
     
    660662    public void shitlist(Hash peer) {
    661663        // Temporary reason, until the job finishes
    662         _context.shitlist().shitlistRouterForever(peer, "IP Banned");
     664        _context.shitlist().shitlistRouterForever(peer, _x("IP banned"));
    663665        if (! "true".equals( _context.getProperty(PROP_BLOCKLIST_DETAIL, "true")))
    664666            return;
     
    730732                    if (match(ipint, toEntry(e.ip1, e.ip2))) {
    731733                        try { in.close(); } catch (IOException ioe) {}
    732                         String reason = "IP ";
    733                         for (int i = 0; i < 4; i++) {
    734                             reason = reason + (ip[i] & 0xff);
    735                             if (i != 3)
    736                                 reason = reason + '.';
    737                         }
    738                         reason = reason + " banned by " + BLOCKLIST_FILE_DEFAULT + " entry \"" + buf + "\"";
     734                        String reason = _x("IP banned by blocklist.txt entry {0}");
     735                        // only one translate parameter for now
     736                        //for (int i = 0; i < 4; i++) {
     737                        //    reason = reason + (ip[i] & 0xff);
     738                        //    if (i != 3)
     739                        //        reason = reason + '.';
     740                        //}
     741                        //reason = reason + " banned by " + BLOCKLIST_FILE_DEFAULT + " entry \"" + buf + "\"";
    739742                        if (_log.shouldLog(Log.WARN))
    740743                            _log.warn("Shitlisting " + peer + " " + reason);
    741                         _context.shitlist().shitlistRouterForever(peer, reason);
     744                        _context.shitlist().shitlistRouterForever(peer, reason, buf.toString());
    742745                        return;
    743746                    }
     
    792795    }
    793796
     797    /**
     798     *  Mark a string for extraction by xgettext and translation.
     799     *  Use this only in static initializers.
     800     *  It does not translate!
     801     *  @return s
     802     */
     803    private static final String _x(String s) {
     804        return s;
     805    }
     806
    794807    public static void main(String args[]) {
    795808        Blocklist b = new Blocklist();
  • router/java/src/net/i2p/router/RouterVersion.java

    r573ac35 r6c00bb2  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 15;
     21    public final static long BUILD = 16;
    2222    /** for example "-test" */
    2323    public final static String EXTRA = "";
  • router/java/src/net/i2p/router/Shitlist.java

    r573ac35 r6c00bb2  
    1313import java.util.concurrent.ConcurrentHashMap;
    1414import java.util.ArrayList;
    15 import java.util.Comparator;
     15import java.util.HashMap;
    1616import java.util.Iterator;
    1717import java.util.List;
    1818import java.util.Map;
    1919import java.util.Set;
    20 import java.util.TreeMap;
    2120
    2221import net.i2p.data.DataHelper;
     
    3736    private Map<Hash, Entry> _entries;
    3837   
    39     private static class Entry {
     38    public static class Entry {
    4039        /** when it should expire, per the i2p clock */
    41         long expireOn;
     40        public long expireOn;
    4241        /** why they were shitlisted */
    43         String cause;
     42        public String cause;
     43        /** separate code so cause can contain {0} for translation */
     44        public String causeCode;
    4445        /** what transports they were shitlisted for (String), or null for all transports */
    45         Set<String> transports;
     46        public Set<String> transports;
    4647    }
    4748   
     
    9697    }
    9798   
     99    /** for ShitlistRenderer in router console */
     100    public Map<Hash, Entry> getEntries() {
     101        return new HashMap<Hash, Entry>(_entries);
     102    }
     103   
    98104    public boolean shitlistRouter(Hash peer) {
    99105        return shitlistRouter(peer, null);
    100106    }
    101107    public boolean shitlistRouter(Hash peer, String reason) { return shitlistRouter(peer, reason, null); }
     108    /** ick have to put the reasonCode in the front to avoid ambiguity */
     109    public boolean shitlistRouter(String reasonCode, Hash peer, String reason) {
     110        return shitlistRouter(peer, reason, reasonCode, null, false);
     111    }
    102112    public boolean shitlistRouter(Hash peer, String reason, String transport) {
    103113        return shitlistRouter(peer, reason, transport, false);
     
    106116        return shitlistRouter(peer, reason, null, true);
    107117    }
     118    public boolean shitlistRouterForever(Hash peer, String reason, String reasonCode) {
     119        return shitlistRouter(peer, reason, reasonCode, null, true);
     120    }
    108121    public boolean shitlistRouter(Hash peer, String reason, String transport, boolean forever) {
     122        return shitlistRouter(peer, reason, null, null, true);
     123    }
     124    private boolean shitlistRouter(Hash peer, String reason, String reasonCode, String transport, boolean forever) {
    109125        if (peer == null) {
    110126            _log.error("wtf, why did we try to shitlist null?", new Exception("shitfaced"));
     
    138154        }
    139155        e.cause = reason;
     156        e.causeCode = reasonCode;
    140157        e.transports = null;
    141158        if (transport != null) {
     
    151168                    e.expireOn = old.expireOn;
    152169                    e.cause = old.cause;
     170                    e.causeCode = old.causeCode;
    153171                }
    154172                if (e.transports != null) {
     
    158176                        e.transports = null;
    159177                        e.cause = reason;
     178                        e.causeCode = reasonCode;
    160179                    }
    161180                }
     
    246265    }
    247266
    248     class HashComparator implements Comparator {
    249          public int compare(Object l, Object r) {
    250              return ((Hash)l).toBase64().compareTo(((Hash)r).toBase64());
    251         }
    252     }
    253 
     267    /** @deprecated moved to router console */
    254268    public void renderStatusHTML(Writer out) throws IOException {
    255         StringBuilder buf = new StringBuilder(1024);
    256         // move to the jsp
    257         //buf.append("<h2>Banned Peers</h2>");
    258         Map<Hash, Entry> entries = new TreeMap(new HashComparator());
    259        
    260         entries.putAll(_entries);
    261 
    262         buf.append("<ul>");
    263        
    264         for (Map.Entry<Hash, Entry> e : entries.entrySet()) {
    265             Hash key = e.getKey();
    266             Entry entry = e.getValue();
    267             buf.append("<li>").append(_context.commSystem().renderPeerHTML(key));
    268             long expires = entry.expireOn-_context.clock().now();
    269             if (expires < 5l*24*60*60*1000)
    270                 buf.append(" Temporary ban expiring in ");
    271             else
    272                 buf.append(" Banned until restart or in ");
    273             buf.append(DataHelper.formatDuration(expires));
    274             Set transports = entry.transports;
    275             if ( (transports != null) && (transports.size() > 0) )
    276                 buf.append(" on the following transport: ").append(transports);
    277             if (entry.cause != null) {
    278                 buf.append("<br>\n");
    279                 buf.append(entry.cause);
    280             }
    281             buf.append(" (<a href=\"configpeer.jsp?peer=").append(key.toBase64()).append("#unsh\">unban now</a>)");
    282             buf.append("</li>\n");
    283         }
    284         buf.append("</ul>\n");
    285         out.write(buf.toString());
    286         out.flush();
    287269    }
    288270}
  • router/java/src/net/i2p/router/transport/GetBidsJob.java

    r573ac35 r6c00bb2  
    6868                context.statManager().addRateData("transport.bidFailNoTransports", msg.getLifetime(), 0);
    6969                // This used to be "no common transports" but it is almost always no transports at all
    70                 context.shitlist().shitlistRouter(to, "No transports (hidden or starting up?)");
     70                context.shitlist().shitlistRouter(to, _x("No transports (hidden or starting up?)"));
    7171            } else if (failedCount >= facade.getTransportCount()) {
    7272                context.statManager().addRateData("transport.bidFailAllTransports", msg.getLifetime(), 0);
     
    9999        msg.discardData();
    100100    }
     101
     102    /**
     103     *  Mark a string for extraction by xgettext and translation.
     104     *  Use this only in static initializers.
     105     *  It does not translate!
     106     *  @return s
     107     */
     108    private static final String _x(String s) {
     109        return s;
     110    }
    101111}
  • router/java/src/net/i2p/router/transport/TransportManager.java

    r573ac35 r6c00bb2  
    448448            if (unreachableTransports >= _transports.size() && countActivePeers() > 0) {
    449449                _context.statManager().addRateData("transport.shitlistOnUnreachable", msg.getLifetime(), msg.getLifetime());
    450                 _context.shitlist().shitlistRouter(peer, "Unreachable on any transport");
     450                _context.shitlist().shitlistRouter(peer, _x("Unreachable on any transport"));
    451451            }
    452452        } else if (rv == null) {
     
    494494        }
    495495        StringBuilder buf = new StringBuilder(4*1024);
    496         buf.append("<h3>Router Transport Addresses:</h3><pre>\n");
     496        buf.append("<h3>Router Transport Addresses</h3><pre>\n");
    497497        for (int i = 0; i < _transports.size(); i++) {
    498498            Transport t = (Transport)_transports.get(i);
     
    509509        out.flush();
    510510    }
     511
     512    /**
     513     *  Mark a string for extraction by xgettext and translation.
     514     *  Use this only in static initializers.
     515     *  It does not translate!
     516     *  @return s
     517     */
     518    private static final String _x(String s) {
     519        return s;
     520    }
     521
    511522}
  • router/java/src/net/i2p/router/transport/ntcp/EstablishState.java

    r573ac35 r6c00bb2  
    369369                    _context.statManager().addRateData("ntcp.invalidOutboundSkew", diff, 0);
    370370                    _transport.markReachable(_con.getRemotePeer().calculateHash(), false);
    371                     _context.shitlist().shitlistRouter(_con.getRemotePeer().calculateHash(),
    372                                                        "Excessive clock skew: " + DataHelper.formatDuration(diff));
     371                    _context.shitlist().shitlistRouter(DataHelper.formatDuration(diff),
     372                                                       _con.getRemotePeer().calculateHash(),
     373                                                       _x("Excessive clock skew: {0}"));
    373374                    fail("Clocks too skewed (" + diff + " ms)", null, true);
    374375                    return;
     
    573574                    _context.statManager().addRateData("ntcp.invalidInboundSkew", diff, 0);
    574575                    _transport.markReachable(alice.calculateHash(), true);
    575                     _context.shitlist().shitlistRouter(alice.calculateHash(), "Clock skew of " + diff + " ms");
     576                    _context.shitlist().shitlistRouter(DataHelper.formatDuration(diff),
     577                                                       alice.calculateHash(),
     578                                                       _x("Excessive clock skew: {0}"));
    576579                    fail("Clocks too skewed (" + diff + " ms)", null, true);
    577580                    return;
     
    924927        }
    925928    }
     929
     930    /**
     931     *  Mark a string for extraction by xgettext and translation.
     932     *  Use this only in static initializers.
     933     *  It does not translate!
     934     *  @return s
     935     */
     936    private static final String _x(String s) {
     937        return s;
     938    }
     939
    926940}
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r573ac35 r6c00bb2  
    20602060    }
    20612061   
    2062     private static final String KEY = "<h3>Definitions:</h3><div class=\"configure\">" +
     2062    private static final String KEY = "<h3>Definitions</h3><div class=\"configure\">" +
    20632063        "<p><b id=\"def.peer\">Peer</b>: the remote peer.<br>\n" +
    20642064        "<b id=\"def.dir\">Dir</b>: v means they offer to introduce us, ^ means we offer to introduce them.<br>\n" +
Note: See TracChangeset for help on using the changeset viewer.