GPCM: Remove IP address from friend status

This commit is contained in:
mkwcat
2023-12-07 05:37:39 -05:00
parent 7ff2bfa4d9
commit 30b400d939
3 changed files with 10 additions and 32 deletions

View File

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

View File

@@ -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"],
},
})

View File

@@ -21,6 +21,8 @@ type GameSpySession struct {
ModuleName string
LoggedIn bool
Challenge string
LoginTicket string
SessionKey int32
Status string
LocString string
FriendList []uint32