Changeset b5784d6


Ignore:
Timestamp:
Sep 13, 2005 12:11:56 AM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c8c1090
Parents:
31bdb89
git-author:
jrandom <jrandom> (09/13/05 00:11:56)
git-committer:
zzz <zzz@…> (09/13/05 00:11:56)
Message:

2005-09-12 jrandom

  • More aggressively publish updated routerInfo.
  • Expose the flag to force SSU introductions on the router console
  • Don't give people the option to disable SNTP time sync, at least not through the router console, because there is no reason to disable it. No, not even if your OS is "ntp synced", because chances are, its not.
Files:
12 edited

Legend:

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

    r31bdb89 rb5784d6  
    1717
    1818import net.i2p.time.Timestamper;
     19import net.i2p.router.transport.udp.UDPTransport;
    1920
    2021/**
     
    3031    private boolean _recheckReachabilityRequested;
    3132    private boolean _timeSyncEnabled;
     33    private boolean _requireIntroductions;
    3234    private String _tcpPort;
    3335    private String _udpPort;
     
    5860    public void setEnabletimesync(String moo) { _timeSyncEnabled = true; }
    5961    public void setRecheckReachability(String moo) { _recheckReachabilityRequested = true; }
     62    public void setRequireIntroductions(String moo) { _requireIntroductions = true; }
    6063   
    6164    public void setHostname(String hostname) {
     
    254257        }
    255258       
    256         if (_timeSyncEnabled) {
     259        if (_requireIntroductions) {
     260            _context.router().setConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS, "true");
     261            addFormNotice("Requiring SSU introduers");
     262        } else {
     263            _context.router().removeConfigSetting(UDPTransport.PROP_FORCE_INTRODUCERS);
     264        }
     265       
     266        if (true || _timeSyncEnabled) {
    257267            // Time sync enable, means NOT disabled
    258268            _context.router().setConfigSetting(Timestamper.PROP_DISABLED, "false");
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java

    r31bdb89 rb5784d6  
    33import net.i2p.time.Timestamper;
    44import net.i2p.router.RouterContext;
     5import net.i2p.router.CommSystemFacade;
     6import net.i2p.data.RouterAddress;
     7import net.i2p.router.transport.udp.UDPAddress;
    58
    69public class ConfigNetHelper {
     
    4447    }
    4548   
    46     public String getUdpPort() {
    47         int port = 8887;
    48         String val = _context.getProperty(PROP_I2NP_UDP_PORT);
    49         if (val == null)
    50             val = _context.getProperty(PROP_I2NP_INTERNAL_UDP_PORT);
    51         if (val != null) {
    52             try {
    53                 port = Integer.parseInt(val);
    54             } catch (NumberFormatException nfe) {
    55                 // ignore, use default from above
    56             }
    57         }
    58         return "" + port;
     49    public String getUdpAddress() {
     50        RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
     51        if (addr == null)
     52            return "unknown";
     53        UDPAddress ua = new UDPAddress(addr);
     54        return ua.toString();
    5955    }
    6056   
     
    6561        else
    6662            return " checked ";
     63    }
     64   
     65    public String getRequireIntroductionsChecked() {
     66        short status = _context.commSystem().getReachabilityStatus();
     67        switch (status) {
     68            case CommSystemFacade.STATUS_OK:
     69                return "";
     70            case CommSystemFacade.STATUS_DIFFERENT:
     71            case CommSystemFacade.STATUS_REJECT_UNSOLICITED:
     72                return "checked=\"true\"";
     73            case CommSystemFacade.STATUS_UNKNOWN:
     74                return "";
     75            default:
     76                return "checked=\"true\"";
     77        }
    6778    }
    6879   
  • apps/routerconsole/jsp/config.jsp

    r31bdb89 rb5784d6  
    2929 <input type="hidden" name="action" value="blah" />
    3030
    31  UDP port: <i><jsp:getProperty name="nethelper" property="udpPort" /></i><br />
    32 <!-- <input name="udpPort" type="text" size="5" value="<jsp:getProperty name="nethelper" property="udpPort" />" /><br /> -->
    33 <b>You must poke a hole in your firewall or NAT (if applicable) to receive new inbound UDP packets on
    34 this port from arbitrary peers (this requirement will be removed in i2p 0.6.1, but is necessary now)</b><br />
    35  TCP port: <input name="tcpPort" type="text" size="5" value="<jsp:getProperty name="nethelper" property="tcpPort" />" /> <br />
    36  <b>You must poke a hole in your firewall or NAT (if applicable) so that you can receive inbound TCP
    37  connections on it (this requirement will be removed in i2p 0.6.1, but is necessary now)</b>
    38 <br />
     31 <b>External UDP address:</b> <i><jsp:getProperty name="nethelper" property="udpAddress" /></i><br />
     32 <b>Require SSU introductions through NAT hole punching? </b>
     33<input type="checkbox" name="requireIntroductions" value="true" <jsp:getProperty name="nethelper" property="requireIntroductionsChecked" /> /><br />
     34 <p>If you can't poke a hole in your NAT or firewall to allow unsolicited UDP packets to reach the
     35    router, as detected with the <i>Status: ERR-Reject</i>, then you will need SSU introductions. 
     36    Users behind symmetric NATs, such as OpenBSD's pf, are not currently supported.</p>
    3937<input type="submit" name="recheckReachability" value="Check network reachability..." />
    4038 <hr />
     
    5452 Sharing a higher percentage will improve your anonymity and help the network
    5553 <hr />
    56  Enable internal time synchronization? <input type="checkbox" <jsp:getProperty name="nethelper" property="enableTimeSyncChecked" /> name="enabletimesync" /><br />
    57  <i>If disabled, your machine <b>must</b> be NTP synchronized - your clock must always
    58     be within a few seconds of "correct".  You will need to be able to send outbound UDP
    59     packets on port 123 to one of the pool.ntp.org machines (or some other SNTP server).</i>
    60  <hr />
    6154 <input type="submit" name="save" value="Save changes" /> <input type="reset" value="Cancel" /><br />
    62  <i>Changing the TCP or UDP port will force a 'soft restart' - dropping your connections and clients as
    63     if the router was stopped and restarted.  <b>Please be patient</b> - it may take
    64     a few seconds to complete.</i>
    6555 </form>
    66  <hr />
    67  <b>Advanced network config:</b>
    68  <p>
    69  One advanced network option has to do with reseeding - you should never need to
    70  reseed your router as long as you can find at least one other peer on the network.  However,
    71  when you do need to reseed, a link will show up on the left hand side which will
    72  fetch all of the routerInfo-* files from http://dev.i2p.net/i2pdb/.  That URL is just an
    73  apache folder pointing at the netDb/ directory of a router - anyone can run one, and you can
    74  configure your router to seed off an alternate URL by adding the java environmental property
    75  "i2p.reseedURL=someURL" (e.g. java -Di2p.reseedURL=http://dev.i2p.net/i2pdb/ ...).  You can
    76  also do it manually by getting routerInfo-*.dat files from someone (a friend, someone on IRC,
    77  whatever) and saving them to your netDb/ directory.</p>
    78 <p>
    79  With the SSU transport, the internal UDP port may be different from the external
    80  UDP port (in case of a firewall/NAT) - the UDP port field above specifies the
    81  external one and assumes they are the same, but if you want to set the internal
    82  port to something else, you can add "i2np.udp.internalPort=1234" to the
    83  <a href="configadvanced.jsp">advanced</a> config and restart the router.
    84 </p>
    8556</div>
    8657
  • history.txt

    r31bdb89 rb5784d6  
    1 $Id: history.txt,v 1.243 2005/09/09 23:30:37 jrandom Exp $
     1$Id: history.txt,v 1.244 2005/09/10 22:22:52 jrandom Exp $
     2
     32005-09-12  jrandom
     4    * More aggressively publish updated routerInfo.
     5    * Expose the flag to force SSU introductions on the router console
     6    * Don't give people the option to disable SNTP time sync, at least not
     7      through the router console, because there is no reason to disable it.
     8      No, not even if your OS is "ntp synced", because chances are, its not.
    29
    3102005-09-10  jrandom
  • router/java/src/net/i2p/data/i2np/DatabaseStoreMessage.java

    r31bdb89 rb5784d6  
    133133       
    134134        if (_replyToken > 0) {
    135             _replyTunnel = new TunnelId(DataHelper.fromLong(data, curIndex, 4));
     135            long tunnel = DataHelper.fromLong(data, curIndex, 4);
     136            if (tunnel > 0)
     137                _replyTunnel = new TunnelId(tunnel);
    136138            curIndex += 4;
    137139           
     
    203205       
    204206        if (_replyToken > 0) {
    205             byte id[] = DataHelper.toLong(4, _replyTunnel.getTunnelId());
     207            long replyTunnel = 0;
     208            if (_replyTunnel != null)
     209                replyTunnel = _replyTunnel.getTunnelId();
     210            byte id[] = DataHelper.toLong(4, replyTunnel);
    206211            System.arraycopy(id, 0, out, curIndex, 4);
    207212            curIndex += 4;
  • router/java/src/net/i2p/router/RouterVersion.java

    r31bdb89 rb5784d6  
    1616 */
    1717public class RouterVersion {
    18     public final static String ID = "$Revision: 1.230 $ $Date: 2005/09/09 23:30:36 $";
     18    public final static String ID = "$Revision: 1.231 $ $Date: 2005/09/10 22:22:52 $";
    1919    public final static String VERSION = "0.6.0.5";
    20     public final static long BUILD = 5;
     20    public final static long BUILD = 6;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
  • router/java/src/net/i2p/router/StatisticsManager.java

    r31bdb89 rb5784d6  
    231231    }
    232232
    233     private String renderThroughput(double bytes, long ms) {
    234         if (bytes <= 0)
    235             return "0;0;0;0;";
    236         else
    237             return num(bytes/(ms/1000)) + ";0;0;0;";
    238     }
    239    
    240233    private void includeThroughput(Properties stats) {
    241         double sendBytes5m = 0;
    242         double sendBytes60m = 0;
    243         double recvBytes5m = 0;
    244         double recvBytes60m = 0;
    245        
    246         RateStat sendRate = _context.statManager().getRate("transport.sendMessageSize");
     234        RateStat sendRate = _context.statManager().getRate("bw.sendRate");
    247235        if (sendRate != null) {
    248236            Rate r = sendRate.getRate(5*60*1000);
    249237            if (r != null)
    250                 sendBytes5m = r.getLastTotalValue();
     238                stats.setProperty("stat_bandwidthSendBps.5m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;");
    251239            r = sendRate.getRate(60*60*1000);
    252240            if (r != null)
    253                 sendBytes60m = r.getLastTotalValue();
     241                stats.setProperty("stat_bandwidthSendBps.60m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;");
    254242        }
    255243       
    256         RateStat recvRate = _context.statManager().getRate("transport.receiveMessageSize");
     244        RateStat recvRate = _context.statManager().getRate("bw.recvRate");
    257245        if (recvRate != null) {
    258246            Rate r = recvRate.getRate(5*60*1000);
    259247            if (r != null)
    260                 recvBytes5m = r.getLastTotalValue();
     248                stats.setProperty("stat_bandwidthReceiveBps.5m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;");
    261249            r = recvRate.getRate(60*60*1000);
    262250            if (r != null)
    263                 recvBytes60m = r.getLastTotalValue();
    264         }
    265        
    266         String throughputRate = renderThroughput(sendBytes5m, 5*60*1000);
    267         stats.setProperty("stat_bandwidthSendBps.5m", throughputRate);
    268         //throughputRate = renderThroughput(sendBytes60m, 60*60*1000);
    269         //stats.setProperty("stat_bandwidthSendBps.60m", throughputRate);
    270         throughputRate = renderThroughput(recvBytes5m, 5*60*1000);
    271         stats.setProperty("stat_bandwidthReceiveBps.5m", throughputRate);
    272         //throughputRate = renderThroughput(recvBytes60m, 60*60*1000);
    273         //stats.setProperty("stat_bandwidthReceiveBps.60m", throughputRate);
     251                stats.setProperty("stat_bandwidthReceiveBps.60m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;");
     252        }
    274253    }
    275254
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java

    r31bdb89 rb5784d6  
    2323        _context.inNetMessagePool().registerHandlerJobBuilder(DatabaseLookupMessage.MESSAGE_TYPE, new FloodfillDatabaseLookupMessageHandler(_context));
    2424        _context.inNetMessagePool().registerHandlerJobBuilder(DatabaseStoreMessage.MESSAGE_TYPE, new FloodfillDatabaseStoreMessageHandler(_context, this));
     25    }
     26   
     27    private static final long PUBLISH_TIMEOUT = 30*1000;
     28   
     29    /**
     30     * @throws IllegalArgumentException if the local router info is invalid
     31     */
     32    public void publish(RouterInfo localRouterInfo) throws IllegalArgumentException {
     33        super.publish(localRouterInfo);
     34        sendStore(localRouterInfo.getIdentity().calculateHash(), localRouterInfo, null, null, PUBLISH_TIMEOUT, null);
    2535    }
    2636   
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java

    r31bdb89 rb5784d6  
    3535        peersToIgnore.add(_context.router().getRouterInfo().getIdentity().getHash());
    3636        FloodfillSelectionCollector matches = new FloodfillSelectionCollector(key, peersToIgnore, maxNumRouters);
     37        if (kbuckets == null) return new ArrayList();
    3738        kbuckets.getAll(matches);
    3839        List rv = matches.get(maxNumRouters);
     
    4546   
    4647    public List selectFloodfillParticipants(KBucketSet kbuckets) {
     48        if (kbuckets == null) return new ArrayList();
    4749        FloodfillSelectionCollector matches = new FloodfillSelectionCollector(null, null, 0);
    4850        kbuckets.getAll(matches);
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    r31bdb89 rb5784d6  
    99 */
    1010
    11 import java.util.Iterator;
    12 import java.util.List;
    13 import java.util.Set;
     11import java.util.*;
    1412
    1513import net.i2p.data.DataStructure;
     
    2220import net.i2p.router.Job;
    2321import net.i2p.router.JobImpl;
     22import net.i2p.router.OutNetMessage;
    2423import net.i2p.router.ReplyJob;
    2524import net.i2p.router.RouterContext;
     
    199198        //    _log.debug(getJobId() + ": Current routing key for " + key + ": " + rkey);
    200199
    201         return _peerSelector.selectNearestExplicit(rkey, numClosest, alreadyChecked, _facade.getKBuckets());
     200        KBucketSet ks = _facade.getKBuckets();
     201        if (ks == null) return new ArrayList();
     202        return _peerSelector.selectNearestExplicit(rkey, numClosest, alreadyChecked, ks);
    202203    }
    203204
     
    232233   
    233234    private void sendStore(DatabaseStoreMessage msg, RouterInfo peer, long expiration) {
    234         if (msg.getValueType() == DatabaseStoreMessage.KEY_TYPE_LEASESET)
     235        if (msg.getValueType() == DatabaseStoreMessage.KEY_TYPE_LEASESET) {
    235236            getContext().statManager().addRateData("netDb.storeLeaseSetSent", 1, 0);
    236         else
     237            sendStoreThroughGarlic(msg, peer, expiration);
     238        } else {
    237239            getContext().statManager().addRateData("netDb.storeRouterInfoSent", 1, 0);
    238         sendStoreThroughGarlic(msg, peer, expiration);
    239     }
    240 
     240            sendDirect(msg, peer, expiration);
     241        }
     242    }
     243
     244    private void sendDirect(DatabaseStoreMessage msg, RouterInfo peer, long expiration) {
     245        long token = getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE);
     246        msg.setReplyToken(token);
     247        msg.setReplyGateway(getContext().routerHash());
     248
     249        if (_log.shouldLog(Log.DEBUG))
     250            _log.debug(getJobId() + ": send(dbStore) w/ token expected " + token);
     251       
     252        _state.addPending(peer.getIdentity().getHash());
     253       
     254        SendSuccessJob onReply = new SendSuccessJob(getContext(), peer);
     255        FailedJob onFail = new FailedJob(getContext(), peer, getContext().clock().now());
     256        StoreMessageSelector selector = new StoreMessageSelector(getContext(), getJobId(), peer, token, expiration);
     257       
     258        if (_log.shouldLog(Log.DEBUG))
     259            _log.debug("sending store directly to " + peer.getIdentity().getHash());
     260        OutNetMessage m = new OutNetMessage(getContext());
     261        m.setExpiration(expiration);
     262        m.setMessage(msg);
     263        m.setOnFailedReplyJob(onFail);
     264        m.setOnFailedSendJob(onFail);
     265        m.setOnReplyJob(onReply);
     266        m.setPriority(STORE_PRIORITY);
     267        m.setReplySelector(selector);
     268        m.setTarget(peer);
     269        getContext().commSystem().processMessage(m);
     270    }
     271   
    241272    private void sendStoreThroughGarlic(DatabaseStoreMessage msg, RouterInfo peer, long expiration) {
    242273        long token = getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE);
  • router/java/src/net/i2p/router/transport/udp/IntroductionManager.java

    r31bdb89 rb5784d6  
    2727        _outbound = Collections.synchronizedMap(new HashMap(128));
    2828        _inbound = new ArrayList(128);
     29        ctx.statManager().createRateStat("udp.receiveRelayIntro", "How often we get a relayed request for us to talk to someone?", "udp", new long[] { 60*1000, 5*60*1000, 10*60*1000 });
    2930    }
    3031   
     
    8283   
    8384    public void receiveRelayIntro(RemoteHostId bob, UDPPacketReader reader) {
     85        _context.statManager().addRateData("udp.receiveRelayIntro", 1, 0);
    8486        _transport.send(_builder.buildHolePunch(reader));
    8587    }
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r31bdb89 rb5784d6  
    9898    public static final String PROP_FIXED_PORT = "i2np.udp.fixedPort";
    9999    private static final String DEFAULT_FIXED_PORT = "true";
    100    
     100
     101    /** do we require introducers, regardless of our status? */
     102    public static final String PROP_FORCE_INTRODUCERS = "i2np.udp.forceIntroducers";
     103       
    101104    /** how many relays offered to us will we use at a time? */
    102105    public static final int PUBLIC_RELAY_COUNT = 3;
     
    809812    }
    810813   
    811     public static final String PROP_FORCE_INTRODUCERS = "i2np.udp.forceIntroducers";
    812814    public boolean introducersRequired() {
    813815        String forceIntroducers = _context.getProperty(PROP_FORCE_INTRODUCERS);
Note: See TracChangeset for help on using the changeset viewer.