Skip to content

Commit bb5612c

Browse files
authored
Support Forge clients (#27)
* Add nix devshell and .envrc * Add .direnv to .gitignore * Handle forge FML protocol
1 parent df7f23b commit bb5612c

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
data
22

33

4-
.idea
4+
.idea
5+
.direnv

flake.lock

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
outputs = { self, nixpkgs, ... }:
3+
let
4+
forAllSystems = function:
5+
nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ]
6+
(system: function nixpkgs.legacyPackages.${system});
7+
in rec {
8+
devShells =
9+
forAllSystems (pkgs: { default = pkgs.callPackage ./shell.nix { }; });
10+
};
11+
}

pkg/router.go

+5
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,13 @@ func (r Router) handleConnection(client net.Conn) {
117117
return
118118
}
119119
serverAddress := string(serverAddressRaw)
120+
121+
// Its common for proxies or mods to append extra data to the server address after a "///" separator. We ignore this for routing.
120122
serverAddress = strings.Split(serverAddress, "///")[0]
121123

124+
// Forge's "FML" protocol appends a marker to the end of the server address prefixed with a null character.
125+
serverAddress = strings.Split(serverAddress, "\x00")[0]
126+
122127
serverPortRaw := make([]byte, 2)
123128
_, err = packetReader.Read(serverPortRaw)
124129
if err != nil {

shell.nix

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{ pkgs ? import <nixpkgs> { }, ... }:
2+
pkgs.mkShell {
3+
packages = with pkgs; [ go gopls ];
4+
}

0 commit comments

Comments
 (0)