Skip to content

Commit a91234c

Browse files
author
Simple-Tracker
committed
Improve WebUI
1 parent 4744f7b commit a91234c

3 files changed

Lines changed: 374 additions & 92 deletions

File tree

webui.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import (
1717
var WebUI_Index_HTML []byte
1818

1919
type StatusResponse struct {
20-
ProgramName string `json:"program_name"`
21-
ProgramVersion string `json:"program_version"`
22-
UptimeSeconds int64 `json:"uptime_seconds"`
23-
ClientType string `json:"client_type"`
24-
ClientURL string `json:"client_url"`
25-
CurrentStats Stats `json:"stats"`
26-
BTNStatus string `json:"btn_status"`
27-
Runtime Runtime `json:"runtime"`
20+
ProgramName string `json:"program_name"`
21+
ProgramVersion string `json:"program_version"`
22+
UptimeSeconds int64 `json:"uptime_seconds"`
23+
ClientType string `json:"client_type"`
24+
ClientURL string `json:"client_url"`
25+
LoadedExtensions []string `json:"loaded_extensions"`
26+
CurrentStats Stats `json:"stats"`
27+
Runtime Runtime `json:"runtime"`
2828
}
2929

3030
type Stats struct {
@@ -128,13 +128,12 @@ func WebUI_GetStatus(w http.ResponseWriter, r *http.Request) {
128128
var m runtime.MemStats
129129
runtime.ReadMemStats(&m)
130130

131-
btnStatus := "Not Loaded"
131+
loadedExtensions := []string{}
132+
if config.SyncServerURL != "" {
133+
loadedExtensions = append(loadedExtensions, "SyncServer")
134+
}
132135
if btnConfig != nil {
133-
if ability, exists := btnConfig.Ability["reconfigure"]; exists {
134-
btnStatus = "Active (" + ability.Version + ")"
135-
} else {
136-
btnStatus = "Active"
137-
}
136+
loadedExtensions = append(loadedExtensions, "BTN")
138137
}
139138

140139
totalBlockedIPs, totalBlockedPorts := GetWebUIBlockStats()
@@ -145,13 +144,13 @@ func WebUI_GetStatus(w http.ResponseWriter, r *http.Request) {
145144
}
146145

147146
resp := StatusResponse{
148-
ProgramName: programName,
149-
ProgramVersion: programVersion,
150-
UptimeSeconds: time.Now().Unix() - startTimestamp,
151-
ClientType: currentClientType,
152-
ClientURL: config.ClientURL,
153-
CurrentStats: stats,
154-
BTNStatus: btnStatus,
147+
ProgramName: programName,
148+
ProgramVersion: programVersion,
149+
UptimeSeconds: time.Now().Unix() - startTimestamp,
150+
ClientType: currentClientType,
151+
ClientURL: config.ClientURL,
152+
LoadedExtensions: loadedExtensions,
153+
CurrentStats: stats,
155154
Runtime: Runtime{
156155
GoVersion: runtime.Version(),
157156
NumGoroutine: runtime.NumGoroutine(),

0 commit comments

Comments
 (0)