diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHandler.java index 345f17b0d678dfd0dcd4daaa69f6d8812dc7f6e7..88735e28628e94ca15d71b4436c41e6a700b6fba 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHandler.java @@ -7,6 +7,7 @@ import java.util.Properties; import java.util.Set; import net.i2p.data.DataHelper; +import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade; /** * Handler to deal with form submissions from the advanced config form and act @@ -83,6 +84,14 @@ public class ConfigAdvancedHandler extends FormHandler { /** @since 0.9.20 */ private void saveFF() { boolean saved = _context.router().saveConfig(ConfigAdvancedHelper.PROP_FLOODFILL_PARTICIPANT, _ff); + if (_ff.equals("false") || _ff.equals("true")) { + FloodfillNetworkDatabaseFacade fndf = (FloodfillNetworkDatabaseFacade) _context.netDb(); + boolean wasFF = fndf.floodfillEnabled(); + boolean isFF = _ff.equals("true"); + fndf.setFloodfillEnabled(isFF); + if (wasFF != isFF) + _context.router().rebuildRouterInfo(); + } if (saved) addFormNotice(_("Configuration saved successfully")); else diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHelper.java index c64cb2e5a976814cdb947bfce058cb247ada3446..0ee5c0b4f4a9952b33ef711d73f8949c871ca7c8 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHelper.java @@ -35,4 +35,9 @@ public class ConfigAdvancedHelper extends HelperBase { return CHECKED; return ""; } + + /** @since 0.9.21 */ + public boolean isFloodfill() { + return _context.netDb().floodfillEnabled(); + } } diff --git a/apps/routerconsole/jsp/configadvanced.jsp b/apps/routerconsole/jsp/configadvanced.jsp index 637020405e371f82e350f2330b3e474fbf273d05..961ac83fa82fcc96d393b3f8bf68d3d1a459f998 100644 --- a/apps/routerconsole/jsp/configadvanced.jsp +++ b/apps/routerconsole/jsp/configadvanced.jsp @@ -25,7 +25,16 @@ <div class="configure"> <div class="wideload"> <h3><%=intl._("Floodfill Configuration")%></h3> -<p><%=intl._("Floodill participation helps the network, but may use more of your computer's resources.")%></p> +<p><%=intl._("Floodill participation helps the network, but may use more of your computer's resources.")%> +</p><p> +<% + if (advancedhelper.isFloodfill()) { +%><%=intl._("This router is currently a floodfill participant.")%><% + } else { +%><%=intl._("This router is not currently a floodfill participant.")%><% + } +%> +</p> <form action="" method="POST"> <input type="hidden" name="nonce" value="<%=pageNonce%>" > <input type="hidden" name="action" value="ff" > diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index 68621597e741205c20279a281873f89e677d088f..b2029f923b7f0a317a6f2408a490cb9c7eb93064 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -72,6 +72,7 @@ public class Router implements RouterClock.ClockShiftListener { /** full path */ private String _configFilename; private RouterInfo _routerInfo; + private final Object _routerInfoLock = new Object(); /** not for external use */ public final Object routerInfoFileLock = new Object(); private final Object _configFileLock = new Object(); @@ -489,14 +490,20 @@ public class Router implements RouterClock.ClockShiftListener { * Our current router info. * Warning, may be null if called very early. */ - public RouterInfo getRouterInfo() { return _routerInfo; } + public RouterInfo getRouterInfo() { + synchronized (_routerInfoLock) { + return _routerInfo; + } + } /** * Caller must ensure info is valid - no validation done here. * Not for external use. */ public void setRouterInfo(RouterInfo info) { - _routerInfo = info; + synchronized (_routerInfoLock) { + _routerInfo = info; + } if (_log.shouldLog(Log.INFO)) _log.info("setRouterInfo() : " + info, new Exception("I did it")); if (info != null) @@ -817,7 +824,17 @@ public class Router implements RouterClock.ClockShiftListener { public void rebuildRouterInfo(boolean blockingRebuild) { if (_log.shouldLog(Log.INFO)) _log.info("Rebuilding new routerInfo"); + synchronized (_routerInfoLock) { + locked_rebuildRouterInfo(blockingRebuild); + } + } + + /** + * Rebuild and republish our routerInfo since something significant + * has changed. + */ + private void locked_rebuildRouterInfo(boolean blockingRebuild) { RouterInfo ri = null; if (_routerInfo != null) ri = new RouterInfo(_routerInfo); @@ -957,7 +974,10 @@ public class Router implements RouterClock.ClockShiftListener { } public boolean isHidden() { - RouterInfo ri = _routerInfo; + RouterInfo ri; + synchronized (_routerInfoLock) { + ri = _routerInfo; + } if ( (ri != null) && (ri.isHidden()) ) return true; String h = _context.getProperty(PROP_HIDDEN_HIDDEN); diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java index a02013a5f82fe1049ab39617f6dd6f9c09c278e7..de0a6639f568d83898bf9c94b6961ff002ad8878 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java @@ -277,7 +277,7 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad @Override protected PeerSelector createPeerSelector() { return new FloodfillPeerSelector(_context); } - synchronized void setFloodfillEnabled(boolean yes) { + public synchronized void setFloodfillEnabled(boolean yes) { _floodfillEnabled = yes; if (yes && _floodThrottler == null) { _floodThrottler = new FloodThrottler();