Changeset 89bdbed


Ignore:
Timestamp:
Dec 12, 2015 12:43:22 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
cddc1b3
Parents:
3a4e82f
Message:

Sybil: Add start of profile analysis, use for first-heard-about time
Increase pair-distance threat points

File:
1 edited

Legend:

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

    r3a4e82f r89bdbed  
    5959    private static final double POINTS_FAMILY = -2.0;
    6060    private static final double MIN_CLOSE = 242.0;
     61    private static final double PAIR_DISTANCE_FACTOR = 2.0;
    6162    private static final double OUR_KEY_FACTOR = 4.0;
    6263    private static final double MIN_DISPLAY_POINTS = 3.0;
     
    222223        }
    223224
    224         // TODO Profile analysis
     225        // Profile analysis
     226        addProfilePoints(ris, points);
    225227
    226228        if (!points.isEmpty()) {
     
    300302                renderRouterInfo(buf, p.r2, null, false, false);
    301303            }
     304            point *= PAIR_DISTANCE_FACTOR;
    302305            String b2 = p.r2.getHash().toBase64();
    303306            addPoints(points, p.r1.getHash(), point, "Very close (" + fmt.format(distance) +
     
    585588        out.flush();
    586589        buf.setLength(0);
     590    }
     591
     592    private static final long DAY = 24*60*60*1000L;
     593
     594    private void addProfilePoints(List<RouterInfo> ris, Map<Hash, Points> points) throws IOException {
     595        long now = _context.clock().now();
     596        for (RouterInfo info : ris) {
     597            Hash h = info.getHash();
     598            PeerProfile prof = _context.profileOrganizer().getProfileNonblocking(h);
     599            if (prof != null) {
     600                long heard = prof.getFirstHeardAbout();
     601                if (heard > 0) {
     602                    long age = Math.max(now - heard, 1);
     603                    if (age < DAY) {
     604                        // .125 point for every hour under 24, max 3 points
     605                        double point = Math.min(3.0d, (DAY - age) / (DAY / 3.0d));
     606                        addPoints(points, h, point,
     607                                  "First heard about: " + _t("{0} ago", DataHelper.formatDuration2(age)));
     608                    }
     609                }
     610            }
     611        }
    587612    }
    588613
Note: See TracChangeset for help on using the changeset viewer.