diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigKeyringHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigKeyringHandler.java
index f29b107b96..fa2170c884 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigKeyringHandler.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigKeyringHandler.java
@@ -1,5 +1,6 @@
package net.i2p.router.web.helpers;
+import net.i2p.data.Base32;
import net.i2p.data.DataFormatException;
import net.i2p.data.Hash;
import net.i2p.data.SessionKey;
@@ -30,18 +31,23 @@ public class ConfigKeyringHandler extends FormHandler {
try {
sk.fromBase64(_key);
} catch (DataFormatException dfe) {}
- if (h != null && h.getData() != null && sk.getData() != null) {
- _context.keyRing().put(h, sk);
- addFormNotice(_t("Key for") + " " + h.toBase64() + " " + _t("added to keyring"));
+ if (h == null || h.getData() == null) {
+ addFormError(_t("Invalid destination"));
+ } else if (sk.getData() == null) {
+ addFormError(_t("Invalid key"));
} else {
- addFormError(_t("Invalid destination or key"));
+ _context.keyRing().put(h, sk);
+ addFormNotice(_t("Key for {0} added to keyring",
+ Base32.encode(h.getData()) + ".b32.i2p"));
}
} else { // Delete
if (h != null && h.getData() != null) {
if (_context.keyRing().remove(h) != null)
- addFormNotice(_t("Key for") + " " + h.toBase64() + " " + _t("removed from keyring"));
+ addFormNotice(_t("Key for {0} removed from keyring",
+ Base32.encode(h.getData()) + ".b32.i2p"));
else
- addFormNotice(_t("Key for") + " " + h.toBase64() + " " + _t("not found in keyring"));
+ addFormNotice(_t("Key for {0} not found in keyring",
+ Base32.encode(h.getData()) + ".b32.i2p"));
} else {
addFormError(_t("Invalid destination"));
}
@@ -51,6 +57,6 @@ public class ConfigKeyringHandler extends FormHandler {
}
}
- public void setPeer(String peer) { _peer = peer; }
- public void setKey(String peer) { _key = peer; }
+ public void setPeer(String peer) { if (peer != null) _peer = peer.trim(); }
+ public void setKey(String key) { if (key != null) _key = key.trim(); }
}
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigKeyringHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigKeyringHelper.java
index 869a36f2e5..986879291c 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigKeyringHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigKeyringHelper.java
@@ -2,7 +2,13 @@ package net.i2p.router.web.helpers;
import java.io.IOException;
import java.io.StringWriter;
+import java.util.Map;
+import net.i2p.data.Base32;
+import net.i2p.data.Destination;
+import net.i2p.data.Hash;
+import net.i2p.data.SessionKey;
+import net.i2p.router.TunnelPoolSettings;
import net.i2p.router.web.HelperBase;
@@ -12,10 +18,44 @@ public class ConfigKeyringHelper extends HelperBase {
public String getSummary() {
StringWriter sw = new StringWriter(4*1024);
try {
- _context.keyRing().renderStatusHTML(sw);
+ renderStatusHTML(sw);
} catch (IOException ioe) {
ioe.printStackTrace();
}
return sw.toString();
}
+
+ /**
+ * @since 0.9.33 moved from PersistentKeyRing
+ */
+ private void renderStatusHTML(StringWriter out) throws IOException {
+ StringBuilder buf = new StringBuilder(1024);
+ buf.append("\n
").append(_t("Destination"))
+ .append(" | ").append(_t("Name"))
+ .append(" | ").append(_t("Encryption Key"))
+ .append(" |
");
+ for (Map.Entry e : _context.keyRing().entrySet()) {
+ buf.append("\n");
+ Hash h = e.getKey();
+ buf.append(Base32.encode(h.getData())).append(".b32.i2p");
+ buf.append(" | ");
+ Destination dest = _context.netDb().lookupDestinationLocally(h);
+ if (dest != null && _context.clientManager().isLocal(dest)) {
+ TunnelPoolSettings in = _context.tunnelManager().getInboundSettings(h);
+ if (in != null && in.getDestinationNickname() != null)
+ buf.append(in.getDestinationNickname());
+ } else {
+ String host = _context.namingService().reverseLookup(h);
+ if (host != null)
+ buf.append(host);
+ }
+ buf.append(" | ");
+ SessionKey sk = e.getValue();
+ buf.append(sk.toBase64());
+ buf.append(" | \n");
+ }
+ buf.append("
\n");
+ out.write(buf.toString());
+ out.flush();
+ }
}
diff --git a/apps/routerconsole/jsp/configkeyring.jsp b/apps/routerconsole/jsp/configkeyring.jsp
index be2c68cb27..fdcbf2fb4f 100644
--- a/apps/routerconsole/jsp/configkeyring.jsp
+++ b/apps/routerconsole/jsp/configkeyring.jsp
@@ -32,7 +32,7 @@
<%=intl._t("Keys for local destinations must be entered on the")%> <%=intl._t("I2PTunnel page")%>.
- <%=intl._t("Dest. name, hash, or full key")%>: |
+ <%=intl._t("Full destination, name, base 32, or hash")%>: |
|
<%=intl._t("Encryption Key")%>: |
diff --git a/core/java/src/net/i2p/util/KeyRing.java b/core/java/src/net/i2p/util/KeyRing.java
index 6bbfb38dee..d323dd00ce 100644
--- a/core/java/src/net/i2p/util/KeyRing.java
+++ b/core/java/src/net/i2p/util/KeyRing.java
@@ -16,5 +16,9 @@ public class KeyRing extends ConcurrentHashMap {
super(0);
}
+ /**
+ * @deprecated unused since 0.9.33; code moved to routerconsole
+ */
+ @Deprecated
public void renderStatusHTML(Writer out) throws IOException {}
}
diff --git a/history.txt b/history.txt
index 33b9aed3f4..f2bda4a7e3 100644
--- a/history.txt
+++ b/history.txt
@@ -1,8 +1,19 @@
+2017-12-01 zzz
+ * Build: Split net.i2p.router.web into two packages
+ * Console: Move /configkeyring HTML to console, fix deletion,
+ don't truncate hashes, better form errors, tag for translation (ticket #2108)
+ * Streaming: Double the RTO on congestion (ticket #1939)
+
+2017-11-27 zzz
+ * Debian: Exclude gradle, IntelliJ, Docker, .tx, gcj files from source tarballs
+
2017-11-27 str4d
* Build: Add Gradle build scripts for compiling the codebase and generating
IDE project files.
2017-11-26 zzz
+ * Build: Add xenial build option
+ * Console: Safer processing of changes on /configadvanced
* Context: Hopefully fix rare NPE on Android (ticket #2092)
2017-11-25 zzz
diff --git a/router/java/src/net/i2p/router/PersistentKeyRing.java b/router/java/src/net/i2p/router/PersistentKeyRing.java
index f7dadc6c5e..1f8c0631e9 100644
--- a/router/java/src/net/i2p/router/PersistentKeyRing.java
+++ b/router/java/src/net/i2p/router/PersistentKeyRing.java
@@ -4,7 +4,6 @@ import java.io.IOException;
import java.io.Writer;
import net.i2p.data.DataFormatException;
-import net.i2p.data.Destination;
import net.i2p.data.Hash;
import net.i2p.data.LeaseSet;
import net.i2p.data.SessionKey;
@@ -37,9 +36,13 @@ public class PersistentKeyRing extends KeyRing {
return old;
}
- public SessionKey remove(Hash h) {
- _ctx.router().saveConfig(PROP_PFX + h.toBase64().replace("=", "$"), null);
- return super.remove(h);
+ @Override
+ public SessionKey remove(Object o) {
+ if (o != null && o instanceof Hash) {
+ Hash h = (Hash) o;
+ _ctx.router().saveConfig(PROP_PFX + h.toBase64().replace("=", "$"), null);
+ }
+ return super.remove(o);
}
private void addFromProperties() {
@@ -60,38 +63,4 @@ public class PersistentKeyRing extends KeyRing {
} catch (DataFormatException dfe) { continue; }
}
}
-
- @Override
- public void renderStatusHTML(Writer out) throws IOException {
- StringBuilder buf = new StringBuilder(1024);
- buf.append("\nDestination Hash | Name or Dest. | Encryption Key |
");
- for (Entry e : entrySet()) {
- buf.append("\n");
- Hash h = e.getKey();
- buf.append(h.toBase64().substring(0, 6)).append("…");
- buf.append(" | ");
- Destination dest = _ctx.netDb().lookupDestinationLocally(h);
- if (dest != null) {
- if (_ctx.clientManager().isLocal(dest)) {
- TunnelPoolSettings in = _ctx.tunnelManager().getInboundSettings(h);
- if (in != null && in.getDestinationNickname() != null)
- buf.append(in.getDestinationNickname());
- else
- buf.append(dest.toBase64().substring(0, 6)).append("…");
- } else {
- String host = _ctx.namingService().reverseLookup(dest);
- if (host != null)
- buf.append(host);
- else
- buf.append(dest.toBase64().substring(0, 6)).append("…");
- }
- }
- buf.append(" | ");
- SessionKey sk = e.getValue();
- buf.append(sk.toBase64());
- }
- buf.append("\n |
\n");
- out.write(buf.toString());
- out.flush();
- }
}
diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java
index f2522cd4ed..7ca1a3ec2c 100644
--- a/router/java/src/net/i2p/router/RouterVersion.java
+++ b/router/java/src/net/i2p/router/RouterVersion.java
@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
- public final static long BUILD = 9;
+ public final static long BUILD = 10;
/** for example "-test" */
public final static String EXTRA = "";