henkelmax / simple-voice-chat

A working voice chat in Minecraft!
https://modrepo.de/minecraft/voicechat/wiki
457 stars 120 forks source link

Implement Velocity Proxy #674

Closed nilathedragon closed 8 months ago

nilathedragon commented 8 months ago

As mentioned in Discord I'm more than happy to bring this project back upstream, so here it is.

What is this pull-request about?

This Pull-Request aims to officially integrate Simple Voice Chat for Velocity into the Simple Voice Chat project.

Why should Velocity be part of the official Simple Voice Chat project?

By having an official Velocity proxy, more people will be able to find and benefit from this solution. It being an official integration increases trust and lowers the change of malicious code making its way into it. Simple Voice Chat also gains some ground against Plasmo which already offers such proxying capability.

Change summary

In order to allow for future support of other proxy-platforms like Bungeecord, Waterfall or others that I may not know about, this change is divided into two sub-projects.

common-proxy This project is similar to the common project for clients, and it contains most of the actual proxying logic, fully independent of the proxy platform.

velocity This project implements the API common-proxy dictates and is essentially just a thin layer between the Velocity API and the common-proxy API. It also provides the code for the configuration file.

How does the proxying work

The proxy was designed to be lightweight and do as little parsing as necessary. Thanks to a characteristic in the protocol of Simple Voice Chat, we are able to identify incoming packets by reading only a header portion containing the player's UUID.

This UUID can then be used to determine the backend server to which the player is connected to, giving us the target IP for any future traffic. In order to remove any kind of per-server configuration, the proxy is also able to sniff the SecretPacket sent via a plugin message.

The packet contains the target port for voice traffic, which combined with the target server IP is enough to forward traffic. By using one DatagramSocket per player on the backend, we do not require any identification of the packet and can simply take its content, change the target address from the proxy to the player and send it out via the public interface.

As long as no protocol changes occur near the magic byte & player UUID, this proxy should just keep working as is and be mostly mod-version independent.

How I tested this proxy so far

I use this proxy on a survival smp server, which we used Simple Voice Chat numerous times for hours in groups and it has been working fine. I also conducted local tests with Velocity and two Folia 1.20.4 servers with modern forwarding enabled and disabled to ensure both cases are supported. One server has the port set on the game port, the other has a custom one configured. This was to test the sniffer.

I also hopped between servers many times and the connection was always established as expected.

I require assistance with the following

I have no idea how to configure the gradle.properties for releasing to modrinth etc, as I have never worked with that. Since you know your release setup best, I'd appreciate if you would either tell me how to properly configure it, or make the necessary changes yourself.

xiaoluofa commented 7 months ago

NEED GROUP SYNC