forked from I2P_Developers/i2p.i2p
SSU2: Peer Test fixes part 6
Change size/ip/port fields to match changes in proposal 159
This commit is contained in:
10
history.txt
10
history.txt
@ -1,3 +1,13 @@
|
|||||||
|
2022-04-27 zzz
|
||||||
|
* SSU2: Peer test updates and fixes
|
||||||
|
|
||||||
|
2022-04-24 zzz
|
||||||
|
* SSU: Publish empty IPv6 address when missing introducers
|
||||||
|
* SSU2: Finish peer test implementation
|
||||||
|
|
||||||
|
2022-04-17 zzz
|
||||||
|
* More soft restart fixes
|
||||||
|
|
||||||
2022-04-14 zzz
|
2022-04-14 zzz
|
||||||
* Startup: Don't set our RI loaded from disk if too old
|
* Startup: Don't set our RI loaded from disk if too old
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Git";
|
public final static String ID = "Git";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 14;
|
public final static long BUILD = 15;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
@ -358,9 +358,9 @@ class PeerTestManager {
|
|||||||
data[1] = 2; // version
|
data[1] = 2; // version
|
||||||
DataHelper.toLong(data, 2, 4, nonce);
|
DataHelper.toLong(data, 2, 4, nonce);
|
||||||
DataHelper.toLong(data, 6, 4, _context.clock().now() / 1000);
|
DataHelper.toLong(data, 6, 4, _context.clock().now() / 1000);
|
||||||
data[10] = (byte) iplen;
|
data[10] = (byte) (iplen + 2);
|
||||||
System.arraycopy(aliceIP, 0, data, 11, iplen);
|
DataHelper.toLong(data, 11, 2, alicePort);
|
||||||
DataHelper.toLong(data, 11 + iplen, 2, alicePort);
|
System.arraycopy(aliceIP, 0, data, 13, iplen);
|
||||||
packet = _packetBuilder2.buildPeerTestFromAlice(test.getCharlieIP(), test.getCharliePort(),
|
packet = _packetBuilder2.buildPeerTestFromAlice(test.getCharlieIP(), test.getCharliePort(),
|
||||||
test.getCharlieIntroKey(),
|
test.getCharlieIntroKey(),
|
||||||
sendId, rcvId, data);
|
sendId, rcvId, data);
|
||||||
@ -842,20 +842,24 @@ class PeerTestManager {
|
|||||||
long nonce = DataHelper.fromLong(data, 2, 4);
|
long nonce = DataHelper.fromLong(data, 2, 4);
|
||||||
long time = DataHelper.fromLong(data, 6, 4) * 1000;
|
long time = DataHelper.fromLong(data, 6, 4) * 1000;
|
||||||
int iplen = data[10] & 0xff;
|
int iplen = data[10] & 0xff;
|
||||||
if (iplen != 0 && iplen != 4 && iplen != 16) {
|
if (iplen != 0 && iplen != 6 && iplen != 18) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Bad IP length " + iplen);
|
_log.warn("Bad IP length " + iplen);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean isIPv6 = iplen == 16;
|
boolean isIPv6 = iplen == 18;
|
||||||
|
int testPort;
|
||||||
byte[] testIP;
|
byte[] testIP;
|
||||||
if (iplen != 0) {
|
if (iplen != 0) {
|
||||||
testIP = new byte[iplen];
|
testPort = (int) DataHelper.fromLong(data, 11, 2);
|
||||||
System.arraycopy(data, 11, testIP, 0, iplen);
|
testIP = new byte[iplen - 2];
|
||||||
|
System.arraycopy(data, 13, testIP, 0, iplen - 2);
|
||||||
} else {
|
} else {
|
||||||
|
testPort = 0;
|
||||||
testIP = null;
|
testIP = null;
|
||||||
|
if (status == 0)
|
||||||
|
status = 999;
|
||||||
}
|
}
|
||||||
int testPort = (int) DataHelper.fromLong(data, 11 + iplen, 2);
|
|
||||||
Long lNonce = Long.valueOf(nonce);
|
Long lNonce = Long.valueOf(nonce);
|
||||||
PeerTestState state;
|
PeerTestState state;
|
||||||
if (msg == 4 || msg == 5 || msg == 7)
|
if (msg == 4 || msg == 5 || msg == 7)
|
||||||
@ -1285,9 +1289,9 @@ class PeerTestManager {
|
|||||||
data[1] = 2; // version
|
data[1] = 2; // version
|
||||||
DataHelper.toLong(data, 2, 4, nonce);
|
DataHelper.toLong(data, 2, 4, nonce);
|
||||||
DataHelper.toLong(data, 6, 4, now / 1000);
|
DataHelper.toLong(data, 6, 4, now / 1000);
|
||||||
data[10] = (byte) iplen;
|
data[10] = (byte) (iplen + 2);
|
||||||
System.arraycopy(aliceIP, 0, data, 11, iplen);
|
DataHelper.toLong(data, 11, 2, alicePort);
|
||||||
DataHelper.toLong(data, 11 + iplen, 2, alicePort);
|
System.arraycopy(aliceIP, 0, data, 13, iplen);
|
||||||
if (_log.shouldDebug())
|
if (_log.shouldDebug())
|
||||||
_log.debug("Send msg 7 to alice on " + state);
|
_log.debug("Send msg 7 to alice on " + state);
|
||||||
UDPPacket packet = _packetBuilder2.buildPeerTestToAlice(addr, alicePort,
|
UDPPacket packet = _packetBuilder2.buildPeerTestToAlice(addr, alicePort,
|
||||||
|
@ -179,7 +179,7 @@ final class SSU2Util {
|
|||||||
public static byte[] createPeerTestData(I2PAppContext ctx, Hash h, Hash h2,
|
public static byte[] createPeerTestData(I2PAppContext ctx, Hash h, Hash h2,
|
||||||
PeerTestState.Role role, long nonce, byte[] ip, int port,
|
PeerTestState.Role role, long nonce, byte[] ip, int port,
|
||||||
SigningPrivateKey spk) {
|
SigningPrivateKey spk) {
|
||||||
int datalen = 13 + ip.length;
|
int datalen = 13 + (ip != null ? ip.length : 0);
|
||||||
byte[] data = new byte[datalen + spk.getType().getSigLen()];
|
byte[] data = new byte[datalen + spk.getType().getSigLen()];
|
||||||
if (role == PeerTestState.Role.BOB)
|
if (role == PeerTestState.Role.BOB)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
@ -188,10 +188,11 @@ final class SSU2Util {
|
|||||||
DataHelper.toLong(data, 2, 4, nonce);
|
DataHelper.toLong(data, 2, 4, nonce);
|
||||||
DataHelper.toLong(data, 6, 4, ctx.clock().now() / 1000);
|
DataHelper.toLong(data, 6, 4, ctx.clock().now() / 1000);
|
||||||
int iplen = (ip != null) ? ip.length : 0;
|
int iplen = (ip != null) ? ip.length : 0;
|
||||||
data[10] = (byte) iplen;
|
data[10] = (byte) (ip != null ? iplen + 2 : 0);
|
||||||
if (ip != null)
|
if (ip != null) {
|
||||||
System.arraycopy(ip, 0, data, 11, iplen);
|
DataHelper.toLong(data, 11, 2, port);
|
||||||
DataHelper.toLong(data, 11 + iplen, 2, port);
|
System.arraycopy(ip, 0, data, 13, iplen);
|
||||||
|
}
|
||||||
Signature sig = sign(ctx, PEER_TEST_PROLOGUE, h, h2, data, datalen, spk);
|
Signature sig = sign(ctx, PEER_TEST_PROLOGUE, h, h2, data, datalen, spk);
|
||||||
if (sig == null)
|
if (sig == null)
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user