SilkMC / silk

Silk is a Minecraft API for Kotlin - targetting Fabric, Quilt and Paper
https://silkmc.net/silk/docs/
GNU General Public License v3.0
100 stars 12 forks source link

Players cannot connect to server with silk behind modern Velocity after switching server #50

Closed Glucy-2 closed 11 months ago

Glucy-2 commented 11 months ago

Enviroment: Debian 12 (Linux debian 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-1 (2023-07-14) x86_64 GNU/Linux) Zulu Java 20

openjdk version "20.0.2" 2023-07-18
OpenJDK Runtime Environment Zulu20.32+11-CA (build 20.0.2+9)
OpenJDK 64-Bit Server VM Zulu20.32+11-CA (build 20.0.2+9, mixed mode, sharing)

Proxy:

Server:

To reproduce:

  1. Setup a Velocity server with player-info-forwarding-mode = "modern" in velocity.toml
  2. Setup a fabric server with mods above
  3. Copy content in forwarding.secret (generated by Velocity) and paste it in fabric server config/FabricProxy-Lite.toml's secret
  4. Setup another server supporting Velocity's modern player info forwarding, can be a NanoLimbo, or another fabric server with FabricProxy-Lite. If you installed silk on this server, it will cause an infinite loop
  5. Configure server addresses in velocity.toml
  6. Start servers and velocity
  7. Join
  8. Switch to another server using /server
  9. Switch back
  10. You'll get kicked (or fallback to the server you switched first) : Internal Exception: java.lang.IndexOutOfBoundsException: readerIndex(1) + length(1) exceeds writerIndex(1): PooledUnsafeDirectByteBuf(ridx: 1, widx: 1, cap: 1)

fabric log:

