Changeset caada2b


Ignore:
Timestamp:
Dec 11, 2011 1:36:50 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
474909a
Parents:
ec46079
Message:

better logging of corrupted I2NP msgs

Location:
router/java/src/net/i2p/router
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/udp/MessageReceiver.java

    rec46079 rcaada2b  
    203203                m = I2NPMessageImpl.fromRawByteArray(_context, state.getFragments()[0].getData(), 0, state.getCompleteSize(), handler);
    204204            }
    205             if (state.getCompleteSize() == 534 && _log.shouldLog(Log.INFO)) {
    206                 _log.info(HexDump.dump(buf.getData(), 0, state.getCompleteSize()));
    207             }
    208205            m.setUniqueId(state.getMessageId());
    209206            return m;
     
    211208            if (_log.shouldLog(Log.WARN)) {
    212209                _log.warn("Message invalid: " + state, ime);
    213                 _log.warn(HexDump.dump(buf.getData(), 0, state.getCompleteSize()));
    214                 _log.warn("RAW: " + Base64.encode(buf.getData(), 0, state.getCompleteSize()));
     210                _log.warn("DUMP:\n" + HexDump.dump(buf.getData(), 0, state.getCompleteSize()));
     211                _log.warn("RAW:\n" + Base64.encode(buf.getData(), 0, state.getCompleteSize()));
    215212            }
    216213            _context.messageHistory().droppedInboundMessage(state.getMessageId(), state.getFrom(), "error: " + ime.toString() + ": " + state.toString());
  • router/java/src/net/i2p/router/tunnel/FragmentHandler.java

    rec46079 rcaada2b  
    1515import net.i2p.router.RouterContext;
    1616import net.i2p.util.ByteCache;
     17import net.i2p.util.HexDump;
    1718import net.i2p.util.Log;
    1819import net.i2p.util.SimpleByteCache;
     
    469470        if (_log.shouldLog(Log.DEBUG))
    470471            stringified = msg.toString();
     472        byte data[] = null;
    471473        try {
    472474            int fragmentCount = msg.getFragmentCount();
    473475            // toByteArray destroys the contents of the message completely
    474             byte data[] = msg.toByteArray();
     476            data = msg.toByteArray();
    475477            if (data == null)
    476478                throw new I2NPMessageException("null data");   // fragments already released???
     
    489491            noteCompletion(m.getUniqueId());
    490492            _receiver.receiveComplete(m, msg.getTargetRouter(), msg.getTargetTunnel());
    491         } catch (IOException ioe) {
    492             if (stringified == null) stringified = msg.toString();
    493             if (_log.shouldLog(Log.ERROR))
    494                 _log.error("Error receiving fragmented message (corrupt?): " + stringified, ioe);
    495493        } catch (I2NPMessageException ime) {
    496494            if (stringified == null) stringified = msg.toString();
    497             if (_log.shouldLog(Log.WARN))
     495            if (_log.shouldLog(Log.WARN)) {
    498496                _log.warn("Error receiving fragmented message (corrupt?): " + stringified, ime);
     497                _log.warn("DUMP:\n" + HexDump.dump(data));
     498                _log.warn("RAW:\n" + Base64.encode(data));
     499            }
    499500        }
    500501    }
Note: See TracChangeset for help on using the changeset viewer.