mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-05-06 14:24:15 +02:00
fix(api): use configured channel port in dashboard stats
The dashboard JSON hardcoded `54000 + server_id` as the channel port, which is wrong whenever operators configure non-default ports in config.json. Resolve the actual port from `Entrance.Entries[].Channels[]` via a server_id map mirroring main.go's sid formula.
This commit is contained in:
@@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Dashboard channel ports now reflect the actual configured `Entrance.Entries[].Channels[].Port` instead of a hardcoded `54000 + server_id`.
|
||||||
- Fixed backup recovery panic: `recoverFromBackups` now rejects decompressed backup data smaller than the minimum save layout size, preventing a slice-bounds panic when nullcomp passes through garbage bytes as "already decompressed" data ([#182](https://github.com/Mezeporta/Erupe/pull/182)).
|
- Fixed backup recovery panic: `recoverFromBackups` now rejects decompressed backup data smaller than the minimum save layout size, preventing a slice-bounds panic when nullcomp passes through garbage bytes as "already decompressed" data ([#182](https://github.com/Mezeporta/Erupe/pull/182)).
|
||||||
|
|
||||||
## [9.3.2] - 2026-04-06
|
## [9.3.2] - 2026-04-06
|
||||||
|
|||||||
@@ -82,6 +82,20 @@ func (s *APIServer) DashboardStatsJSON(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build a map from server_id to configured port, mirroring main.go's
|
||||||
|
// sid assignment: sid = (4096 + si*256) + (16 + ci) where si is the
|
||||||
|
// entrance entry index and ci is the channel index within that entry.
|
||||||
|
// Disabled channels still increment ci, matching main.go.
|
||||||
|
portByServerID := make(map[int]uint16)
|
||||||
|
if s.erupeConfig != nil {
|
||||||
|
for si, ee := range s.erupeConfig.Entrance.Entries {
|
||||||
|
for ci, ce := range ee.Channels {
|
||||||
|
sid := (4096 + si*256) + (16 + ci)
|
||||||
|
portByServerID[sid] = ce.Port
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Query channel info from servers table.
|
// Query channel info from servers table.
|
||||||
if s.db != nil {
|
if s.db != nil {
|
||||||
rows, err := s.db.Query("SELECT server_id, current_players, world_name, land FROM servers ORDER BY server_id")
|
rows, err := s.db.Query("SELECT server_id, current_players, world_name, land FROM servers ORDER BY server_id")
|
||||||
@@ -100,9 +114,13 @@ func (s *APIServer) DashboardStatsJSON(w http.ResponseWriter, r *http.Request) {
|
|||||||
if worldName != nil {
|
if worldName != nil {
|
||||||
name = *worldName
|
name = *worldName
|
||||||
}
|
}
|
||||||
|
port := 0
|
||||||
|
if p, ok := portByServerID[serverID]; ok {
|
||||||
|
port = int(p)
|
||||||
|
}
|
||||||
ch := ChannelInfo{
|
ch := ChannelInfo{
|
||||||
Name: name,
|
Name: name,
|
||||||
Port: 54000 + serverID,
|
Port: port,
|
||||||
Players: players,
|
Players: players,
|
||||||
}
|
}
|
||||||
stats.Channels = append(stats.Channels, ch)
|
stats.Channels = append(stats.Channels, ch)
|
||||||
|
|||||||
Reference in New Issue
Block a user