Starting net.fabricmc.loader.impl.game.minecraft.BundlerClassPathCapture
[05:10:43] [main/INFO]: Loading Minecraft 1.20.1 with Fabric Loader 0.14.21
[05:10:43] [main/INFO]: Loading 63 mods:
        - fabric-api 0.86.1+1.20.1
           |-- fabric-api-base 0.4.30+7abfd51577
           |-- fabric-api-lookup-api-v1 1.6.35+4d8536c977
           |-- fabric-biome-api-v1 13.0.10+b3afc78b77
           |-- fabric-block-api-v1 1.0.9+e022e5d177
           |-- fabric-blockrenderlayer-v1 1.1.40+b3afc78b77
           |-- fabric-client-tags-api-v1 1.1.1+97bb207577
           |-- fabric-command-api-v1 1.2.33+f71b366f77
           |-- fabric-command-api-v2 2.2.12+b3afc78b77
           |-- fabric-commands-v0 0.2.50+df3654b377
           |-- fabric-containers-v0 0.1.62+df3654b377
           |-- fabric-content-registries-v0 4.0.9+b3afc78b77
           |-- fabric-convention-tags-v1 1.5.4+a1a980da77
           |-- fabric-crash-report-info-v1 0.2.18+aeb40ebe77
           |-- fabric-data-generation-api-v1 12.2.1+1e61dba177
           |-- fabric-dimensions-v1 2.1.52+b3afc78b77
           |-- fabric-entity-events-v1 1.5.22+b3afc78b77
           |-- fabric-events-interaction-v0 0.6.1+e91849a877
           |-- fabric-events-lifecycle-v0 0.2.62+df3654b377
           |-- fabric-game-rule-api-v1 1.0.38+b04edc7a77
           |-- fabric-item-api-v1 2.1.27+b3afc78b77
           |-- fabric-item-group-api-v1 4.0.10+23d9108177
           |-- fabric-key-binding-api-v1 1.0.36+fb8d95da77
           |-- fabric-keybindings-v0 0.2.34+df3654b377
           |-- fabric-lifecycle-events-v1 2.2.21+b3afc78b77
           |-- fabric-loot-api-v2 1.1.39+b3afc78b77
           |-- fabric-loot-tables-v1 1.1.43+9e7660c677
           |-- fabric-message-api-v1 5.1.7+3265161977
           |-- fabric-mining-level-api-v1 2.1.49+b3afc78b77
           |-- fabric-model-loading-api-v1 1.0.2+709a987177
           |-- fabric-models-v0 0.4.1+9386d8a777
           |-- fabric-networking-api-v1 1.3.9+b3afc78b77
           |-- fabric-networking-v0 0.3.49+df3654b377
           |-- fabric-object-builder-api-v1 11.1.1+6beca84877
           |-- fabric-particles-v1 1.1.1+201a23a077
           |-- fabric-recipe-api-v1 1.0.19+b3afc78b77
           |-- fabric-registry-sync-v0 2.3.1+4df89eb277
           |-- fabric-renderer-api-v1 3.1.1+9386d8a777
           |-- fabric-renderer-indigo 1.4.1+9172968c77
           |-- fabric-renderer-registries-v1 3.2.45+df3654b377
           |-- fabric-rendering-data-attachment-v1 0.3.34+b3afc78b77
           |-- fabric-rendering-fluids-v1 3.0.27+b3afc78b77
           |-- fabric-rendering-v0 1.1.48+df3654b377
           |-- fabric-rendering-v1 3.0.7+b3afc78b77
           |-- fabric-resource-conditions-api-v1 2.3.5+ea08f9d877
           |-- fabric-resource-loader-v0 0.11.9+132c48c177
           |-- fabric-screen-api-v1 2.0.7+b3afc78b77
           |-- fabric-screen-handler-api-v1 1.3.28+b3afc78b77
           |-- fabric-sound-api-v1 1.0.12+b3afc78b77
           |-- fabric-transfer-api-v1 3.3.0+cdf060b277
           \-- fabric-transitive-access-wideners-v1 4.3.0+6c31357e77
        - fabric-language-kotlin 1.10.8+kotlin.1.9.0
           |-- org_jetbrains_kotlin_kotlin-reflect 1.9.0
           |-- org_jetbrains_kotlin_kotlin-stdlib 1.9.0
           |-- org_jetbrains_kotlin_kotlin-stdlib-jdk7 1.9.0
           |-- org_jetbrains_kotlin_kotlin-stdlib-jdk8 1.9.0
           |-- org_jetbrains_kotlinx_atomicfu-jvm 0.21.0
           |-- org_jetbrains_kotlinx_kotlinx-coroutines-core-jvm 1.7.2
           |-- org_jetbrains_kotlinx_kotlinx-coroutines-jdk8 1.7.2
           |-- org_jetbrains_kotlinx_kotlinx-datetime-jvm 0.4.0
           |-- org_jetbrains_kotlinx_kotlinx-serialization-cbor-jvm 1.5.1
           |-- org_jetbrains_kotlinx_kotlinx-serialization-core-jvm 1.5.1
           \-- org_jetbrains_kotlinx_kotlinx-serialization-json-jvm 1.5.1
        - fabricloader 0.14.21
        - fabricproxy-lite 2.6.0
           \-- com_moandjiezana_toml_toml4j 0.7.2
        - java 20
        - minecraft 1.20.1
        - silk-all 1.10.0
           |-- silk-commands 1.10.0
           |-- silk-core 1.10.0
           |-- silk-game 1.10.0
           |-- silk-igui 1.10.0
           |-- silk-nbt 1.10.0
           |-- silk-network 1.10.0
           \-- silk-persistence 1.10.0
