diff --git a/router/java/src/net/i2p/router/transport/udp/OutboundMessageState.java b/router/java/src/net/i2p/router/transport/udp/OutboundMessageState.java index 0c05840e364437950da61aa744144a5aad47644d..7a64c0efe3b890687543fdfde8aed763789f2975 100644 --- a/router/java/src/net/i2p/router/transport/udp/OutboundMessageState.java +++ b/router/java/src/net/i2p/router/transport/udp/OutboundMessageState.java @@ -87,11 +87,18 @@ class OutboundMessageState implements CDPQEntry { //_expiration = msg.getExpiration(); // now "fragment" it - int totalSize = _i2npMessage.getRawMessageSize(); + int totalSize; + if (_peer.getVersion() == 2) + totalSize = _i2npMessage.getMessageSize() - 7; // NTCP2 style, 9 byte header + else + totalSize = _i2npMessage.getRawMessageSize(); if (totalSize > MAX_MSG_SIZE) throw new IllegalArgumentException("Size too large! " + totalSize); _messageBuf = new byte[totalSize]; - _i2npMessage.toRawByteArray(_messageBuf); + if (_peer.getVersion() == 2) + _i2npMessage.toRawByteArrayNTCP2(_messageBuf, 0); // NTCP2 style, 9 byte header + else + _i2npMessage.toRawByteArray(_messageBuf); _fragmentSize = _peer.fragmentSize(); int numFragments = totalSize / _fragmentSize; if (numFragments * _fragmentSize < totalSize) diff --git a/router/java/src/net/i2p/router/transport/udp/SSU2Payload.java b/router/java/src/net/i2p/router/transport/udp/SSU2Payload.java index 0439a5b3ad3be1155e398acb59231d1b386063c6..510eff32296eb8663c79cb4da37fcf549060e093 100644 --- a/router/java/src/net/i2p/router/transport/udp/SSU2Payload.java +++ b/router/java/src/net/i2p/router/transport/udp/SSU2Payload.java @@ -393,11 +393,10 @@ class SSU2Payload { } } -/* public static class I2NPBlock extends Block { - private final OutboundMessageState2 m; + private final OutboundMessageState m; - public I2NPBlock(OutboundMessageState2 msg) { + public I2NPBlock(OutboundMessageState msg) { super(BLOCK_I2NP); m = msg; } @@ -412,16 +411,14 @@ class SSU2Payload { return off + m.writeFragment(tgt, off, 0); } } -*/ /** * Same format as I2NPBlock */ -/* public static class FirstFragBlock extends Block { - private final OutboundMessageState2 m; + private final OutboundMessageState m; - public FirstFragBlock(OutboundMessageState2 msg) { + public FirstFragBlock(OutboundMessageState msg) { super(BLOCK_FIRSTFRAG); m = msg; } @@ -436,17 +433,15 @@ class SSU2Payload { return off + m.writeFragment(tgt, off, 0); } } -*/ /** * */ -/* public static class FollowFragBlock extends Block { - private final OutboundMessageState2 m; + private final OutboundMessageState m; private final int f; - public FollowFragBlock(OutboundMessageState2 msg, int frag) { + public FollowFragBlock(OutboundMessageState msg, int frag) { super(BLOCK_FOLLOWONFRAG); if (frag <= 0) throw new IllegalArgumentException(); @@ -468,7 +463,6 @@ class SSU2Payload { return off + m.writeFragment(tgt, off, 0); } } -*/ public static class PaddingBlock extends Block { private final int sz;