From 01bed932c743fe04aa755537bae1ce52dcb26902 Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 1 Sep 2009 14:47:16 +0000 Subject: [PATCH 1/3] * Logging: Fix directory for rotated log --- core/java/src/net/i2p/util/LogWriter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/java/src/net/i2p/util/LogWriter.java b/core/java/src/net/i2p/util/LogWriter.java index ed94081c6..1437b9f4a 100644 --- a/core/java/src/net/i2p/util/LogWriter.java +++ b/core/java/src/net/i2p/util/LogWriter.java @@ -196,7 +196,10 @@ class LogWriter implements Runnable { _rotationNum++; if (_rotationNum > max) _rotationNum = 0; - return new File(replace(pattern, _rotationNum)); + String newf = replace(pattern, _rotationNum); + if (base != null) + return new File(base, newf); + return new File(newf); } /** From 7745bd89a9e6348868bf1280f0994c75538b79ea Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 1 Sep 2009 14:50:22 +0000 Subject: [PATCH 2/3] * configkeyring.jsp: Add delete and cancel buttons --- .../i2p/router/web/ConfigKeyringHandler.java | 43 +++++++++++++------ apps/routerconsole/jsp/configkeyring.jsp | 6 +-- .../src/net/i2p/router/PersistentKeyRing.java | 2 +- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigKeyringHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigKeyringHandler.java index 9cb3bfceb..cb54c77ff 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigKeyringHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigKeyringHandler.java @@ -6,7 +6,7 @@ import net.i2p.data.SessionKey; import net.i2p.util.ConvertToHash; /** - * Support additions via B64 Destkey, B64 Desthash, or blahblah.i2p + * Support additions via B64 Destkey, B64 Desthash, blahblah.i2p, and others supported by ConvertToHash */ public class ConfigKeyringHandler extends FormHandler { private String _peer; @@ -14,21 +14,36 @@ public class ConfigKeyringHandler extends FormHandler { @Override protected void processForm() { - if ("Add key".equals(_action)) { - if (_peer == null || _key == null) { - addFormError("You must enter a destination and a key"); + if (_action == null) return; + boolean adding = _action.startsWith("Add"); + if (adding || _action.startsWith("Delete")) { + if (_peer == null) + addFormError("You must enter a destination"); + if (_key == null && adding) + addFormError("You must enter a key"); + if (_peer == null || (_key == null && adding)) return; - } Hash h = ConvertToHash.getHash(_peer); - SessionKey sk = new SessionKey(); - try { - sk.fromBase64(_key); - } catch (DataFormatException dfe) {} - if (h != null && h.getData() != null && sk.getData() != null) { - _context.keyRing().put(h, sk); - addFormNotice("Key for " + h.toBase64() + " added to keyring"); - } else { - addFormError("Invalid destination or key"); + if (adding) { + SessionKey sk = new SessionKey(); + try { + sk.fromBase64(_key); + } catch (DataFormatException dfe) {} + if (h != null && h.getData() != null && sk.getData() != null) { + _context.keyRing().put(h, sk); + addFormNotice("Key for " + h.toBase64() + " added to keyring"); + } else { + addFormError("Invalid destination or key"); + } + } else { // Delete + if (h != null && h.getData() != null) { + if (_context.keyRing().remove(h) != null) + addFormNotice("Key for " + h.toBase64() + " removed from keyring"); + else + addFormNotice("Key for " + h.toBase64() + " not found in keyring"); + } else { + addFormError("Invalid destination"); + } } } else { addFormError("Unsupported"); diff --git a/apps/routerconsole/jsp/configkeyring.jsp b/apps/routerconsole/jsp/configkeyring.jsp index 88957858d..0c054a7d2 100644 --- a/apps/routerconsole/jsp/configkeyring.jsp +++ b/apps/routerconsole/jsp/configkeyring.jsp @@ -40,9 +40,9 @@ Dest. name, hash, or full key: - Session Key: + Encryption Key: - - + + diff --git a/router/java/src/net/i2p/router/PersistentKeyRing.java b/router/java/src/net/i2p/router/PersistentKeyRing.java index c92437111..af7c8c8de 100644 --- a/router/java/src/net/i2p/router/PersistentKeyRing.java +++ b/router/java/src/net/i2p/router/PersistentKeyRing.java @@ -67,7 +67,7 @@ public class PersistentKeyRing extends KeyRing { @Override public void renderStatusHTML(Writer out) throws IOException { StringBuilder buf = new StringBuilder(1024); - buf.append("\n"); + buf.append("\n
Destination HashName or Dest.Session Key
"); for (Entry e : entrySet()) { buf.append("\n
Destination HashName or Dest.Encryption Key
"); Hash h = e.getKey(); From e392469835fde6cdb4ac39320262c3e98baa03fc Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 1 Sep 2009 14:51:11 +0000 Subject: [PATCH 3/3] TunnelDispatcher cleanup --- .../i2p/router/tunnel/TunnelDispatcher.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java b/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java index 9cd67561d..2ce0b00e6 100644 --- a/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java +++ b/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java @@ -28,20 +28,20 @@ import net.i2p.util.Log; * */ public class TunnelDispatcher implements Service { - private RouterContext _context; - private Log _log; - private Map _outboundGateways; - private Map _outboundEndpoints; - private Map _participants; - private Map _inboundGateways; - private Map _participatingConfig; + private final RouterContext _context; + private final Log _log; + private final Map _outboundGateways; + private final Map _outboundEndpoints; + private final Map _participants; + private final Map _inboundGateways; + private final Map _participatingConfig; /** what is the date/time on which the last non-locally-created tunnel expires? */ private long _lastParticipatingExpiration; private BloomFilterIVValidator _validator; - private LeaveTunnel _leaveJob; + private final LeaveTunnel _leaveJob; /** what is the date/time we last deliberately dropped a tunnel? **/ private long _lastDropTime; - private TunnelGatewayPumper _pumper; + private final TunnelGatewayPumper _pumper; /** Creates a new instance of TunnelDispatcher */ public TunnelDispatcher(RouterContext ctx) { @@ -615,14 +615,14 @@ public class TunnelDispatcher implements Service { return reject; } - private static final int DROP_BASE_INTERVAL = 40 * 1000; - private static final int DROP_RANDOM_BOOST = 10 * 1000; + //private static final int DROP_BASE_INTERVAL = 40 * 1000; + //private static final int DROP_RANDOM_BOOST = 10 * 1000; /** * If a router is too overloaded to build its own tunnels, * the build executor may call this. */ - +/******* public void dropBiggestParticipating() { List partTunnels = listParticipatingTunnels(); @@ -677,7 +677,8 @@ public class TunnelDispatcher implements Service { remove(biggest); _lastDropTime = _context.clock().now() + _context.random().nextInt(DROP_RANDOM_BOOST); } - +******/ + public void startup() { // NB: 256 == assume max rate (size adjusted to handle 256 messages per second) _validator = new BloomFilterIVValidator(_context, 256);