Fix large packets on LAN connections causing End of Stream (RIP).
This commit is contained in:
parent
c0e081c699
commit
47a81e6589
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -7,7 +7,6 @@ eaglercraftbungee/.idea
|
||||||
eaglercraftbungee/bin
|
eaglercraftbungee/bin
|
||||||
eaglercraftbungee/rundir
|
eaglercraftbungee/rundir
|
||||||
eaglercraftbungee/test
|
eaglercraftbungee/test
|
||||||
eaglercraftbungee/minecrafthtml5bungee.iml
|
|
||||||
eaglercraftbungee/src/main/java/META-INF
|
eaglercraftbungee/src/main/java/META-INF
|
||||||
eaglercraftbungee/out
|
eaglercraftbungee/out
|
||||||
epkcompiler/bin
|
epkcompiler/bin
|
||||||
|
@ -26,11 +25,10 @@ sp-server/bin
|
||||||
stable-download/_repl*
|
stable-download/_repl*
|
||||||
lwjgl-rundir/_eagstorage*
|
lwjgl-rundir/_eagstorage*
|
||||||
*.bak
|
*.bak
|
||||||
sp-relay/sp-relay.iml
|
|
||||||
sp-relay/out
|
sp-relay/out
|
||||||
sp-relay/test
|
sp-relay/test
|
||||||
sp-relay/.idea
|
sp-relay/.idea
|
||||||
sp-relay/src/main/java/META-INF
|
sp-relay/src/main/java/META-INF
|
||||||
zip-generator/zip-generator.iml
|
|
||||||
zip-generator/out
|
zip-generator/out
|
||||||
zip-generator/src/main/java/META-INF
|
zip-generator/src/main/java/META-INF
|
||||||
|
*.iml
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module version="4">
|
|
||||||
<component name="EclipseModuleManager">
|
|
||||||
<conelement value="org.eclipse.buildship.core.gradleclasspathcontainer" />
|
|
||||||
<src_description expected_position="0">
|
|
||||||
<src_folder value="file://$MODULE_DIR$/src/main/java" expected_position="0" />
|
|
||||||
<src_folder value="file://$MODULE_DIR$/src/teavm/java" expected_position="1" />
|
|
||||||
<src_folder value="file://$MODULE_DIR$/sp-server/src/ipc/java" expected_position="2" />
|
|
||||||
</src_description>
|
|
||||||
</component>
|
|
||||||
</module>
|
|
36426
javascript/classes.js
36426
javascript/classes.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -7,4 +7,4 @@
|
||||||
* in the user manual at https://docs.gradle.org/6.0/userguide/multi_project_builds.html
|
* in the user manual at https://docs.gradle.org/6.0/userguide/multi_project_builds.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rootProject.name = 'eaglercraft-sp'
|
rootProject.name = 'eaglercraft'
|
||||||
|
|
|
@ -6,7 +6,7 @@ public class ConfigConstants {
|
||||||
|
|
||||||
public static boolean profanity = false;
|
public static boolean profanity = false;
|
||||||
|
|
||||||
public static final String version = "22w34a";
|
public static final String version = "22w34b";
|
||||||
public static final String mainMenuString = "eaglercraft " + version;
|
public static final String mainMenuString = "eaglercraft " + version;
|
||||||
|
|
||||||
public static final String forkMe = "https://github.com/lax1dude/eaglercraft";
|
public static final String forkMe = "https://github.com/lax1dude/eaglercraft";
|
||||||
|
|
|
@ -244,6 +244,8 @@ public class LANClientNetworkManager implements INetworkManager {
|
||||||
// no
|
// no
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private byte[] fragmentedPacket = new byte[0];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processReadPackets() {
|
public void processReadPackets() {
|
||||||
|
|
||||||
|
@ -260,7 +262,25 @@ public class LANClientNetworkManager implements INetworkManager {
|
||||||
if(this.theNetHandler != null) {
|
if(this.theNetHandler != null) {
|
||||||
byte[] data;
|
byte[] data;
|
||||||
while((data = EaglerAdapter.clientLANReadPacket()) != null) {
|
while((data = EaglerAdapter.clientLANReadPacket()) != null) {
|
||||||
ByteArrayInputStream bai = new ByteArrayInputStream(data);
|
byte[] fullData;
|
||||||
|
|
||||||
|
if (data[0] == 0) {
|
||||||
|
fullData = new byte[fragmentedPacket.length + data.length - 1];
|
||||||
|
System.arraycopy(fragmentedPacket, 0, fullData, 0, fragmentedPacket.length);
|
||||||
|
System.arraycopy(data, 1, fullData, fragmentedPacket.length, data.length - 1);
|
||||||
|
fragmentedPacket = new byte[0];
|
||||||
|
} else if (data[0] == 1) {
|
||||||
|
fullData = new byte[fragmentedPacket.length + data.length - 1];
|
||||||
|
System.arraycopy(fragmentedPacket, 0, fullData, 0, fragmentedPacket.length);
|
||||||
|
System.arraycopy(data, 1, fullData, fragmentedPacket.length, data.length - 1);
|
||||||
|
fragmentedPacket = fullData;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayInputStream bai = new ByteArrayInputStream(fullData);
|
||||||
|
|
||||||
int pktId = bai.read();
|
int pktId = bai.read();
|
||||||
|
|
||||||
if(pktId == -1) {
|
if(pktId == -1) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class LANServerList {
|
||||||
public void update() {
|
public void update() {
|
||||||
long millis = System.currentTimeMillis();
|
long millis = System.currentTimeMillis();
|
||||||
if(millis - lastRefresh > 10000l) {
|
if(millis - lastRefresh > 10000l) {
|
||||||
if(++refreshCounter < 25) {
|
if(++refreshCounter < 10) {
|
||||||
refresh();
|
refresh();
|
||||||
}else {
|
}else {
|
||||||
lastRefresh = millis;
|
lastRefresh = millis;
|
||||||
|
|
|
@ -3919,11 +3919,27 @@ public class EaglerAdapterImpl2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int fragmentSize = 16384;
|
||||||
|
|
||||||
public static final void serverLANWritePacket(String peer, byte[] data) {
|
public static final void serverLANWritePacket(String peer, byte[] data) {
|
||||||
ArrayBuffer arr = ArrayBuffer.create(data.length);
|
if (data.length > fragmentSize) {
|
||||||
Uint8Array.create(arr).set(data);
|
for (int i = 0; i < data.length; i += fragmentSize) {
|
||||||
|
byte[] fragData = new byte[((i + fragmentSize > data.length) ? (data.length % fragmentSize) : fragmentSize) + 1];
|
||||||
|
System.arraycopy(data, i, fragData, 1, fragData.length - 1);
|
||||||
|
fragData[0] = (i + fragmentSize < data.length) ? (byte) 1 : (byte) 0;
|
||||||
|
ArrayBuffer arr = ArrayBuffer.create(fragData.length);
|
||||||
|
Uint8Array.create(arr).set(fragData);
|
||||||
rtcLANServer.sendPacketToRemoteClient(peer, arr);
|
rtcLANServer.sendPacketToRemoteClient(peer, arr);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
byte[] sendData = new byte[data.length + 1];
|
||||||
|
sendData[0] = 0;
|
||||||
|
System.arraycopy(data, 0, sendData, 1, data.length);
|
||||||
|
ArrayBuffer arr = ArrayBuffer.create(sendData.length);
|
||||||
|
Uint8Array.create(arr).set(sendData);
|
||||||
|
rtcLANServer.sendPacketToRemoteClient(peer, arr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final void serverLANCreatePeer(String peer) {
|
public static final void serverLANCreatePeer(String peer) {
|
||||||
rtcLANServer.signalRemoteConnect(peer);
|
rtcLANServer.signalRemoteConnect(peer);
|
||||||
|
|
60400
stable-download/Offline_Download_Version.html
vendored
60400
stable-download/Offline_Download_Version.html
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user