From 095d69d8a30349bf1d6f038abd32282e429a4aac Mon Sep 17 00:00:00 2001 From: TomatoPuddin Date: Sun, 20 Oct 2024 08:22:55 +0800 Subject: [PATCH] Fix forge connection. --- cmd/gateway/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/gateway/main.go b/cmd/gateway/main.go index 9755314..a5785b5 100644 --- a/cmd/gateway/main.go +++ b/cmd/gateway/main.go @@ -8,6 +8,7 @@ import ( "os" "sync" "time" + "strings" "github.com/fsnotify/fsnotify" "github.com/rs/zerolog/log" @@ -211,5 +212,11 @@ func GetMcHost(buf []byte) string { return "" } - return string(buf[1 : host_len+1]) + host := string(buf[1 : host_len+1]) + + if spliterIndex := strings.IndexRune(host, 0); spliterIndex != -1 { + return host[0:spliterIndex] + } else { + return host + } }