propagate from branch 'i2p.i2p.zzz.test3' (head f18425568ef4ef20f5054f6fb133cf217bfab485)

to branch 'i2p.i2p' (head 36f4774eb9dd538b3a7c314de79a6fb3bc4df813)
This commit is contained in:
zzz
2009-09-04 15:14:36 +00:00
5 changed files with 51 additions and 32 deletions

View File

@ -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,12 +14,17 @@ 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);
if (adding) {
SessionKey sk = new SessionKey();
try {
sk.fromBase64(_key);
@ -30,6 +35,16 @@ public class ConfigKeyringHandler extends FormHandler {
} 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");
}

View File

@ -40,9 +40,9 @@
<td class="mediumtags" align="right">Dest. name, hash, or full key:</td>
<td><textarea name="peer" cols="44" rows="1" style="height: 3em;" wrap="off"></textarea></td>
</tr><tr>
<td class="mediumtags" align="right">Session Key:</td>
<td class="mediumtags" align="right">Encryption Key:</td>
<td><input type="text" size="55" name="key" /></td>
</tr><tr>
<td></td>
<td align="right"><input type="submit" name="action" value="Add key" /></td>
<td align="right" colspan="2"><input type="submit" name="action" value="Add key" />
<input type="submit" name="action" value="Delete key" /> <input type="reset" value="Cancel" /></td>
</tr></table></div></form></div></div></body></html>

View File

@ -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);
}
/**

View File

@ -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<table><tr><th align=\"left\">Destination Hash<th align=\"left\">Name or Dest.<th align=\"left\">Session Key</tr>");
buf.append("\n<table><tr><th align=\"left\">Destination Hash<th align=\"left\">Name or Dest.<th align=\"left\">Encryption Key</tr>");
for (Entry<Hash, SessionKey> e : entrySet()) {
buf.append("\n<tr><td>");
Hash h = e.getKey();

View File

@ -28,20 +28,20 @@ import net.i2p.util.Log;
*
*/
public class TunnelDispatcher implements Service {
private RouterContext _context;
private Log _log;
private Map<TunnelId, TunnelGateway> _outboundGateways;
private Map<TunnelId, OutboundTunnelEndpoint> _outboundEndpoints;
private Map<TunnelId, TunnelParticipant> _participants;
private Map<TunnelId, TunnelGateway> _inboundGateways;
private Map<TunnelId, HopConfig> _participatingConfig;
private final RouterContext _context;
private final Log _log;
private final Map<TunnelId, TunnelGateway> _outboundGateways;
private final Map<TunnelId, OutboundTunnelEndpoint> _outboundEndpoints;
private final Map<TunnelId, TunnelParticipant> _participants;
private final Map<TunnelId, TunnelGateway> _inboundGateways;
private final Map<TunnelId, HopConfig> _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<HopConfig> partTunnels = listParticipatingTunnels();
@ -677,6 +677,7 @@ 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)