summaryrefslogtreecommitdiff
path: root/pkg/standalone/bonafide.go
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2019-05-23 12:54:15 +0200
committerRuben Pollan <meskio@sindominio.net>2019-05-23 12:54:15 +0200
commitbce7470262385baca771feee90e48e0c2e3616c6 (patch)
treeb546f9cb7375839e56f2ac07afa2ebcb520b7c52 /pkg/standalone/bonafide.go
parent2407fa387cb22461dc6aa50cd5da799cbba8c297 (diff)
[feat] retry fetching the eip json
If bitmask-vpn attempts to connect when there is no internet let's keep retrying fetching the eip json until internet comes. - Resolves: #126
Diffstat (limited to 'pkg/standalone/bonafide.go')
-rw-r--r--pkg/standalone/bonafide.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/pkg/standalone/bonafide.go b/pkg/standalone/bonafide.go
index ac09362..a3c0b22 100644
--- a/pkg/standalone/bonafide.go
+++ b/pkg/standalone/bonafide.go
@@ -34,9 +34,10 @@ import (
)
const (
- certAPI = config.APIURL + "1/cert"
- eipAPI = config.APIURL + "1/config/eip-service.json"
- secondsPerHour = 60 * 60
+ certAPI = config.APIURL + "1/cert"
+ eipAPI = config.APIURL + "1/config/eip-service.json"
+ secondsPerHour = 60 * 60
+ retryFetchJSONSeconds = 15
)
type bonafide struct {
@@ -184,8 +185,10 @@ func (b *bonafide) fetchGeolocation() ([]string, error) {
func (b *bonafide) fetchEipJSON() error {
resp, err := b.client.Post(eipAPI, "", nil)
- if err != nil {
- return err
+ for err != nil {
+ log.Printf("Error fetching eip json: %v", err)
+ time.Sleep(retryFetchJSONSeconds * time.Second)
+ resp, err = b.client.Post(eipAPI, "", nil)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {