Author: toad
Date: 2008-09-03 17:08:59 +0000 (Wed, 03 Sep 2008)
New Revision: 22373
Modified:
trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
trunk/freenet/src/freenet/node/SecurityLevels.java
Log:
All 3 settings can now be changed and will be stored when changed.
Confirmation dialog for setting friends=high, as IMHO it's not usually the
right decision.
Modified: trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConfigToadlet.java 2008-09-03
16:44:21 UTC (rev 22372)
+++ trunk/freenet/src/freenet/clients/http/ConfigToadlet.java 2008-09-03
17:08:59 UTC (rev 22373)
@@ -159,6 +159,55 @@
}
}
}
+
+ configName = "security-levels.friendsThreatLevel";
+ confirm = "security-levels.friendsThreatLevel.confirm";
+ tryConfirm =
"security-levels.friendsThreatLevel.tryConfirm";
+ String friendsThreatLevel =
request.getPartAsString(configName, 128);
+ FRIENDS_THREAT_LEVEL newFriendsLevel =
SecurityLevels.parseFriendsThreatLevel(friendsThreatLevel);
+ if(newFriendsLevel != null) {
+ if(newFriendsLevel !=
node.securityLevels.getFriendsThreatLevel()) {
+ if(!request.isPartSet(confirm) &&
!request.isPartSet(tryConfirm)) {
+ HTMLNode warning =
node.securityLevels.getConfirmWarning(newFriendsLevel, confirm);
+ if(warning != null) {
+ if(pageNode == null) {
+ pageNode =
ctx.getPageMaker().getPageNode(L10n.getString("ConfigToadlet.fullTitle", new
String[] { "name" }, new String[] { node.getMyName() }), ctx);
+ content =
ctx.getPageMaker().getContentNode(pageNode);
+ formNode =
ctx.addFormChild(content, ".", "configFormSecLevels");
+ ul =
formNode.addChild("ul", "class", "config");
+ }
+ HTMLNode seclevelGroup
= ul.addChild("li");
+
+
seclevelGroup.addChild("input", new String[] { "type", "name", "value" }, new
String[] { "hidden", configName, friendsThreatLevel });
+ HTMLNode infobox =
seclevelGroup.addChild("div", "class", "infobox infobox-information");
+ infobox.addChild("div",
"class", "infobox-header", l10nSec("friendsThreatLevelConfirmTitle", "mode",
SecurityLevels.localisedName(newThreatLevel)));
+ HTMLNode infoboxContent
= infobox.addChild("div", "class", "infobox-content");
+
infoboxContent.addChild(warning);
+
infoboxContent.addChild("input", new String[] { "type", "name", "value" }, new
String[] { "hidden", tryConfirm, "on" });
+ addedWarning = true;
+ } else {
+ // Apply immediately,
no confirm needed.
+
node.securityLevels.setThreatLevel(newFriendsLevel);
+ }
+ } else if(request.isPartSet(confirm)) {
+ // Apply immediately, user
confirmed it.
+
node.securityLevels.setThreatLevel(newFriendsLevel);
+ }
+ }
+ }
+
+ configName = "security-levels.physicalThreatLevel";
+ confirm = "security-levels.physicalThreatLevel.confirm";
+ tryConfirm =
"security-levels.physicalThreatLevel.tryConfirm";
+ String physicalThreatLevel =
request.getPartAsString(configName, 128);
+ PHYSICAL_THREAT_LEVEL newPhysicalLevel =
SecurityLevels.parsePhysicalThreatLevel(physicalThreatLevel);
+ if(newPhysicalLevel != null) {
+ if(newPhysicalLevel !=
node.securityLevels.getPhysicalThreatLevel()) {
+ // No confirmation for changes to
physical threat level.
+
node.securityLevels.setThreatLevel(newPhysicalLevel);
+ }
+ }
+
if(pageNode != null) {
formNode.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "hidden", "seclevels", "on" });
formNode.addChild("input", new String[] {
"type", "value" }, new String[] { "submit", l10n("apply")});
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-09-03
16:44:21 UTC (rev 22372)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-09-03
17:08:59 UTC (rev 22373)
@@ -1068,6 +1068,7 @@
SecurityLevels.maximumNetworkThreatLevelCheckbox=Yes I really want to enable
maximum security, I understand that Freenet is still experimental and it may
still be possible to trace me, and that this setting may dramatically reduce
Freenet's performance!
SecurityLevels.friendsThreatLevelShort=Protection if your friends attack your
anonymity
SecurityLevels.friendsThreatLevel=How concerned are you about those you add as
friends attempting to monitor your activities, either deliberately or as a
result of their computers being compromised? (This is a default level and for
most purposes can be overridden on a per-friend basis.) If you set the network
security level to HIGH above, then the friends security level determines
performance, along with the number of friends added.
+SecurityLevels.friendsThreatLevelConfirmTitle=WARNING: Setting friends
security level to ${mode}
SecurityLevels.friendsThreatLevel.name.HIGH=HIGH
SecurityLevels.friendsThreatLevel.name.NORMAL=NORMAL
SecurityLevels.friendsThreatLevel.name.LOW=LOW
@@ -1077,6 +1078,8 @@
SecurityLevels.friendsThreatLevel.desc.NORMAL=Freenet will share a limited
amount of information with friends, and be slower than in LOW mode.
SecurityLevels.friendsThreatLevel.choice.LOW=I am not concerned about attacks
from friends. I trust my friends and their computer security abilities.
SecurityLevels.friendsThreatLevel.desc.LOW=Freenet will share a lot of
information with your friends' nodes to maximize performance.
+SecurityLevels.highFriendsThreatLevelWarning=You are about to set your friends
threat level to high. This will reduce Freenet's performance, and shouldn't be
necessary most of the time. If the reason you are setting this is that you have
added people you don't know as Friends, you should consider whether you would
be better off disconnecting from them and downgrading your network level to
NORMAL if necessary. On the other hand if you expect an attacker to compromize
your friends' computers or actively seek to turn them against you, this may be
a prudent precaution.
+SecurityLevels.highFriendsThreatLevelCheckbox=I am sure I need high level
protection against compromised or treacherous friends' nodes.
SecurityLevels.physicalThreatLevelShort=Protection if your computer is seized
or stolen
SecurityLevels.physicalThreatLevel=How concerned are you about your computer
being physically seized and examined?
SecurityLevels.physicalThreatLevel.name.NORMAL=NORMAL
Modified: trunk/freenet/src/freenet/node/SecurityLevels.java
===================================================================
--- trunk/freenet/src/freenet/node/SecurityLevels.java 2008-09-03 16:44:21 UTC
(rev 22372)
+++ trunk/freenet/src/freenet/node/SecurityLevels.java 2008-09-03 17:08:59 UTC
(rev 22373)
@@ -231,6 +231,22 @@
return null;
}
}
+
+ public static FRIENDS_THREAT_LEVEL parseFriendsThreatLevel(String arg) {
+ try {
+ return FRIENDS_THREAT_LEVEL.valueOf(arg);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ public static PHYSICAL_THREAT_LEVEL parsePhysicalThreatLevel(String
arg) {
+ try {
+ return PHYSICAL_THREAT_LEVEL.valueOf(arg);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
/**
* If changing to the new threat level is a potential problem, warn the
user,
@@ -282,6 +298,18 @@
}
return null;
}
+
+ public HTMLNode getConfirmWarning(FRIENDS_THREAT_LEVEL newFriendsLevel,
String checkboxName) {
+ if(newFriendsLevel == friendsThreatLevel)
+ return null; // Not going to be changed.
+ if(newFriendsLevel == FRIENDS_THREAT_LEVEL.HIGH) {
+ HTMLNode parent = new HTMLNode("div");
+ parent.addChild("p",
l10n("highFriendsThreatLevelWarning"));
+ parent.addChild("input", new String[] { "type", "name",
"value" }, new String[] { "checkbox", checkboxName, "off" },
l10n("highFriendsThreatLevelCheckbox"));
+ return parent;
+ }
+ return null;
+ }
private String l10n(String string) {
return L10n.getString("SecurityLevels."+string);
@@ -303,6 +331,22 @@
node.config.store();
}
+ public void setThreatLevel(FRIENDS_THREAT_LEVEL newThreatLevel) {
+ if(newThreatLevel == null) throw new NullPointerException();
+ synchronized(this) {
+ friendsThreatLevel = newThreatLevel;
+ }
+ node.config.store();
+ }
+
+ public void setThreatLevel(PHYSICAL_THREAT_LEVEL newThreatLevel) {
+ if(newThreatLevel == null) throw new NullPointerException();
+ synchronized(this) {
+ physicalThreatLevel = newThreatLevel;
+ }
+ node.config.store();
+ }
+
public static String localisedName(NETWORK_THREAT_LEVEL newThreatLevel)
{
return
L10n.getString("SecurityLevels.networkThreatLevel.name."+newThreatLevel.name());
}