feat(updater): Configurable min ratio

- `UPDATER_MIN_RATIO` variable
- `-minratio` flag for CLI operation
This commit is contained in:
Quentin McGaw
2022-06-12 14:03:00 +00:00
parent 1ea15a1a13
commit 9898387579
11 changed files with 61 additions and 12 deletions

View File

@@ -37,7 +37,8 @@ func New(httpClient *http.Client, storage Storage,
}
}
func (u *Updater) UpdateServers(ctx context.Context, providers []string) (err error) {
func (u *Updater) UpdateServers(ctx context.Context, providers []string,
minRatio float64) (err error) {
caser := cases.Title(language.English)
for _, providerName := range providers {
u.logger.Info("updating " + caser.String(providerName) + " servers...")
@@ -45,7 +46,7 @@ func (u *Updater) UpdateServers(ctx context.Context, providers []string) (err er
fetcher := u.providers.Get(providerName)
// TODO support servers offering only TCP or only UDP
// for NordVPN and PureVPN
err := u.updateProvider(ctx, fetcher)
err := u.updateProvider(ctx, fetcher, minRatio)
if err == nil {
continue
}