forked from I2P_Developers/i2p.i2p
Sybil: Register blocklist version with update manager
Fix "very close" message when configured for all routers
This commit is contained in:
@@ -117,6 +117,7 @@ public class Blocklist {
|
||||
private static final String ID_LOCAL = "local";
|
||||
private static final String ID_COUNTRY = "country";
|
||||
private static final String ID_USER = "user";
|
||||
public static final String ID_SYBIL = "sybil";
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -499,6 +499,7 @@ public class Analysis extends JobImpl implements RouterApp {
|
||||
}
|
||||
|
||||
double avg = total / (sz * sz / 2d);
|
||||
String other = _context.getBooleanProperty(PROP_NONFF) ? "router" : "floodfill";
|
||||
for (Pair p : pairs) {
|
||||
double distance = biLog2(p.dist);
|
||||
double point = MIN_CLOSE - distance;
|
||||
@@ -507,10 +508,10 @@ public class Analysis extends JobImpl implements RouterApp {
|
||||
point *= PAIR_DISTANCE_FACTOR;
|
||||
String b2 = p.r2.getHash().toBase64();
|
||||
addPoints(points, p.r1.getHash(), point, "Very close (" + fmt.format(distance) +
|
||||
") to other floodfill <a href=\"netdb?r=" + b2 + "\">" + b2 + "</a>");
|
||||
") to other " + other + " <a href=\"netdb?r=" + b2 + "\">" + b2 + "</a>");
|
||||
String b1 = p.r1.getHash().toBase64();
|
||||
addPoints(points, p.r2.getHash(), point, "Very close (" + fmt.format(distance) +
|
||||
") to other floodfill <a href=\"netdb?r=" + b1 + "\">" + b1 + "</a>");
|
||||
") to other " + other + " <a href=\"netdb?r=" + b1 + "\">" + b1 + "</a>");
|
||||
}
|
||||
return avg;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ import net.i2p.data.Base64;
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.router.Blocklist;
|
||||
import net.i2p.update.UpdateManager;
|
||||
import net.i2p.update.UpdateType;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.FileSuffixFilter;
|
||||
import net.i2p.util.SecureDirectory;
|
||||
@@ -241,7 +244,10 @@ public class PersistSybil {
|
||||
Map<String, Long> readBlocklist() {
|
||||
File f = new File(_context.getConfigDir(), SDIR);
|
||||
f = new File(f, BLOCKLIST_SYBIL_FILE);
|
||||
return readBlocklist(f);
|
||||
Map<String, Long> rv = readBlocklist(f);
|
||||
if (rv != null)
|
||||
notifyVersion(f.lastModified());
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,6 +325,7 @@ public class PersistSybil {
|
||||
out.write(e.getValue().toString());
|
||||
out.write('\n');
|
||||
}
|
||||
notifyVersion(_context.clock().now());
|
||||
} catch (IOException ioe) {
|
||||
if (_log.shouldWarn())
|
||||
_log.warn("Error writing the blocklist file", ioe);
|
||||
@@ -327,6 +334,18 @@ public class PersistSybil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.9.50
|
||||
*/
|
||||
private void notifyVersion(long v) {
|
||||
ClientAppManager cmgr = _context.clientAppManager();
|
||||
if (cmgr != null) {
|
||||
UpdateManager umgr = (UpdateManager) cmgr.getRegisteredApp(UpdateManager.APP_NAME);
|
||||
if (umgr != null)
|
||||
umgr.notifyInstalled(UpdateType.BLOCKLIST, Blocklist.ID_SYBIL, Long.toString(v));
|
||||
}
|
||||
}
|
||||
|
||||
/****
|
||||
public static void main(String[] args) {
|
||||
I2PAppContext ctx = I2PAppContext.getGlobalContext();
|
||||
|
||||
Reference in New Issue
Block a user