Changeset 258d01f


Ignore:
Timestamp:
Aug 20, 2008 2:58:45 PM (13 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
33e8abf
Parents:
49af13a
Message:
  • Blocklists: Handle blank lines and \r\n in blocklist.txt
  • NTCP: Add connection limit, set by i2np.ntcp.maxConnections, default is 500 (very high for now)
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r49af13a r258d01f  
     12008-08-20 zzz
     2    * Blocklists: Handle blank lines and \r\n in blocklist.txt
     3    * NTCP: Add connection limit, set by i2np.ntcp.maxConnections,
     4      default is 500 (very high for now)
     5
    162008-08-13 zzz
    27    * i2psnark: Fix OOM vulnerability by checking incoming message length
  • router/java/src/net/i2p/router/Blocklist.java

    r49af13a r258d01f  
    276276        int start1 = 0;
    277277        int end1 = buf.length();
     278        if (end1 <= 0)
     279            return null;  // blank
     280        if (buf.charAt(end1 - 1) == '\r') {  // DataHelper.readLine leaves the \r on there
     281            buf.deleteCharAt(end1 - 1);
     282            end1--;
     283        }
     284        if (end1 <= 0)
     285            return null;  // blank
    278286        int start2 = -1;
    279287        int mask = -1;
     
    303311            }
    304312        }
     313        if (end1 - start1 <= 0)
     314            return null;  // blank
    305315        try {
    306316            InetAddress pi = InetAddress.getByName(buf.substring(start1, end1));
  • router/java/src/net/i2p/router/RouterVersion.java

    r49af13a r258d01f  
    1818    public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $";
    1919    public final static String VERSION = "0.6.2";
    20     public final static long BUILD = 12;
     20    public final static long BUILD = 13;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
  • router/java/src/net/i2p/router/transport/ntcp/EventPumper.java

    r49af13a r258d01f  
    384384            SocketChannel chan = servChan.accept();
    385385            chan.configureBlocking(false);
     386
     387            if (!_transport.allowConnection()) {
     388                if (_log.shouldLog(Log.WARN))
     389                    _log.warn("Receive session request but at connection limit: " + chan.socket().getInetAddress());
     390                try { chan.close(); } catch (IOException ioe) { }
     391                return;
     392            }
     393
    386394            if (_context.blocklist().isBlocklisted(chan.socket().getInetAddress().getAddress())) {
    387395                if (_log.shouldLog(Log.WARN))
     
    392400                return;
    393401            }
     402
    394403            SelectionKey ckey = chan.register(_selector, SelectionKey.OP_READ);
    395404            NTCPConnection con = new NTCPConnection(_context, _transport, chan, ckey);
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    r49af13a r258d01f  
    287287        }
    288288       
     289        if (!allowConnection()) {
     290            if (_log.shouldLog(Log.WARN))
     291                _log.warn("no bid when trying to send to " + toAddress.getIdentity().calculateHash().toBase64() + ", max connection limit reached");
     292            return null;
     293        }
     294
    289295        //if ( (_myAddress != null) && (_myAddress.equals(addr)) )
    290296        //    return null; // dont talk to yourself
     
    295301    }
    296302   
     303    private static final int DEFAULT_MAX_CONNECTIONS = 500;
     304    public boolean allowConnection() {
     305        int max = DEFAULT_MAX_CONNECTIONS;
     306        String mc = _context.getProperty("i2np.ntcp.maxConnections");
     307        if (mc != null) {
     308            try {
     309                  max = Integer.parseInt(mc);
     310            } catch (NumberFormatException nfe) {}
     311        }
     312        return countActivePeers() < max;
     313    }
     314
     315
    297316    void sendComplete(OutNetMessage msg) { _finisher.add(msg); }
    298317    /** async afterSend call, which can take some time w/ jobs, etc */
Note: See TracChangeset for help on using the changeset viewer.