Windscribe support (#114)
This commit is contained in:
@@ -53,6 +53,10 @@ type ParamsReader interface {
|
||||
GetMullvadISP() (country models.MullvadProvider, err error)
|
||||
GetMullvadPort() (port uint16, err error)
|
||||
|
||||
// Windscribe getters
|
||||
GetWindscribeRegion() (country models.WindscribeRegion, err error)
|
||||
GetWindscribePort(protocol models.NetworkProtocol) (port uint16, err error)
|
||||
|
||||
// Shadowsocks getters
|
||||
GetShadowSocks() (activated bool, err error)
|
||||
GetShadowSocksLog() (activated bool, err error)
|
||||
@@ -92,6 +96,6 @@ func NewParamsReader(logger logging.Logger) ParamsReader {
|
||||
|
||||
// GetVPNSP obtains the VPN service provider to use from the environment variable VPNSP
|
||||
func (p *paramsReader) GetVPNSP() (vpnServiceProvider string, err error) {
|
||||
s, err := p.envParams.GetValueIfInside("VPNSP", []string{"pia", "mullvad"})
|
||||
s, err := p.envParams.GetValueIfInside("VPNSP", []string{"pia", "mullvad", "windscribe"})
|
||||
return s, err
|
||||
}
|
||||
|
||||
45
internal/params/windscribe.go
Normal file
45
internal/params/windscribe.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package params
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
libparams "github.com/qdm12/golibs/params"
|
||||
"github.com/qdm12/private-internet-access-docker/internal/constants"
|
||||
"github.com/qdm12/private-internet-access-docker/internal/models"
|
||||
)
|
||||
|
||||
// GetWindscribeRegion obtains the region for the Windscribe server from the
|
||||
// environment variable REGION
|
||||
func (p *paramsReader) GetWindscribeRegion() (country models.WindscribeRegion, err error) {
|
||||
choices := append(constants.WindscribeRegionChoices())
|
||||
s, err := p.envParams.GetValueIfInside("REGION", choices)
|
||||
return models.WindscribeRegion(strings.ToLower(s)), err
|
||||
}
|
||||
|
||||
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
||||
// environment variable PORT
|
||||
func (p *paramsReader) GetWindscribePort(protocol models.NetworkProtocol) (port uint16, err error) {
|
||||
n, err := p.envParams.GetEnvIntRange("PORT", 0, 65535, libparams.Default("0"))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if n == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
switch protocol {
|
||||
case constants.TCP:
|
||||
switch n {
|
||||
case 21, 22, 80, 123, 143, 443, 587, 1194, 3306, 8080, 54783:
|
||||
default:
|
||||
return 0, fmt.Errorf("port %d is not valid for protocol %s", n, protocol)
|
||||
}
|
||||
case constants.UDP:
|
||||
switch n {
|
||||
case 53, 80, 123, 443, 1194, 54783:
|
||||
default:
|
||||
return 0, fmt.Errorf("port %d is not valid for protocol %s", n, protocol)
|
||||
}
|
||||
}
|
||||
return uint16(n), nil
|
||||
}
|
||||
Reference in New Issue
Block a user