From b19999f95a422ce40fe4f5f50ade6d5c70203648 Mon Sep 17 00:00:00 2001
From: zzz <zzz@i2pmail.org>
Date: Thu, 14 Jan 2021 09:46:38 -0500
Subject: [PATCH] Router: Move Sybil subsystem from console to router

---
 apps/routerconsole/java/bundle-messages.sh               | 1 +
 .../java/src/net/i2p/router/web/RouterConsoleRunner.java | 9 ---------
 build.xml                                                | 2 +-
 router/java/src/net/i2p/router/Router.java               | 7 +++++++
 .../java/src/net/i2p/router/sybil/Analysis.java          | 8 +++++---
 .../java/src/net/i2p/router/sybil/Pair.java              | 0
 .../java/src/net/i2p/router/sybil/PersistSybil.java      | 1 -
 .../java/src/net/i2p/router/sybil/Points.java            | 0
 .../java/src/net/i2p/router/sybil/Util.java              | 0
 .../java/src/net/i2p/router/sybil/package.html           | 1 +
 10 files changed, 15 insertions(+), 14 deletions(-)
 rename {apps/routerconsole => router}/java/src/net/i2p/router/sybil/Analysis.java (99%)
 rename {apps/routerconsole => router}/java/src/net/i2p/router/sybil/Pair.java (100%)
 rename {apps/routerconsole => router}/java/src/net/i2p/router/sybil/PersistSybil.java (99%)
 rename {apps/routerconsole => router}/java/src/net/i2p/router/sybil/Points.java (100%)
 rename {apps/routerconsole => router}/java/src/net/i2p/router/sybil/Util.java (100%)
 rename {apps/routerconsole => router}/java/src/net/i2p/router/sybil/package.html (77%)

diff --git a/apps/routerconsole/java/bundle-messages.sh b/apps/routerconsole/java/bundle-messages.sh
index 6f06291210..ba08c7f1e4 100755
--- a/apps/routerconsole/java/bundle-messages.sh
+++ b/apps/routerconsole/java/bundle-messages.sh
@@ -40,6 +40,7 @@ fi
 ROUTERFILES="\
    ../../../router/java/src/net/i2p/router/Blocklist.java \
    ../../../router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java \
+   ../../../router/java/src/net/i2p/router/sybil/Analysis.java \
    ../../../router/java/src/net/i2p/router/tasks/CoalesceStatsEvent.java \
    ../../../router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java \
    ../../../router/java/src/net/i2p/router/transport/GetBidsJob.java \
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java b/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java
index 7b0e7481ef..9101a5495d 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java
@@ -35,7 +35,6 @@ import net.i2p.jetty.I2PLogger;
 import net.i2p.router.RouterContext;
 import net.i2p.router.app.RouterApp;
 import net.i2p.router.news.NewsManager;
-import net.i2p.router.sybil.Analysis;
 import net.i2p.router.update.ConsoleUpdateManager;
 import net.i2p.util.Addresses;
 import net.i2p.util.FileSuffixFilter;
