Commit Graph

31 Commits

Author SHA1 Message Date
Houmgaor
82b967b715 refactor: replace raw SQL with repository interfaces in entranceserver and API server
Extract all direct database calls from entranceserver (2 calls) and
API server (17 calls) into typed repository interfaces with PostgreSQL
implementations, matching the pattern established in signserver and
channelserver.

Entranceserver: EntranceServerRepo, EntranceSessionRepo
API server: APIUserRepo, APICharacterRepo, APISessionRepo

Also fix the 3 remaining fmt.Sprintf calls inside logger invocations
in handlers_commands.go and handlers_stage.go, replacing them with
structured zap fields.

Unskip 5 TestNewAuthData* tests that previously required a real
database — they now run with mock repos.
2026-02-22 17:04:58 +01:00
Houmgaor
f17cb96b52 refactor(config): rename package _config to config with cfg alias
The config package used `package _config` with a leading underscore,
which is unconventional in Go. Rename to `package config` (matching the
directory name) and use `cfg` as the standard import alias across all
93 importing files.
2026-02-21 13:20:15 +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
5f3c843082 refactor(config): eliminate ErupeConfig global variable
Replace the mutable global `_config.ErupeConfig` with dependency
injection across 79 files. Config is now threaded through existing
paths: `ClientContext.RealClientMode` for packet encoding, `s.server.
erupeConfig` for channel handlers, and explicit parameters for utility
functions. This removes hidden coupling, enables test parallelism
without global save/restore, and prevents low-level packages from
reaching up to the config layer.

Key changes:
- Enrich ClientContext with RealClientMode for packet files
- Add mode parameter to CryptConn, mhfitem, mhfcourse functions
- Convert handlers_commands init() to lazy sync.Once initialization
- Delete global var, init(), and helper functions from config.go
- Update all tests to pass config explicitly
2026-02-20 17:07:42 +01:00
Houmgaor
d2b5bb72f8 refactor: extract gametime package, replace fmt.Printf with zap logging
Move time utilities (TimeAdjusted, TimeMidnight, TimeWeekStart, TimeWeekNext,
TimeGameAbsolute) from channelserver into common/gametime to break the
inappropriate dependency where signserver, entranceserver, and api imported
the 38K-line channelserver package just for time functions.

Replace all fmt.Printf debug logging in sys_session.go and handlers_object.go
with structured zap logging for consistent observability.
2026-02-17 17:54:51 +01:00
Houmgaor
73e874f43f fix: array bound crashes on clans. 2025-10-21 00:21:50 +02:00
wish
7d760bd3b4 fix EntranceServer clan member list limits 2024-08-08 22:16:39 +10:00
wish
1766b6f2bd rewrite EntranceServer response 2024-01-02 20:04:40 +11:00
wish
1aa2e36087 simplify World name concatenation 2023-12-31 16:30:11 +11:00
wish
5a8bc3b67a fix EntranceServer response on G5 2023-12-31 15:12:20 +11:00
wish
0ea0dc217b simplify config 2023-12-31 12:51:24 +11:00
wish
a2f488e5e3 move ProxyPort config out of DevMode 2023-11-26 20:50:08 +11:00
rockisch
e39630564e Add dev proxy config 2023-11-22 00:01:04 -03:00
wish
385a672c3d rewrite Channel response structure 2023-07-30 18:05:33 +10:00
wish
d1d3ddd803 Merge branch 'main' into main 2023-07-29 17:18:32 +10:00
wish
aad9425a73 guess Forward.5 compatibility 2023-07-22 18:22:21 +10:00
wish
dbedab4d33 add ClientMode support based on Forward.4 2023-07-22 16:47:44 +10:00
wish
123434c374 add S6 Entrance compatibility 2023-07-21 20:18:14 +10:00
wish
411477f9b3 fix time calculations & undo config changes 2023-07-16 21:14:44 +10:00
Matthe815
6938b57a60 fix: Timescale fixes for seasons 2023-07-06 17:00:17 -04:00
Matthe815
35f9d5ac18 feature: Season implementation 2023-07-05 19:29:39 -04:00
wish
d130233860 add support for SVR Entrance responses 2023-07-03 03:13:23 +10:00
wish
1f93419cb7 add support for more versions 2023-07-03 00:30:44 +10:00
wish
b4df642ee3 add ClientMode config option 2023-06-18 20:31:18 +10:00
wish
dcab41a6c7 rework logging code 2023-03-09 22:05:32 +11:00
wish
e811dd1274 initial time fix 2023-03-04 21:43:10 +11:00
wish
747f21c4db workaround for localhost connections 2023-02-25 16:12:51 +11:00
wish
7d3aa8c5b9 use default currentplayers integer on fail 2022-10-12 05:19:48 +11:00
wish
f9e9aaa303 use default season integer on fail 2022-10-12 05:15:40 +11:00
wish
e9cc5cc3e2 parse host as FQDN or IP 2022-08-04 23:52:13 +10:00
wish
2c0e7a5267 repository cleanup 2022-07-29 03:25:23 +10:00