Skip to content

Commit

Permalink
Add customizable MTU support (GeyserMC#1068)
Browse files Browse the repository at this point in the history
* Add customizable MTU support

Fixes clients being unable to connect in rare instances.

* Make config.yml nicer
  • Loading branch information
Camotoy authored Jul 31, 2020
1 parent af5e8a8 commit 7fc14d8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ public String getUniqueId() {
}
}

@Override
public int getMtu() {
return node.getNode("mtu").getInt(1400);
}

@Override
public int getConfigVersion() {
return node.getNode("config-version").getInt(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nukkitx.network.raknet.RakNetConstants;
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
import com.nukkitx.protocol.bedrock.BedrockServer;
import com.nukkitx.protocol.bedrock.v407.Bedrock_v407;
Expand Down Expand Up @@ -168,6 +169,10 @@ private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) {
if (config.isAboveBedrockNetherBuilding())
DimensionUtils.changeBedrockNetherId(); // Apply End dimension ID workaround to Nether

// https://github.com/GeyserMC/Geyser/issues/957
RakNetConstants.MAXIMUM_MTU_SIZE = (short) config.getMtu();
logger.debug("Setting MTU to " + config.getMtu());

bedrockServer = new BedrockServer(new InetSocketAddress(config.getBedrock().getAddress(), config.getBedrock().getPort()));
bedrockServer.setHandler(new ConnectorServerEventHandler(this));
bedrockServer.bind().whenComplete((avoid, throwable) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ interface IMetricsInfo {
String getUniqueId();
}

int getMtu();

int getConfigVersion();

static void checkGeyserConfiguration(GeyserConfiguration geyserConfig, GeyserLogger geyserLogger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public static class MetricsInfo implements IMetricsInfo {
private String uniqueId;
}

@JsonProperty("mtu")
private int mtu = 1400;

@JsonProperty("config-version")
private int configVersion;
}
6 changes: 5 additions & 1 deletion connector/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,9 @@ metrics:
# UUID of server, don't change!
uuid: generateduuid

# DO NOT TOUCH!
# ADVANCED OPTIONS - DO NOT TOUCH UNLESS YOU KNOW WHAT YOU ARE DOING!
# The internet supports a maximum MTU of 1492 but could cause issues with packet fragmentation.
# 1400 is the default.
# mtu: 1400

config-version: 3

0 comments on commit 7fc14d8

Please sign in to comment.