@@ -901,14 +900,6 @@ public class RouterConsoleRunner implements RouterApp {
             if (_mgr == null)
                 _context.addShutdownTask(new ServerShutdown());
             ConfigServiceHandler.registerSignalHandler(_context);
-
-            if (_mgr != null &&
-                //_context.getBooleanProperty(HelperBase.PROP_ADVANCED) &&
-                !SystemVersion.isSlow() &&
-                _context.getProperty(Analysis.PROP_FREQUENCY, Analysis.DEFAULT_FREQUENCY) > 0) {
-                // registers and starts itself
-                Analysis.getInstance(_context);
-            }
     }
     
     /**
diff --git a/build.xml b/build.xml
index e68e5b240f..ab85e1d56f 100644
--- a/build.xml
+++ b/build.xml
@@ -973,7 +973,7 @@
             <group title="Core SDK (i2p.jar)" packages="net.i2p:net.i2p.*:net.i2p.client:net.i2p.client.*:net.i2p.internal:net.i2p.internal.*:freenet.support.CPUInformation:gnu.crypto.*:gnu.getopt:gnu.gettext:com.nettgryppa.security:org.apache.http.conn.ssl:org.apache.http.conn.util:org.apache.http.util:org.json.simple:com.southernstorm.noise.crypto.x25519:com.southernstorm.noise.crypto.chacha20:org.minidns:org.minidns.*" />
             <group title="Streaming Library" packages="net.i2p.client.streaming:net.i2p.client.streaming.impl" />
             <group title="Router" packages="net.i2p.router:net.i2p.router.*:net.i2p.data.i2np:net.i2p.data.router:org.cybergarage:org.cybergarage.*:org.freenetproject:org.xlattice.crypto.filters:com.maxmind.*:com.southernstorm.noise.*" />
-            <group title="Router Console" packages="net.i2p.router.web:net.i2p.router.web.*:net.i2p.router.update:net.i2p.router.sybil:edu.internet2.ndt:net.i2p.router.news:com.vuze.*" />
+            <group title="Router Console" packages="net.i2p.router.web:net.i2p.router.web.*:net.i2p.router.update:edu.internet2.ndt:net.i2p.router.news:com.vuze.*" />
             <!-- apps and bridges starting here, alphabetical please -->
             <group title="Addressbook Application" packages="net.i2p.addressbook:net.i2p.router.naming:net.metanotion:net.metanotion.*" />
             <group title="BOB Bridge" packages="net.i2p.BOB" />
diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java
index 201729b7b6..bd1c2e98f6 100644
--- a/router/java/src/net/i2p/router/Router.java
+++ b/router/java/src/net/i2p/router/Router.java
@@ -50,6 +50,7 @@ import net.i2p.router.startup.CreateRouterInfoJob;
 import net.i2p.router.startup.PortableWorkingDir;
 import net.i2p.router.startup.StartupJob;
 import net.i2p.router.startup.WorkingDir;
+import net.i2p.router.sybil.Analysis;
 import net.i2p.router.tasks.*;
 import net.i2p.router.transport.FIFOBandwidthLimiter;
 import net.i2p.router.transport.UPnPScannerCallback;
@@ -928,6 +929,12 @@ public class Router implements RouterClock.ClockShiftListener {
             // but just to be safe
             _context.simpleTimer2().addEvent(r, 0);
             _context.commSystem().initGeoIP();
+
+            if (!SystemVersion.isSlow() &&
+                _context.getProperty(Analysis.PROP_FREQUENCY, Analysis.DEFAULT_FREQUENCY) > 0) {
+                // registers and starts itself
+                Analysis.getInstance(_context);
+            }
         }
     }
 
diff --git a/apps/routerconsole/java/src/net/i2p/router/sybil/Analysis.java b/router/java/src/net/i2p/router/sybil/Analysis.java
similarity index 99%
rename from apps/routerconsole/java/src/net/i2p/router/sybil/Analysis.java
rename to router/java/src/net/i2p/router/sybil/Analysis.java
index cf4a1856cb..fc826406b8 100644
--- a/apps/routerconsole/java/src/net/i2p/router/sybil/Analysis.java
+++ b/router/java/src/net/i2p/router/sybil/Analysis.java
@@ -33,7 +33,6 @@ import net.i2p.router.peermanager.DBHistory;
 import net.i2p.router.peermanager.PeerProfile;
 import net.i2p.router.tunnel.pool.TunnelPool;
 import net.i2p.router.util.HashDistance;
-import net.i2p.router.web.Messages;
 import net.i2p.stat.Rate;
 import net.i2p.stat.RateAverages;
 import net.i2p.stat.RateStat;
@@ -41,6 +40,7 @@ import net.i2p.util.Addresses;
 import net.i2p.util.Log;
 import net.i2p.util.ObjectCounter;
 import net.i2p.util.SystemVersion;
+import net.i2p.util.Translate;
 
 /**
  *
@@ -843,8 +843,10 @@ public class Analysis extends JobImpl implements RouterApp {
         return Util.biLog2(a);
     }
 
+    private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
+
     private String _t(String s) {
-        return Messages.getString(s, _context);
+        return Translate.getString(s, _context, BUNDLE_NAME);
     }
 
     /**
@@ -860,6 +862,6 @@ public class Analysis extends JobImpl implements RouterApp {
      *    Use autoboxing to call with ints, longs, floats, etc.
      */
     private String _t(String s, Object o) {
-        return Messages.getString(s, o, _context);
+        return Translate.getString(s, o, _context, BUNDLE_NAME);
     }
 }
diff --git a/apps/routerconsole/java/src/net/i2p/router/sybil/Pair.java b/router/java/src/net/i2p/router/sybil/Pair.java
similarity index 100%
rename from apps/routerconsole/java/src/net/i2p/router/sybil/Pair.java
rename to router/java/src/net/i2p/router/sybil/Pair.java
diff --git a/apps/routerconsole/java/src/net/i2p/router/sybil/PersistSybil.java b/router/java/src/net/i2p/router/sybil/PersistSybil.java
similarity index 99%
rename from apps/routerconsole/java/src/net/i2p/router/sybil/PersistSybil.java
rename to router/java/src/net/i2p/router/sybil/PersistSybil.java
index 5e72aacd08..a79d1a0e84 100644
--- a/apps/routerconsole/java/src/net/i2p/router/sybil/PersistSybil.java
+++ b/router/java/src/net/i2p/router/sybil/PersistSybil.java
@@ -23,7 +23,6 @@ import net.i2p.data.Base64;
 import net.i2p.data.DataFormatException;
 import net.i2p.data.DataHelper;
 import net.i2p.data.Hash;
-import net.i2p.router.web.helpers.SybilRenderer;
 import net.i2p.util.Log;
 import net.i2p.util.FileSuffixFilter;
 import net.i2p.util.SecureDirectory;
diff --git a/apps/routerconsole/java/src/net/i2p/router/sybil/Points.java b/router/java/src/net/i2p/router/sybil/Points.java
similarity index 100%
rename from apps/routerconsole/java/src/net/i2p/router/sybil/Points.java
rename to router/java/src/net/i2p/router/sybil/Points.java
diff --git a/apps/routerconsole/java/src/net/i2p/router/sybil/Util.java b/router/java/src/net/i2p/router/sybil/Util.java
similarity index 100%
rename from apps/routerconsole/java/src/net/i2p/router/sybil/Util.java
rename to router/java/src/net/i2p/router/sybil/Util.java
diff --git a/apps/routerconsole/java/src/net/i2p/router/sybil/package.html b/router/java/src/net/i2p/router/sybil/package.html
similarity index 77%
rename from apps/routerconsole/java/src/net/i2p/router/sybil/package.html
rename to router/java/src/net/i2p/router/sybil/package.html
index a1219ceb5c..f8f7e6150b 100644
--- a/apps/routerconsole/java/src/net/i2p/router/sybil/package.html
+++ b/router/java/src/net/i2p/router/sybil/package.html
@@ -5,5 +5,6 @@ store and load the results.
 </p>
 <p>
 Since 0.9.38.
+Moved from console to router in 0.9.49.
 </p>
 </body></html>
-- 
GitLab