From 30b400d93998b7e87fef542ba27d6347d9660373 Mon Sep 17 00:00:00 2001 From: mkwcat Date: Thu, 7 Dec 2023 05:37:39 -0500 Subject: [PATCH] GPCM: Remove IP address from friend status --- gpcm/friend.go | 30 ++---------------------------- gpcm/login.go | 10 ++++++---- gpcm/main.go | 2 ++ 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/gpcm/friend.go b/gpcm/friend.go index 628c27a..6d9ce82 100644 --- a/gpcm/friend.go +++ b/gpcm/friend.go @@ -120,20 +120,7 @@ func (g *GameSpySession) setStatus(command common.GameSpyCommand) { locstring = "" } - // Get the IP address for the status msg - var rawIP int - for i, s := range strings.Split(strings.Split(g.Conn.RemoteAddr().String(), ":")[0], ".") { - val, err := strconv.Atoi(s) - if err != nil { - panic(err) - } - - rawIP |= val << (24 - i*8) - } - - ip := strconv.FormatInt(int64(int32(rawIP)), 10) - - statusMsg := "|s|" + status + "|ss|" + statstring + "|ls|" + locstring + "|ip|" + ip + "|p|0|qm|0" + statusMsg := "|s|" + status + "|ss|" + statstring + "|ls|" + locstring + "|ip|0|p|0|qm|0" logging.Notice(g.ModuleName, "New status:", aurora.BrightMagenta(statusMsg)) mutex.Lock() @@ -271,22 +258,9 @@ func (g *GameSpySession) exchangeFriendStatus(profileId uint32) { } func (g *GameSpySession) sendLogoutStatus() { - // Get the IP address for the status msg - var rawIP int - for i, s := range strings.Split(strings.Split(g.Conn.RemoteAddr().String(), ":")[0], ".") { - val, err := strconv.Atoi(s) - if err != nil { - panic(err) - } - - rawIP |= val << (24 - i*8) - } - - ip := strconv.FormatInt(int64(int32(rawIP)), 10) - mutex.Lock() for _, storedPid := range g.AuthFriendList { - sendMessageToProfileId("100", g.User.ProfileId, storedPid, "|s|0|ss|Offline|ls||ip|"+ip+"|p|0|qm|0") + sendMessageToProfileId("100", g.User.ProfileId, storedPid, "|s|0|ss|Offline|ls||ip|0|p|0|qm|0") } mutex.Unlock() } diff --git a/gpcm/login.go b/gpcm/login.go index e71a4d2..c695752 100644 --- a/gpcm/login.go +++ b/gpcm/login.go @@ -6,6 +6,7 @@ import ( "encoding/base64" "encoding/hex" "fmt" + "math/rand" "strconv" "strings" "wwfc/common" @@ -173,9 +174,10 @@ func (g *GameSpySession) login(command common.GameSpyCommand) { sessions[g.User.ProfileId] = g mutex.Unlock() - loginTicket := strings.Replace(base64.StdEncoding.EncodeToString([]byte(common.RandomString(16))), "=", "_", -1) + g.LoginTicket = strings.Replace(base64.StdEncoding.EncodeToString([]byte(common.RandomString(16))), "=", "_", -1) // Now initiate the session - _ = database.CreateSession(pool, ctx, g.User.ProfileId, loginTicket) + _ = database.CreateSession(pool, ctx, g.User.ProfileId, g.LoginTicket) + g.SessionKey = rand.Int31n(290000000) + 10000000 g.LoggedIn = true g.ModuleName = "GPCM:" + strconv.FormatInt(int64(g.User.ProfileId), 10) @@ -185,12 +187,12 @@ func (g *GameSpySession) login(command common.GameSpyCommand) { Command: "lc", CommandValue: "2", OtherValues: map[string]string{ - "sesskey": "199714190", + "sesskey": strconv.FormatInt(int64(g.SessionKey), 10), "proof": proof, "userid": strconv.FormatInt(g.User.UserId, 10), "profileid": strconv.FormatInt(int64(g.User.ProfileId), 10), "uniquenick": g.User.UniqueNick, - "lt": loginTicket, + "lt": g.LoginTicket, "id": command.OtherValues["id"], }, }) diff --git a/gpcm/main.go b/gpcm/main.go index 4828443..84e19e1 100644 --- a/gpcm/main.go +++ b/gpcm/main.go @@ -21,6 +21,8 @@ type GameSpySession struct { ModuleName string LoggedIn bool Challenge string + LoginTicket string + SessionKey int32 Status string LocString string FriendList []uint32