Changeset 54074e76


Ignore:
Timestamp:
Sep 7, 2005 10:31:11 PM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
79906f5
Parents:
c2ea8db
git-author:
jrandom <jrandom> (09/07/05 22:31:11)
git-committer:
zzz <zzz@…> (09/07/05 22:31:11)
Message:

2005-09-07 BarkerJr?

  • HTML cleanup for the router console (thanks!)

2005-09-07 jrandom

  • Lay the foundation for 'client routers' - the ability for peers to opt out of participating in tunnels entirely due to firewall/NAT issues. Individual routers have control over where those peers are used in tunnels - in outbound or inbound, exploratory or client tunnels, or none at all. The defaults with this build are to simply act as before - placing everyone as potential participants in any tunnel.
  • Another part of the foundation includes the option for netDb participants to refuse to answer queries regarding peers who are marked as unreachable, though this too is disabled by default (meaning the routerInfo is retrievable from the netDb).
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/jsp/config.jsp

    rc2ea8db r54074e76  
    33
    44<html><head>
    5 <title>I2P Router Console - logs</title>
     5<title>I2P Router Console - config networking</title>
    66<link rel="stylesheet" href="default.css" type="text/css" />
    77</head><body>
  • apps/routerconsole/jsp/configlogging.jsp

    rc2ea8db r54074e76  
    44
    55<html><head>
    6 <title>I2P Router Console - config clients</title>
     6<title>I2P Router Console - config logging</title>
    77<link rel="stylesheet" href="default.css" type="text/css" />
    88</head><body>
  • apps/routerconsole/jsp/configservice.jsp

    rc2ea8db r54074e76  
    44
    55<html><head>
    6 <title>I2P Router Console - config clients</title>
     6<title>I2P Router Console - config service</title>
    77<link rel="stylesheet" href="default.css" type="text/css" />
    88</head><body>
  • apps/routerconsole/jsp/oldconsole.jsp

    rc2ea8db r54074e76  
    44
    55<html><head>
    6 <title>I2P Router Console - home</title>
     6<title>I2P Router Console - internals</title>
    77<link rel="stylesheet" href="default.css" type="text/css" />
    88</head><body>
  • apps/routerconsole/jsp/oldstats.jsp

    rc2ea8db r54074e76  
    44
    55<html><head>
    6 <title>I2P Router Console - home</title>
     6<title>I2P Router Console - statistics</title>
    77<link rel="stylesheet" href="default.css" type="text/css" />
    88</head><body>
  • history.txt

    rc2ea8db r54074e76  
    1 $Id: history.txt,v 1.239 2005/09/04 15:26:42 jrandom Exp $
     1$Id: history.txt,v 1.240 2005/09/05 14:30:09 jrandom Exp $
     2
     32005-09-07  BarkerJr
     4    * HTML cleanup for the router console (thanks!)
     5
     62005-09-07  jrandom
     7    * Lay the foundation for 'client routers' - the ability for peers to opt
     8      out of participating in tunnels entirely due to firewall/NAT issues. 
     9      Individual routers have control over where those peers are used in
     10      tunnels - in outbound or inbound, exploratory or client tunnels, or
     11      none at all.  The defaults with this build are to simply act as before -
     12      placing everyone as potential participants in any tunnel.
     13    * Another part of the foundation includes the option for netDb
     14      participants to refuse to answer queries regarding peers who are marked
     15      as unreachable, though this too is disabled by default (meaning the
     16      routerInfo is retrievable from the netDb).
    217
    3182005-09-05  jrandom
  • readme.html

    rc2ea8db r54074e76  
    66<ul>
    77 <li><b>chat anonymously</b> - fire up your own IRC client and connect to the
    8      server at <b>localhost port 6668</b>.  This points at one of three anonymously hosted
     8     server at <b>localhost port 6668</b>.  This points at one of two anonymously hosted
    99     IRC servers, but neither you nor they know where the other is.</li>
    1010 <li><b>browse "eepsites"</b> - on I2P there are anonymously hosted websites -
     
    1212     browse to an eepsite -
    1313     <ul>
    14          <li><a href="http://duck.i2p/">duck.i2p</a>: duck's eepsite, with links to other active sites</li>
    1514         <li><a href="http://ugha.i2p/">ugha.i2p</a>: ugha's eepsite, a wiki that anyone can edit, and lots of links</li>
    1615         <li><a href="http://orion.i2p/">orion.i2p</a>: a site which tracks eepsite uptime and changes</li>
     
    2221     There are many more eepsites - just follow the links from the ones you see,
    2322     bookmark your favorites, and visit them often!</li>
    24  <li><b>browse the web</b> - there are a pair of HTTP "outproxies" in I2P hooked
     23 <li><b>browse the web</b> - there is currently an HTTP "outproxy" in I2P hooked
    2524     up to your own HTTP proxy on port 4444 - simply set your browser's proxy to
    2625     use it (as above) and go to any normal URL - your requests will be bounced
     
    6564<a href="http://www.i2p.net/">I2P website</a>, post up messages to the
    6665<a href="http://forum.i2p.net/">I2P discussion forum</a>, or swing by #i2p or
    67 #i2p-chat on IRC at <a href="irc://irc.freenode.net/#i2p">irc.freenode.net</a>, irc.postman.i2p, irc.freshcoffee.i2p or
    68 irc.arcturus.i2p (they're all linked together).</p>
     66#i2p-chat on IRC at <a href="irc://irc.freenode.net/#i2p">irc.freenode.net</a>, irc.postman.i2p or irc.freshcoffee.i2p (they're linked together).</p>
    6967
    7068<p><b>As a note, you can change this page by editing the file "docs/readme.html"</b></p>
  • router/java/src/net/i2p/router/PeerManagerFacade.java

    rc2ea8db r54074e76  
    1111import java.io.Writer;
    1212import java.util.List;
     13import net.i2p.data.Hash;
    1314
    1415/**
     
    2627     */
    2728    public List selectPeers(PeerSelectionCriteria criteria);
     29    public List getPeersByCapability(char capability);
     30    public void setCapabilities(Hash peer, String caps);
     31    public void removeCapabilities(Hash peer);
     32    public Hash selectRandomByCapability(char capability);
    2833}
    2934
     
    3439    public void renderStatusHTML(Writer out) { }   
    3540    public List selectPeers(PeerSelectionCriteria criteria) { return null; }
     41    public List getPeersByCapability(char capability) { return null; }
     42    public void setCapabilities(Hash peer, String caps) {}
     43    public void removeCapabilities(Hash peer) {}
     44    public Hash selectRandomByCapability(char capability) { return null; }
    3645}
  • router/java/src/net/i2p/router/Router.java

    rc2ea8db r54074e76  
    295295            if (FloodfillNetworkDatabaseFacade.floodfillEnabled(_context))
    296296                ri.addCapability(FloodfillNetworkDatabaseFacade.CAPACITY_FLOODFILL);
     297            addReachabilityCapability(ri);
    297298            SigningPrivateKey key = _context.keyManager().getSigningPrivateKey();
    298299            if (key == null) {
     
    312313        }
    313314    }
    314 
     315   
     316    public static final char CAPABILITY_REACHABLE = 'R';
     317    public static final char CAPABILITY_UNREACHABLE = 'U';
     318    public static final String PROP_FORCE_UNREACHABLE = "router.forceUnreachable";
     319
     320    public void addReachabilityCapability(RouterInfo ri) {
     321        String forceUnreachable = _context.getProperty(PROP_FORCE_UNREACHABLE);
     322        if ( (forceUnreachable != null) && ("true".equalsIgnoreCase(forceUnreachable)) ) {
     323            ri.addCapability(CAPABILITY_UNREACHABLE);
     324            return;
     325        }
     326        switch (_context.commSystem().getReachabilityStatus()) {
     327            case CommSystemFacade.STATUS_OK:
     328                ri.addCapability(CAPABILITY_REACHABLE);
     329                break;
     330            case CommSystemFacade.STATUS_DIFFERENT:
     331            case CommSystemFacade.STATUS_REJECT_UNSOLICITED:
     332                ri.addCapability(CAPABILITY_UNREACHABLE);
     333                break;
     334            case CommSystemFacade.STATUS_UNKNOWN:
     335                // no explicit capability
     336                break;
     337        }
     338    }
     339   
    315340    /**
    316341     * Ugly list of files that we need to kill if we are building a new identity
  • router/java/src/net/i2p/router/RouterVersion.java

    rc2ea8db r54074e76  
    1616 */
    1717public class RouterVersion {
    18     public final static String ID = "$Revision: 1.226 $ $Date: 2005/09/02 14:10:06 $";
     18    public final static String ID = "$Revision: 1.227 $ $Date: 2005/09/04 14:15:49 $";
    1919    public final static String VERSION = "0.6.0.5";
    20     public final static long BUILD = 1;
     20    public final static long BUILD = 2;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION);
  • router/java/src/net/i2p/router/networkdb/HandleDatabaseLookupMessageJob.java

    rc2ea8db r54074e76  
    1010
    1111import java.util.Iterator;
     12import java.util.HashSet;
    1213import java.util.Set;
    1314
     
    2627import net.i2p.router.JobImpl;
    2728import net.i2p.router.RouterContext;
     29import net.i2p.router.Router;
    2830import net.i2p.router.TunnelInfo;
    2931import net.i2p.router.message.SendMessageDirectJob;
     
    110112            RouterInfo info = getContext().netDb().lookupRouterInfoLocally(_message.getSearchKey());
    111113            if ( (info != null) && (info.isCurrent(EXPIRE_DELAY)) ) {
    112                 // send that routerInfo to the _message.getFromHash peer
    113                 if (_log.shouldLog(Log.DEBUG))
    114                     _log.debug("We do have key " + _message.getSearchKey().toBase64()
    115                                + " locally as a router info.  sending to " + fromKey.toBase64());
    116                 sendData(_message.getSearchKey(), info, fromKey, _message.getReplyTunnel());
     114                if (isUnreachable(info) && !publishUnreachable()) {
     115                    if (_log.shouldLog(Log.DEBUG))
     116                        _log.debug("Not answering a query for a netDb peer who isn't reachable");
     117                    Set us = new HashSet(1);
     118                    us.add(getContext().router().getRouterInfo());
     119                    sendClosest(_message.getSearchKey(), us, fromKey, _message.getReplyTunnel());
     120                } else {
     121                    // send that routerInfo to the _message.getFromHash peer
     122                    if (_log.shouldLog(Log.DEBUG))
     123                        _log.debug("We do have key " + _message.getSearchKey().toBase64()
     124                                   + " locally as a router info.  sending to " + fromKey.toBase64());
     125                    sendData(_message.getSearchKey(), info, fromKey, _message.getReplyTunnel());
     126                }
    117127            } else {
    118128                // not found locally - return closest peer routerInfo structs
     
    126136            }
    127137        }
     138    }
     139   
     140    private boolean isUnreachable(RouterInfo info) {
     141        if (info == null) return true;
     142        String cap = info.getCapabilities();
     143        if (cap == null) return false;
     144        return cap.indexOf(Router.CAPABILITY_REACHABLE) >= 0;
     145    }
     146   
     147    public static final String PROP_PUBLISH_UNREACHABLE = "router.publishUnreachableRouters";
     148    public static final boolean DEFAULT_PUBLISH_UNREACHABLE = true;
     149   
     150    private boolean publishUnreachable() {
     151        String publish = getContext().getProperty(PROP_PUBLISH_UNREACHABLE);
     152        if (publish != null)
     153            return Boolean.valueOf(publish).booleanValue();
     154        else
     155            return DEFAULT_PUBLISH_UNREACHABLE;
    128156    }
    129157   
  • router/java/src/net/i2p/router/networkdb/PublishLocalRouterInfoJob.java

    rc2ea8db r54074e76  
    4848            if (FloodfillNetworkDatabaseFacade.floodfillEnabled(getContext()))
    4949                ri.addCapability(FloodfillNetworkDatabaseFacade.CAPACITY_FLOODFILL);
     50            getContext().router().addReachabilityCapability(ri);
    5051            SigningPrivateKey key = getContext().keyManager().getSigningPrivateKey();
    5152            if (key == null) {
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillStoreJob.java

    rc2ea8db r54074e76  
    4949    }
    5050
    51     protected int getParallelization() { return 2; }
     51    protected int getParallelization() { return 1; }
    5252    protected int getRedundancy() { return 1; }
    5353
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    rc2ea8db r54074e76  
    689689            + routerInfo.getOptions().size() + " options on "
    690690            + new Date(routerInfo.getPublished()));
    691        
     691   
     692        _context.peerManager().setCapabilities(key, routerInfo.getCapabilities());
    692693        _ds.put(key, routerInfo);
    693694        synchronized (_lastSent) {
     
    722723            }
    723724           
     725            _context.peerManager().removeCapabilities(dbEntry);
    724726            boolean removed = _kb.remove(dbEntry);
    725727            if (removed) {
     
    738740        if (o == null) {
    739741            boolean removed = _kb.remove(dbEntry);
     742            _context.peerManager().removeCapabilities(dbEntry);
    740743            // if we dont know the key, lets make sure it isn't a now-dead peer
    741744        }
  • router/java/src/net/i2p/router/networkdb/kademlia/SearchJob.java

    rc2ea8db r54074e76  
    5353    private long _startedOn;
    5454   
    55     private static final int SEARCH_BREDTH = 10; // 10 peers at a time
     55    private static final int SEARCH_BREDTH = 3; // 10 peers at a time
    5656    private static final int SEARCH_PRIORITY = 400; // large because the search is probably for a real search
    5757    /** only send the 10 closest "dont tell me about" refs */
  • router/java/src/net/i2p/router/peermanager/PeerManager.java

    rc2ea8db r54074e76  
    1111import java.io.IOException;
    1212import java.io.Writer;
    13 import java.util.ArrayList;
    14 import java.util.HashSet;
    15 import java.util.Iterator;
    16 import java.util.List;
    17 import java.util.Set;
     13import java.util.*;
    1814
    1915import net.i2p.data.Hash;
     
    3127    private ProfileOrganizer _organizer;
    3228    private ProfilePersistenceHelper _persistenceHelper;
     29    private List _peersByCapability[];
     30    private Map _capabilitiesByPeer;
    3331   
    3432    public PeerManager(RouterContext context) {
     
    3836        _organizer = context.profileOrganizer();
    3937        _organizer.setUs(context.routerHash());
     38        _capabilitiesByPeer = new HashMap(128);
     39        _peersByCapability = new List[26];
     40        for (int i = 0; i < _peersByCapability.length; i++)
     41            _peersByCapability[i] = new ArrayList(64);
    4042        loadProfiles();
    4143        _context.jobQueue().addJob(new EvaluateProfilesJob(_context));
     
    117119    }
    118120   
     121    public void setCapabilities(Hash peer, String caps) {
     122        if (_log.shouldLog(Log.DEBUG))
     123            _log.debug("Setting capabilities for " + peer.toBase64() + " to " + caps);
     124        if (caps != null) caps = caps.toLowerCase();
     125        synchronized (_capabilitiesByPeer) {
     126            String oldCaps = null;
     127            if (caps != null)
     128                oldCaps = (String)_capabilitiesByPeer.put(peer, caps);
     129            else
     130                oldCaps = (String)_capabilitiesByPeer.remove(peer);
     131           
     132            if (oldCaps != null) {
     133                for (int i = 0; i < oldCaps.length(); i++) {
     134                    char c = oldCaps.charAt(i);
     135                    if ( (caps == null) || (caps.indexOf(c) < 0) ) {
     136                        List peers = locked_getPeers(c);
     137                        if (peers != null)
     138                            peers.remove(peer);
     139                    }
     140                }
     141            }
     142            if (caps != null) {
     143                for (int i = 0; i < caps.length(); i++) {
     144                    char c = caps.charAt(i);
     145                    if ( (oldCaps != null) && (oldCaps.indexOf(c) >= 0) )
     146                        continue;
     147                    List peers = locked_getPeers(c);
     148                    if ( (peers != null) && (!peers.contains(peer)) )
     149                        peers.add(peer);
     150                }
     151            }
     152        }
     153    }
     154   
     155    private List locked_getPeers(char c) {
     156        c = Character.toLowerCase(c);
     157        int i = c - 'a';
     158        if ( (i < 0) || (i >= _peersByCapability.length) ) {
     159            if (_log.shouldLog(Log.DEBUG))
     160                _log.debug("Invalid capability " + c + " (" + i + ")");
     161            return null;
     162        }
     163        return _peersByCapability[i];
     164    }
     165   
     166    public void removeCapabilities(Hash peer) {
     167        if (_log.shouldLog(Log.DEBUG))
     168            _log.debug("Removing capabilities from " + peer.toBase64());
     169        synchronized (_capabilitiesByPeer) {
     170            String oldCaps = (String)_capabilitiesByPeer.remove(peer);
     171            if (oldCaps != null) {
     172                for (int i = 0; i < oldCaps.length(); i++) {
     173                    char c = oldCaps.charAt(i);
     174                    List peers = locked_getPeers(c);
     175                    if (peers != null)
     176                        peers.remove(peer);
     177                }
     178            }
     179        }
     180    }
     181    public Hash selectRandomByCapability(char capability) {
     182        int index = _context.random().nextInt(Integer.MAX_VALUE);
     183        synchronized (_capabilitiesByPeer) {
     184            List peers = locked_getPeers(capability);
     185            if ( (peers != null) && (peers.size() > 0) ) {
     186                index = index % peers.size();
     187                return (Hash)peers.get(index);
     188            }
     189        }
     190        return null;
     191    }
     192    public List getPeersByCapability(char capability) {
     193        synchronized (_capabilitiesByPeer) {
     194            List peers = locked_getPeers(capability);
     195            if (peers != null)
     196                return new ArrayList(peers);
     197        }
     198        return null;
     199    }
     200
    119201    public void renderStatusHTML(Writer out) throws IOException {
    120202        _organizer.renderStatusHTML(out);
  • router/java/src/net/i2p/router/peermanager/PeerManagerFacadeImpl.java

    rc2ea8db r54074e76  
    1111import java.io.IOException;
    1212import java.io.Writer;
     13import java.util.ArrayList;
    1314import java.util.List;
    1415
     16import net.i2p.data.Hash;
    1517import net.i2p.router.PeerManagerFacade;
    1618import net.i2p.router.PeerSelectionCriteria;
     
    5860        return _manager.selectPeers(criteria);
    5961    }
    60    
     62
     63    public void setCapabilities(Hash peer, String caps) {
     64        if (_manager == null) return;
     65        _manager.setCapabilities(peer, caps);
     66    }
     67    public void removeCapabilities(Hash peer) {
     68        if (_manager == null) return;
     69        _manager.removeCapabilities(peer);
     70    }
     71    public Hash selectRandomByCapability(char capability) {
     72        if (_manager == null) return null;
     73        return _manager.selectRandomByCapability(capability);
     74    }
     75    public List getPeersByCapability(char capability) {
     76        if (_manager == null) return new ArrayList(0);
     77        return _manager.getPeersByCapability(capability);
     78    }
     79
    6180    public void renderStatusHTML(Writer out) throws IOException {
    6281        _manager.renderStatusHTML(out);
    6382    }
     83   
    6484}
  • router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java

    rc2ea8db r54074e76  
    5757            if (FloodfillNetworkDatabaseFacade.floodfillEnabled(getContext()))
    5858                info.addCapability(FloodfillNetworkDatabaseFacade.CAPACITY_FLOODFILL);
     59            getContext().router().addReachabilityCapability(info);
    5960            info.setOptions(stats);
    6061            info.setPeers(new HashSet());
  • router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java

    rc2ea8db r54074e76  
    130130                if (FloodfillNetworkDatabaseFacade.floodfillEnabled(getContext()))
    131131                    info.addCapability(FloodfillNetworkDatabaseFacade.CAPACITY_FLOODFILL);
     132                getContext().router().addReachabilityCapability(info);
    132133                // info.setPeers(new HashSet()); // this would have the trusted peers
    133134                info.setPublished(CreateRouterInfoJob.getCurrentPublishDate(getContext()));
  • router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java

    rc2ea8db r54074e76  
    7676    }
    7777
    78     public short getReachabilityStatus() { return _manager.getReachabilityStatus(); }
     78    public short getReachabilityStatus() {
     79        if (_manager == null) return CommSystemFacade.STATUS_UNKNOWN;
     80        return _manager.getReachabilityStatus();
     81    }
    7982    public void recheckReachability() { _manager.recheckReachability(); }
    8083
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    rc2ea8db r54074e76  
    1010import java.text.DecimalFormat;
    1111
    12 import java.util.ArrayList;
    13 import java.util.Collections;
    14 import java.util.HashMap;
    15 import java.util.Iterator;
    16 import java.util.List;
    17 import java.util.Map;
    18 import java.util.Properties;
    19 import java.util.Set;
     12import java.util.*;
    2013
    2114import net.i2p.data.Base64;
     
    251244        _flooder.startup();
    252245        _expireEvent.setIsAlive(true);
    253         _testEvent.setIsAlive(true);
     246        _testEvent.setIsAlive(true); // this queues it for 3-6 minutes in the future...
     247        SimpleTimer.getInstance().addEvent(_testEvent, 10*1000); // lets requeue it for Real Soon
    254248    }
    255249   
     
    833827    }
    834828   
     829    private static class AlphaComparator implements Comparator {
     830        private static final AlphaComparator _instance = new AlphaComparator();
     831        public static final AlphaComparator instance() { return _instance; }
     832       
     833        public int compare(Object lhs, Object rhs) {
     834            if ( (lhs == null) || (rhs == null) || !(lhs instanceof PeerState) || !(rhs instanceof PeerState))
     835                throw new IllegalArgumentException("rhs = " + rhs + " lhs = " + lhs);
     836            PeerState l = (PeerState)lhs;
     837            PeerState r = (PeerState)rhs;
     838            // base64 retains binary ordering
     839            return DataHelper.compareTo(l.getRemotePeer().getData(), r.getRemotePeer().getData());
     840        }
     841       
     842    }
    835843    public void renderStatusHTML(Writer out) throws IOException {
    836         List peers = null;
     844        TreeSet peers = new TreeSet(AlphaComparator.instance());
    837845        synchronized (_peersByIdent) {
    838             peers = new ArrayList(_peersByIdent.values());
     846            peers.addAll(_peersByIdent.values());
    839847        }
    840848        long offsetTotal = 0;
     
    843851        buf.append("<b>UDP connections: ").append(peers.size()).append("</b><br />\n");
    844852        buf.append("<table border=\"1\">\n");
    845         buf.append(" <tr><td><b>peer</b></td><td><b>activity (in/out)</b></td>");
    846         buf.append("     <td><b>transfer (in/out)</b></td>\n");
    847         buf.append("     <td><b>uptime</b></td><td><b>skew</b></td>\n");
     853        buf.append(" <tr><td><b>peer</b></td><td><b>idle</b></td>");
     854        buf.append("     <td><b>in/out</b></td>\n");
     855        buf.append("     <td><b>up</b></td><td><b>skew</b></td>\n");
    848856        buf.append("     <td><b>cwnd</b></td><td><b>ssthresh</b></td>\n");
    849857        buf.append("     <td><b>rtt</b></td><td><b>dev</b></td><td><b>rto</b></td>\n");
     
    854862        buf.setLength(0);
    855863        long now = _context.clock().now();
    856         for (int i = 0; i < peers.size(); i++) {
    857             PeerState peer = (PeerState)peers.get(i);
     864        for (Iterator iter = peers.iterator(); iter.hasNext(); ) {
     865            PeerState peer = (PeerState)iter.next();
    858866            if (now-peer.getLastReceiveTime() > 60*60*1000)
    859867                continue; // don't include old peers
     
    862870           
    863871            String name = peer.getRemotePeer().toBase64().substring(0,6);
    864             buf.append("<td nowrap>");
     872            buf.append("<td valign=\"top\" nowrap><code>");
    865873            buf.append("<a href=\"netdb.jsp#");
    866874            buf.append(name);
     
    869877            byte ip[] = peer.getRemoteIP();
    870878            for (int j = 0; j < ip.length; j++) {
    871                 buf.append(ip[j] & 0xFF);
     879                int num = ip[j] & 0xFF;
     880                if (num < 10)
     881                    buf.append("00");
     882                else if (num < 100)
     883                    buf.append("0");
     884                buf.append(num);
    872885                if (j + 1 < ip.length)
    873886                    buf.append('.');
    874887            }
    875             buf.append(':').append(peer.getRemotePort());
     888            buf.append(':');
     889            int port = peer.getRemotePort();
     890            if (port < 10)
     891                buf.append("0000");
     892            else if (port < 100)
     893                buf.append("000");
     894            else if (port < 1000)
     895                buf.append("00");
     896            else if (port < 10000)
     897                buf.append("0");
     898            buf.append(port);
    876899            buf.append("</a>");
    877             if (_activeThrottle.isChoked(peer.getRemotePeer()))
     900            boolean appended = false;
     901            if (_activeThrottle.isChoked(peer.getRemotePeer())) {
     902                if (!appended) buf.append("<br />");
    878903                buf.append(" [choked]");
    879             if (peer.getConsecutiveFailedSends() > 0)
     904                appended = true;
     905            }
     906            if (peer.getConsecutiveFailedSends() > 0) {
     907                if (!appended) buf.append("<br />");
    880908                buf.append(" [").append(peer.getConsecutiveFailedSends()).append(" failures]");
    881             if (_context.shitlist().isShitlisted(peer.getRemotePeer()))
     909                appended = true;
     910            }
     911            if (_context.shitlist().isShitlisted(peer.getRemotePeer())) {
     912                if (!appended) buf.append("<br />");
    882913                buf.append(" [shitlisted]");
    883             buf.append("</td>");
    884            
    885             buf.append("<td>");
     914                appended = true;
     915            }
     916            buf.append("</code></td>");
     917           
     918            buf.append("<td valign=\"top\" ><code>");
    886919            buf.append((now-peer.getLastReceiveTime())/1000);
    887920            buf.append("s/");
    888921            buf.append((now-peer.getLastSendTime())/1000);
    889             buf.append("s</td>");
    890    
    891             buf.append("<td>");
     922            buf.append("s</code></td>");
     923   
     924            buf.append("<td valign=\"top\" ><code>");
    892925            buf.append(formatKBps(peer.getReceiveBps()));
    893926            buf.append("KBps/");
     
    898931            //buf.append(formatKBps(peer.getSendACKBps()));
    899932            //buf.append("KBps ");
    900             buf.append("</td>");
    901 
    902             buf.append("<td>");
     933            buf.append("</code></td>");
     934
     935            buf.append("<td valign=\"top\" ><code>");
    903936            buf.append(DataHelper.formatDuration(now-peer.getKeyEstablishedTime()));
    904             buf.append("</td>");
    905            
    906             buf.append("<td>");
     937            buf.append("</code></td>");
     938           
     939            buf.append("<td valign=\"top\" ><code>");
    907940            buf.append(peer.getClockSkew()/1000);
    908             buf.append("s</td>");
     941            buf.append("s</code></td>");
    909942            offsetTotal = offsetTotal + peer.getClockSkew();
    910943
    911             buf.append("<td>");
     944            buf.append("<td valign=\"top\" ><code>");
    912945            buf.append(peer.getSendWindowBytes()/1024);
    913             buf.append("K</td>");
    914 
    915             buf.append("<td>");
     946            buf.append("K</code></td>");
     947
     948            buf.append("<td valign=\"top\" ><code>");
    916949            buf.append(peer.getSlowStartThreshold()/1024);
    917             buf.append("K</td>");
    918 
    919             buf.append("<td>");
     950            buf.append("K</code></td>");
     951
     952            buf.append("<td valign=\"top\" ><code>");
    920953            buf.append(peer.getRTT());
    921             buf.append("</td>");
    922            
    923             buf.append("<td>");
     954            buf.append("</code></td>");
     955           
     956            buf.append("<td valign=\"top\" ><code>");
    924957            buf.append(peer.getRTTDeviation());
    925             buf.append("</td>");
    926 
    927             buf.append("<td>");
     958            buf.append("</code></td>");
     959
     960            buf.append("<td valign=\"top\" ><code>");
    928961            buf.append(peer.getRTO());
    929             buf.append("</td>");
    930            
    931             buf.append("<td>");
     962            buf.append("</code></td>");
     963           
     964            buf.append("<td valign=\"top\" ><code>");
    932965            buf.append(peer.getPacketsTransmitted());
    933             buf.append("</td>");
    934            
    935             buf.append("<td>");
     966            buf.append("</code></td>");
     967           
     968            buf.append("<td valign=\"top\" ><code>");
    936969            buf.append(peer.getPacketsReceived());
    937             buf.append("</td>");
     970            buf.append("</code></td>");
    938971           
    939972            double sent = (double)peer.getPacketsPeriodTransmitted();
     
    942975                sendLostPct = (double)peer.getPacketsRetransmitted()/(sent);
    943976           
    944             buf.append("<td>");
     977            buf.append("<td valign=\"top\" ><code>");
    945978            //buf.append(formatPct(sendLostPct));
    946979            buf.append(peer.getPacketsRetransmitted()); // + "/" + peer.getPacketsPeriodRetransmitted() + "/" + sent);
    947980            //buf.append(peer.getPacketRetransmissionRate());
    948             buf.append("</td>");
     981            buf.append("</code></td>");
    949982           
    950983            double recvDupPct = (double)peer.getPacketsReceivedDuplicate()/(double)peer.getPacketsReceived();
    951             buf.append("<td>");
     984            buf.append("<td valign=\"top\" ><code>");
    952985            buf.append(formatPct(recvDupPct));
    953             buf.append("</td>");
     986            buf.append("</code></td>");
    954987
    955988            buf.append("</tr>");
  • router/java/src/net/i2p/router/tunnel/pool/ClientPeerSelector.java

    rc2ea8db r54074e76  
    11package net.i2p.router.tunnel.pool;
    22
    3 import java.util.ArrayList;
    4 import java.util.Collections;
    5 import java.util.HashSet;
    6 import java.util.List;
     3import java.util.*;
    74import net.i2p.router.RouterContext;
    85import net.i2p.router.TunnelPoolSettings;
     
    2320            return selectExplicit(ctx, settings, length);
    2421       
    25         ctx.profileOrganizer().selectFastPeers(length, null, matches);
     22        Set exclude = getExclude(ctx, settings.isInbound(), settings.isExploratory());
     23        ctx.profileOrganizer().selectFastPeers(length, exclude, matches);
    2624       
    2725        matches.remove(ctx.routerHash());
  • router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java

    rc2ea8db r54074e76  
    11package net.i2p.router.tunnel.pool;
    22
    3 import java.util.ArrayList;
    4 import java.util.Collections;
    5 import java.util.HashSet;
    6 import java.util.List;
     3import java.util.*;
    74import net.i2p.router.RouterContext;
    85import net.i2p.router.TunnelPoolSettings;
     
    3128        }
    3229       
    33         HashSet exclude = new HashSet(1);
     30        Set exclude = getExclude(ctx, settings.isInbound(), settings.isExploratory());
    3431        exclude.add(ctx.routerHash());
    3532        HashSet matches = new HashSet(length);
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPeerSelector.java

    rc2ea8db r54074e76  
    11package net.i2p.router.tunnel.pool;
    22
    3 import java.util.ArrayList;
    4 import java.util.Collections;
    5 import java.util.List;
    6 import java.util.Properties;
    7 import java.util.StringTokenizer;
     3import java.util.*;
    84import net.i2p.data.DataFormatException;
    95import net.i2p.data.Hash;
     6import net.i2p.router.Router;
    107import net.i2p.router.RouterContext;
    118import net.i2p.router.TunnelPoolSettings;
     
    115112        return rv;
    116113    }
     114   
     115    /**
     116     * Pick peers that we want to avoid
     117     */
     118    public Set getExclude(RouterContext ctx, boolean isInbound, boolean isExploratory) {
     119        if (filterUnreachable(ctx, isInbound, isExploratory)) {
     120            List caps = ctx.peerManager().getPeersByCapability(Router.CAPABILITY_UNREACHABLE);
     121            if (caps == null) return new HashSet(0);
     122            HashSet rv = new HashSet(caps);
     123            return rv;
     124        } else {
     125            return new HashSet(1);
     126        }
     127    }
     128   
     129    private static final String PROP_OUTBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE = "router.outboundExploratoryExcludeUnreachable";
     130    private static final String PROP_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE = "router.outboundClientExcludeUnreachable";
     131    private static final String PROP_INBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE = "router.inboundExploratoryExcludeUnreachable";
     132    private static final String PROP_INBOUND_CLIENT_EXCLUDE_UNREACHABLE = "router.inboundClientExcludeUnreachable";
     133    private static final boolean DEFAULT_OUTBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE = false;
     134    private static final boolean DEFAULT_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE = false;
     135    private static final boolean DEFAULT_INBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE = false;
     136    private static final boolean DEFAULT_INBOUND_CLIENT_EXCLUDE_UNREACHABLE = false;
     137   
     138    protected boolean filterUnreachable(RouterContext ctx, boolean isInbound, boolean isExploratory) {
     139        boolean def = false;
     140        String val = null;
     141       
     142        if (isExploratory)
     143            if (isInbound)
     144                val = ctx.getProperty(PROP_INBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE);
     145            else
     146                val = ctx.getProperty(PROP_OUTBOUND_EXPLORATORY_EXCLUDE_UNREACHABLE);
     147        else
     148            if (isInbound)
     149                val = ctx.getProperty(PROP_INBOUND_CLIENT_EXCLUDE_UNREACHABLE);
     150            else
     151                val = ctx.getProperty(PROP_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE);
     152       
     153        boolean rv = (val != null ? Boolean.valueOf(val).booleanValue() : def);
     154        //System.err.println("Filter unreachable? " + rv + " (inbound? " + isInbound + ", exploratory? " + isExploratory);
     155        return rv;
     156    }
    117157}
Note: See TracChangeset for help on using the changeset viewer.