From ecb3e2a1154abcbfde1fc9124de78c3f66442ecc Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Fri, 4 Aug 2023 17:35:29 -0400 Subject: [PATCH] Router: Don't publish local RI unless dbid is floodfill --- .../FloodfillNetworkDatabaseSegmentor.java | 5 +++- .../KademliaNetworkDatabaseFacade.java | 30 ++++++++++--------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseSegmentor.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseSegmentor.java index 0959f566b0..ac5fc7f84a 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseSegmentor.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseSegmentor.java @@ -111,7 +111,10 @@ public synchronized void shutdown() { * @throws IllegalArgumentException if the local router info is invalid */ public void publish(RouterInfo localRouterInfo) throws IllegalArgumentException { - floodfillNetDB().publish(localRouterInfo); + if (localRouterInfo == null) + throw new IllegalArgumentException("localRouterInfo must not be null"); + if (localRouterInfo.getReceivedBy() == null) + floodfillNetDB().publish(localRouterInfo); } /** diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java index 033a4e70a0..a11760416a 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java @@ -359,21 +359,23 @@ public synchronized void startup() { _log.warn("Operating in quiet mode - not exploring or pushing data proactively, simply reactively"); _log.warn("This should NOT be used in production"); } - // periodically update and resign the router's 'published date', which basically - // serves as a version - Job plrij = new PublishLocalRouterInfoJob(_context); - // do not delay this, as this creates the RI too, and we need a good local routerinfo right away - //plrij.getTiming().setStartAfter(_context.clock().now() + PUBLISH_JOB_DELAY); - _context.jobQueue().addJob(plrij); + if (_dbid == null || _dbid.equals("floodfill") || _dbid.isEmpty()) { + // periodically update and resign the router's 'published date', which basically + // serves as a version + Job plrij = new PublishLocalRouterInfoJob(_context); + // do not delay this, as this creates the RI too, and we need a good local routerinfo right away + //plrij.getTiming().setStartAfter(_context.clock().now() + PUBLISH_JOB_DELAY); + _context.jobQueue().addJob(plrij); - // plrij calls publish() for us - //try { - // publish(ri); - //} catch (IllegalArgumentException iae) { - // _context.router().rebuildRouterInfo(true); - // //_log.log(Log.CRIT, "Our local router info is b0rked, clearing from scratch", iae); - // //_context.router().rebuildNewIdentity(); - //} + // plrij calls publish() for us + //try { + // publish(ri); + //} catch (IllegalArgumentException iae) { + // _context.router().rebuildRouterInfo(true); + // //_log.log(Log.CRIT, "Our local router info is b0rked, clearing from scratch", iae); + // //_context.router().rebuildNewIdentity(); + //} + } } /** unused, see override */