Files
gluetun/internal/provider/provider.go
Quentin McGaw ec157f102b PIA nextgen portforward (#242)
* Split provider/pia.go in piav3.go and piav4.go
* Change port forwarding signature
* Enable port forwarding parameter for PIA v4
* Fix VPN gateway IP obtention
* Setup HTTP client for TLS with custom cert
* Error message for regions not supporting pf
2020-10-12 10:55:08 -04:00

48 lines
1.7 KiB
Go

package provider
import (
"context"
"net"
"net/http"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/firewall"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/golibs/files"
"github.com/qdm12/golibs/logging"
)
// Provider contains methods to read and modify the openvpn configuration to connect as a client
type Provider interface {
GetOpenVPNConnections(selection models.ServerSelection) (connections []models.OpenVPNConnection, err error)
BuildConf(connections []models.OpenVPNConnection, verbosity, uid, gid int, root bool, cipher, auth string, extras models.ExtraConfigOptions) (lines []string)
PortForward(ctx context.Context, client *http.Client,
fileManager files.FileManager, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
syncState func(port uint16) (pfFilepath models.Filepath))
}
func New(provider models.VPNProvider, allServers models.AllServers) Provider {
switch provider {
case constants.PrivateInternetAccess:
return newPrivateInternetAccessV4(allServers.Pia.Servers)
case constants.PrivateInternetAccessOld:
return newPrivateInternetAccessV3(allServers.PiaOld.Servers)
case constants.Mullvad:
return newMullvad(allServers.Mullvad.Servers)
case constants.Windscribe:
return newWindscribe(allServers.Windscribe.Servers)
case constants.Surfshark:
return newSurfshark(allServers.Surfshark.Servers)
case constants.Cyberghost:
return newCyberghost(allServers.Cyberghost.Servers)
case constants.Vyprvpn:
return newVyprvpn(allServers.Vyprvpn.Servers)
case constants.Nordvpn:
return newNordvpn(allServers.Nordvpn.Servers)
case constants.Purevpn:
return newPurevpn(allServers.Purevpn.Servers)
default:
return nil // should never occur
}
}