Commit Graph

31 Commits

Author SHA1 Message Date
Houmgaor
7ef5efc549 feat(network): add protocol packet capture and replay system
Add a recording and replay foundation for the MHF network protocol.
A RecordingConn decorator wraps network.Conn to transparently capture
all decrypted packets to binary .mhfr files, with zero handler changes
and zero overhead when disabled.

- network/pcap: binary capture format (writer, reader, filters)
- RecordingConn: thread-safe Conn decorator with direction tracking
- CaptureOptions in config (disabled by default)
- Capture wired into all three server types (sign, entrance, channel)
- cmd/replay: CLI tool with dump, json, stats, and compare modes
- 19 new tests, all passing with -race
2026-02-23 18:50:44 +01:00
Houmgaor
f640cfee27 fix: log SJIS decoding errors instead of silently discarding them
Add SJISToUTF8Lossy() that wraps SJISToUTF8() and logs decode errors at
slog.Debug level. Replace all 31 call sites across 17 files that previously
discarded the error with `_, _ =`. This makes garbled text from malformed
SJIS client data debuggable without adding noise at default log levels.
2026-02-22 17:01:22 +01:00
Houmgaor
b3f75232a3 refactor(signserver): replace raw SQL with repository interfaces
Extract all direct database access into three repository interfaces
(SignUserRepo, SignCharacterRepo, SignSessionRepo) matching the
pattern established in channelserver. This surfaces 9 previously
silenced errors that are now logged with structured context, and
makes the sign server testable with mock repos instead of go-sqlmock.

Security fix: GetFriends now uses parameterized ANY($1) queries
instead of string-concatenated WHERE clauses (SQL injection vector).
2026-02-22 16:30:24 +01:00
Houmgaor
d32e77efba refactor: replace panic calls with structured error handling
Replace ~25 panic() calls in non-fatal code paths with proper
s.logger.Error + return patterns. Panics in handler code crashed
goroutines (caught by defer/recover but still disruptive) instead
of failing gracefully.

Key changes:
- SJISToUTF8 now returns (string, error); all 30+ callers updated
- Handler DB/IO panics replaced with log + return/ack fail
- Unhandled switch-case panics replaced with logger.Error
- Sign server Accept() panic replaced with log + continue
- Dead unreachable panic in guild_model.go removed
- deltacomp patch error logs and returns partial data

Panics intentionally kept: ByteFrame sentinel, unimplemented
packet stubs, os.Exit in main.go.
2026-02-20 19:11:41 +01:00
Houmgaor
06cb3afa57 refactor: standardize logging on zap across all packages
Replace all fmt.Printf/Println and log.Printf/Fatal with structured
zap.Logger calls to eliminate inconsistent logging (anti-pattern #12).

- network/crypt_conn: inject logger via NewCryptConn, replace 6 fmt calls
- signserver/session: use existing s.logger for debug packet dumps
- entranceserver: use s.logger for inbound/outbound debug logging
- api/utils: accept logger param in verifyPath, replace fmt.Println
- api/endpoints: use s.logger for screenshot path diagnostics
- config: replace log.Fatal with error return in getOutboundIP4
- deltacomp: replace log.Printf with zap.L() global logger
2026-02-20 18:59:12 +01:00
Houmgaor
2a0e3e2c84 fix: re-enable CI lint job and fix ~65 lint errors (partial)
Re-enable the golangci-lint job in CI (disabled Oct 2025), update to
Go 1.25 and golangci-lint-action v7. Fix errcheck, gosimple S1009,
staticcheck SA4031 and SA2001 errors across 54 files. Remaining ~39
lint errors will be addressed in follow-up commits.
2026-02-17 17:59:00 +01:00
stratic-dev
4d134d0624 Remove reformatting 2024-03-20 19:44:54 +00:00
stratic-dev
7d7fd50ba8 init ps4 support 2024-03-20 19:12:57 +00:00
wish
a968f18438 add support for SIGN requests 2024-02-20 14:53:59 +11:00
wish
0ea0dc217b simplify config 2023-12-31 12:51:24 +11:00
wish
86f63d6a38 properly support PS3 account linking 2023-08-09 22:04:15 +10:00
wish
2eeab72c1c update legacy WIIU code 2023-07-25 00:45:11 +10:00
wish
7edf07d853 use universal Sign request names 2023-07-25 00:44:19 +10:00
wish
a3e1207dfd fix conflicts 2023-07-24 23:42:51 +10:00
wish
2a9504cd26 Merge remote-tracking branch 'origin/main' into feature/psn-link
# Conflicts:
#	server/signserver/dbutils.go
#	server/signserver/dsgn_resp.go
#	server/signserver/session.go
2023-07-24 23:36:38 +10:00
wish
76a3d73102 add WIIUSGN:000 2023-07-03 03:59:00 +10:00
wish
e96e6372f5 hacky fix for PSSGN panic 2023-06-27 22:39:44 +10:00
wish
086b338f84 automatically create new character when none exist 2023-05-13 01:21:37 +10:00
wish
a260500bb5 further sign server rewrite 2023-04-30 13:51:30 +10:00
wish
6601285218 unfinished proof of concept 2023-04-30 01:32:38 +10:00
wish
058c387b11 only read first 64 bytes of wiiusgn key 2023-04-16 21:03:21 +10:00
wish
56ec654c72 wiiusgn test 2023-04-16 19:55:08 +10:00
wish
f379c27a01 combine login process again 2023-04-16 14:29:29 +10:00
wish
2e8d5fa823 implement support for PS3SGN 2023-04-16 14:15:22 +10:00
wish
90cb8525e5 add support for PS3SGN 2023-04-15 11:27:43 +10:00
wish
f5ae129cad implement psn linking capability 2023-04-15 11:00:49 +10:00
wish
2ede81925a rewrite signserver 2023-04-12 05:37:41 +10:00
wish
dcab41a6c7 rework logging code 2023-03-09 22:05:32 +11:00
wish
55f1de11fe add account creation toggle 2022-10-24 17:48:57 +11:00
wish
5e42402a3d signserver cleanup 2022-10-18 11:42:12 +11:00
wish
2c0e7a5267 repository cleanup 2022-07-29 03:25:23 +10:00