From 4dda86651a6d4b421f4584d2f16e8aac20d6a9b3 Mon Sep 17 00:00:00 2001 From: mkwcat Date: Tue, 6 Feb 2024 19:41:22 -0500 Subject: [PATCH] QR2/SB: Allow different public IP for TCP and UDP --- qr2/session.go | 8 +++----- serverbrowser/server.go | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/qr2/session.go b/qr2/session.go index 1921a98..dc6c9ed 100644 --- a/qr2/session.go +++ b/qr2/session.go @@ -4,7 +4,6 @@ import ( "math/rand" "net" "strconv" - "strings" "time" "wwfc/common" "wwfc/logging" @@ -187,10 +186,7 @@ func (session *Session) setProfileID(moduleName string, newPID string) bool { return false } - if strings.Split(gpPublicIP, ":")[0] != strings.Split(session.Addr.String(), ":")[0] { - logging.Error(moduleName, "Caller public IP does not match GPCM session") - return false - } + // TODO: Some kind of authentication if ratingError := checkValidRating(moduleName, session.Data); ratingError != "ok" { callback := loginInfo.GPErrorCallback @@ -218,6 +214,8 @@ func (session *Session) setProfileID(moduleName string, newPID string) bool { session.Data["+deviceauth"] = "0" } + session.Data["+gppublicip"], _ = common.IPFormatToString(gpPublicIP) + session.Data["dwc_pid"] = newPID logging.Notice(moduleName, "Opened session with PID", aurora.Cyan(newPID)) diff --git a/serverbrowser/server.go b/serverbrowser/server.go index c9e8c47..bcd18d7 100644 --- a/serverbrowser/server.go +++ b/serverbrowser/server.go @@ -205,7 +205,7 @@ func handleServerListRequest(conn net.Conn, buffer []byte) { continue } - if publicip == callerPublicIP { + if publicip == callerPublicIP || server["+gppublicip"] == callerPublicIP { // Use the real public IP if it matches the caller's ip, err := strconv.ParseInt(publicip, 10, 32) if err != nil {