chore(updater): incorporate FetchServers method in Provider interface

- Each provider interface can now fetch updated servers data
- Rename each provider updater subpackage name to `updater`
- Updater constructor does not take a settings struct
- Updater update method takes in a slice of provider strings
This commit is contained in:
Quentin McGaw
2022-06-09 23:47:12 +00:00
parent 11b55abff3
commit ebd94723c1
148 changed files with 374 additions and 281 deletions

View File

@@ -2,24 +2,27 @@ package privateinternetaccess
import (
"math/rand"
"net/http"
"time"
"github.com/qdm12/gluetun/internal/constants/openvpn"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/provider/common"
"github.com/qdm12/gluetun/internal/provider/privateinternetaccess/updater"
)
type Provider struct {
storage common.Storage
randSource rand.Source
timeNow func() time.Time
common.Fetcher
// Port forwarding
portForwardPath string
authFilePath string
}
func New(storage common.Storage, randSource rand.Source,
timeNow func() time.Time) *Provider {
timeNow func() time.Time, client *http.Client) *Provider {
const jsonPortForwardPath = "/gluetun/piaportforward.json"
return &Provider{
storage: storage,
@@ -27,6 +30,7 @@ func New(storage common.Storage, randSource rand.Source,
randSource: randSource,
portForwardPath: jsonPortForwardPath,
authFilePath: openvpn.AuthConf,
Fetcher: updater.New(client),
}
}