perf(channelserver): cache rengoku_data.bin at startup

Load and validate rengoku_data.bin once during server initialization
instead of reading it from disk on every client request. The file is
static ECD-encrypted config data (~4.9 KB) that never changes at
runtime. Validation checks file size and ECD magic bytes, logging a
warning if the file is missing or invalid so misconfiguration is
caught before any client connects.
This commit is contained in:
Houmgaor
2026-03-02 20:12:39 +01:00
parent aee53534a2
commit 5b631d1704
5 changed files with 139 additions and 8 deletions

View File

@@ -3,8 +3,6 @@ package channelserver
import (
"encoding/binary"
ps "erupe-ce/common/pascalstring"
"os"
"path/filepath"
"erupe-ce/common/byteframe"
"erupe-ce/network/mhfpacket"
@@ -180,10 +178,8 @@ func handleMsgMhfLoadRengokuData(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfGetRengokuBinary(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetRengokuBinary)
// a (massively out of date) version resides in the game's /dat/ folder or up to date can be pulled from packets
data, err := os.ReadFile(filepath.Join(s.server.erupeConfig.BinPath, "rengoku_data.bin"))
if err != nil {
s.logger.Error("Failed to read rengoku_data.bin", zap.Error(err))
data := s.server.rengokuBin
if data == nil {
doAckBufFail(s, pkt.AckHandle, nil)
return
}