From 71dafa45cf9c61edea145923543fb74ba743af2c Mon Sep 17 00:00:00 2001 From: the_aceix Date: Thu, 12 Jun 2025 13:22:43 +0000 Subject: [PATCH] feat: collect location from netdesk --- controllers/ext_client.go | 1 + logic/extpeers.go | 6 ++++++ models/extclient.go | 2 ++ 3 files changed, 9 insertions(+) diff --git a/controllers/ext_client.go b/controllers/ext_client.go index d376d3c8..f1443fd1 100644 --- a/controllers/ext_client.go +++ b/controllers/ext_client.go @@ -780,6 +780,7 @@ func createExtClient(w http.ResponseWriter, r *http.Request) { } extclient.PublicEndpoint = customExtClient.PublicEndpoint extclient.Country = customExtClient.Country + extclient.Location = customExtClient.Location if err = logic.CreateExtClient(&extclient); err != nil { slog.Error( diff --git a/logic/extpeers.go b/logic/extpeers.go index 2c0d97f8..67a3b874 100644 --- a/logic/extpeers.go +++ b/logic/extpeers.go @@ -427,6 +427,12 @@ func UpdateExtClient(old *models.ExtClient, update *models.CustomExtClient) mode new.PostUp = strings.Replace(update.PostUp, "\r\n", "\n", -1) new.PostDown = strings.Replace(update.PostDown, "\r\n", "\n", -1) new.Tags = update.Tags + if update.Location != "" && update.Location != old.Location { + new.Location = update.Location + } + if update.Country != "" && update.Country != old.Country { + new.Country = update.Country + } return new } diff --git a/models/extclient.go b/models/extclient.go index 710429cf..2347061d 100644 --- a/models/extclient.go +++ b/models/extclient.go @@ -27,6 +27,7 @@ type ExtClient struct { DeviceName string `json:"device_name"` PublicEndpoint string `json:"public_endpoint"` Country string `json:"country"` + Location string `json:"location"` //format: lat,long Mutex *sync.Mutex `json:"-"` } @@ -47,6 +48,7 @@ type CustomExtClient struct { IsAlreadyConnectedToInetGw bool `json:"is_already_connected_to_inet_gw"` PublicEndpoint string `json:"public_endpoint"` Country string `json:"country"` + Location string `json:"location"` //format: lat,long } func (ext *ExtClient) ConvertToStaticNode() Node {