Documentation
¶
Index ¶
- func ExecRconCommand(name string, command string) (string, error)
- func ExecRconCommands(name string, commands []string) ([]string, error)
- func ExecRconCommandsConcurrent(serverCommands map[string][]string) (map[string][]string, error)
- func FullName(name string) string
- func GetEnvValue(name string, key string) (string, error)
- func ServerSetRouter(router *gin.Engine)
- func WebServerSetRouter(router *gin.Engine)
- type App
- type ClientInfo
- type MapInfo
- type PlayerInfo
- type PlayerSummary
- type RconConnection
- type RconPool
- type ServerInfo
- type ServerStatus
- type ServerStatusJSON
- type Spawngroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecRconCommand ¶
执行单个RCON命令 - 优化版本
func ExecRconCommands ¶
批量执行RCON命令 - 优化版本
func ExecRconCommandsConcurrent ¶
并发执行多个服务器的命令
func WebServerSetRouter ¶
WebServerSetRouter 设置 Web 静态资源路由
Types ¶
type ClientInfo ¶
type MapInfo ¶
type MapInfo struct {
Name string `json:"name"` // 地图显示名
InternalName string `json:"internal_name"` // 对应 VMAP/VPK 文件名
PlayableModes []string `json:"playable_modes"` // 在 CS2 各模式下可玩的模式列表
}
MapInfo 只保留 name、internal_name 和 playable_modes
type PlayerInfo ¶
type PlayerSummary ¶
type RconConnection ¶
type RconConnection struct {
// contains filtered or unexported fields
}
RCON连接封装
type RconPool ¶
type RconPool struct {
// contains filtered or unexported fields
}
连接池结构
func NewRconPool ¶
func (*RconPool) GetConnection ¶
func (rp *RconPool) GetConnection(name, port, passwd string) (*RconConnection, error)
获取或创建连接
func (*RconPool) HealthCheck ¶
健康检查 - 测试连接是否正常
type ServerInfo ¶
type ServerInfo struct {
Hibernating bool `json:"hibernating"`
CPUUsage float64 `json:"cpu_usage"`
ClientsBot int `json:"clients_bot"`
ClientsHuman int `json:"clients_human"`
ClientsProxies int `json:"clients_proxies"`
Map string `json:"map"`
Addon string `json:"addon"`
UDPPort int `json:"udp_port"`
Clients []ClientInfo `json:"clients"`
AsyncNetworkingWaitMs float64 `json:"async_networking_wait_ms"`
StartupServerModuleInit int `json:"startup_ServerModuleInit"`
StartupGameRulesCreated int `json:"startup_GameRulesCreated"`
StartupSteamLoggedOn int `json:"startup_SteamLoggedOn"`
StartupRequestedGcSession int `json:"startup_RequestedGcSession"`
GameVars int `json:"game_vars"`
GCStatus string `json:"gc_status"`
SVShutdownRequested bool `json:"sv_shutdown_requested"`
SteamLoggedOn bool `json:"steam_loggedon"`
SteamID64 string `json:"steamid64"`
SteamID string `json:"steamid"`
}
type ServerStatus ¶
type ServerStatus struct {
ServerAddress string `json:"server_address"`
ClientStatus string `json:"client_status"`
CurrentState string `json:"current_state"`
Source string `json:"source"`
Hostname string `json:"hostname"`
SpawnGroup int `json:"spawn_group"`
Version string `json:"version"`
SteamID string `json:"steam_id"`
SteamID64 string `json:"steam_id_64"`
LocalIP string `json:"local_ip"`
PublicIP string `json:"public_ip"`
OS string `json:"os"`
PlayerSummary PlayerSummary `json:"player_summary"`
Spawngroups []Spawngroup `json:"spawngroups"`
PlayerList []PlayerInfo `json:"player_list"`
}
====================== 服务器状态相关 ======================
type ServerStatusJSON ¶
type ServerStatusJSON struct {
FrametimeMs float64 `json:"frametime_ms"`
FramecomputetimeMs float64 `json:"framecomputetime_ms"`
ProcessUptime int `json:"process_uptime"`
BuildVersion int `json:"build_version"`
BuildSourceRevision string `json:"build_source_revision"`
MemPhysTotalGb float64 `json:"mem_phys_total_gb"`
MemPhysAvailGb float64 `json:"mem_phys_avail_gb"`
MemVirtTotalGb float64 `json:"mem_virt_total_gb"`
MemVirtAvailGb float64 `json:"mem_virt_avail_gb"`
Server ServerInfo `json:"server"`
}
在适当的位置添加这些结构体定义
func GetServerStatusJSON ¶
func GetServerStatusJSON(name string) (*ServerStatusJSON, error)
修改 GetServerStatusJSON 函数
Click to show internal directories.
Click to hide internal directories.