mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-10-01 03:26:35 -05:00
Merge branch 'main' into split-process
This commit is contained in:
@@ -92,8 +92,9 @@ type MatchCommandDataResvOK struct {
|
||||
}
|
||||
|
||||
type MatchCommandDataResvDeny struct {
|
||||
Reason uint32
|
||||
ReasonString string
|
||||
Reason uint32
|
||||
ReasonString string
|
||||
ReasonSpecified bool
|
||||
|
||||
UserData []byte
|
||||
}
|
||||
@@ -388,18 +389,23 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
||||
}, true
|
||||
|
||||
case MatchResvDeny:
|
||||
if len(buffer) != 0x04 {
|
||||
break
|
||||
var reason uint32
|
||||
var userData []byte
|
||||
if len(buffer) >= 0x04 {
|
||||
reason = binary.LittleEndian.Uint32(buffer[0x00:0x04])
|
||||
userData = buffer[0x04:]
|
||||
} else {
|
||||
reason = 0
|
||||
userData = buffer
|
||||
}
|
||||
|
||||
reason := binary.LittleEndian.Uint32(buffer[0x00:0x04])
|
||||
|
||||
return MatchCommandData{
|
||||
Version: version,
|
||||
Command: command,
|
||||
ResvDeny: &MatchCommandDataResvDeny{
|
||||
Reason: reason,
|
||||
ReasonString: map[uint32]string{
|
||||
0x00: "Unspecified reason.",
|
||||
0x10: "Game server is fully occupied.",
|
||||
0x11: "This Domain is already closed.",
|
||||
0x12: "The condition was not satisfied.",
|
||||
@@ -410,7 +416,8 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
||||
0x17: "The reservation came from a different other host.",
|
||||
0x18: "Illegal mesh reservation.",
|
||||
}[reason],
|
||||
UserData: buffer[0x4:],
|
||||
ReasonSpecified: len(buffer) > 0x04,
|
||||
UserData: userData,
|
||||
},
|
||||
}, true
|
||||
|
||||
@@ -418,6 +425,7 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
||||
if len(buffer) != 0x00 {
|
||||
break
|
||||
}
|
||||
|
||||
return MatchCommandData{
|
||||
Version: version,
|
||||
Command: command,
|
||||
@@ -427,6 +435,7 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
||||
if len(buffer) != 0x00 {
|
||||
break
|
||||
}
|
||||
|
||||
return MatchCommandData{
|
||||
Version: version,
|
||||
Command: command,
|
||||
@@ -480,6 +489,7 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
||||
if len(buffer) != 0x00 {
|
||||
break
|
||||
}
|
||||
|
||||
return MatchCommandData{
|
||||
Version: version,
|
||||
Command: command,
|
||||
@@ -489,6 +499,7 @@ func DecodeMatchCommand(command byte, buffer []byte, version int) (MatchCommandD
|
||||
if len(buffer) != 0x04 {
|
||||
break
|
||||
}
|
||||
|
||||
return MatchCommandData{
|
||||
Version: version,
|
||||
Command: command,
|
||||
@@ -642,6 +653,10 @@ func EncodeMatchCommand(command byte, data MatchCommandData) ([]byte, bool) {
|
||||
return message, true
|
||||
|
||||
case MatchResvDeny:
|
||||
if !data.ResvDeny.ReasonSpecified {
|
||||
return data.ResvDeny.UserData, true
|
||||
}
|
||||
|
||||
message := binary.LittleEndian.AppendUint32([]byte{}, data.ResvDeny.Reason)
|
||||
|
||||
message = append(message, data.ResvDeny.UserData...)
|
||||
|
||||
@@ -598,6 +598,7 @@ Call of Atlantis CallofAtlantis
|
||||
Call of Cthulhu: Dark Corners of the Earth callofc
|
||||
Call of Duty callofduty 852 K3dV7n
|
||||
Call of Duty (PS2) callofdutyps2 1022 tR32nC
|
||||
Call of Duty - Modern Warfare 3 - Defiance (DS) codprojorlds HfhmfO 1 DMSNakbmGAxdCBGOuDSC
|
||||
Call of Duty 2 callofduty2 1296 DSpIxw
|
||||
Call of Duty 2: Big Red One (PS2) codbigredps2 1209 ye4Fd8
|
||||
Call of Duty 4: Modern Warfare callofduty4 1968 AOPMCh
|
||||
@@ -2282,6 +2283,8 @@ Mario Party (DS) mparty1ds 1575 rUpE9b
|
||||
Mario Sports MIX (Wii) mariosprtwii TpMQw7
|
||||
Mario Strikers Charged (Wii) mschargedwii 1556 B4LdGW 3 DbfBialvJznkQWYuOrRa
|
||||
Mario vs Donkey Kong 2.5 (DS) mvsdk25ds 2448 ko7R42
|
||||
Maru Goukaku - Shikaku Dasshu! Special Kaigo Fukushisi Shiken gokakufs2ds 3 rxKIKGNHXPYDlhTVwhFF
|
||||
Maru Goukaku - Shikaku Dasshu! Special Takken Shiken gokakuds 3 TeQxSAEKVjHgBSERaIvK
|
||||
Marvel Legends Automatch (PC) marvlegpcam 1314 eAMh9M
|
||||
Marvel Legends Automatch (PS2) marvlegps2am 1310 eAMh9M
|
||||
Marvel Legends Automatch (PS3) marvlegps3am 1480 eAMh9M
|
||||
@@ -3024,7 +3027,7 @@ Puyo Puyo (Wii) puyowii M8k3Hd
|
||||
Puyo Puyo Bomber (DS) puyobomberds 1886 rU1vT5
|
||||
Puyo Puyo Tsu (Wii) puyo2wii S33ip8
|
||||
Puyo Puyo! (DS) puyopuyods 1460 9bx1UP
|
||||
Puyo Puyo!! - Puyopuyo 20th Anniversary (DS) puyopuyo20ds ZoMcPo
|
||||
Puyo Puyo!! - Puyopuyo 20th Anniversary (DS) puyopuyo20ds ZoMcPo 1 NVHozzbWHZkMKdBlNNtS
|
||||
PuyoPuyo 7 (DS/Wii) puyopuyo7ds 2604 1SeVl7 1 cXyhQjWHQRQejbfTwblV
|
||||
Puyopuyo 7 (Wii) puyopuyo7wii 2741 h9HtSg
|
||||
Puzzle Chronicles puzzlechronicles
|
||||
@@ -3056,6 +3059,7 @@ R.U.S.E: The Art of Deception s_ruse
|
||||
RHEM 4 RHEM4
|
||||
RIFT RIFT
|
||||
RPG Planet g_rpg
|
||||
RPG Tsukuru DS+ - Create the New World (DS) rpgtkoolds GJPRBX
|
||||
RPG tkool DS (DSi) rpgtkooldsi 2899 NaGK7x
|
||||
RTL Winter Sports 2010 (Wii) rtlwsportswii 2690 flKPhR
|
||||
RTL Winter Sports 2011 Automatch (Wii) rtlwspor11wiiam lGM9Xg
|
||||
@@ -4321,6 +4325,7 @@ Ultima Online: Mondain's Legacy UltimaOnlineMondai
|
||||
Ultima Online: Stygian Abyss ultimaonlinestygia
|
||||
Ultimate Band (Wii) ultibandwii 2145 F8KfNf
|
||||
Ultimate Brain Games (DS) ubraingamesds 2746 MzT7MD
|
||||
Ultimate Card Games (DS) cardgamesds 2747 4rcSUc
|
||||
Ultimate Card Games (DS) ucardgamesds 2747 PpmQVg
|
||||
Ultimate Knight Windom XP ultimateknightwind
|
||||
Ultimate Mortal Kombat (DS) ultimateMKds 1820 irQTn8
|
||||
|
||||
|
@@ -4,7 +4,9 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"wwfc/common"
|
||||
"wwfc/database"
|
||||
@@ -117,40 +119,80 @@ func handleRequest(conn net.Conn) {
|
||||
|
||||
// Here we go into the listening loop
|
||||
for {
|
||||
// TODO: Handle split packets
|
||||
buffer := make([]byte, 1024)
|
||||
n, err := bufio.NewReader(conn).Read(buffer)
|
||||
if err != nil {
|
||||
logging.Notice(session.ModuleName, "Connection lost:", err.Error())
|
||||
return
|
||||
}
|
||||
buffer := make([]byte, 0x4000)
|
||||
bufferSize := 0
|
||||
message := ""
|
||||
|
||||
// Decrypt the data
|
||||
for i := 0; i < n; i++ {
|
||||
if i+7 <= n && bytes.Equal(buffer[i:i+7], []byte(`\final\`)) {
|
||||
i += 6
|
||||
// Packets can be received in fragments, so this loop makes sure the packet has been fully received before continuing
|
||||
for {
|
||||
if bufferSize >= len(buffer) {
|
||||
logging.Error(session.ModuleName, "Buffer overflow")
|
||||
return
|
||||
}
|
||||
|
||||
readSize, err := bufio.NewReader(conn).Read(buffer[bufferSize:])
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
logging.Info(session.ModuleName, "Connection closed")
|
||||
return
|
||||
}
|
||||
|
||||
logging.Error(session.ModuleName, "Connection error:", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
bufferSize += readSize
|
||||
|
||||
if !bytes.Contains(buffer[max(0, bufferSize-readSize-6):bufferSize], []byte(`\final\`)) {
|
||||
continue
|
||||
}
|
||||
|
||||
buffer[i] ^= "GameSpy3D"[i%9]
|
||||
// Decrypt the data
|
||||
decrypted := ""
|
||||
for i := 0; i < bufferSize; i++ {
|
||||
if i+7 <= bufferSize && bytes.Equal(buffer[i:i+7], []byte(`\final\`)) {
|
||||
// Append the decrypted content to the message
|
||||
message += decrypted + `\final\`
|
||||
decrypted = ""
|
||||
|
||||
// Remove the processed data
|
||||
buffer = buffer[i+7:]
|
||||
bufferSize -= i + 7
|
||||
i = 0
|
||||
|
||||
if bufferSize < 7 || !bytes.Contains(buffer[:bufferSize], []byte(`\final\`)) {
|
||||
break
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
decrypted += string(rune(buffer[i] ^ "GameSpy3D"[i%9]))
|
||||
}
|
||||
|
||||
// Continue to processing the message if we have a full message and another message is not expected
|
||||
if len(message) > 0 && bufferSize <= 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
commands, err := common.ParseGameSpyMessage(string(buffer[:n]))
|
||||
commands, err := common.ParseGameSpyMessage(message)
|
||||
if err != nil {
|
||||
logging.Error(session.ModuleName, "Error parsing message:", err.Error())
|
||||
logging.Error(session.ModuleName, "Raw data:", string(buffer[:n]))
|
||||
logging.Error(session.ModuleName, "Raw data:", message)
|
||||
session.replyError(gpcm.ErrParse)
|
||||
return
|
||||
}
|
||||
|
||||
commands = session.handleCommand("ka", commands, func(command common.GameSpyCommand) {
|
||||
session.Conn.Write([]byte(`\ka\\final\`))
|
||||
session.Write(common.GameSpyCommand{
|
||||
Command: "ka",
|
||||
})
|
||||
})
|
||||
|
||||
commands = session.handleCommand("auth", commands, session.auth)
|
||||
commands = session.handleCommand("authp", commands, session.authp)
|
||||
|
||||
if len(commands) != 0 && session.Authenticated == false {
|
||||
if len(commands) != 0 && !session.Authenticated {
|
||||
logging.Error(session.ModuleName, "Attempt to run command before authentication:", aurora.Cyan(commands[0]))
|
||||
session.replyError(gpcm.ErrNotLoggedIn)
|
||||
return
|
||||
@@ -158,6 +200,7 @@ func handleRequest(conn net.Conn) {
|
||||
|
||||
commands = session.handleCommand("getpd", commands, session.getpd)
|
||||
commands = session.handleCommand("setpd", commands, session.setpd)
|
||||
common.UNUSED(session.ignoreCommand)
|
||||
|
||||
for _, command := range commands {
|
||||
logging.Error(session.ModuleName, "Unknown command:", aurora.Cyan(command))
|
||||
|
||||
10
go.mod
10
go.mod
@@ -3,23 +3,23 @@ module wwfc
|
||||
go 1.21.1
|
||||
|
||||
require (
|
||||
github.com/jackc/pgx/v4 v4.18.1
|
||||
github.com/jackc/pgx/v4 v4.18.2
|
||||
github.com/logrusorgru/aurora/v3 v3.0.0
|
||||
github.com/sasha-s/go-deadlock v0.3.1
|
||||
golang.org/x/net v0.17.0
|
||||
golang.org/x/net v0.23.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgconn v1.14.0 // indirect
|
||||
github.com/jackc/pgconn v1.14.3 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||
github.com/jackc/pgtype v1.14.0 // indirect
|
||||
github.com/jackc/puddle v1.3.0 // indirect
|
||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
|
||||
golang.org/x/crypto v0.17.0 // indirect
|
||||
golang.org/x/crypto v0.21.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
gvisor.dev/gvisor v0.0.0-20240119232905-7b151e25d076
|
||||
)
|
||||
|
||||
47
go.sum
47
go.sum
@@ -24,8 +24,8 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU
|
||||
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
|
||||
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
|
||||
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
|
||||
github.com/jackc/pgconn v1.14.0 h1:vrbA9Ud87g6JdFWkHTJXppVce58qPIdP7N8y0Ml/A7Q=
|
||||
github.com/jackc/pgconn v1.14.0/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E=
|
||||
github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w=
|
||||
github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM=
|
||||
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
|
||||
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
|
||||
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
|
||||
@@ -41,8 +41,8 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvW
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgproto3/v2 v2.3.2 h1:7eY55bdBeCz1F2fTzSz69QC+pG46jYq9/jtSPiJ5nn0=
|
||||
github.com/jackc/pgproto3/v2 v2.3.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag=
|
||||
github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
@@ -56,8 +56,8 @@ github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08
|
||||
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
||||
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
||||
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
|
||||
github.com/jackc/pgx/v4 v4.18.1 h1:YP7G1KABtKpB5IHrO9vYwSrCOhs7p3uqhvhhQBptya0=
|
||||
github.com/jackc/pgx/v4 v4.18.1/go.mod h1:FydWkUyadDmdNH/mHnGob881GawxeEm7TcMCzkb+qQE=
|
||||
github.com/jackc/pgx/v4 v4.18.2 h1:xVpYkNR5pk5bMCZGfClbO962UIqVABcAGt7ha1s/FeU=
|
||||
github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
|
||||
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
@@ -84,8 +84,9 @@ github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=
|
||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
@@ -103,18 +104,13 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
@@ -136,25 +132,19 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -167,22 +157,19 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
@@ -190,9 +177,7 @@ golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgw
|
||||
golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@@ -91,7 +91,8 @@ func (g *GameSpySession) addFriend(command common.GameSpyCommand) {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
|
||||
if !g.User.OpenHost && g.isFriendAuthorized(uint32(newProfileId)) {
|
||||
authorized := g.isFriendAuthorized(uint32(newProfileId))
|
||||
if !g.User.OpenHost && authorized {
|
||||
logging.Info(g.ModuleName, "Attempt to add a friend who is already authorized")
|
||||
// This seems to always happen, do we need to return an error?
|
||||
// DWC vocally ignores the error anyway, so let's not bother
|
||||
@@ -125,8 +126,10 @@ func (g *GameSpySession) addFriend(command common.GameSpyCommand) {
|
||||
|
||||
// Friends are now mutual!
|
||||
// TODO: Add a limit
|
||||
g.AuthFriendList = append(g.AuthFriendList, uint32(newProfileId))
|
||||
newSession.AuthFriendList = append(newSession.AuthFriendList, g.User.ProfileId)
|
||||
if !authorized {
|
||||
g.AuthFriendList = append(g.AuthFriendList, uint32(newProfileId))
|
||||
newSession.AuthFriendList = append(newSession.AuthFriendList, g.User.ProfileId)
|
||||
}
|
||||
|
||||
// Send friend auth message
|
||||
sendMessageToSessionBuffer("4", newSession.User.ProfileId, g, "")
|
||||
@@ -149,6 +152,9 @@ func (g *GameSpySession) removeFriend(command common.GameSpyCommand) {
|
||||
}
|
||||
delProfileID32 := uint32(delProfileID64)
|
||||
|
||||
fc := common.CalcFriendCodeString(delProfileID32, g.User.GsbrCode[:4])
|
||||
logging.Info(g.ModuleName, "Remove friend:", aurora.Cyan(strDelProfileID), aurora.Cyan(fc))
|
||||
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
|
||||
|
||||
13
nas/auth.go
13
nas/auth.go
@@ -220,12 +220,23 @@ func login(moduleName string, fields map[string]string, isLocalhost bool) map[st
|
||||
return param
|
||||
}
|
||||
|
||||
if len(gsbrcd) < 4 || strings.ContainsRune(gsbrcd, 0) {
|
||||
if (len(gsbrcd) < 4 && len(gsbrcd) != 0) || strings.ContainsRune(gsbrcd, 0) {
|
||||
logging.Error(moduleName, "Invalid gsbrcd string in form")
|
||||
param["returncd"] = "103"
|
||||
return param
|
||||
}
|
||||
|
||||
// Some games like Fortune Street make login requests without a gsbr code, so we temporarily fake one
|
||||
if len(gsbrcd) == 0 {
|
||||
if len(gamecd) < 4 {
|
||||
logging.Error(moduleName, "Invalid gamecd string in form")
|
||||
param["returncd"] = "103"
|
||||
return param
|
||||
}
|
||||
|
||||
gsbrcd = gamecd[:3] + "J"
|
||||
}
|
||||
|
||||
lang, ok := fields["lang"]
|
||||
if !ok {
|
||||
lang = "ff"
|
||||
|
||||
Reference in New Issue
Block a user