From f21001c71e69feca36ee155f956982597b9c56ff Mon Sep 17 00:00:00 2001 From: Akizon77 Date: Wed, 16 Apr 2025 14:34:06 +0800 Subject: [PATCH] fix: ws api endpoint --- config/remote.go | 6 +++--- main.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/remote.go b/config/remote.go index a0db34b..33dcc58 100644 --- a/config/remote.go +++ b/config/remote.go @@ -16,10 +16,10 @@ type RemoteConfig struct { Swap bool `json:"swap"` Load bool `json:"load"` Uptime bool `json:"uptime"` - Temperature bool `json:"temp"` + Temperature bool `json:"temperature"` Os bool `json:"os"` Disk bool `json:"disk"` - Network bool `json:"net"` + Network bool `json:"network"` Process bool `json:"process"` Interval int `json:"interval"` Connections bool `json:"connections"` @@ -32,7 +32,7 @@ type RemoteConfig struct { // Request the remote configuration func LoadRemoteConfig(endpoint string, token string) (RemoteConfig, error) { const maxRetry = 3 - endpoint = strings.TrimSuffix(endpoint, "/") + "/api/getRemoteConfig" + "?token=" + token + endpoint = strings.TrimSuffix(endpoint, "/") + "/api/clients/getRemoteConfig" + "?token=" + token var resp *http.Response var err error diff --git a/main.go b/main.go index d57694e..cd87ea3 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,7 @@ func main() { log.Fatalln("Failed to upload basic info:", err) } - websocketEndpoint := strings.TrimSuffix(localConfig.Endpoint, "/") + "/ws/report" + websocketEndpoint := strings.TrimSuffix(localConfig.Endpoint, "/") + "/api/clients/report?token=" + localConfig.Token websocketEndpoint = "ws" + strings.TrimPrefix(websocketEndpoint, "http") var conn *websocket.Conn @@ -130,7 +130,7 @@ func handleWebSocketMessages(localConfig config.LocalConfig, remoteConfig config } func reportWithPOST(endpoint string, data []byte) error { - url := strings.TrimSuffix(endpoint, "/") + "/api/report" + url := strings.TrimSuffix(endpoint, "/") + "/api/clients/report" req, err := http.NewRequest("POST", url, strings.NewReader(string(data))) if err != nil { return err @@ -163,7 +163,7 @@ func uploadBasicInfo(endpoint string, token string) error { "os": osname, } - endpoint = strings.TrimSuffix(endpoint, "/") + "/api/nodeBasicInfo" + endpoint = strings.TrimSuffix(endpoint, "/") + "/api/clients/uploadBasicInfo?token=" + token payload, err := json.Marshal(data) if err != nil { return err