Author: toad
Date: 2008-11-06 19:18:47 +0000 (Thu, 06 Nov 2008)
New Revision: 23361

Modified:
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/NodeIPDetector.java
   trunk/freenet/src/freenet/node/useralerts/IPUndetectedUserAlert.java
Log:
Tell the user if don't know IP and no IP detection plugins loaded.


Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-11-06 
18:49:03 UTC (rev 23360)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-11-06 
19:18:47 UTC (rev 23361)
@@ -523,6 +523,8 @@
 IPUndetectedUserAlert.detecting=Freenet is currently attempting to detect your 
external IP address. If this takes more than a few minutes there is something 
wrong...
 IPUndetectedUserAlert.detectingShort=Freenet is currently attempting to detect 
your external IP address.
 IPUndetectedUserAlert.detectingWithConfigLink=Freenet is currently attempting 
to detect your external IP address. If this takes more than a few minutes there 
is something wrong and you can use the Temporary IP Address Hint 
${link}configuration parameter${/link}.
+IPUndetectedUserAlert.loadDetectPlugins=Freenet is unable to detect your 
external IP address, and no IP detection plugins are currently loaded. It will 
be very difficult for Freenet to connect to other nodes. Please go to the 
${plugins}Plugins page${/plugins} and load the UPnP and JSTUN plugins. 
Alternatively if you have a static IP address or domain name, please tell 
Freenet about it using the "IP address override" option on the 
${config}configuration page${/config}.
+IPUndetectedUserAlert.noDetectorPlugins=Freenet is unable to detect your IP 
address! Please load the UPnP and JSTUN plugins!
 IPUndetectedUserAlert.unknownAddress=Freenet was unable to determine your 
external IP address (or the IP address of your NAT or Firewall). You can still 
exchange references with other people, however this will only work if the other 
user is not behind a NAT or Firewall. As soon as you have connected to one 
other user in this way, Freenet will be able to determine your external IP 
address. You can determine your current IP address and tell your node with the 
'Temporary IP address hint' ${link}configuration parameter${/link}.
 IPUndetectedUserAlert.unknownAddressTitle=Unknown external address
 IPUndetectedUserAlert.unknownAddressWithConfigLink=Freenet was unable to 
determine your external IP address (or the IP address of your NAT-device or 
firewall). You can still exchange references with other people, however this 
will only work if the other user is not behind a NAT-device or firewall. As 
soon as you have connected to one other user in this way, Freenet will be able 
to determine your external IP address. You can determine your current IP 
address and tell your node with the 'Temporary IP address hint' 
${link}configuration parameter${/link}.

Modified: trunk/freenet/src/freenet/node/NodeIPDetector.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeIPDetector.java  2008-11-06 18:49:03 UTC 
(rev 23360)
+++ trunk/freenet/src/freenet/node/NodeIPDetector.java  2008-11-06 19:18:47 UTC 
(rev 23361)
@@ -69,6 +69,7 @@
        /** Subsidiary detectors: NodeIPPortDetector's which rely on this 
object */
        private NodeIPPortDetector[] portDetectors;
        private boolean hasValidIP;
+       private boolean firstDetection = true;

        SimpleUserAlert maybeSymmetricAlert;

@@ -112,20 +113,28 @@
                        addedValidIP |= innerDetect(addresses);
                }

+               boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
                if(node.clientCore != null) {
                        boolean hadValidIP;
                        synchronized(this) {
                                hadValidIP = hasValidIP;
                                hasValidIP = addedValidIP;
+                               if(firstDetection) {
+                                       hadValidIP = !addedValidIP;
+                                       firstDetection = false;
+                               }
                        }
                        if(hadValidIP != addedValidIP) {
                                if (addedValidIP) {
+                                       if(logMINOR) Logger.minor(this, "Got 
valid IP");
                                        onAddedValidIP();
                                } else {
+                                       if(logMINOR) Logger.minor(this, "No 
valid IP");
                                        onNotAddedValidIP();
                                }
                        }
-               }
+               } else if(logMINOR)
+                       Logger.minor(this, "Client core not loaded");
                synchronized(this) {
                        hasValidIP = addedValidIP;
                }
@@ -566,4 +575,8 @@
        public void addConnectionTypeBox(HTMLNode contentNode) {
                ipDetectorManager.addConnectionTypeBox(contentNode);
        }
+
+       public boolean noDetectPlugins() {
+               return !ipDetectorManager.hasDetectors();
+       }
 }

Modified: trunk/freenet/src/freenet/node/useralerts/IPUndetectedUserAlert.java
===================================================================
--- trunk/freenet/src/freenet/node/useralerts/IPUndetectedUserAlert.java        
2008-11-06 18:49:03 UTC (rev 23360)
+++ trunk/freenet/src/freenet/node/useralerts/IPUndetectedUserAlert.java        
2008-11-06 19:18:47 UTC (rev 23361)
@@ -25,6 +25,8 @@

        @Override
        public String getText() {
+               if(node.ipDetector.noDetectPlugins())
+                       return l10n("noDetectorPlugins");
                if(node.ipDetector.isDetecting())
                        return l10n("detecting");
                else
@@ -45,10 +47,15 @@

        @Override
        public HTMLNode getHTMLText() {
+               if(node.ipDetector.noDetectPlugins()) {
+                       HTMLNode p = new HTMLNode("p");
+                       L10n.addL10nSubstitution(p, 
"IPUndetectedUserAlert.loadDetectPlugins", new String[] { "plugins", 
"/plugins", "config", "/config" }, new String[] { "<a href=\"/plugins/\">", 
"</a>", "<a href=\"/config/\">", "</a>" });
+                       return p;
+               }
+               HTMLNode textNode = new HTMLNode("div");
                SubConfig sc = node.config.get("node");
                Option<?> o = sc.getOption("tempIPAddressHint");

-               HTMLNode textNode = new HTMLNode("div");
                L10n.addL10nSubstitution(textNode, 
"IPUndetectedUserAlert."+(node.ipDetector.isDetecting() ? 
"detectingWithConfigLink" : "unknownAddressWithConfigLink"), 
                                new String[] { "link", "/link" }, 
                                new String[] { "<a href=\"/config/\">", "</a>" 
});
@@ -98,6 +105,8 @@

        @Override
        public String getShortText() {
+               if(node.ipDetector.noDetectPlugins())
+                       return l10n("noDetectorPlugins");
                if(node.ipDetector.isDetecting())
                        return l10n("detectingShort");
                else


Reply via email to