Commit Graph

103 Commits

Author SHA1 Message Date
Houmgaor
1d507b3d11 fix: replace fmt.Sprintf in logger calls with structured fields and add LoopDelay default
fmt.Sprintf inside zap logger calls defeats structured logging,
making log aggregation and filtering harder. All 6 sites now use
proper zap fields (zap.Uint32, zap.Uint8, zap.String).

LoopDelay had no viper.SetDefault, so omitting it from config.json
caused a zero-value (0 ms) busy-loop in the recv loop. Default is
now 50 ms, matching config.example.json.
2026-02-22 16:32:43 +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
754b5a3bff feat(channelserver): decouple channel servers for independent operation (#33)
Enable multiple Erupe instances to share a single PostgreSQL database
without destroying each other's state, fix existing data races in
cross-channel access, and lay groundwork for future distributed
channel server deployments.

Phase 1 — DB safety:
- Scope DELETE FROM servers/sign_sessions to this instance's server IDs
- Fix ci++ bug where failed channel start shifted subsequent IDs

Phase 2 — Fix data races in cross-channel access:
- Lock sessions map in FindSessionByCharID and DisconnectUser
- Lock stagesLock in handleMsgSysLockGlobalSema
- Snapshot sessions/stages under lock in TransitMessage types 1-4
- Lock channel when finding mail notification targets

Phase 3 — ChannelRegistry interface:
- Define ChannelRegistry interface with 7 cross-channel operations
- Implement LocalChannelRegistry with proper locking
- Add SessionSnapshot/StageSnapshot immutable copy types
- Delegate WorldcastMHF, FindSessionByCharID, DisconnectUser to Registry
- Migrate LockGlobalSema and guild mail handlers to use Registry
- Add comprehensive tests including concurrent access

Phase 4 — Per-channel enable/disable:
- Add Enabled *bool to EntranceChannelInfo (nil defaults to true)
- Skip disabled channels in startup loop, preserving ID stability
- Add IsEnabled() helper with backward-compatible default
- Update config.example.json with Enabled field
2026-02-19 18:13:34 +01:00
Houmgaor
c64dabc3ba fix: check all Close() return values for errcheck lint
Add explicit error discards (_ =) for Close() calls on network
connections, SQL rows, and file handles across 28 files. Also add
.golangci.yml with standard linter defaults to match CI configuration.
2026-02-17 23:57:14 +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
Houmgaor
8a92a7957e fix(crashes): trying to investigate the causes of crash.
New unit tests to that end.
2025-10-19 19:02:29 +02:00
wish
8191994acb add LoopDelay config option 2024-10-08 22:26:00 +11:00
stratic-dev
d123182a2f Renamed signv2 to api and enabled it by default 2024-03-15 19:37:55 +00:00
stratic-dev
3797438ca2 No database 2024-03-15 00:54:18 +00:00
stratic-dev
def2bc3d2c initial commit 2024-03-12 23:00:01 +00:00
wish
a0282bd11e prevent rand.Intn panic 2024-02-25 21:32:07 +11:00
wish
7640195d2b add min and max Feature Weapons 2024-02-25 21:18:14 +11:00
wish
6ec9d9d869 add AutoBackportQuest DebugOption 2024-02-11 23:22:42 +11:00
wish
bbf4fa2472 further tune value configuration 2024-02-10 03:07:13 +11:00
wish
0d28637095 support long messages, rename to RelayChannel, move commands out of main 2024-01-01 21:22:51 +11:00
wish
b3a265e218 Merge remote-tracking branch 'origin/main' into feature/discord-login 2023-12-31 22:38:08 +11:00
wish
32dee9039e simplify config 2023-12-31 12:54:18 +11:00
wish
0ea0dc217b simplify config 2023-12-31 12:51:24 +11:00
wish
fd02a12ae9 add DefaultCourses DevModeOption 2023-12-31 10:22:27 +11:00
wish
b8f431ae66 parse CapLink responses 2023-12-17 17:47:35 +11:00
Matthew
c1b9c75138 Merge branch 'ZeruLight:main' into feature/discord-login 2023-12-04 10:45:26 -08:00
wish
5662564842 add option to dump raw saves 2023-12-03 17:57:23 +11:00
wish
4bae0e5758 add option to alter maximum Clan Members 2023-11-30 23:07:13 +11:00
Matthew
b7c5fe70e7 Merge branch 'main' into feature/discord-login 2023-11-29 10:52:01 -08:00
wish
a108a67522 add support for multiple Conquest War targets 2023-11-30 00:34:51 +11:00
Matthew
ce773a6c56 feat: Finish help command and add description to commands. 2023-11-27 04:05:15 -05:00
Matthew
76ba7cb942 feat: Custom prefixes and basic help command 2023-11-27 03:41:48 -05:00
Matthew
523266fc68 refactor: Move realtime channels to its own config 2023-11-27 02:18:01 -05:00
wish
22b1d1b716 Merge pull request #99 from rockisch/dev-proxy
Add dev proxy config
2023-11-26 20:53:55 +11:00
wish
a2f488e5e3 move ProxyPort config out of DevMode 2023-11-26 20:50:08 +11:00
wish
dfc359f5e2 structure & change config for MezFes 2023-11-26 19:42:27 +11:00
wish
a0fbfc248b fix TimeWeekX inconsistencies & limit MezFes duration 2023-11-26 19:21:31 +11:00
wish
b3af01b803 use seconds for arbitrary durations in config 2023-11-26 18:54:04 +11:00
rockisch
0481b15b9b Allow signv2 response to be configured 2023-11-23 22:12:36 -03:00
rockisch
a0b50bdf8d Implement final changes for custom launcher 2023-11-23 20:51:25 -03:00
rockisch
e39630564e Add dev proxy config 2023-11-22 00:01:04 -03:00
wish
405e65346b add LogMessageData DevModeOption & disable Logging by default 2023-11-20 00:58:24 +11:00
wish
b6cc8c3a12 fix incorrect Client Version string 2023-11-20 00:01:22 +11:00
wish
72bda06916 implement Quest caching 2023-11-16 21:51:28 +11:00
wish
2f8d09b09e more GuildTresure optimisation 2023-10-24 21:21:21 +11:00
wish
7194cdbc07 optimise GuildTresure handlers 2023-10-12 23:54:35 +11:00
wish
dd26fc73c3 adjust GUrgentRate definition 2023-10-12 23:25:35 +11:00
wish
a9fabcab23 clean up config.go 2023-08-20 22:19:16 +10:00
wish
6860098829 implement customisable Raviente latency 2023-08-09 23:20:50 +10:00
wish
d1d3ddd803 Merge branch 'main' into main 2023-07-29 17:18:32 +10:00
wish
c80afa6005 add customisable Raviente max players 2023-07-29 17:15:53 +10:00
wish
769f989c91 add MaximumFP option, hide null Festa Armor 2023-07-22 23:12:26 +10:00
wish
6a34fc9a76 add KaijiEvent GameplayOption 2023-07-20 22:51:05 +10:00