mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
fix(protbot,channelserver): fix sign protocol and entrance parsing, guard nil save data
The protbot sent "DSGN:\x00" as the sign request type, but the server strips the last 3 characters as a version suffix. Send "DSGN:041" (ZZ client mode 41) to match the real client format. The entrance channel entry parser read 14 bytes for remaining fields but the server writes 18 bytes (9 uint16, not 7), causing a panic when parsing the server list. The channel server panicked on disconnect when a session had no decompressed save data (e.g. protbot or early client disconnect). Guard Save() against nil decompSave. Also fix docker-compose volume mount for Postgres 18 which changed its data directory layout.
This commit is contained in:
@@ -115,13 +115,13 @@ func parseServerEntries(data []byte, entryCount uint16) ([]ServerEntry, error) {
|
|||||||
name += string(nameBytes[j])
|
name += string(nameBytes[j])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read channel entries
|
// Read channel entries (14 x uint16 = 28 bytes each)
|
||||||
for j := uint16(0); j < channelCount; j++ {
|
for j := uint16(0); j < channelCount; j++ {
|
||||||
port := bf.ReadUint16()
|
port := bf.ReadUint16()
|
||||||
_ = bf.ReadUint16() // channelIdx | 16
|
_ = bf.ReadUint16() // channelIdx | 16
|
||||||
_ = bf.ReadUint16() // maxPlayers
|
_ = bf.ReadUint16() // maxPlayers
|
||||||
_ = bf.ReadUint16() // currentPlayers
|
_ = bf.ReadUint16() // currentPlayers
|
||||||
_ = bf.ReadBytes(14) // remaining channel fields (7 x uint16)
|
_ = bf.ReadBytes(18) // remaining channel fields (9 x uint16: 6 zeros + unk319 + unk254 + unk255)
|
||||||
_ = bf.ReadUint16() // 12345
|
_ = bf.ReadUint16() // 12345
|
||||||
|
|
||||||
serverIP := ip.String()
|
serverIP := ip.String()
|
||||||
|
|||||||
@@ -27,10 +27,11 @@ func DoSign(addr, username, password string) (*SignResult, error) {
|
|||||||
}
|
}
|
||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
||||||
// Build DSGN request: "DSGN:\x00" + SJIS(user) + "\x00" + SJIS(pass) + "\x00" + "\x00"
|
// Build DSGN request: "DSGN:041" + \x00 + SJIS(user) + \x00 + SJIS(pass) + \x00 + \x00
|
||||||
// The server reads: null-terminated request type, null-terminated user, null-terminated pass, null-terminated unk.
|
// The server reads: null-terminated request type, null-terminated user, null-terminated pass, null-terminated unk.
|
||||||
|
// The request type has a 3-char version suffix (e.g. "041" for ZZ client mode 41) that the server strips.
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
bf.WriteNullTerminatedBytes([]byte("DSGN:\x00")) // reqType (server strips last 3 chars to get "DSGN:")
|
bf.WriteNullTerminatedBytes([]byte("DSGN:041")) // reqType with version suffix (server strips last 3 chars to get "DSGN:")
|
||||||
bf.WriteNullTerminatedBytes(stringsupport.UTF8ToSJIS(username))
|
bf.WriteNullTerminatedBytes(stringsupport.UTF8ToSJIS(username))
|
||||||
bf.WriteNullTerminatedBytes(stringsupport.UTF8ToSJIS(password))
|
bf.WriteNullTerminatedBytes(stringsupport.UTF8ToSJIS(password))
|
||||||
bf.WriteUint8(0) // Unk null-terminated empty string
|
bf.WriteUint8(0) // Unk null-terminated empty string
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- ./db-data/:/var/lib/postgresql/data/
|
- ./db-data/:/var/lib/postgresql/
|
||||||
- ../schemas/:/schemas/
|
- ../schemas/:/schemas/
|
||||||
- ./init/setup.sh:/docker-entrypoint-initdb.d/setup.sh
|
- ./init/setup.sh:/docker-entrypoint-initdb.d/setup.sh
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|||||||
@@ -48,6 +48,13 @@ func GetCharacterSaveData(s *Session, charID uint32) (*CharacterSaveData, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (save *CharacterSaveData) Save(s *Session) {
|
func (save *CharacterSaveData) Save(s *Session) {
|
||||||
|
if save.decompSave == nil {
|
||||||
|
s.logger.Warn("No decompressed save data, skipping save",
|
||||||
|
zap.Uint32("charID", save.CharID),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !s.kqfOverride {
|
if !s.kqfOverride {
|
||||||
s.kqf = save.KQF
|
s.kqf = save.KQF
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user