summaryrefslogtreecommitdiff
path: root/pkg/backend
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-03-17 23:46:46 +0100
committerkali kaneko (leap communications) <kali@leap.se>2021-05-04 14:58:39 +0200
commit3baa3b7eba9696e69958c89a2b004a219f8c8d00 (patch)
tree3affa0d1ae5a8dfb1dcdce3031f19b2d00700447 /pkg/backend
parent67bdccaac5e095301bc3841d85c3a94bad2db144 (diff)
fix filter gws by transport
Diffstat (limited to 'pkg/backend')
-rw-r--r--pkg/backend/status.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/pkg/backend/status.go b/pkg/backend/status.go
index cfc68d1..3d78a0b 100644
--- a/pkg/backend/status.go
+++ b/pkg/backend/status.go
@@ -45,26 +45,25 @@ type connectionCtx struct {
Version string `json:"version"`
Errors string `json:"errors"`
Status status `json:"status"`
- /* XXX rename to GatewaysByCity */
- Gateways map[string]bonafide.Gateway `json:"gateways"`
- CurrentGateway string `json:"currentGateway"`
- bm bitmask.Bitmask
- autostart bitmask.Autostart
- cfg *config.Config
+ /* XXX perhaps rename to GatewaysByCity */
+ Gateways map[string]bonafide.Gateway `json:"gateways"`
+ CurrentGateway string `json:"currentGateway"`
+ CurrentLocation string `json:"currentLocation"`
+ bm bitmask.Bitmask
+ autostart bitmask.Autostart
+ cfg *config.Config
}
func (c connectionCtx) toJson() ([]byte, error) {
statusMutex.Lock()
if c.bm != nil {
- c.Gateways = map[string]bonafide.Gateway{}
- /* FIXME this returns hostnames, could return bonafide gateway directly */
- gateways, _ := c.bm.ListGatewaysByCity("openvpn")
- log.Println(">>> got gws for cities", gateways)
- for city, host := range gateways {
- gw, _ := c.bm.GetGatewayDetails(host)
- c.Gateways[city] = gw.(bonafide.Gateway)
+ gws, err := c.bm.ListGatewaysByCity("openvpn")
+ if err != nil {
+ log.Println("error getting gateways for city")
}
+ c.Gateways = gws
c.CurrentGateway = c.bm.GetCurrentGateway()
+ c.CurrentLocation = c.bm.GetCurrentLocation()
}
defer statusMutex.Unlock()
b, err := json.Marshal(c)