summaryrefslogtreecommitdiff
path: root/gateways.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-08-31 21:32:55 +0200
committerkali kaneko (leap communications) <kali@leap.se>2021-11-09 22:08:06 +0100
commit01ec91df04b079246434952a5d8f34c6d4e3914b (patch)
tree61f921c824a8a138ffa9b7631fe71fdf9ebfb9a0 /gateways.go
parentba67fe02dbda8c6f0c3b0a46ecf892e9a73846de (diff)
[feat] make api configurable
Diffstat (limited to 'gateways.go')
-rw-r--r--gateways.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/gateways.go b/gateways.go
index 05220c3..c4597a0 100644
--- a/gateways.go
+++ b/gateways.go
@@ -21,16 +21,10 @@ import (
"net/http"
)
-const (
- // yes, I am cheating. The config file is also exposed on the top-level
- // domain, which is served behind a letsencrypt certificate. this saves passing
- // the certificate for the ca etc.
- eipAPI = "https://black.riseup.net/1/config/eip-service.json"
-)
-
type bonafide struct {
client *http.Client
eip *eipService
+ eipAPI string
}
type eipService struct {
@@ -55,9 +49,10 @@ type coordinates struct {
Longitude float64
}
-func newBonafide() *bonafide {
+func newBonafide(apiDomain string) *bonafide {
client := &http.Client{}
- return &bonafide{client, nil}
+ eipAPI := apiDomain + "/3/config/eip-service.json"
+ return &bonafide{client, nil, eipAPI}
}
func (b *bonafide) getGateways() ([]gateway, error) {
@@ -71,7 +66,7 @@ func (b *bonafide) getGateways() ([]gateway, error) {
}
func (b *bonafide) fetchEipJSON() error {
- resp, err := b.client.Post(eipAPI, "", nil)
+ resp, err := b.client.Post(b.eipAPI, "", nil)
if err != nil {
return err
}