[05:10:44] [main/INFO]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=file:/var/tmp/skimit/libraries/net/fabricmc/sponge-mixin/0.12.5+mixin.0.8.5/sponge-mixin-0.12.5+mixin.0.8.5.jar Service=Knot/Fabric Env=SERVER
[05:10:44] [main/INFO]: Compatibility level set to JAVA_16
[05:10:44] [main/INFO]: Compatibility level set to JAVA_17
[05:10:48] [main/INFO]: Initializing Silk due to init call
[05:10:48] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[05:10:49] [main/INFO]: Loaded 7 recipes
[05:10:49] [main/INFO]: Loaded 1271 advancements
[05:10:49] [main/INFO]: Applied 0 biome modifications to 0 of 64 new biomes in 982.7 μs
[05:10:49] [Server thread/INFO]: Reached SERVER_STARTING state
[05:10:49] [Server thread/INFO]: Initialized mcCoroutineScope (MinecraftServer as executor)
[05:10:49] [Server thread/INFO]: Starting minecraft server version 1.20.1
[05:10:49] [Server thread/INFO]: Loading properties
[05:10:49] [Server thread/INFO]: Default game type: CREATIVE
[05:10:49] [Server thread/INFO]: Generating keypair
[05:10:49] [Server thread/INFO]: Starting Minecraft server on *:25566
[05:10:49] [Server thread/INFO]: Using epoll channel type
[05:10:50] [Server thread/INFO]: Preparing level "world2"
[05:10:51] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[05:10:52] [Worker-Main-3/INFO]: Preparing spawn area: 0%
[05:10:52] [Worker-Main-1/INFO]: Preparing spawn area: 0%
[05:10:52] [Worker-Main-6/INFO]: Preparing spawn area: 1%
[05:10:53] [Worker-Main-7/INFO]: Preparing spawn area: 3%
[05:10:53] [Worker-Main-15/INFO]: Preparing spawn area: 6%
[05:10:54] [Worker-Main-13/INFO]: Preparing spawn area: 10%
[05:10:54] [Worker-Main-3/INFO]: Preparing spawn area: 16%
[05:10:55] [Worker-Main-13/INFO]: Preparing spawn area: 20%
[05:10:55] [Worker-Main-10/INFO]: Preparing spawn area: 24%
[05:10:56] [Worker-Main-12/INFO]: Preparing spawn area: 27%
[05:10:56] [Worker-Main-1/INFO]: Preparing spawn area: 34%
[05:10:57] [Worker-Main-1/INFO]: Preparing spawn area: 41%
[05:10:57] [Worker-Main-9/INFO]: Preparing spawn area: 47%
[05:10:58] [Worker-Main-11/INFO]: Preparing spawn area: 54%
[05:10:58] [Worker-Main-14/INFO]: Preparing spawn area: 58%
[05:10:59] [Worker-Main-8/INFO]: Preparing spawn area: 67%
[05:10:59] [Worker-Main-6/INFO]: Preparing spawn area: 71%
[05:11:00] [Worker-Main-13/INFO]: Preparing spawn area: 77%
[05:11:00] [Worker-Main-9/INFO]: Preparing spawn area: 84%
[05:11:01] [Worker-Main-7/INFO]: Preparing spawn area: 90%
[05:11:01] [Worker-Main-4/INFO]: Preparing spawn area: 97%
[05:11:01] [Server thread/INFO]: Time elapsed: 10096 ms
[05:11:01] [Server thread/INFO]: Done (11.860s)! For help, type "help"
[05:11:25] [Server thread/INFO]: Glucy2[/xxx.xxx.xxx.xxx:47038] logged in with entity id 392 at (110.5, 78.0, -91.5)
[05:11:25] [Server thread/INFO]: Glucy2 joined the game
[05:11:25] [Server thread/INFO]: Glucy2 lost connection: Internal Exception: java.lang.IndexOutOfBoundsException: readerIndex(1) + length(1) exceeds writerIndex(1): PooledUnsafeDirectByteBuf(ridx: 1, widx: 1, cap: 1)
[05:11:25] [Server thread/INFO]: Glucy2 left the game
Glucy-2 commented 11 months ago

The bug is in silk-network's mixin, here Commenting the code solves the bug Maybe conflicting with FabricProxy-Lite's mixin? I don't know how to solve it elegantly, I know very little in Java and Kotlin

jakobkmar commented 11 months ago

Thanks for the report, I am not entirely sure what is causing this, but it indeed has something to do with this mixin. I will try some possible fixes - and I hope that velocity is not preventing custom packets in some way.

jakobkmar commented 11 months ago

Hi, I pushed some commits to main, if you want you can already test if this fixed the issue.

Glucy-2 commented 11 months ago

Yes it's fixed, running great, thank you.

jakobkmar commented 11 months ago

Thank you for the report and testing out the fix!

jakobkmar commented 10 months ago

The release including the fix is now out: 1.10.1.