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:
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package privateinternetaccess
|
||||
package updater
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package privateinternetaccess
|
||||
package updater
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Package pia contains code to obtain the server information
|
||||
// Package updater contains code to obtain the server information
|
||||
// for the Private Internet Access provider.
|
||||
package privateinternetaccess
|
||||
package updater
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package privateinternetaccess
|
||||
package updater
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
Reference in New Issue
Block a user