Changeset 25b0603f
- Timestamp:
- Dec 9, 2011 5:36:49 PM (9 years ago)
- Branches:
- master
- Children:
- 50606a6
- Parents:
- 937ae8ad
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
history.txt
r937ae8ad r25b0603f 1 2011-12-09 zzz 2 * Base64: Add decodestring command in main() 3 * Console, i2psnark: More button CSS tweaks 4 * I2NP: 5 - Earlier detection and better logging of 6 truncated TunnelGatewayMessage and DatabaseStoreMessage 7 - Fix and enhance UnknownI2NPMessage implementation 8 - Don't deserialize or verify the checksum of the 9 embeddedI2NP message in the TunnelGatewayMessage 10 at the IBGW, just use UnknownI2NPMessage and pass it along, 11 except if zero hop; Still to do: similar thing at OBEP 12 - Cleanups and javadoc 13 * LeaseSet: Fix size calculations 14 * UDP: 15 - Fix major bug from 2005 that corrupted outbound messages 16 that were an exact multiple of the fragment size. 17 - Round expiration times when converting to seconds 18 - Zero-copy of single-fragment messages in MessageReceiver 19 - Optimizations, log tweaks, comments 20 1 21 2011-12-06 zzz 2 22 * Router: -
router/java/src/net/i2p/data/i2np/DatabaseStoreMessage.java
r937ae8ad r25b0603f 24 24 * Defines the message a router sends to another router to test the network 25 25 * database reachability, as well as the reply message sent back. 26 * 27 * TODO: Don't decompress and recompress RouterInfos at the OBEP and IBGW. 28 * Could this even change the message length or corrupt things? 26 29 * 27 30 * @author jrandom … … 129 132 int compressedSize = (int)DataHelper.fromLong(data, curIndex, 2); 130 133 curIndex += 2; 134 if (compressedSize <= 0 || curIndex + compressedSize > data.length || (curIndex - offset) + compressedSize > dataSize) 135 throw new I2NPMessageException("Compressed RI length: " + compressedSize + 136 " but remaining bytes: " + Math.min(data.length - curIndex, dataSize - (curIndex - offset))); 131 137 132 138 try { 139 // TODO we could delay decompression, just copy to a new byte array and store in _byteCache 140 // May not be necessary since the IBGW now uses UnknownI2NPMessage. 141 // DSMs at the OBEP are generally garlic wrapped, so the OBEP won't see it. 142 // If we do delay it, getEntry() will have to check if _dbEntry is null and _byteCache 143 // is non-null, and then decompress. 133 144 byte decompressed[] = DataHelper.decompress(data, curIndex, compressedSize); 134 145 _dbEntry.readBytes(new ByteArrayInputStream(decompressed)); … … 136 147 throw new I2NPMessageException("Error reading the routerInfo", dfe); 137 148 } catch (IOException ioe) { 138 throw new I2NPMessageException("Co mpressed routerInfo was corrupt", ioe);149 throw new I2NPMessageException("Corrupt compressed routerInfo size = " + compressedSize, ioe); 139 150 } 140 151 } else { … … 146 157 147 158 148 /** calculate the message body's length (not including the header and footer */ 159 /** 160 * calculate the message body's length (not including the header and footer) 161 * 162 * @throws IllegalStateException 163 */ 149 164 protected int calculateWrittenLength() { 165 // TODO if _byteCache is non-null, don't check _dbEntry 166 if (_dbEntry == null) 167 throw new IllegalStateException("Missing entry"); 150 168 int len = Hash.HASH_LENGTH + 1 + 4; // key+type+replyToken 151 169 if (_replyToken > 0) … … 153 171 int type = _dbEntry.getType(); 154 172 if (type == DatabaseEntry.KEY_TYPE_LEASESET) { 155 _byteCache = _dbEntry.toByteArray(); 173 if (_byteCache == null) { 174 _byteCache = _dbEntry.toByteArray(); 175 } 156 176 } else if (type == DatabaseEntry.KEY_TYPE_ROUTERINFO) { 157 byte uncompressed[] = _dbEntry.toByteArray(); 158 _byteCache = DataHelper.compress(uncompressed); 177 // only decompress once 178 if (_byteCache == null) { 179 byte uncompressed[] = _dbEntry.toByteArray(); 180 _byteCache = DataHelper.compress(uncompressed); 181 } 159 182 len += 2; 160 183 } else { -
router/java/src/net/i2p/data/i2np/GarlicMessage.java
r937ae8ad r25b0603f 13 13 import net.i2p.I2PAppContext; 14 14 import net.i2p.data.DataHelper; 15 import net.i2p.util.Log;16 15 17 16 /** … … 21 20 */ 22 21 public class GarlicMessage extends I2NPMessageImpl { 23 private final static Log _log = new Log(GarlicMessage.class);24 22 public final static int MESSAGE_TYPE = 11; 25 23 private byte[] _data; -
router/java/src/net/i2p/data/i2np/I2NPMessageHandler.java
r937ae8ad r25b0603f 50 50 _lastReadBegin = System.currentTimeMillis(); 51 51 I2NPMessage msg = I2NPMessageImpl.createMessage(_context, type); 52 if (msg == null) 53 throw new I2NPMessageException("The type "+ type + " is an unknown I2NP message"); 52 // can't be null 53 //if (msg == null) 54 // throw new I2NPMessageException("The type "+ type + " is an unknown I2NP message"); 54 55 try { 55 56 _lastSize = msg.readBytes(in, type, _messageBuffer); … … 89 90 return lastRead(); 90 91 } 92 91 93 public int readMessage(byte data[], int offset) throws IOException, I2NPMessageException { 92 94 int cur = offset; … … 95 97 _lastReadBegin = System.currentTimeMillis(); 96 98 I2NPMessage msg = I2NPMessageImpl.createMessage(_context, type); 97 if (msg == null) { 98 int sz = data.length-offset; 99 boolean allZero = false; 100 for (int i = offset; i < data.length; i++) { 101 if (data[i] != 0) { 102 allZero = false; 103 break; 104 } 105 } 106 throw new I2NPMessageException("The type "+ type + " is an unknown I2NP message (remaining sz=" 107 + sz + " all zeros? " + allZero + ")"); 108 } 99 // can't be null 100 //if (msg == null) { 101 // int sz = data.length-offset; 102 // boolean allZero = false; 103 // for (int i = offset; i < data.length; i++) { 104 // if (data[i] != 0) { 105 // allZero = false; 106 // break; 107 // } 108 // } 109 // throw new I2NPMessageException("The type "+ type + " is an unknown I2NP message (remaining sz=" 110 // + sz + " all zeros? " + allZero + ")"); 111 //} 109 112 try { 110 113 _lastSize = msg.readBytes(data, type, cur); … … 128 131 public int getLastSize() { return _lastSize; } 129 132 133 /**** 130 134 public static void main(String args[]) { 131 135 try { … … 136 140 } 137 141 } 142 ****/ 138 143 } -
router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java
r937ae8ad r25b0603f 29 29 */ 30 30 public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPMessage { 31 pr ivatefinal Log _log;31 protected final Log _log; 32 32 protected final I2PAppContext _context; 33 33 private long _expiration; … … 37 37 public final static int CHECKSUM_LENGTH = 1; //Hash.HASH_LENGTH; 38 38 39 private static final boolean RAW_FULL_SIZE = false; 39 // Whether SSU used the full header or a truncated header. 40 // We are stuck with the short header, can't change it now. 41 //private static final boolean RAW_FULL_SIZE = false; 40 42 41 43 /** unused */ 42 44 private static final Map<Integer, Builder> _builders = new ConcurrentHashMap(1); 45 43 46 /** @deprecated unused */ 44 47 public static final void registerBuilder(Builder builder, int type) { _builders.put(Integer.valueOf(type), builder); } 48 45 49 /** interface for extending the types of messages handled - unused */ 46 50 public interface Builder { … … 121 125 SimpleByteCache.release(calc); 122 126 if (!eq) 123 throw new I2NPMessageException(" Hash does not match for " + getClass().getName());127 throw new I2NPMessageException("Bad checksum on " + size + " byte I2NP " + getClass().getSimpleName()); 124 128 125 129 //long start = _context.clock().now(); … … 183 187 SimpleByteCache.release(calc); 184 188 if (!eq) 185 throw new I2NPMessageException(" Hash does not match for " + getClass().getName());189 throw new I2NPMessageException("Bad checksum on " + size + " byte I2NP " + getClass().getSimpleName()); 186 190 187 191 //long start = _context.clock().now(); … … 221 225 return calculateWrittenLength()+15 + CHECKSUM_LENGTH; // 16 bytes in the header 222 226 } 227 228 /** 229 * The raw header consists of a one-byte type and a 4-byte expiration in seconds only. 230 * Used by SSU only! 231 */ 223 232 public synchronized int getRawMessageSize() { 224 if (RAW_FULL_SIZE)225 return getMessageSize();226 else233 //if (RAW_FULL_SIZE) 234 // return getMessageSize(); 235 //else 227 236 return calculateWrittenLength()+5; 228 237 } … … 311 320 312 321 313 /** used by SSU only */ 322 /** 323 * Write the message with a short 5-byte header. 324 * THe header consists of a one-byte type and a 4-byte expiration in seconds only. 325 * Used by SSU only! 326 */ 314 327 public int toRawByteArray(byte buffer[]) { 315 if (RAW_FULL_SIZE)316 return toByteArray(buffer);328 //if (RAW_FULL_SIZE) 329 // return toByteArray(buffer); 317 330 try { 318 331 int off = 0; 319 332 DataHelper.toLong(buffer, off, 1, getType()); 320 333 off += 1; 321 DataHelper.toLong(buffer, off, 4, _expiration/1000); // seconds 334 // January 19 2038? No, unsigned, good until Feb. 7 2106 335 // in seconds, round up so we don't lose time every hop 336 DataHelper.toLong(buffer, off, 4, (_expiration + 500) / 1000); 322 337 off += 4; 323 338 return writeMessageBody(buffer, off); … … 345 360 *****/ 346 361 347 /** used by SSU only */ 362 /** 363 * Read the message with a short 5-byte header. 364 * THe header consists of a one-byte type and a 4-byte expiration in seconds only. 365 * Used by SSU only! 366 */ 348 367 public static I2NPMessage fromRawByteArray(I2PAppContext ctx, byte buffer[], int offset, int len, I2NPMessageHandler handler) throws I2NPMessageException { 349 368 int type = (int)DataHelper.fromLong(buffer, offset, 1); … … 352 371 if (msg == null) 353 372 throw new I2NPMessageException("Unknown message type: " + type); 354 if (RAW_FULL_SIZE) { 355 try { 356 msg.readBytes(buffer, type, offset); 357 } catch (IOException ioe) { 358 throw new I2NPMessageException("Error reading the " + msg, ioe); 359 } 360 return msg; 361 } 362 363 try { 364 long expiration = DataHelper.fromLong(buffer, offset, 4) * 1000; // seconds 373 //if (RAW_FULL_SIZE) { 374 // try { 375 // msg.readBytes(buffer, type, offset); 376 // } catch (IOException ioe) { 377 // throw new I2NPMessageException("Error reading the " + msg, ioe); 378 // } 379 // return msg; 380 //} 381 382 try { 383 // January 19 2038? No, unsigned, good until Feb. 7 2106 384 // in seconds, round up so we don't lose time every hop 385 long expiration = (DataHelper.fromLong(buffer, offset, 4) * 1000) + 500; 365 386 offset += 4; 366 387 int dataSize = len - 1 - 4; … … 378 399 * Yes, this is fairly ugly, but its the only place it ever happens. 379 400 * 401 * @return non-null, returns an UnknownI2NPMessage if unknown type 380 402 */ 381 403 public static I2NPMessage createMessage(I2PAppContext context, int type) throws I2NPMessageException { -
router/java/src/net/i2p/data/i2np/TunnelDataMessage.java
r937ae8ad r25b0603f 23 23 */ 24 24 public class TunnelDataMessage extends I2NPMessageImpl { 25 private Log _log;26 25 private long _tunnelId; 27 26 private TunnelId _tunnelIdObj; … … 102 101 public TunnelDataMessage(I2PAppContext context) { 103 102 super(context); 104 _log = context.logManager().getLog(TunnelDataMessage.class);105 103 setMessageExpiration(context.clock().now() + EXPIRATION_PERIOD); 106 104 } -
router/java/src/net/i2p/data/i2np/TunnelGatewayMessage.java
r937ae8ad r25b0603f 22 22 */ 23 23 public class TunnelGatewayMessage extends I2NPMessageImpl { 24 private Log _log;25 24 private TunnelId _tunnelId; 26 25 private I2NPMessage _msg; 27 26 private byte _msgData[]; 28 private Exception _creator;27 //private Exception _creator; 29 28 30 29 public final static int MESSAGE_TYPE = 19; … … 34 33 public TunnelGatewayMessage(I2PAppContext context) { 35 34 super(context); 36 _log = context.logManager().getLog(TunnelGatewayMessage.class);37 35 setMessageExpiration(context.clock().now() + EXPIRATION_PERIOD); 38 36 //_creator = new Exception("i made this"); … … 42 40 public void setTunnelId(TunnelId id) { _tunnelId = id; } 43 41 42 /** 43 * Warning, at the IBGW, where the message was read in, 44 * this will be an UnknownI2NPMessage. 45 * If you need a real message class, use UnknownI2NPMessage.convert(). 46 */ 44 47 public I2NPMessage getMessage() { return _msg; } 48 45 49 public void setMessage(I2NPMessage msg) { 46 50 if (msg == null) … … 62 66 protected int writeMessageBody(byte out[], int curIndex) throws I2NPMessageException { 63 67 if ( (_tunnelId == null) || ( (_msg == null) && (_msgData == null) ) ) { 64 _log.log(Log.CRIT, "failing to write out gateway message , created by: ", _creator);68 _log.log(Log.CRIT, "failing to write out gateway message"); 65 69 throw new I2NPMessageException("Not enough data to write out (id=" + _tunnelId + " data=" + _msg + ")"); 66 70 } … … 88 92 89 93 public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException, IOException { 90 I2NPMessageHandler h = new I2NPMessageHandler(_context); 91 readMessage(data, offset, dataSize, type, h); 94 //I2NPMessageHandler h = new I2NPMessageHandler(_context); 95 //readMessage(data, offset, dataSize, type, h); 96 readMessage(data, offset, dataSize, type, null); 92 97 } 98 99 /** 100 * Note that for efficiency at the IBGW, this does not fully deserialize the included 101 * I2NP Message. It just puts it in an UnknownI2NPMessage. 102 * 103 * @param handler unused, may be null 104 */ 93 105 @Override 94 106 public void readMessage(byte data[], int offset, int dataSize, int type, I2NPMessageHandler handler) throws I2NPMessageException, IOException { … … 102 114 throw new I2NPMessageException("Invalid tunnel Id " + _tunnelId); 103 115 104 DataHelper.fromLong(data, curIndex, 2);116 int len = (int) DataHelper.fromLong(data, curIndex, 2); 105 117 curIndex += 2; 106 curIndex = handler.readMessage(data, curIndex); 107 _msg = handler.lastRead(); 108 if (_msg == null) 109 throw new I2NPMessageException("wtf, message read has no payload?"); 118 if (len <= 1 || curIndex + len > data.length || len > dataSize - 6) 119 throw new I2NPMessageException("I2NP length in TGM: " + len + 120 " but remaining bytes: " + Math.min(data.length - curIndex, dataSize - 6)); 121 122 // OLD WAY full message parsing and instantiation 123 //handler.readMessage(data, curIndex); 124 //_msg = handler.lastRead(); 125 //if (_msg == null) 126 // throw new I2NPMessageException("wtf, message read has no payload?"); 127 128 // NEW WAY save lots of effort at the IBGW by reading as an UnknownI2NPMessage instead 129 // This will save a lot of object churn and processing, 130 // primarily for unencrypted msgs (V)TBRM, DatabaseStoreMessage, and DSRMs. 131 // DatabaseStoreMessages in particluar are intensive for readBytes() 132 // since the RI is decompressed. 133 // For a zero-hop IB tunnel, where we do need the real thing, 134 // it is converted to a real message class in TunnelGatewayZeroHop 135 // using UnknownI2NPMessage.convert() in TunnelGatewayZeroHop. 136 // We also skip processing the checksum as it's covered by the TGM checksum. 137 // If a zero-hop, the checksum will be verified in convert(). 138 int utype = data[curIndex++] & 0xff; 139 UnknownI2NPMessage umsg = new UnknownI2NPMessage(_context, utype); 140 umsg.readBytesIgnoreChecksum(data, curIndex); 141 _msg = umsg; 110 142 } 111 143 -
router/java/src/net/i2p/data/i2np/UnknownI2NPMessage.java
r937ae8ad r25b0603f 13 13 import net.i2p.I2PAppContext; 14 14 import net.i2p.data.DataHelper; 15 import net.i2p.data.Hash; 16 import net.i2p.util.SimpleByteCache; 15 17 16 18 /** … … 24 26 * read it with readMessage() (i.e., it came from some other router) 25 27 * 26 * @since 0.7.12 28 * @since 0.7.12 but broken before 0.8.12 27 29 */ 28 30 public class UnknownI2NPMessage extends I2NPMessageImpl { 29 31 private byte _data[]; 30 private int _type; 32 private final int _type; 33 // we assume CHECKSUM_LENGTH = 1 34 private byte _checksum; 31 35 32 36 /** @param type 0-255 */ … … 36 40 } 37 41 38 /** warning - only public for equals() */39 public byte[] getData() {40 return _data;41 }42 43 42 public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException, IOException { 44 43 if (type != _type) throw new I2NPMessageException("Message type is incorrect for this message"); 45 int curIndex = offset; 46 long size = DataHelper.fromLong(data, curIndex, 4); 47 curIndex += 4; 48 if (size > MAX_SIZE) 49 throw new I2NPMessageException("wtf, size=" + size); 50 _data = new byte[(int)size]; 51 System.arraycopy(data, curIndex, _data, 0, (int)size); 44 if (dataSize > MAX_SIZE) 45 throw new I2NPMessageException("wtf, size=" + dataSize); 46 _data = new byte[dataSize]; 47 System.arraycopy(data, offset, _data, 0, dataSize); 52 48 } 53 49 … … 55 51 protected int calculateWrittenLength() { 56 52 if (_data == null) 57 return 4;53 return 0; 58 54 else 59 return 4 +_data.length;55 return _data.length; 60 56 } 61 57 62 58 /** write the message body to the output array, starting at the given index */ 63 59 protected int writeMessageBody(byte out[], int curIndex) { 64 if (_data == null) { 65 out[curIndex++] = 0x0; 66 out[curIndex++] = 0x0; 67 out[curIndex++] = 0x0; 68 out[curIndex++] = 0x0; 69 } else { 70 byte len[] = DataHelper.toLong(4, _data.length); 71 System.arraycopy(len, 0, out, curIndex, 4); 72 curIndex += 4; 60 if (_data != null) { 73 61 System.arraycopy(_data, 0, out, curIndex, _data.length); 74 62 curIndex += _data.length; … … 80 68 public int getType() { return _type; } 81 69 70 71 /** 72 * Read the full message including the header. 73 * This is the same as I2NPMessageImpl.readBytes(), except 74 * start after the type field, and 75 * do NOT verify the checksum, but simply save it for later 76 * so it can be verified in convert() if required. 77 * 78 *<pre> 79 * Standard message format AFTER the type field 80 * 4 byte ID 81 * 8 byte expiration 82 * 2 byte size 83 * 1 byte checksum (saved in case we need to check later) 84 * size bytes of payload, read by readMessage() 85 *</pre> 86 * 87 * @param offset starting at the ID (must skip the type) 88 * @return total length of the message 89 * @since 0.8.12 90 */ 91 public void readBytesIgnoreChecksum(byte data[], int offset) throws I2NPMessageException, IOException { 92 int cur = offset; 93 setUniqueId(DataHelper.fromLong(data, cur, 4)); 94 cur += 4; 95 setMessageExpiration(DataHelper.fromLong(data, cur, DataHelper.DATE_LENGTH)); 96 cur += DataHelper.DATE_LENGTH; 97 int size = (int)DataHelper.fromLong(data, cur, 2); 98 cur += 2; 99 _checksum = data[cur]; 100 cur++; 101 102 if (cur + size > data.length) 103 throw new I2NPMessageException("Payload is too short [" 104 + "data.len=" + data.length 105 + " offset=" + offset 106 + " cur=" + cur 107 + " wanted=" + size + ']'); 108 109 readMessage(data, cur, size, _type); 110 } 111 112 /** 113 * Attempt to convert this message to a known message class. 114 * Must have been created with readBytesIgnoreChecksum previously, 115 * as this does the delayed verification using the saved checksum. 116 * 117 * Used by TunnelGatewayZeroHop. 118 * 119 * @throws I2NPMessageException if the conversion fails 120 * @since 0.8.12 121 */ 122 public I2NPMessage convert() throws I2NPMessageException { 123 I2NPMessage msg = I2NPMessageImpl.createMessage(_context, _type); 124 if (msg instanceof UnknownI2NPMessage) 125 throw new I2NPMessageException("Unable to convert unknown type " + _type); 126 byte[] calc = SimpleByteCache.acquire(Hash.HASH_LENGTH); 127 _context.sha().calculateHash(_data, 0, _data.length, calc, 0); 128 boolean eq = _checksum == calc[0]; 129 SimpleByteCache.release(calc); 130 if (!eq) 131 throw new I2NPMessageException("Bad checksum on " + _data.length + " byte msg type " + _type); 132 try { 133 msg.readMessage(_data, 0, _data.length, _type); 134 } catch (IOException ioe) { 135 throw new I2NPMessageException("Unable to convert type " + _type, ioe); 136 } 137 msg.setUniqueId(getUniqueId()); 138 msg.setMessageExpiration(getMessageExpiration()); 139 return msg; 140 } 141 82 142 @Override 83 143 public int hashCode() { 84 return _type + DataHelper.hashCode( getData());144 return _type + DataHelper.hashCode(_data); 85 145 } 86 146 … … 89 149 if ( (object != null) && (object instanceof UnknownI2NPMessage) ) { 90 150 UnknownI2NPMessage msg = (UnknownI2NPMessage)object; 91 return _type == msg.getType() && DataHelper.eq( getData(), msg.getData());151 return _type == msg.getType() && DataHelper.eq(_data, msg._data); 92 152 } else { 93 153 return false; … … 100 160 buf.append("[UnknownI2NPMessage: "); 101 161 buf.append("\n\tType: ").append(_type); 102 buf.append("\n\tLength: ").append(calculateWrittenLength() - 4);162 buf.append("\n\tLength: ").append(calculateWrittenLength()); 103 163 buf.append("]"); 104 164 return buf.toString(); -
router/java/src/net/i2p/router/RouterVersion.java
r937ae8ad r25b0603f 19 19 public final static String ID = "Monotone"; 20 20 public final static String VERSION = CoreVersion.VERSION; 21 public final static long BUILD = 1 7;21 public final static long BUILD = 18; 22 22 23 23 /** for example "-test" */ -
router/java/src/net/i2p/router/tunnel/FragmentHandler.java
r937ae8ad r25b0603f 478 478 _log.debug("RECV(" + data.length + "): "); // + Base64.encode(data) 479 479 //+ " " + _context.sha().calculateHash(data).toBase64()); 480 481 // TODO read in as unknown message for outbound tunnels, 482 // since this will just be packaged in a TunnelGatewayMessage. 483 // Not a big savings since most everything is a GarlicMessage 484 // and so the readMessage() call is fast. 485 // The unencrypted messages at the OBEP are (V)TBMs 486 // and perhaps an occasional DatabaseLookupMessage 480 487 I2NPMessage m = new I2NPMessageHandler(_context).readMessage(data); 481 488 noteReception(m.getUniqueId(), fragmentCount-1, "complete: ");// + msg.toString()); -
router/java/src/net/i2p/router/tunnel/OutboundMessageDistributor.java
r937ae8ad r25b0603f 62 62 if (_log.shouldLog(Log.DEBUG)) 63 63 _log.debug("queueing inbound message to ourselves: " + m); 64 // TODO if UnknownI2NPMessage, convert it. 65 // See FragmentHandler.receiveComplete() 64 66 _context.inNetMessagePool().add(m, null, null); 65 67 return; -
router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java
r937ae8ad r25b0603f 453 453 + " and/or the content's expiration is in " + DataHelper.formatDuration(msg.getMessage().getMessageExpiration()-before) 454 454 + " with messageId " + msg.getUniqueId() + "/" + msg.getMessage().getUniqueId() + " and message type " 455 + msg.getMessage().getClass().get Name());455 + msg.getMessage().getClass().getSimpleName()); 456 456 return; 457 457 } … … 472 472 + " messageId " + msg.getUniqueId() 473 473 + "/" + msg.getMessage().getUniqueId() 474 + " messageType: " + msg.getMessage().getClass().get Name()474 + " messageType: " + msg.getMessage().getClass().getSimpleName() 475 475 + " existing = " + _inboundGateways.size(), new Exception("source")); 476 476 } -
router/java/src/net/i2p/router/tunnel/TunnelGatewayZeroHop.java
r937ae8ad r25b0603f 4 4 import net.i2p.data.TunnelId; 5 5 import net.i2p.data.i2np.I2NPMessage; 6 import net.i2p.data.i2np.I2NPMessageException; 6 7 import net.i2p.data.i2np.TunnelGatewayMessage; 8 import net.i2p.data.i2np.UnknownI2NPMessage; 7 9 import net.i2p.router.RouterContext; 8 10 import net.i2p.util.Log; … … 31 33 /** 32 34 * Add a message to be sent down the tunnel, where we are the inbound gateway. 35 * This requires converting the message included in the TGM from an 36 * UnknownI2NPMessage to the correct message class. 37 * See TunnelGatewayMessage for details. 33 38 * 34 39 * @param msg message received to be sent through the tunnel … … 36 41 @Override 37 42 public void add(TunnelGatewayMessage msg) { 38 add(msg.getMessage(), null, null); 43 I2NPMessage imsg = msg.getMessage(); 44 if (_config.isInbound()) { 45 if (imsg instanceof UnknownI2NPMessage) { 46 // Do the delayed deserializing - convert to a standard message class 47 try { 48 UnknownI2NPMessage umsg = (UnknownI2NPMessage) imsg; 49 imsg = umsg.convert(); 50 } catch (I2NPMessageException ime) { 51 if (_log.shouldLog(Log.WARN)) 52 _log.warn("Unable to convert to std. msg. class at zero-hop IBGW", ime); 53 return; 54 } 55 } 56 } 57 add(imsg, null, null); 39 58 } 40 59 … … 51 70 public void add(I2NPMessage msg, Hash toRouter, TunnelId toTunnel) { 52 71 if (_log.shouldLog(Log.DEBUG)) 53 _log.debug("zero hop gateway: distribute " + (_config.isInbound() ? "inbound " : " outbound")72 _log.debug("zero hop gateway: distribute " + (_config.isInbound() ? "inbound" : " outbound") 54 73 + " to " + (toRouter != null ? toRouter.toBase64().substring(0,4) : "" ) 55 74 + "." + (toTunnel != null ? toTunnel.getTunnelId() + "" : "")
Note: See TracChangeset
for help on using the changeset viewer.