2021-05-11 17:10:51 +00:00
|
|
|
package privateinternetaccess
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"math/rand"
|
|
|
|
|
"time"
|
|
|
|
|
|
2021-07-23 16:06:19 +00:00
|
|
|
"github.com/qdm12/gluetun/internal/constants"
|
2021-05-11 17:10:51 +00:00
|
|
|
"github.com/qdm12/gluetun/internal/models"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type PIA struct {
|
2021-08-16 19:16:05 +00:00
|
|
|
servers []models.PIAServer
|
|
|
|
|
randSource rand.Source
|
|
|
|
|
timeNow func() time.Time
|
2021-07-23 16:06:19 +00:00
|
|
|
// Port forwarding
|
|
|
|
|
portForwardPath string
|
|
|
|
|
authFilePath string
|
2021-05-11 17:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
2021-07-23 16:06:19 +00:00
|
|
|
func New(servers []models.PIAServer, randSource rand.Source,
|
|
|
|
|
timeNow func() time.Time) *PIA {
|
2022-01-29 15:34:59 +00:00
|
|
|
const jsonPortForwardPath = "/gluetun/piaportforward.json"
|
2021-05-11 17:10:51 +00:00
|
|
|
return &PIA{
|
2021-07-23 16:06:19 +00:00
|
|
|
servers: servers,
|
|
|
|
|
timeNow: timeNow,
|
|
|
|
|
randSource: randSource,
|
2022-01-29 15:34:59 +00:00
|
|
|
portForwardPath: jsonPortForwardPath,
|
2021-07-23 16:06:19 +00:00
|
|
|
authFilePath: constants.OpenVPNAuthConf,
|
2021-05-11 17:10:51 +00:00
|
|
|
}
|
|
|
|
|
}
|