diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2021-03-17 17:15:19 +0100 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2021-05-04 14:58:39 +0200 |
commit | 76cacf3d60e3dbfcb6fcb82558d9d79f6d068fb8 (patch) | |
tree | 8a9a06e9748836d47a67465be470d70e1a808060 /pkg/backend | |
parent | 8d616ba53416e5ca6205e9e29a2b3b0fc625f2d1 (diff) |
wip: select by city from the gui
Diffstat (limited to 'pkg/backend')
-rw-r--r-- | pkg/backend/status.go | 45 | ||||
-rw-r--r-- | pkg/backend/webapi.go | 4 |
2 files changed, 26 insertions, 23 deletions
diff --git a/pkg/backend/status.go b/pkg/backend/status.go index 20128ca..cfc68d1 100644 --- a/pkg/backend/status.go +++ b/pkg/backend/status.go @@ -33,33 +33,36 @@ var updateMutex sync.Mutex // them. type connectionCtx struct { - AppName string `json:"appName"` - Provider string `json:"provider"` - TosURL string `json:"tosURL"` - HelpURL string `json:"helpURL"` - AskForDonations bool `json:"askForDonations"` - DonateDialog bool `json:"donateDialog"` - DonateURL string `json:"donateURL"` - LoginDialog bool `json:"loginDialog"` - LoginOk bool `json:"loginOk"` - Version string `json:"version"` - Errors string `json:"errors"` - Status status `json:"status"` - Gateways map[string]bonafide.Gateway `json:"gateways"` - CurrentGateway string `json:"currentGateway"` - bm bitmask.Bitmask - autostart bitmask.Autostart - cfg *config.Config + AppName string `json:"appName"` + Provider string `json:"provider"` + TosURL string `json:"tosURL"` + HelpURL string `json:"helpURL"` + AskForDonations bool `json:"askForDonations"` + DonateDialog bool `json:"donateDialog"` + DonateURL string `json:"donateURL"` + LoginDialog bool `json:"loginDialog"` + LoginOk bool `json:"loginOk"` + 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 } func (c connectionCtx) toJson() ([]byte, error) { statusMutex.Lock() if c.bm != nil { c.Gateways = map[string]bonafide.Gateway{} - gateways, _ := c.bm.ListGateways("openvpn") - for _, label := range gateways { - gw, _ := c.bm.GetGatewayDetails(label) - c.Gateways[label] = gw.(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) } c.CurrentGateway = c.bm.GetCurrentGateway() } diff --git a/pkg/backend/webapi.go b/pkg/backend/webapi.go index 11abc24..a19d933 100644 --- a/pkg/backend/webapi.go +++ b/pkg/backend/webapi.go @@ -64,9 +64,9 @@ func webGatewaySet(w http.ResponseWriter, r *http.Request) { } func webGatewayList(w http.ResponseWriter, r *http.Request) { - gws, err := ctx.bm.ListGateways(ctx.Provider) + gws, err := ctx.bm.ListGatewaysByCity(ctx.Provider) if err != nil { - fmt.Fprintf(w, "ListGateways() err: %v", err) + fmt.Fprintf(w, "ListGatewaysByCity() err: %v", err) } gwJson, _ := json.Marshal(gws) fmt.Fprintf(w, string(gwJson)) |