Commit bce74702 authored by meskio's avatar meskio

[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
parent 2407fa38
Pipeline #24912 passed with stages
in 15 minutes and 36 seconds
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment