forked from I2P_Developers/i2p.i2p
I2CP:
- Add support for b64 conversion in destLookup() - Catch invalid message length sooner I2Ping: - Extend I2PTunnelClientBase so non-shared-client, I2CP options, and other features will work - Fixes for fields and threading Streaming: - Send LS with ping (broken since 0.9.2) - Set the NO_ACK flag on pings and pongs
This commit is contained in:
@ -1209,6 +1209,19 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
* @return null on failure
|
||||
*/
|
||||
public Destination lookupDest(String name, long maxWait) throws I2PSessionException {
|
||||
if (name.length() == 0)
|
||||
return null;
|
||||
// Shortcut for b64
|
||||
if (name.length() >= 516) {
|
||||
try {
|
||||
return new Destination(name);
|
||||
} catch (DataFormatException dfe) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// won't fit in Mapping
|
||||
if (name.length() >= 256 && !_context.isRouterContext())
|
||||
return null;
|
||||
synchronized (_lookupCache) {
|
||||
Destination rv = _lookupCache.get(name);
|
||||
if (rv != null)
|
||||
|
@ -21,6 +21,12 @@ import net.i2p.data.DataHelper;
|
||||
*/
|
||||
public class I2CPMessageHandler {
|
||||
|
||||
/**
|
||||
* This is huge. Mainly to catch a completly bogus response, possibly not an I2CP socket.
|
||||
* @since 0.9.10
|
||||
*/
|
||||
public static final int MAX_LENGTH = 128*1024;
|
||||
|
||||
/**
|
||||
* Read an I2CPMessage from the stream and return the fully populated object.
|
||||
*
|
||||
@ -37,8 +43,9 @@ public class I2CPMessageHandler {
|
||||
} catch (DataFormatException dfe) {
|
||||
throw new IOException("Connection closed");
|
||||
}
|
||||
if (length > MAX_LENGTH)
|
||||
throw new I2CPMessageException("Invalid message length specified");
|
||||
try {
|
||||
if (length < 0) throw new I2CPMessageException("Invalid message length specified");
|
||||
int type = (int) DataHelper.readLong(in, 1);
|
||||
I2CPMessage msg = createMessage(type);
|
||||
// Note that the readMessage() calls don't, in general, read and discard
|
||||
|
Reference in New Issue
Block a user