Refactor server query logic and add new endpoint for listing monitored game servers
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 47s

This commit is contained in:
2025-10-06 18:35:04 +08:00
parent d488511238
commit 97c68bafa2
10 changed files with 130 additions and 198 deletions

View File

@@ -180,31 +180,15 @@ type (
)
type (
A2SQueryReqServer {
ServerIP string `json:"serverIP"` // Server IP address
ServerPort int `json:"serverPort"` // Server port
Timeout int `json:"timeout,example=3000,default=3000"` // Timeout in milliseconds (default: 3000ms)
}
A2SQueryReq {
Servers []A2SQueryReqServer `json:"servers"` // List of servers to query
}
A2SQueryRespServer {
ServerName string `json:"serverName"` // Server name
MapName string `json:"mapName"` // Current map name
GameDirectory string `json:"gameDirectory"` // Game directory
GameDescription string `json:"gameDescription"` // Game description
AppID int `json:"appID"` // Steam App ID
PlayerCount int `json:"playerCount"` // Current player count
MaxPlayers int `json:"maxPlayers"` // Maximum player count
BotCount int `json:"botCount"` // Bot count
ServerType string `json:"serverType"` // Server type (e.g., "d" for dedicated)
Environment string `json:"environment"` // Environment (e.g., "w" for Windows, "l" for Linux)
Visibility int `json:"visibility"` // Visibility (0 for public, 1 for private)
VAC int `json:"vac"` // VAC status (0 for unsecured, 1 for secured)
Version string `json:"version"` // Server version
}
A2SQueryResp {
Results []A2SQueryRespServer `json:"results"` // List of query results for each server
ServerListReq {}
ServerListResp {
ServerName string `json:"serverName"` // Server name
ServerIP string `json:"serverIP"` // Server IP address
ServerPort int `json:"serverPort"` // Server port
Category string `json:"category"` // Server category
MapName string `json:"mapName"` // Current map name
PlayerCount int `json:"playerCount"` // Current player count
BotCount int `json:"botCount"` // Bot count
}
)
@@ -304,10 +288,10 @@ service ServerStatistics {
post /top-killer (TopKillerReq) returns (TopKillerResp)
@doc (
summary: "Perform an A2S query to get real-time server information"
description: "Perform an A2S query to get real-time server information"
summary: "Get the list of monitored game servers"
description: "Get the list of monitored game servers"
)
@handler a2sQueryHandler
post /a2s-query (A2SQueryReq) returns (A2SQueryResp)
@handler ServerListHandler
get /list (ServerListReq) returns ([]ServerListResp)
}