Author: toad
Date: 2007-06-21 17:32:47 +0000 (Thu, 21 Jun 2007)
New Revision: 13688
Modified:
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
trunk/freenet/src/freenet/node/PeerManager.java
trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java
Log:
Tell the user if there is a clock problem
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-06-21
17:29:08 UTC (rev 13687)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-06-21
17:32:47 UTC (rev 13688)
@@ -587,6 +587,8 @@
NodeUpdateManager.updateURILong=Where should the node look for updates?
PNGFilter.invalidHeader=The file you tried to fetch is not a PNG. It does not
include a valid PNG header. It might be some other file format, and your
browser may do something dangerous with it, therefore we have blocked it.
PNGFilter.invalidHeaderTitle=Not a PNG - invalid header
+PeerManagerUserAlert.clockProblemTitle=Clock problem
+PeerManagerUserAlert.clockProblem=${count} of your nodes are unable to connect
because their system clock is more than 24 hours different to yours. Please
check whether your computer has the correct time. Incorrect time will cause
many node and client mechanisms to fail.
PeerManagerUserAlert.noConns=This node has not been able to connect to any
other nodes so far; it will not be able to function normally. Hopefully some of
your peers will connect soon; if not, try to get some more peers. You need at
least 3 peers at any time, and should aim for 5-10.
PeerManagerUserAlert.noConnsTitle=No open connections
PeerManagerUserAlert.noPeersDarknet=This node has no peers to connect to,
therefore it will not be able to function normally. Ideally you should connect
to peers run by people you know (if you are paranoid, then people you trust; if
not, then at least people you've talked to). You need at least 3 connected
peers at all times, and ideally 5-10. You could log on to irc.freenode.net
channel #freenet-refs and ask around for somebody to connect to, but remember
that you are vulnerable to those you are directly connected to. (This is
especially true in this early alpha of Freenet 0.7...) BE SURE THAT THE OTHER
PERSON HAS ADDED YOUR REFERENCE, TOO, AS ONE-WAY CONNECTIONS WON'T WORK!
Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java 2007-06-21 17:29:08 UTC
(rev 13687)
+++ trunk/freenet/src/freenet/node/PeerManager.java 2007-06-21 17:32:47 UTC
(rev 13688)
@@ -809,6 +809,7 @@
ua.conns = conns;
ua.peers = peers;
ua.neverConn =
getPeerNodeStatusSize(PEER_NODE_STATUS_NEVER_CONNECTED);
+ ua.clockProblem =
getPeerNodeStatusSize(PEER_NODE_STATUS_CLOCK_PROBLEM);
}
if(anyConnectedPeers())
node.onConnectedPeer();
Modified: trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java
===================================================================
--- trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java
2007-06-21 17:29:08 UTC (rev 13687)
+++ trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java
2007-06-21 17:32:47 UTC (rev 13688)
@@ -13,6 +13,7 @@
public int conns = 0;
public int peers = 0;
public int neverConn = 0;
+ public int clockProblem = 0;
boolean isValid=true;
int bwlimitDelayTime = 1;
int nodeAveragePingTime = 1;
@@ -30,6 +31,9 @@
/** How many never-connected peers can we have without getting alerted
about too many */
static final int MAX_NEVER_CONNECTED_PEER_ALERT_THRESHOLD = 5;
+ /** How many peers with clock problems can we have without getting
alerted about too many */
+ static final int MAX_CLOCK_PROBLEM_PEER_ALERT_THRESHOLD = 5;
+
/** How many peers we can have without getting alerted about too many */
static final int MAX_PEER_ALERT_THRESHOLD = 100;
@@ -53,6 +57,8 @@
return l10n("onlyFewConnsTitle", "count",
Integer.toString(conns));
if(neverConn > MAX_NEVER_CONNECTED_PEER_ALERT_THRESHOLD)
return l10n("tooManyNeverConnectedTitle");
+ if(clockProblem > MAX_CLOCK_PROBLEM_PEER_ALERT_THRESHOLD)
+ return l10n("clockProblemTitle");
if((peers - conns) > MAX_DISCONN_PEER_ALERT_THRESHOLD)
return l10n("tooManyDisconnectedTitle");
if(conns > MAX_CONN_ALERT_THRESHOLD)
@@ -88,6 +94,8 @@
return l10n("noPeersTestnet");
else
return l10n("noPeersDarknet");
+ } else if(conns < 3 && clockProblem >
MAX_CLOCK_PROBLEM_PEER_ALERT_THRESHOLD) {
+ s = l10n("clockProblem", "count",
Integer.toString(clockProblem));
} else if(conns == 0) {
return l10n("noConns");
} else if(conns == 1) {
@@ -96,6 +104,8 @@
return l10n("twoConns");
} else if(neverConn > MAX_NEVER_CONNECTED_PEER_ALERT_THRESHOLD)
{
s = l10n("tooManyNeverConnected", "count",
Integer.toString(neverConn));
+ } else if(clockProblem >
MAX_CLOCK_PROBLEM_PEER_ALERT_THRESHOLD) {
+ s = l10n("clockProblem", "count",
Integer.toString(clockProblem));
} else if((peers - conns) > MAX_DISCONN_PEER_ALERT_THRESHOLD){
s = l10n("tooManyDisconnected", new String[] { "count",
"max" },
new String[] {
Integer.toString(disconnected),
Integer.toString(MAX_DISCONN_PEER_ALERT_THRESHOLD)});
@@ -150,6 +160,8 @@
alertNode.addChild("#", l10n("noPeersTestnet"));
else
alertNode.addChild("#",
l10n("noPeersDarknet"));
+ } else if(conns < 3 && clockProblem >
MAX_CLOCK_PROBLEM_PEER_ALERT_THRESHOLD) {
+ alertNode.addChild("#", l10n("clockProblem", "count",
Integer.toString(clockProblem)));
} else if (conns == 0) {
alertNode.addChild("#", l10n("noConns"));
} else if (conns == 1) {
@@ -160,6 +172,8 @@
L10n.addL10nSubstitution(alertNode,
"PeerManagerUserAlert.tooManyNeverConnectedWithLink",
new String[] { "link", "/link", "count"
},
new String[] { "<a
href=\"/friends/myref.fref\">", "</a>", Integer.toString(neverConn) });
+ } else if (clockProblem >
MAX_CLOCK_PROBLEM_PEER_ALERT_THRESHOLD) {
+ alertNode.addChild("#", l10n("clockProblem", "count",
Integer.toString(clockProblem)));
} else if ((peers - conns) > MAX_DISCONN_PEER_ALERT_THRESHOLD) {
alertNode.addChild("#", l10n("tooManyDisconnected", new
String[] { "count", "max" }, new String[] { Integer.toString(disconnected),
Integer.toString(MAX_DISCONN_PEER_ALERT_THRESHOLD)}));
} else if (conns > MAX_CONN_ALERT_THRESHOLD) {
@@ -205,6 +219,7 @@
((peers - conns) >
MAX_DISCONN_PEER_ALERT_THRESHOLD) ||
(conns > MAX_CONN_ALERT_THRESHOLD) ||
(peers > MAX_PEER_ALERT_THRESHOLD) ||
+ (clockProblem >
MAX_CLOCK_PROBLEM_PEER_ALERT_THRESHOLD) ||
(n.bwlimitDelayAlertRelevant &&
(bwlimitDelayTime > NodeStats.MAX_BWLIMIT_DELAY_TIME_ALERT_THRESHOLD)) ||
(n.nodeAveragePingAlertRelevant &&
(nodeAveragePingTime > NodeStats.MAX_NODE_AVERAGE_PING_TIME_ALERT_THRESHOLD)) ||
(oldestNeverConnectedPeerAge >
MAX_OLDEST_NEVER_CONNECTED_PEER_AGE_ALERT_THRESHOLD)) &&