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

Skip to content
Snippets Groups Projects
Unverified Commit 4d650249 authored by zzz's avatar zzz
Browse files

SSU2: Peer test improvements

- Return OK as Alice when only receiving msg 5, unless snatted (SSU 1 also)
- Allow and handle firewalled Charlie as Alice
- Only create peer test data once as Alice
- Store test status and send-to-Alice time in test state to support retransmission
- Don't delete state after sending msg 4 as Bob, for possible retransmission
- Check for IP mismatch from Charlie as Alice, abort test and assume good
- Check for port mismatch from Charlie as Alice and validate
- Skip unroutable addresses when searching through RI for the right one
- Respond to retransmitted msg 1 as Bob
- Respond to retransmitted msg 2 as Charlie
- Update Charlie timer to retransmit msg 5
- Only send Charlie RI to Alice (as Bob) if test was accepted
- Convert timers to SimpleTimer2 (SSU 1 also)
- Log tweaks
parent 72e21619
No related branches found
No related tags found
No related merge requests found
......@@ -83,8 +83,9 @@ class PeerTestEvent extends SimpleTimer2.TimedEvent {
if (bob != null) {
if (_log.shouldLog(Log.INFO))
_log.info("Running periodic test with bob = " + bob);
_testManager.runTest(bob);
setLastTested(isIPv6);
boolean started = _testManager.runTest(bob);
if (started)
setLastTested(isIPv6);
} else {
if (_log.shouldLog(Log.WARN))
_log.warn("Unable to run peer test, no peers available - v6? " + isIPv6);
......@@ -107,15 +108,15 @@ class PeerTestEvent extends SimpleTimer2.TimedEvent {
* @since 0.9.39
*/
public synchronized void forceRunSoon(boolean isIPv6, long delay) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("PTE.forceRunSoon() - v6? " + isIPv6, new Exception());
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("PTE.forceRunSoon() - v6? " + isIPv6, new Exception());
if (!isIPv6 && _transport.isIPv4Firewalled())
return;
if (isIPv6 && _transport.isIPv6Firewalled())
return;
_forceRun = isIPv6 ? FORCE_IPV6 : FORCE_IPV4;
if (_log.shouldDebug())
_log.debug("reschedule for " + net.i2p.data.DataHelper.formatDuration(delay));
_log.debug("PTE.forceRunSoon(), v6? " + isIPv6 + ", reschedule for " + net.i2p.data.DataHelper.formatDuration(delay));
reschedule(delay);
}
......@@ -153,8 +154,8 @@ class PeerTestEvent extends SimpleTimer2.TimedEvent {
_lastTestedV6.set(now);
else
_lastTested.set(now);
if (_log.shouldLog(Log.DEBUG))
_log.debug("PTE.setLastTested() - v6? " + isIPv6, new Exception());
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("PTE.setLastTested() - v6? " + isIPv6, new Exception());
}
private boolean shouldTest() {
......
......@@ -42,6 +42,8 @@ class PeerTestState {
private long _receiveAliceTime;
private long _receiveBobTime;
private long _receiveCharlieTime;
private long _sendAliceTime;
private int _status;
private final AtomicInteger _packetsRelayed = new AtomicInteger();
public enum Role {ALICE, BOB, CHARLIE};
......@@ -198,13 +200,39 @@ class PeerTestState {
public void setReceiveCharlieTime(long when) { _receiveCharlieTime = when; }
/**
* SSU2 only, we are Bob
* when did we send to alice, SSU2 Bob only
* @since 0.9.57
*/
public long getSendAliceTime() { return _sendAliceTime; }
/**
* when did we send to alice, SSU2 Bob only
* @since 0.9.57
*/
public void setSendAliceTime(long when) { _sendAliceTime = when; }
/**
* what code did we send to alice, SSU2 Bob only
* @since 0.9.57
*/
public int getStatus() { return _status; }
/**
* what code did we send to alice, SSU2 Bob only
* @since 0.9.57
*/
public void setStatus(int status) { _status = status; }
/**
* Get for retransmission.
* SSU2 only, we are Alice, Bob or Charlie
* @since 0.9.57
*/
public byte[] getTestData() { return _testData; }
/**
* SSU2 only, we are Bob
* Save for retransmission.
* SSU2 only, we are Alice, Bob or Charlie
* @since 0.9.57
*/
public void setTestData(byte[] data) { _testData = data; }
......
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