I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 3cd65207 authored by zzz's avatar zzz
Browse files

logging and javadoc tweaks

parent da1a50bf
No related branches found
No related tags found
No related merge requests found
...@@ -359,8 +359,8 @@ public class ElGamalAESEngine { ...@@ -359,8 +359,8 @@ public class ElGamalAESEngine {
* @param target public key to which the data should be encrypted. * @param target public key to which the data should be encrypted.
* @param key session key to use during encryption * @param key session key to use during encryption
* @param tagsForDelivery session tags to be associated with the key (or newKey if specified), or null * @param tagsForDelivery session tags to be associated with the key (or newKey if specified), or null
* @param currentTag sessionTag to use, or null if it should use ElG * @param currentTag sessionTag to use, or null if it should use ElG (i.e. new session)
* @param newKey key to be delivered to the target, with which the tagsForDelivery should be associated * @param newKey key to be delivered to the target, with which the tagsForDelivery should be associated, or null
* @param paddedSize minimum size in bytes of the body after padding it (if less than the * @param paddedSize minimum size in bytes of the body after padding it (if less than the
* body's real size, no bytes are appended but the body is not truncated) * body's real size, no bytes are appended but the body is not truncated)
*/ */
...@@ -368,12 +368,12 @@ public class ElGamalAESEngine { ...@@ -368,12 +368,12 @@ public class ElGamalAESEngine {
SessionTag currentTag, SessionKey newKey, long paddedSize) { SessionTag currentTag, SessionKey newKey, long paddedSize) {
if (currentTag == null) { if (currentTag == null) {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Current tag is null, encrypting as new session", new Exception("encrypt new")); _log.info("Current tag is null, encrypting as new session");
_context.statManager().updateFrequency("crypto.elGamalAES.encryptNewSession"); _context.statManager().updateFrequency("crypto.elGamalAES.encryptNewSession");
return encryptNewSession(data, target, key, tagsForDelivery, newKey, paddedSize); return encryptNewSession(data, target, key, tagsForDelivery, newKey, paddedSize);
} }
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Current tag is NOT null, encrypting as existing session", new Exception("encrypt existing")); _log.info("Current tag is NOT null, encrypting as existing session");
_context.statManager().updateFrequency("crypto.elGamalAES.encryptExistingSession"); _context.statManager().updateFrequency("crypto.elGamalAES.encryptExistingSession");
byte rv[] = encryptExistingSession(data, target, key, tagsForDelivery, currentTag, newKey, paddedSize); byte rv[] = encryptExistingSession(data, target, key, tagsForDelivery, currentTag, newKey, paddedSize);
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
...@@ -383,6 +383,7 @@ public class ElGamalAESEngine { ...@@ -383,6 +383,7 @@ public class ElGamalAESEngine {
/** /**
* Encrypt the data to the target using the given key and deliver the specified tags * Encrypt the data to the target using the given key and deliver the specified tags
* No new session key
*/ */
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery, public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
SessionTag currentTag, long paddedSize) { SessionTag currentTag, long paddedSize) {
...@@ -391,6 +392,8 @@ public class ElGamalAESEngine { ...@@ -391,6 +392,8 @@ public class ElGamalAESEngine {
/** /**
* Encrypt the data to the target using the given key and deliver the specified tags * Encrypt the data to the target using the given key and deliver the specified tags
* No new session key
* No current tag (encrypt as new session)
*/ */
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery, long paddedSize) { public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery, long paddedSize) {
return encrypt(data, target, key, tagsForDelivery, null, null, paddedSize); return encrypt(data, target, key, tagsForDelivery, null, null, paddedSize);
...@@ -398,6 +401,8 @@ public class ElGamalAESEngine { ...@@ -398,6 +401,8 @@ public class ElGamalAESEngine {
/** /**
* Encrypt the data to the target using the given key delivering no tags * Encrypt the data to the target using the given key delivering no tags
* No new session key
* No current tag (encrypt as new session)
*/ */
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, long paddedSize) { public byte[] encrypt(byte data[], PublicKey target, SessionKey key, long paddedSize) {
return encrypt(data, target, key, null, null, null, paddedSize); return encrypt(data, target, key, null, null, null, paddedSize);
......
...@@ -19,7 +19,7 @@ import net.i2p.util.Log; ...@@ -19,7 +19,7 @@ import net.i2p.util.Log;
/** /**
* Build a HandleDatabaseLookupMessageJob whenever a DatabaseLookupMessage arrives * Build a HandleDatabaseLookupMessageJob whenever a DatabaseLookupMessage arrives
* * Unused - see kademlia/ for replacement
*/ */
public class DatabaseLookupMessageHandler implements HandlerJobBuilder { public class DatabaseLookupMessageHandler implements HandlerJobBuilder {
private RouterContext _context; private RouterContext _context;
......
...@@ -18,7 +18,7 @@ import net.i2p.router.RouterContext; ...@@ -18,7 +18,7 @@ import net.i2p.router.RouterContext;
/** /**
* Create a HandleDatabaseStoreMessageJob whenever a DatabaseStoreMessage arrives * Create a HandleDatabaseStoreMessageJob whenever a DatabaseStoreMessage arrives
* * Unused - see kademlia/ for replacement
*/ */
public class DatabaseStoreMessageHandler implements HandlerJobBuilder { public class DatabaseStoreMessageHandler implements HandlerJobBuilder {
private RouterContext _context; private RouterContext _context;
......
...@@ -33,7 +33,7 @@ import net.i2p.util.Log; ...@@ -33,7 +33,7 @@ import net.i2p.util.Log;
/** /**
* Handle a lookup for a key received from a remote peer. Needs to be implemented * Handle a lookup for a key received from a remote peer. Needs to be implemented
* to send back replies, etc * to send back replies, etc
* * Unused directly - see kademlia/ for extension
*/ */
public class HandleDatabaseLookupMessageJob extends JobImpl { public class HandleDatabaseLookupMessageJob extends JobImpl {
private Log _log; private Log _log;
......
...@@ -22,7 +22,7 @@ import net.i2p.util.Log; ...@@ -22,7 +22,7 @@ import net.i2p.util.Log;
/** /**
* Receive DatabaseStoreMessage data and store it in the local net db * Receive DatabaseStoreMessage data and store it in the local net db
* * Unused - see kademlia/ for replacement
*/ */
public class HandleDatabaseStoreMessageJob extends JobImpl { public class HandleDatabaseStoreMessageJob extends JobImpl {
private Log _log; private Log _log;
......
...@@ -64,6 +64,11 @@ public class HandleFloodfillDatabaseStoreMessageJob extends JobImpl { ...@@ -64,6 +64,11 @@ public class HandleFloodfillDatabaseStoreMessageJob extends JobImpl {
RouterInfo prevNetDb = null; RouterInfo prevNetDb = null;
if (_message.getValueType() == DatabaseStoreMessage.KEY_TYPE_LEASESET) { if (_message.getValueType() == DatabaseStoreMessage.KEY_TYPE_LEASESET) {
getContext().statManager().addRateData("netDb.storeLeaseSetHandled", 1, 0); getContext().statManager().addRateData("netDb.storeLeaseSetHandled", 1, 0);
Hash key = _message.getKey();
if (_log.shouldLog(Log.INFO))
_log.info("Handling dbStore of leaseset " + _message);
//_log.info("Handling dbStore of leasset " + key + " with expiration of "
// + new Date(_message.getLeaseSet().getEarliestLeaseDate()));
try { try {
// Never store a leaseSet for a local dest received from somebody else. // Never store a leaseSet for a local dest received from somebody else.
...@@ -72,18 +77,18 @@ public class HandleFloodfillDatabaseStoreMessageJob extends JobImpl { ...@@ -72,18 +77,18 @@ public class HandleFloodfillDatabaseStoreMessageJob extends JobImpl {
// somebody has our keys... // somebody has our keys...
// This could happen with multihoming - where it's really important to prevent // This could happen with multihoming - where it's really important to prevent
// storing the other guy's leaseset, it will confuse us badly. // storing the other guy's leaseset, it will confuse us badly.
if (getContext().clientManager().isLocal(_message.getKey())) { if (getContext().clientManager().isLocal(key)) {
//getContext().statManager().addRateData("netDb.storeLocalLeaseSetAttempt", 1, 0); //getContext().statManager().addRateData("netDb.storeLocalLeaseSetAttempt", 1, 0);
// throw rather than return, so that we send the ack below (prevent easy attack) // throw rather than return, so that we send the ack below (prevent easy attack)
throw new IllegalArgumentException("Peer attempted to store local leaseSet: " + throw new IllegalArgumentException("Peer attempted to store local leaseSet: " +
_message.getKey().toBase64().substring(0, 4)); key.toBase64().substring(0, 4));
} }
LeaseSet ls = _message.getLeaseSet(); LeaseSet ls = _message.getLeaseSet();
// mark it as something we received, so we'll answer queries // mark it as something we received, so we'll answer queries
// for it. this flag does NOT get set on entries that we // for it. this flag does NOT get set on entries that we
// receive in response to our own lookups. // receive in response to our own lookups.
ls.setReceivedAsPublished(true); ls.setReceivedAsPublished(true);
LeaseSet match = getContext().netDb().store(_message.getKey(), _message.getLeaseSet()); LeaseSet match = getContext().netDb().store(key, _message.getLeaseSet());
if ( (match == null) || (match.getEarliestLeaseDate() < _message.getLeaseSet().getEarliestLeaseDate()) ) { if ( (match == null) || (match.getEarliestLeaseDate() < _message.getLeaseSet().getEarliestLeaseDate()) ) {
wasNew = true; wasNew = true;
} else { } else {
......
...@@ -49,7 +49,7 @@ public class OutboundTunnelEndpoint { ...@@ -49,7 +49,7 @@ public class OutboundTunnelEndpoint {
_log.debug("outbound tunnel " + _config + " received a full message: " + msg _log.debug("outbound tunnel " + _config + " received a full message: " + msg
+ " to be forwarded on to " + " to be forwarded on to "
+ (toRouter != null ? toRouter.toBase64().substring(0,4) : "") + (toRouter != null ? toRouter.toBase64().substring(0,4) : "")
+ (toTunnel != null ? toTunnel.getTunnelId() + "" : "")); + (toTunnel != null ? ":" + toTunnel.getTunnelId() : ""));
// don't drop it if we are the target // don't drop it if we are the target
if ((!_context.routerHash().equals(toRouter)) && if ((!_context.routerHash().equals(toRouter)) &&
_context.tunnelDispatcher().shouldDropParticipatingMessage("OBEP " + msg.getType(), msg.getMessageSize())) _context.tunnelDispatcher().shouldDropParticipatingMessage("OBEP " + msg.getType(), msg.getMessageSize()))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment