forked from I2P_Developers/i2p.i2p
* I2CP:
- Better fix for logging dropped messages (ticket #758) - Implement fast receive to reduce per-message handshakes - Make messageReliability=none the default
This commit is contained in:
@ -40,6 +40,24 @@ public interface I2PClient {
|
||||
/** @since 0.8.1 */
|
||||
public final static String PROP_RELIABILITY_NONE = "none";
|
||||
|
||||
/**
|
||||
* For router->client payloads.
|
||||
*
|
||||
* If false, the router will send the MessageStatus,
|
||||
* the client must respond with a ReceiveMessageBegin,
|
||||
* the router will send the MessagePayload,
|
||||
* and the client respond with a ReceiveMessageEnd.
|
||||
*
|
||||
* If true, the router will send the MessagePayload immediately,
|
||||
* and will not send a MessageStatus.
|
||||
* The client will not send ReceiveMessageBegin or ReceiveMessageEnd.
|
||||
*
|
||||
* Default false, but the implementation in this package sets to true.
|
||||
*
|
||||
* @since 0.9.4
|
||||
*/
|
||||
public final static String PROP_FAST_RECEIVE = "i2cp.fastReceive";
|
||||
|
||||
/** protocol flag that must be sent when opening the i2cp connection to the router */
|
||||
public final static int PROTOCOL_BYTE = 0x2A;
|
||||
|
||||
|
@ -136,6 +136,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
|
||||
private long _lastActivity;
|
||||
private boolean _isReduced;
|
||||
private final boolean _fastReceive;
|
||||
|
||||
/**
|
||||
* @since 0.8.9
|
||||
@ -168,6 +169,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
if (options == null)
|
||||
options = (Properties) System.getProperties().clone();
|
||||
loadConfig(options);
|
||||
_fastReceive = Boolean.parseBoolean(_options.getProperty(I2PClient.PROP_FAST_RECEIVE));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,6 +230,10 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
_options.setProperty("i2cp.password", configPW);
|
||||
}
|
||||
}
|
||||
if (_options.getProperty(I2PClient.PROP_FAST_RECEIVE) == null)
|
||||
_options.setProperty(I2PClient.PROP_FAST_RECEIVE, "true");
|
||||
if (_options.getProperty(I2PClient.PROP_RELIABILITY) == null)
|
||||
_options.setProperty(I2PClient.PROP_RELIABILITY, "none");
|
||||
}
|
||||
|
||||
/** save some memory, don't pass along the pointless properties */
|
||||
@ -280,6 +286,13 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
} catch (I2PSessionException ise) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.9.4
|
||||
*/
|
||||
public boolean getFastReceive() {
|
||||
return _fastReceive;
|
||||
}
|
||||
|
||||
void setLeaseSet(LeaseSet ls) {
|
||||
_leaseSet = ls;
|
||||
if (ls != null) {
|
||||
|
@ -40,10 +40,19 @@ class MessagePayloadMessageHandler extends HandlerImpl {
|
||||
decryptPayload(msg, session);
|
||||
session.addNewMessage(msg);
|
||||
|
||||
ReceiveMessageEndMessage m = new ReceiveMessageEndMessage();
|
||||
m.setMessageId(id);
|
||||
m.setSessionId(msg.getSessionId());
|
||||
session.sendMessage(m);
|
||||
// Small chance of this, but
|
||||
// if we are a new I2P lib talking to an old router
|
||||
// and we don't send this, the router will OOM as it has
|
||||
// no cleaner for old messages.
|
||||
// TODO after 0.9.4 is out, check router version from handshake
|
||||
// and send it all the time if 0.9.3 or less
|
||||
// (needs router version saving support in SetDateMessageHandler)
|
||||
//if (!session.getFastReceive()) {
|
||||
ReceiveMessageEndMessage m = new ReceiveMessageEndMessage();
|
||||
m.setMessageId(id);
|
||||
m.setSessionId(msg.getSessionId());
|
||||
session.sendMessage(m);
|
||||
//}
|
||||
} catch (DataFormatException dfe) {
|
||||
session.propogateError("Error handling a new payload message", dfe);
|
||||
} catch (I2PSessionException ise) {
|
||||
|
Reference in New Issue
Block a user