Maintenance: split each provider in a package

- Fix VyprVPN port
- Fix missing Auth overrides
This commit is contained in:
Quentin McGaw
2021-05-11 17:10:51 +00:00
parent 1cb93d76ed
commit e8c8742bae
104 changed files with 3685 additions and 3026 deletions

View File

@@ -0,0 +1,31 @@
package privateinternetaccess
import (
"context"
"time"
"github.com/qdm12/golibs/logging"
)
func tryUntilSuccessful(ctx context.Context, logger logging.Logger, fn func() error) {
const initialRetryPeriod = 5 * time.Second
retryPeriod := initialRetryPeriod
for {
err := fn()
if err == nil {
break
}
logger.Error(err)
logger.Info("Trying again in " + retryPeriod.String())
timer := time.NewTimer(retryPeriod)
select {
case <-timer.C:
case <-ctx.Done():
if !timer.Stop() {
<-timer.C
}
return
}
retryPeriod *= 2
}
}