Changeset c8a46da


Ignore:
Timestamp:
Aug 29, 2012 1:45:29 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
832d66b
Parents:
7005376
Message:

i2psnark:

  • Add new flood-resistant KBucket trim policy
  • Limit received MsgID size
Location:
apps/i2psnark/java/src/org/klomp/snark/dht
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/dht/DHTNodes.java

    r7005376 rc8a46da  
    4747    /** Buckets older than this are refreshed - BEP 5 says 15 minutes */
    4848    private static final long MAX_BUCKET_AGE = 15*60*1000;
     49    private static final int KAD_K = 8;
     50    private static final int KAD_B = 1;
    4951
    5052    public DHTNodes(I2PAppContext ctx, NID me) {
     
    5355        _log = _context.logManager().getLog(DHTNodes.class);
    5456        _nodeMap = new ConcurrentHashMap();
    55         _kad = new KBucketSet(ctx, me, 8, 1);
     57        _kad = new KBucketSet(ctx, me, KAD_K, KAD_B, new KBTrimmer(ctx, KAD_K));
    5658    }
    5759
  • apps/i2psnark/java/src/org/klomp/snark/dht/MsgID.java

    r7005376 rc8a46da  
    1515class MsgID extends ByteArray {
    1616
     17    /** BEP 5: 2 bytes, incremented */
    1718    private static final int MY_TOK_LEN = 8;
     19    private static final int MAX_TOK_LEN = 16;
    1820
    1921    /** outgoing - generate a random ID */
     
    2931    public MsgID(byte[] data) {
    3032        super(data);
     33        // lets not get carried away
     34        if (data.length > MAX_TOK_LEN)
     35            throw new IllegalArgumentException();
    3136    }
    3237}
Note: See TracChangeset for help on using the changeset viewer.