propagate from branch 'i2p.i2p.zzz.test3' (head f18425568ef4ef20f5054f6fb133cf217bfab485)
to branch 'i2p.i2p' (head 36f4774eb9dd538b3a7c314de79a6fb3bc4df813)
This commit is contained in:
@ -6,7 +6,7 @@ import net.i2p.data.SessionKey;
|
|||||||
import net.i2p.util.ConvertToHash;
|
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 {
|
public class ConfigKeyringHandler extends FormHandler {
|
||||||
private String _peer;
|
private String _peer;
|
||||||
@ -14,12 +14,17 @@ public class ConfigKeyringHandler extends FormHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processForm() {
|
protected void processForm() {
|
||||||
if ("Add key".equals(_action)) {
|
if (_action == null) return;
|
||||||
if (_peer == null || _key == null) {
|
boolean adding = _action.startsWith("Add");
|
||||||
addFormError("You must enter a destination and a key");
|
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;
|
return;
|
||||||
}
|
|
||||||
Hash h = ConvertToHash.getHash(_peer);
|
Hash h = ConvertToHash.getHash(_peer);
|
||||||
|
if (adding) {
|
||||||
SessionKey sk = new SessionKey();
|
SessionKey sk = new SessionKey();
|
||||||
try {
|
try {
|
||||||
sk.fromBase64(_key);
|
sk.fromBase64(_key);
|
||||||
@ -30,6 +35,16 @@ public class ConfigKeyringHandler extends FormHandler {
|
|||||||
} else {
|
} else {
|
||||||
addFormError("Invalid destination or key");
|
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 {
|
} else {
|
||||||
addFormError("Unsupported");
|
addFormError("Unsupported");
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,9 @@
|
|||||||
<td class="mediumtags" align="right">Dest. name, hash, or full key:</td>
|
<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>
|
<td><textarea name="peer" cols="44" rows="1" style="height: 3em;" wrap="off"></textarea></td>
|
||||||
</tr><tr>
|
</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>
|
<td><input type="text" size="55" name="key" /></td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td></td>
|
<td align="right" colspan="2"><input type="submit" name="action" value="Add key" />
|
||||||
<td align="right"><input type="submit" name="action" value="Add key" /></td>
|
<input type="submit" name="action" value="Delete key" /> <input type="reset" value="Cancel" /></td>
|
||||||
</tr></table></div></form></div></div></body></html>
|
</tr></table></div></form></div></div></body></html>
|
||||||
|
@ -196,7 +196,10 @@ class LogWriter implements Runnable {
|
|||||||
_rotationNum++;
|
_rotationNum++;
|
||||||
if (_rotationNum > max) _rotationNum = 0;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ public class PersistentKeyRing extends KeyRing {
|
|||||||
@Override
|
@Override
|
||||||
public void renderStatusHTML(Writer out) throws IOException {
|
public void renderStatusHTML(Writer out) throws IOException {
|
||||||
StringBuilder buf = new StringBuilder(1024);
|
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()) {
|
for (Entry<Hash, SessionKey> e : entrySet()) {
|
||||||
buf.append("\n<tr><td>");
|
buf.append("\n<tr><td>");
|
||||||
Hash h = e.getKey();
|
Hash h = e.getKey();
|
||||||
|
@ -28,20 +28,20 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TunnelDispatcher implements Service {
|
public class TunnelDispatcher implements Service {
|
||||||
private RouterContext _context;
|
private final RouterContext _context;
|
||||||
private Log _log;
|
private final Log _log;
|
||||||
private Map<TunnelId, TunnelGateway> _outboundGateways;
|
private final Map<TunnelId, TunnelGateway> _outboundGateways;
|
||||||
private Map<TunnelId, OutboundTunnelEndpoint> _outboundEndpoints;
|
private final Map<TunnelId, OutboundTunnelEndpoint> _outboundEndpoints;
|
||||||
private Map<TunnelId, TunnelParticipant> _participants;
|
private final Map<TunnelId, TunnelParticipant> _participants;
|
||||||
private Map<TunnelId, TunnelGateway> _inboundGateways;
|
private final Map<TunnelId, TunnelGateway> _inboundGateways;
|
||||||
private Map<TunnelId, HopConfig> _participatingConfig;
|
private final Map<TunnelId, HopConfig> _participatingConfig;
|
||||||
/** what is the date/time on which the last non-locally-created tunnel expires? */
|
/** what is the date/time on which the last non-locally-created tunnel expires? */
|
||||||
private long _lastParticipatingExpiration;
|
private long _lastParticipatingExpiration;
|
||||||
private BloomFilterIVValidator _validator;
|
private BloomFilterIVValidator _validator;
|
||||||
private LeaveTunnel _leaveJob;
|
private final LeaveTunnel _leaveJob;
|
||||||
/** what is the date/time we last deliberately dropped a tunnel? **/
|
/** what is the date/time we last deliberately dropped a tunnel? **/
|
||||||
private long _lastDropTime;
|
private long _lastDropTime;
|
||||||
private TunnelGatewayPumper _pumper;
|
private final TunnelGatewayPumper _pumper;
|
||||||
|
|
||||||
/** Creates a new instance of TunnelDispatcher */
|
/** Creates a new instance of TunnelDispatcher */
|
||||||
public TunnelDispatcher(RouterContext ctx) {
|
public TunnelDispatcher(RouterContext ctx) {
|
||||||
@ -615,14 +615,14 @@ public class TunnelDispatcher implements Service {
|
|||||||
return reject;
|
return reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int DROP_BASE_INTERVAL = 40 * 1000;
|
//private static final int DROP_BASE_INTERVAL = 40 * 1000;
|
||||||
private static final int DROP_RANDOM_BOOST = 10 * 1000;
|
//private static final int DROP_RANDOM_BOOST = 10 * 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a router is too overloaded to build its own tunnels,
|
* If a router is too overloaded to build its own tunnels,
|
||||||
* the build executor may call this.
|
* the build executor may call this.
|
||||||
*/
|
*/
|
||||||
|
/*******
|
||||||
public void dropBiggestParticipating() {
|
public void dropBiggestParticipating() {
|
||||||
|
|
||||||
List<HopConfig> partTunnels = listParticipatingTunnels();
|
List<HopConfig> partTunnels = listParticipatingTunnels();
|
||||||
@ -677,6 +677,7 @@ public class TunnelDispatcher implements Service {
|
|||||||
remove(biggest);
|
remove(biggest);
|
||||||
_lastDropTime = _context.clock().now() + _context.random().nextInt(DROP_RANDOM_BOOST);
|
_lastDropTime = _context.clock().now() + _context.random().nextInt(DROP_RANDOM_BOOST);
|
||||||
}
|
}
|
||||||
|
******/
|
||||||
|
|
||||||
public void startup() {
|
public void startup() {
|
||||||
// NB: 256 == assume max rate (size adjusted to handle 256 messages per second)
|
// NB: 256 == assume max rate (size adjusted to handle 256 messages per second)
|
||||||
|
Reference in New Issue
Block a user