Author: nextgens
Date: 2006-10-31 18:01:19 +0000 (Tue, 31 Oct 2006)
New Revision: 10759
Modified:
trunk/freenet/src/freenet/node/NodeIPDetector.java
trunk/freenet/src/freenet/node/useralerts/IPUndetectedUserAlert.java
Log:
Some untested code to improve IPUndetectedUserAlert.
Modified: trunk/freenet/src/freenet/node/NodeIPDetector.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeIPDetector.java 2006-10-31 17:57:52 UTC
(rev 10758)
+++ trunk/freenet/src/freenet/node/NodeIPDetector.java 2006-10-31 18:01:19 UTC
(rev 10759)
@@ -61,7 +61,7 @@
this.ticker = node.ps;
ipDetectorManager = new IPDetectorPluginManager(node, this);
ipDetector = new IPAddressDetector(10*1000, this);
- primaryIPUndetectedAlert = new IPUndetectedUserAlert(this);
+ primaryIPUndetectedAlert = new IPUndetectedUserAlert(node);
arkPutter = new NodeARKInserter(node, this);
}
Modified: trunk/freenet/src/freenet/node/useralerts/IPUndetectedUserAlert.java
===================================================================
--- trunk/freenet/src/freenet/node/useralerts/IPUndetectedUserAlert.java
2006-10-31 17:57:52 UTC (rev 10758)
+++ trunk/freenet/src/freenet/node/useralerts/IPUndetectedUserAlert.java
2006-10-31 18:01:19 UTC (rev 10759)
@@ -1,16 +1,18 @@
package freenet.node.useralerts;
-import freenet.node.NodeIPDetector;
+import freenet.config.Option;
+import freenet.config.SubConfig;
+import freenet.node.Node;
import freenet.support.HTMLNode;
public class IPUndetectedUserAlert implements UserAlert {
- public IPUndetectedUserAlert(NodeIPDetector ipm) {
- this.ipm = ipm;
+ public IPUndetectedUserAlert(Node n) {
+ this.node = n;
}
boolean isValid=true;
- final NodeIPDetector ipm;
+ final Node node;
public boolean userCanDismiss() {
return true;
@@ -21,7 +23,7 @@
}
public String getText() {
- if(ipm.isDetecting())
+ if(node.ipDetector.isDetecting())
return "Freenet is currently attempting to detect your
external IP address. " +
"If this takes more than a few minutes
there is something wrong...";
else
@@ -31,22 +33,36 @@
"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'
<a href=\"/config/\">configuration parameter</a>.";
+ "your node with the 'Temporary IP address hint'
configuration parameter.";
}
public HTMLNode getHTMLText() {
+ SubConfig sc = node.config.get("node");
+ Option o = sc.getOption("tempIPAddressHint");
+
HTMLNode textNode = new HTMLNode("div");
- if(ipm.isDetecting())
+ if(node.ipDetector.isDetecting())
textNode.addChild("#", "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 ");
else
textNode.addChild("#", "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 \u201cTemporary IP Address Hint\u201d ");
textNode.addChild("a", "href", "/config/", "configuration
parameter");
textNode.addChild("#", ".");
+ HTMLNode formNode = textNode.addChild("form", new String[] {
"action", "method" }, new String[] { "/config/", "post" });
+ formNode.addChild("input", new String[] { "type", "name",
"value" }, new String[] { "hidden", "formPassword",
node.clientCore.formPassword });
+ HTMLNode listNode = formNode.addChild("ul", "class", "config");
+ HTMLNode itemNode = listNode.addChild("li");
+ itemNode.addChild("span", "class", "configshortdesc",
o.getShortDesc()).addChild("input", new String[] { "type", "name", "value" },
new String[] { "text", sc.getPrefix() + ".name", o.getValueString() });
+ itemNode.addChild("span", "class", "configlongdesc",
o.getLongDesc());
+ formNode.addChild("input", new String[] { "type", "value" },
new String[] { "submit", "Apply" });
+ formNode.addChild("input", new String[] { "type", "value" },
new String[] { "reset", "Reset" });
return textNode;
}
public short getPriorityClass() {
- return UserAlert.ERROR;
+ if(node.ipDetector.isDetecting())
+ return UserAlert.WARNING;
+ else
+ return UserAlert.ERROR;
}
public boolean isValid() {