Skip to content

Commit 73e28e4

Browse files
committed
Properly skip over "v6" IP address in compatibility mode
Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
1 parent 34b7c23 commit 73e28e4

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ You can join the [Discord](https://discord.gg/5z4GuSnqmQ) for help with this for
1313
- Allows for resetting security state if `Open Connection Reply 1` is resent by the server
1414
- Only do retries with `Open Connection Request 1`, and reserve `Open Connection Request 2` only as a direct response to `Open Connection Reply 1`
1515
- Allows using datagram channel factories for raknet (from [@AlexProgrammerDE](https://github.com/AlexProgrammerDE))
16+
- Skips over improperly typed client address fields
1617

1718
## Usage
1819

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Only update version on publishing to Maven Central
2-
version=1.2.1
2+
version=1.2.2

transport-raknet/src/main/java/org/cloudburstmc/netty/handler/codec/raknet/client/RakClientOfflineHandlerCompatible.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import org.cloudburstmc.netty.handler.codec.raknet.common.RakSessionCodec;
1717
import org.cloudburstmc.netty.util.RakUtils;
1818

19+
import static org.cloudburstmc.netty.channel.raknet.RakConstants.MAXIMUM_MTU_SIZE;
20+
1921
public class RakClientOfflineHandlerCompatible extends RakClientOfflineHandler {
2022
public static final String NAME = "rak-client-handler";
2123

transport-raknet/src/main/java/org/cloudburstmc/netty/util/RakUtils.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,15 @@ public static InetSocketAddress readAddress(ByteBuf buffer) {
9898
}
9999

100100
public static boolean skipAddress(ByteBuf buffer) {
101-
short type = buffer.readByte();
101+
short type = buffer.readUnsignedByte();
102102
try {
103103
if (type == 4) {
104104
// Skip 4 + 2 bytes
105105
buffer.skipBytes(6);
106-
} else if (type == 6) {
106+
} else {
107107
// Skip 2 + 2 + 4 + 16 + 4 bytes
108+
// Vanilla client treats as v6 if unknown type
108109
buffer.skipBytes(28);
109-
} else {
110-
// Vanilla client skips over if the type is not 4 or 6
111-
return false;
112110
}
113111
} catch (IndexOutOfBoundsException e) {
114112
return false;

0 commit comments

Comments
 (0)