Author: toad
Date: 2008-09-02 17:44:41 +0000 (Tue, 02 Sep 2008)
New Revision: 22356

Modified:
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/Announcer.java
Log:
Clarify wording in announcement warning slightly.
Tell the user when we are not announcing yet because we don't know our IP 
address yet.
Announcement-related logging.


Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-09-02 
16:57:38 UTC (rev 22355)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-09-02 
17:44:41 UTC (rev 22356)
@@ -1,5 +1,5 @@
 testing.test=test$(test1)test$(test2)test
-Announcer.announceAlertIntro=Freenet is connecting to the network - this may 
take a few minutes. Performance will continue to improve during the next few 
hours. This will happen each time you restart Freenet, so try to leave it 
running 24 hours a day if possible.
+Announcer.announceAlertIntro=Freenet is connecting to the network - this may 
take a few minutes. Performance will continue to improve during the next few 
hours. This will happen each time you shut down Freenet for more than a few 
minutes, so try to leave it running 24 hours a day if possible.
 Announcer.announceAlertTitle=Node Announcing
 Announcer.announceDetails=We have recently sent ${recentSentAnnouncements} 
announcements, ${runningAnnouncements} of which are still running, and added 
${addedNodes} nodes (${refusedNodes} nodes have rejected us). We are currently 
connected to ${connectedSeednodes} seednodes and trying to connect to another 
${disconnectedSeednodes}.
 Announcer.announceAlertNoSeednodes=There is no seednodes.fref file found, so 
the node will not be able to automatically bootstrap itself onto the opennet. 
Please add some nodes manually, or download the seednodes file from 
http://downloads.freenetproject.org/alpha/opennet/ .
@@ -9,6 +9,7 @@
 Announcer.announceDisabledTooOldShort=The node has tried to connect to the 
network but your copy of Freenet is too old. You should upgrade.
 Announcer.announceAlertShort=The node is trying to connect to the network, it 
will be slow for a while.
 Announcer.coolingOff=For the next ${time} seconds, the node is waiting for the 
nodes that it just announced to to connect, if there are not enough nodes it 
will try a different node.
+Announcer.dontKnowAddress=Freenet has not yet been able to determine our IP 
address, we cannot announce until we know what it is.
 Bookmark.noName=no name
 BookmarkEditorToadlet.addBookmark=Add Bookmark
 BookmarkEditorToadlet.addCategory=Add Category

Modified: trunk/freenet/src/freenet/node/Announcer.java
===================================================================
--- trunk/freenet/src/freenet/node/Announcer.java       2008-09-02 16:57:38 UTC 
(rev 22355)
+++ trunk/freenet/src/freenet/node/Announcer.java       2008-09-02 17:44:41 UTC 
(rev 22356)
@@ -78,7 +78,10 @@
        public void start() {
                if(!node.isOpennetEnabled()) return;
                registerAlert();
-               if(node.peers.getDarknetPeers().length + 
node.peers.getOpennetPeers().length + om.countOldOpennetPeers() == 0) {
+               int darkPeers = node.peers.getDarknetPeers().length;
+               int openPeers = node.peers.getOpennetPeers().length;
+               int oldOpenPeers = om.countOldOpennetPeers();
+               if(darkPeers + openPeers + oldOpenPeers == 0) {
                        // We know opennet is enabled.
                        // We have no peers AT ALL.
                        // So lets connect to a few seednodes, and attempt an 
announcement.
@@ -88,6 +91,7 @@
                        }
                        connectSomeSeednodes();
                } else {
+                       System.out.println("Not attempting immediate 
announcement: dark peers="+darkPeers+" open peers="+openPeers+" old open 
peers="+oldOpenPeers+" - will wait 1 minute...");
                        // Wait a minute, then check whether we need to seed.
                        node.getTicker().queueTimedJob(new Runnable() {
                                public void run() {
@@ -302,6 +306,9 @@
        static final int RETRY_DELAY = 60*1000;
        private boolean started = false;

+       private long toldUserNoIP = -1;
+       private boolean dontKnowOurIPAddress;
+       
        public void maybeSendAnnouncement() {
                started = true;
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
@@ -339,6 +346,11 @@
                }
                if((!ignoreIPUndetected) && (!node.ipDetector.hasValidIP())) {
                        if(node.ipDetector.ipDetectorManager.hasDetectors()) {
+                               if(now - toldUserNoIP > 60*1000)
+                                       System.out.println("Don't know our IP 
address, waiting for another 2 minutes...");
+                               synchronized(this) {
+                                       dontKnowOurIPAddress = true;
+                               }
                                // Wait a bit
                                node.getTicker().queueTimedJob(new Runnable() {
                                        public void run() {
@@ -353,6 +365,7 @@
                        }
                }
                synchronized(this) {
+                       dontKnowOurIPAddress = false;
                        // Double check after taking the lock.
                        if(enoughPeers()) return;
                        // Second, do we have many announcements running?
@@ -533,8 +546,10 @@
                        StringBuffer sb = new StringBuffer();
                        sb.append(l10n("announceAlertIntro"));
                        int status;
+                       boolean dontKnowAddress;
                        synchronized(this) {
                                status = Announcer.this.status;
+                               dontKnowAddress = dontKnowOurIPAddress;
                        }
                        if(status == STATUS_NO_SEEDNODES) {
                                return l10n("announceAlertNoSeednodes");
@@ -567,16 +582,20 @@
                                        else
                                                disconnectedSeednodes++;
                                }
-                               sb.append(l10n("announceDetails", 
-                                               new String[] { "addedNodes", 
"refusedNodes", "recentSentAnnouncements", "runningAnnouncements", 
"connectedSeednodes", "disconnectedSeednodes" },
-                                               new String[] {
-                                               Integer.toString(addedNodes),
-                                               Integer.toString(refusedNodes),
-                                               
Integer.toString(recentSentAnnouncements),
-                                               
Integer.toString(runningAnnouncements),
-                                               
Integer.toString(connectedSeednodes),
-                                               
Integer.toString(disconnectedSeednodes)
-                               }));
+                               if(dontKnowAddress) {
+                                       sb.append(l10n("dontKnowAddress"));
+                               } else {
+                                       sb.append(l10n("announceDetails", 
+                                                       new String[] { 
"addedNodes", "refusedNodes", "recentSentAnnouncements", 
"runningAnnouncements", "connectedSeednodes", "disconnectedSeednodes" },
+                                                       new String[] {
+                                                       
Integer.toString(addedNodes),
+                                                       
Integer.toString(refusedNodes),
+                                                       
Integer.toString(recentSentAnnouncements),
+                                                       
Integer.toString(runningAnnouncements),
+                                                       
Integer.toString(connectedSeednodes),
+                                                       
Integer.toString(disconnectedSeednodes)
+                                       }));
+                               }
                                if(coolingOffSeconds > 0) {
                                        sb.append(' ');
                                        sb.append(l10n("coolingOff", "time", 
Long.toString(coolingOffSeconds)));


Reply via email to