QR2/SB: Allow different public IP for TCP and UDP

This commit is contained in:
mkwcat 2024-02-06 19:41:22 -05:00
parent 820138ac60
commit 4dda86651a
No known key found for this signature in database
GPG Key ID: 7A505679CE9E7AA9
2 changed files with 4 additions and 6 deletions

View File

@ -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))

View File

@ -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 {