From e3435dce103bd4c6b5ec18a3838e23a00d5ffe8b Mon Sep 17 00:00:00 2001 From: zzz Date: Fri, 25 Nov 2016 13:54:17 +0000 Subject: [PATCH] sybil tweaks --- .../src/net/i2p/router/web/SybilRenderer.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/SybilRenderer.java b/apps/routerconsole/java/src/net/i2p/router/web/SybilRenderer.java index 56d693e9b8..9ce3419986 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/SybilRenderer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/SybilRenderer.java @@ -16,7 +16,6 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import net.i2p.data.Base64; import net.i2p.data.DataHelper; import net.i2p.data.Destination; import net.i2p.data.Hash; @@ -35,6 +34,7 @@ import net.i2p.router.util.HashDistance; import net.i2p.stat.Rate; import net.i2p.stat.RateAverages; import net.i2p.stat.RateStat; +import net.i2p.util.ConvertToHash; import net.i2p.util.Log; import net.i2p.util.ObjectCounter; import net.i2p.util.Translate; @@ -921,7 +921,8 @@ class SybilRenderer { Collections.sort(sybils, xor); Hash prev = null; for (Hash h : sybils) { - out.write("" + h.toBase64() + ""); + String hh = h.toBase64(); + out.write("" + hh + ""); if (prev != null) { BigInteger dist = HashDistance.getDistance(prev, h); writeDistance(out, fmt, dist); @@ -937,20 +938,23 @@ class SybilRenderer { final int days = 7; Hash from = ctx.routerHash(); if (victim != null) { - byte[] b = Base64.decode(victim); - if (b != null && b.length == Hash.HASH_LENGTH) - from = Hash.create(b); + Hash v = ConvertToHash.getHash(victim); + if (v != null) + from = v; } out.write("

Distance to " + from.toBase64() + "

"); prev = null; + final int limit = Math.min(10, sybils.size()); for (int i = 0; i < days; i++) { out.write("

Distance for " + new Date(now) + "

\n"); Hash rkey = rkgen.getRoutingKey(from, now); xor = new XORComparator(rkey); Collections.sort(sybils, xor); - for (Hash h : sybils) { - out.write("
HashDistanceDistance from previous
" + h.toBase64() + ""); + for (int j = 0; j < limit; j++) { + Hash h = sybils.get(j); + String hh = h.toBase64(); + out.write("
" + hh + ""); BigInteger dist = HashDistance.getDistance(rkey, h); writeDistance(out, fmt, dist); out.write("");