Maint: configuration Openvpn selection structure
- Move network protocol from ServerSelection to OpenVPNSelection child - Move PIA encryption preset from ServerSelection to OpenVPNSelection child - Move custom port from ServerSelection to OpenVPNSelection child
This commit is contained in:
@@ -17,17 +17,14 @@ func (settings *Provider) cyberghostLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readCyberghost(r reader) (err error) {
|
||||
settings.Name = constants.Cyberghost
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -49,7 +46,7 @@ func (settings *Provider) readCyberghost(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolAndPort(r.env)
|
||||
}
|
||||
|
||||
func (settings *OpenVPN) readCyberghost(r reader) (err error) {
|
||||
|
||||
@@ -15,17 +15,14 @@ func (settings *Provider) fastestvpnLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readFastestvpn(r reader) (err error) {
|
||||
settings.Name = constants.Fastestvpn
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -41,5 +38,5 @@ func (settings *Provider) readFastestvpn(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable COUNTRY: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolOnly(r.env)
|
||||
}
|
||||
|
||||
@@ -23,17 +23,14 @@ func (settings *Provider) hideMyAssLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readHideMyAss(r reader) (err error) {
|
||||
settings.Name = constants.HideMyAss
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -59,5 +56,5 @@ func (settings *Provider) readHideMyAss(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolAndPort(r.env)
|
||||
}
|
||||
|
||||
@@ -19,17 +19,14 @@ func (settings *Provider) ipvanishLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readIpvanish(r reader) (err error) {
|
||||
settings.Name = constants.Ipvanish
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -50,5 +47,5 @@ func (settings *Provider) readIpvanish(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolOnly(r.env)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,12 @@ func Test_Provider_ipvanishLines(t *testing.T) {
|
||||
settings Provider
|
||||
lines []string
|
||||
}{
|
||||
"empty settings": {},
|
||||
"empty settings": {
|
||||
lines: []string{
|
||||
"|--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"full settings": {
|
||||
settings: Provider{
|
||||
ServerSelection: ServerSelection{
|
||||
@@ -32,6 +37,8 @@ func Test_Provider_ipvanishLines(t *testing.T) {
|
||||
"|--Countries: A, B",
|
||||
"|--Cities: C, D",
|
||||
"|--Hostnames: E, F",
|
||||
"|--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -65,23 +72,15 @@ func Test_Provider_readIpvanish(t *testing.T) {
|
||||
}
|
||||
|
||||
testCases := map[string]struct {
|
||||
protocol singleStringCall
|
||||
targetIP singleStringCall
|
||||
countries sliceStringCall
|
||||
cities sliceStringCall
|
||||
hostnames sliceStringCall
|
||||
protocol singleStringCall
|
||||
settings Provider
|
||||
err error
|
||||
}{
|
||||
"protocol error": {
|
||||
protocol: singleStringCall{call: true, err: errDummy},
|
||||
settings: Provider{
|
||||
Name: constants.Ipvanish,
|
||||
},
|
||||
err: errors.New("environment variable PROTOCOL: dummy test error"),
|
||||
},
|
||||
"target IP error": {
|
||||
protocol: singleStringCall{call: true},
|
||||
targetIP: singleStringCall{call: true, value: "something", err: errDummy},
|
||||
settings: Provider{
|
||||
Name: constants.Ipvanish,
|
||||
@@ -89,7 +88,6 @@ func Test_Provider_readIpvanish(t *testing.T) {
|
||||
err: errors.New("environment variable OPENVPN_TARGET_IP: dummy test error"),
|
||||
},
|
||||
"countries error": {
|
||||
protocol: singleStringCall{call: true},
|
||||
targetIP: singleStringCall{call: true},
|
||||
countries: sliceStringCall{call: true, err: errDummy},
|
||||
settings: Provider{
|
||||
@@ -98,7 +96,6 @@ func Test_Provider_readIpvanish(t *testing.T) {
|
||||
err: errors.New("environment variable COUNTRY: dummy test error"),
|
||||
},
|
||||
"cities error": {
|
||||
protocol: singleStringCall{call: true},
|
||||
targetIP: singleStringCall{call: true},
|
||||
countries: sliceStringCall{call: true},
|
||||
cities: sliceStringCall{call: true, err: errDummy},
|
||||
@@ -108,7 +105,6 @@ func Test_Provider_readIpvanish(t *testing.T) {
|
||||
err: errors.New("environment variable CITY: dummy test error"),
|
||||
},
|
||||
"hostnames error": {
|
||||
protocol: singleStringCall{call: true},
|
||||
targetIP: singleStringCall{call: true},
|
||||
countries: sliceStringCall{call: true},
|
||||
cities: sliceStringCall{call: true},
|
||||
@@ -118,26 +114,39 @@ func Test_Provider_readIpvanish(t *testing.T) {
|
||||
},
|
||||
err: errors.New("environment variable SERVER_HOSTNAME: dummy test error"),
|
||||
},
|
||||
"default settings": {
|
||||
protocol: singleStringCall{call: true},
|
||||
"protocol error": {
|
||||
targetIP: singleStringCall{call: true},
|
||||
countries: sliceStringCall{call: true},
|
||||
cities: sliceStringCall{call: true},
|
||||
hostnames: sliceStringCall{call: true},
|
||||
protocol: singleStringCall{call: true, err: errDummy},
|
||||
settings: Provider{
|
||||
Name: constants.Ipvanish,
|
||||
},
|
||||
err: errors.New("environment variable PROTOCOL: dummy test error"),
|
||||
},
|
||||
"default settings": {
|
||||
targetIP: singleStringCall{call: true},
|
||||
countries: sliceStringCall{call: true},
|
||||
cities: sliceStringCall{call: true},
|
||||
hostnames: sliceStringCall{call: true},
|
||||
protocol: singleStringCall{call: true},
|
||||
settings: Provider{
|
||||
Name: constants.Ipvanish,
|
||||
},
|
||||
},
|
||||
"set settings": {
|
||||
protocol: singleStringCall{call: true, value: constants.TCP},
|
||||
targetIP: singleStringCall{call: true, value: "1.2.3.4"},
|
||||
countries: sliceStringCall{call: true, values: []string{"A", "B"}},
|
||||
cities: sliceStringCall{call: true, values: []string{"C", "D"}},
|
||||
hostnames: sliceStringCall{call: true, values: []string{"E", "F"}},
|
||||
protocol: singleStringCall{call: true, value: constants.TCP},
|
||||
settings: Provider{
|
||||
Name: constants.Ipvanish,
|
||||
ServerSelection: ServerSelection{
|
||||
OpenVPN: OpenVPNSelection{
|
||||
TCP: true,
|
||||
},
|
||||
TargetIP: net.IPv4(1, 2, 3, 4),
|
||||
Countries: []string{"A", "B"},
|
||||
Cities: []string{"C", "D"},
|
||||
@@ -153,10 +162,6 @@ func Test_Provider_readIpvanish(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
|
||||
env := mock_params.NewMockEnv(ctrl)
|
||||
if testCase.protocol.call {
|
||||
env.EXPECT().Inside("PROTOCOL", []string{constants.TCP, constants.UDP}, gomock.Any()).
|
||||
Return(testCase.protocol.value, testCase.protocol.err)
|
||||
}
|
||||
if testCase.targetIP.call {
|
||||
env.EXPECT().Get("OPENVPN_TARGET_IP").
|
||||
Return(testCase.targetIP.value, testCase.targetIP.err)
|
||||
@@ -173,6 +178,10 @@ func Test_Provider_readIpvanish(t *testing.T) {
|
||||
env.EXPECT().CSVInside("SERVER_HOSTNAME", constants.IpvanishHostnameChoices()).
|
||||
Return(testCase.hostnames.values, testCase.hostnames.err)
|
||||
}
|
||||
if testCase.protocol.call {
|
||||
env.EXPECT().Inside("PROTOCOL", []string{constants.TCP, constants.UDP}, gomock.Any()).
|
||||
Return(testCase.protocol.value, testCase.protocol.err)
|
||||
}
|
||||
|
||||
r := reader{env: env}
|
||||
|
||||
|
||||
@@ -19,17 +19,14 @@ func (settings *Provider) ivpnLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readIvpn(r reader) (err error) {
|
||||
settings.Name = constants.Ivpn
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -50,5 +47,5 @@ func (settings *Provider) readIvpn(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolOnly(r.env)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,12 @@ func Test_Provider_ivpnLines(t *testing.T) {
|
||||
settings Provider
|
||||
lines []string
|
||||
}{
|
||||
"empty settings": {},
|
||||
"empty settings": {
|
||||
lines: []string{
|
||||
"|--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"full settings": {
|
||||
settings: Provider{
|
||||
ServerSelection: ServerSelection{
|
||||
@@ -32,6 +37,8 @@ func Test_Provider_ivpnLines(t *testing.T) {
|
||||
"|--Countries: A, B",
|
||||
"|--Cities: C, D",
|
||||
"|--Hostnames: E, F",
|
||||
"|--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -73,15 +80,7 @@ func Test_Provider_readIvpn(t *testing.T) {
|
||||
settings Provider
|
||||
err error
|
||||
}{
|
||||
"protocol error": {
|
||||
protocol: singleStringCall{call: true, err: errDummy},
|
||||
settings: Provider{
|
||||
Name: constants.Ivpn,
|
||||
},
|
||||
err: errors.New("environment variable PROTOCOL: dummy test error"),
|
||||
},
|
||||
"target IP error": {
|
||||
protocol: singleStringCall{call: true},
|
||||
targetIP: singleStringCall{call: true, value: "something", err: errDummy},
|
||||
settings: Provider{
|
||||
Name: constants.Ivpn,
|
||||
@@ -89,7 +88,6 @@ func Test_Provider_readIvpn(t *testing.T) {
|
||||
err: errors.New("environment variable OPENVPN_TARGET_IP: dummy test error"),
|
||||
},
|
||||
"countries error": {
|
||||
protocol: singleStringCall{call: true},
|
||||
targetIP: singleStringCall{call: true},
|
||||
countries: sliceStringCall{call: true, err: errDummy},
|
||||
settings: Provider{
|
||||
@@ -98,7 +96,6 @@ func Test_Provider_readIvpn(t *testing.T) {
|
||||
err: errors.New("environment variable COUNTRY: dummy test error"),
|
||||
},
|
||||
"cities error": {
|
||||
protocol: singleStringCall{call: true},
|
||||
targetIP: singleStringCall{call: true},
|
||||
countries: sliceStringCall{call: true},
|
||||
cities: sliceStringCall{call: true, err: errDummy},
|
||||
@@ -108,7 +105,6 @@ func Test_Provider_readIvpn(t *testing.T) {
|
||||
err: errors.New("environment variable CITY: dummy test error"),
|
||||
},
|
||||
"hostnames error": {
|
||||
protocol: singleStringCall{call: true},
|
||||
targetIP: singleStringCall{call: true},
|
||||
countries: sliceStringCall{call: true},
|
||||
cities: sliceStringCall{call: true},
|
||||
@@ -118,26 +114,39 @@ func Test_Provider_readIvpn(t *testing.T) {
|
||||
},
|
||||
err: errors.New("environment variable SERVER_HOSTNAME: dummy test error"),
|
||||
},
|
||||
"default settings": {
|
||||
protocol: singleStringCall{call: true},
|
||||
"protocol error": {
|
||||
targetIP: singleStringCall{call: true},
|
||||
countries: sliceStringCall{call: true},
|
||||
cities: sliceStringCall{call: true},
|
||||
hostnames: sliceStringCall{call: true},
|
||||
protocol: singleStringCall{call: true, err: errDummy},
|
||||
settings: Provider{
|
||||
Name: constants.Ivpn,
|
||||
},
|
||||
err: errors.New("environment variable PROTOCOL: dummy test error"),
|
||||
},
|
||||
"default settings": {
|
||||
targetIP: singleStringCall{call: true},
|
||||
countries: sliceStringCall{call: true},
|
||||
cities: sliceStringCall{call: true},
|
||||
hostnames: sliceStringCall{call: true},
|
||||
protocol: singleStringCall{call: true},
|
||||
settings: Provider{
|
||||
Name: constants.Ivpn,
|
||||
},
|
||||
},
|
||||
"set settings": {
|
||||
protocol: singleStringCall{call: true, value: constants.TCP},
|
||||
targetIP: singleStringCall{call: true, value: "1.2.3.4"},
|
||||
countries: sliceStringCall{call: true, values: []string{"A", "B"}},
|
||||
cities: sliceStringCall{call: true, values: []string{"C", "D"}},
|
||||
hostnames: sliceStringCall{call: true, values: []string{"E", "F"}},
|
||||
protocol: singleStringCall{call: true, value: constants.TCP},
|
||||
settings: Provider{
|
||||
Name: constants.Ivpn,
|
||||
ServerSelection: ServerSelection{
|
||||
OpenVPN: OpenVPNSelection{
|
||||
TCP: true,
|
||||
},
|
||||
TargetIP: net.IPv4(1, 2, 3, 4),
|
||||
Countries: []string{"A", "B"},
|
||||
Cities: []string{"C", "D"},
|
||||
|
||||
@@ -2,7 +2,6 @@ package configuration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/golibs/params"
|
||||
@@ -25,9 +24,7 @@ func (settings *Provider) mullvadLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"ISPs: "+commaJoin(settings.ServerSelection.ISPs))
|
||||
}
|
||||
|
||||
if settings.ServerSelection.CustomPort > 0 {
|
||||
lines = append(lines, lastIndent+"Custom port: "+strconv.Itoa(int(settings.ServerSelection.CustomPort)))
|
||||
}
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
@@ -35,11 +32,6 @@ func (settings *Provider) mullvadLines() (lines []string) {
|
||||
func (settings *Provider) readMullvad(r reader) (err error) {
|
||||
settings.Name = constants.Mullvad
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -65,16 +57,25 @@ func (settings *Provider) readMullvad(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable ISP: %w", err)
|
||||
}
|
||||
|
||||
settings.ServerSelection.CustomPort, err = readCustomPort(r.env, settings.ServerSelection.TCP,
|
||||
[]uint16{80, 443, 1401}, []uint16{53, 1194, 1195, 1196, 1197, 1300, 1301, 1302, 1303, 1400})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.Owned, err = r.env.YesNo("OWNED", params.Default("no"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("environment variable OWNED: %w", err)
|
||||
}
|
||||
|
||||
return settings.ServerSelection.OpenVPN.readMullvad(r.env)
|
||||
}
|
||||
|
||||
func (settings *OpenVPNSelection) readMullvad(env params.Env) (err error) {
|
||||
settings.TCP, err = readProtocol(env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.CustomPort, err = readCustomPort(env, settings.TCP,
|
||||
[]uint16{80, 443, 1401}, []uint16{53, 1194, 1195, 1196, 1197, 1300, 1301, 1302, 1303, 1400})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -29,17 +29,14 @@ func (settings *Provider) nordvpnLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Numbers: "+commaJoin(numbersString))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readNordvpn(r reader) (err error) {
|
||||
settings.Name = constants.Nordvpn
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -65,7 +62,7 @@ func (settings *Provider) readNordvpn(r reader) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolOnly(r.env)
|
||||
}
|
||||
|
||||
func readNordVPNServerNumbers(env params.Env) (numbers []uint16, err error) {
|
||||
|
||||
@@ -150,8 +150,6 @@ func (settings *OpenVPN) read(r reader, serviceProvider string) (err error) {
|
||||
switch serviceProvider {
|
||||
case constants.Cyberghost:
|
||||
err = settings.readCyberghost(r)
|
||||
case constants.PrivateInternetAccess:
|
||||
err = settings.readPrivateInternetAccess(r)
|
||||
case constants.VPNUnlimited:
|
||||
err = settings.readVPNUnlimited(r)
|
||||
}
|
||||
@@ -161,3 +159,11 @@ func (settings *OpenVPN) read(r reader, serviceProvider string) (err error) {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func readProtocol(env params.Env) (tcp bool, err error) {
|
||||
protocol, err := env.Inside("PROTOCOL", []string{constants.TCP, constants.UDP}, params.Default(constants.UDP))
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("environment variable PROTOCOL: %w", err)
|
||||
}
|
||||
return protocol == constants.TCP, nil
|
||||
}
|
||||
|
||||
@@ -23,17 +23,14 @@ func (settings *Provider) privadoLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readPrivado(r reader) (err error) {
|
||||
settings.Name = constants.Privado
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -2,7 +2,6 @@ package configuration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/golibs/params"
|
||||
@@ -21,9 +20,7 @@ func (settings *Provider) privateinternetaccessLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Names: "+commaJoin(settings.ServerSelection.Names))
|
||||
}
|
||||
|
||||
if settings.ServerSelection.CustomPort > 0 {
|
||||
lines = append(lines, lastIndent+"Custom port: "+strconv.Itoa(int(settings.ServerSelection.CustomPort)))
|
||||
}
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
if settings.PortForwarding.Enabled {
|
||||
lines = append(lines, lastIndent+"Port forwarding:")
|
||||
@@ -38,11 +35,6 @@ func (settings *Provider) privateinternetaccessLines() (lines []string) {
|
||||
func (settings *Provider) readPrivateInternetAccess(r reader) (err error) {
|
||||
settings.Name = constants.PrivateInternetAccess
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -63,16 +55,6 @@ func (settings *Provider) readPrivateInternetAccess(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable SERVER_NAME: %w", err)
|
||||
}
|
||||
|
||||
settings.ServerSelection.CustomPort, err = readPortOrZero(r.env, "PORT")
|
||||
if err != nil {
|
||||
return fmt.Errorf("environment variable PORT: %w", err)
|
||||
}
|
||||
|
||||
settings.ServerSelection.EncryptionPreset, err = getPIAEncryptionPreset(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.PortForwarding.Enabled, err = r.env.OnOff("PORT_FORWARDING", params.Default("off"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("environment variable PORT_FORWARDING: %w", err)
|
||||
@@ -86,14 +68,23 @@ func (settings *Provider) readPrivateInternetAccess(r reader) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readPrivateInternetAccess(r)
|
||||
}
|
||||
|
||||
func (settings *OpenVPN) readPrivateInternetAccess(r reader) (err error) {
|
||||
func (settings *OpenVPNSelection) readPrivateInternetAccess(r reader) (err error) {
|
||||
settings.EncPreset, err = getPIAEncryptionPreset(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.CustomPort, err = readPortOrZero(r.env, "PORT")
|
||||
if err != nil {
|
||||
return fmt.Errorf("environment variable PORT: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getPIAEncryptionPreset(r reader) (encryptionPreset string, err error) {
|
||||
encryptionPreset, err = r.env.Inside("PIA_ENCRYPTION",
|
||||
[]string{constants.PIAEncryptionPresetNone, constants.PIAEncryptionPresetNormal, constants.PIAEncryptionPresetStrong},
|
||||
@@ -103,5 +94,6 @@ func getPIAEncryptionPreset(r reader) (encryptionPreset string, err error) {
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("environment variable PIA_ENCRYPTION: %w", err)
|
||||
}
|
||||
|
||||
return encryptionPreset, nil
|
||||
}
|
||||
|
||||
@@ -19,17 +19,14 @@ func (settings *Provider) privatevpnLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readPrivatevpn(r reader) (err error) {
|
||||
settings.Name = constants.Privatevpn
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -50,5 +47,5 @@ func (settings *Provider) readPrivatevpn(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolAndPort(r.env)
|
||||
}
|
||||
|
||||
@@ -32,27 +32,19 @@ func (settings *Provider) protonvpnLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Free only: yes")
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readProtonvpn(r reader) (err error) {
|
||||
settings.Name = constants.Protonvpn
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.CustomPort, err = readPortOrZero(r.env, "PORT")
|
||||
if err != nil {
|
||||
return fmt.Errorf("environment variable PORT: %w", err)
|
||||
}
|
||||
|
||||
settings.ServerSelection.Countries, err = r.env.CSVInside("COUNTRY", constants.ProtonvpnCountryChoices())
|
||||
if err != nil {
|
||||
return fmt.Errorf("environment variable COUNTRY: %w", err)
|
||||
@@ -83,5 +75,5 @@ func (settings *Provider) readProtonvpn(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable FREE_ONLY: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolAndPort(r.env)
|
||||
}
|
||||
|
||||
@@ -18,12 +18,14 @@ type Provider struct {
|
||||
}
|
||||
|
||||
func (settings *Provider) lines() (lines []string) {
|
||||
if settings.Name == "" { // custom OpenVPN configuration
|
||||
return nil
|
||||
}
|
||||
|
||||
lines = append(lines, lastIndent+strings.Title(settings.Name)+" settings:")
|
||||
|
||||
selection := settings.ServerSelection
|
||||
|
||||
lines = append(lines, indent+lastIndent+"Network protocol: "+protoToString(selection.TCP))
|
||||
|
||||
if selection.TargetIP != nil {
|
||||
lines = append(lines, indent+lastIndent+"Target IP address: "+selection.TargetIP.String())
|
||||
}
|
||||
@@ -153,14 +155,6 @@ func commaJoin(slice []string) string {
|
||||
return strings.Join(slice, ", ")
|
||||
}
|
||||
|
||||
func readProtocol(env params.Env) (tcp bool, err error) {
|
||||
protocol, err := env.Inside("PROTOCOL", []string{constants.TCP, constants.UDP}, params.Default(constants.UDP))
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("environment variable PROTOCOL: %w", err)
|
||||
}
|
||||
return protocol == constants.TCP, nil
|
||||
}
|
||||
|
||||
func protoToString(tcp bool) string {
|
||||
if tcp {
|
||||
return constants.TCP
|
||||
|
||||
@@ -30,9 +30,10 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Cyberghost settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Server groups: group",
|
||||
" |--Regions: a, El country",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"fastestvpn": {
|
||||
@@ -45,9 +46,10 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Fastestvpn settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Hostnames: a, b",
|
||||
" |--Countries: c, d",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"hidemyass": {
|
||||
@@ -61,10 +63,11 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Hidemyass settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Countries: a, b",
|
||||
" |--Cities: c, d",
|
||||
" |--Hostnames: e, f",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"ipvanish": {
|
||||
@@ -78,10 +81,11 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Ipvanish settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Countries: a, b",
|
||||
" |--Cities: c, d",
|
||||
" |--Hostnames: e, f",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"ivpn": {
|
||||
@@ -95,10 +99,11 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Ivpn settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Countries: a, b",
|
||||
" |--Cities: c, d",
|
||||
" |--Hostnames: e, f",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"mullvad": {
|
||||
@@ -108,15 +113,18 @@ func Test_Provider_lines(t *testing.T) {
|
||||
Countries: []string{"a", "b"},
|
||||
Cities: []string{"c", "d"},
|
||||
ISPs: []string{"e", "f"},
|
||||
OpenVPN: OpenVPNSelection{
|
||||
CustomPort: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
lines: []string{
|
||||
"|--Mullvad settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Countries: a, b",
|
||||
" |--Cities: c, d",
|
||||
" |--ISPs: e, f",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
" |--Custom port: 1",
|
||||
},
|
||||
},
|
||||
@@ -130,9 +138,10 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Nordvpn settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Regions: a, b",
|
||||
" |--Numbers: 1, 2",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"privado": {
|
||||
@@ -144,8 +153,9 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Privado settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Hostnames: a, b",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"privatevpn": {
|
||||
@@ -159,10 +169,11 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Privatevpn settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Countries: c, d",
|
||||
" |--Cities: e, f",
|
||||
" |--Hostnames: a, b",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"protonvpn": {
|
||||
@@ -178,12 +189,13 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Protonvpn settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Countries: a, b",
|
||||
" |--Regions: c, d",
|
||||
" |--Cities: e, f",
|
||||
" |--Names: g, h",
|
||||
" |--Hostnames: i, j",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"private internet access": {
|
||||
@@ -191,8 +203,10 @@ func Test_Provider_lines(t *testing.T) {
|
||||
Name: constants.PrivateInternetAccess,
|
||||
ServerSelection: ServerSelection{
|
||||
Regions: []string{"a", "b"},
|
||||
OpenVPN: OpenVPNSelection{
|
||||
CustomPort: 1,
|
||||
},
|
||||
},
|
||||
PortForwarding: PortForwarding{
|
||||
Enabled: true,
|
||||
Filepath: string("/here"),
|
||||
@@ -200,8 +214,9 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Private Internet Access settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Regions: a, b",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
" |--Custom port: 1",
|
||||
" |--Port forwarding:",
|
||||
" |--File path: /here",
|
||||
@@ -218,10 +233,11 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Purevpn settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Regions: a, b",
|
||||
" |--Countries: c, d",
|
||||
" |--Cities: e, f",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"surfshark": {
|
||||
@@ -233,8 +249,9 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Surfshark settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Regions: a, b",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"torguard": {
|
||||
@@ -248,10 +265,11 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Torguard settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Countries: a, b",
|
||||
" |--Cities: c, d",
|
||||
" |--Hostnames: e",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
constants.VPNUnlimited: {
|
||||
@@ -267,12 +285,13 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Vpn Unlimited settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Countries: a, b",
|
||||
" |--Cities: c, d",
|
||||
" |--Hostnames: e, f",
|
||||
" |--Free servers only",
|
||||
" |--Stream servers only",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"vyprvpn": {
|
||||
@@ -284,8 +303,9 @@ func Test_Provider_lines(t *testing.T) {
|
||||
},
|
||||
lines: []string{
|
||||
"|--Vyprvpn settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Regions: a, b",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"windscribe": {
|
||||
@@ -295,15 +315,18 @@ func Test_Provider_lines(t *testing.T) {
|
||||
Regions: []string{"a", "b"},
|
||||
Cities: []string{"c", "d"},
|
||||
Hostnames: []string{"e", "f"},
|
||||
OpenVPN: OpenVPNSelection{
|
||||
CustomPort: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
lines: []string{
|
||||
"|--Windscribe settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--Regions: a, b",
|
||||
" |--Cities: c, d",
|
||||
" |--Hostnames: e, f",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
" |--Custom port: 1",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -23,17 +23,14 @@ func (settings *Provider) purevpnLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readPurevpn(r reader) (err error) {
|
||||
settings.Name = constants.Purevpn
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -59,5 +56,5 @@ func (settings *Provider) readPurevpn(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolOnly(r.env)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package configuration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
type ServerSelection struct { //nolint:maligned
|
||||
// Common
|
||||
TCP bool `json:"tcp"` // UDP if TCP is false
|
||||
TargetIP net.IP `json:"target_ip,omitempty"`
|
||||
// TODO comments
|
||||
// Cyberghost, PIA, Protonvpn, Surfshark, Windscribe, Vyprvpn, NordVPN
|
||||
@@ -27,20 +29,57 @@ type ServerSelection struct { //nolint:maligned
|
||||
ISPs []string `json:"isps"`
|
||||
Owned bool `json:"owned"`
|
||||
|
||||
// Mullvad, Windscribe, PIA
|
||||
CustomPort uint16 `json:"custom_port"`
|
||||
|
||||
// NordVPN
|
||||
Numbers []uint16 `json:"numbers"`
|
||||
|
||||
// PIA - needed to get the port number
|
||||
EncryptionPreset string `json:"encryption_preset"`
|
||||
|
||||
// ProtonVPN
|
||||
FreeOnly bool `json:"free_only"`
|
||||
|
||||
// VPNUnlimited
|
||||
StreamOnly bool `json:"stream_only"`
|
||||
|
||||
OpenVPN OpenVPNSelection `json:"openvpn"`
|
||||
}
|
||||
|
||||
type OpenVPNSelection struct {
|
||||
TCP bool `json:"tcp"` // UDP if TCP is false
|
||||
CustomPort uint16 `json:"custom_port"` // HideMyAss, Mullvad, PIA, ProtonVPN, Windscribe
|
||||
EncPreset string `json:"encryption_preset"` // PIA - needed to get the port number
|
||||
}
|
||||
|
||||
func (settings *OpenVPNSelection) lines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"OpenVPN selection:")
|
||||
|
||||
lines = append(lines, indent+lastIndent+"Protocol: "+protoToString(settings.TCP))
|
||||
|
||||
if settings.CustomPort != 0 {
|
||||
lines = append(lines, indent+lastIndent+"Custom port: "+fmt.Sprint(settings.CustomPort))
|
||||
}
|
||||
|
||||
if settings.EncPreset != "" {
|
||||
lines = append(lines, indent+lastIndent+"PIA encryption preset: "+settings.EncPreset)
|
||||
}
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *OpenVPNSelection) readProtocolOnly(env params.Env) (err error) {
|
||||
settings.TCP, err = readProtocol(env)
|
||||
return err
|
||||
}
|
||||
|
||||
func (settings *OpenVPNSelection) readProtocolAndPort(env params.Env) (err error) {
|
||||
settings.TCP, err = readProtocol(env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.CustomPort, err = readPortOrZero(env, "PORT")
|
||||
if err != nil {
|
||||
return fmt.Errorf("environment variable PORT: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// PortForwarding contains settings for port forwarding.
|
||||
|
||||
@@ -34,7 +34,8 @@ func Test_Settings_lines(t *testing.T) {
|
||||
" |--Version: 2.5",
|
||||
" |--Verbosity level: 0",
|
||||
" |--Mullvad settings:",
|
||||
" |--Network protocol: udp",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
"|--DNS:",
|
||||
"|--Firewall: disabled ⚠️",
|
||||
"|--System:",
|
||||
|
||||
@@ -15,17 +15,14 @@ func (settings *Provider) surfsharkLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readSurfshark(r reader) (err error) {
|
||||
settings.Name = constants.Surfshark
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -41,5 +38,5 @@ func (settings *Provider) readSurfshark(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolOnly(r.env)
|
||||
}
|
||||
|
||||
@@ -19,17 +19,14 @@ func (settings *Provider) torguardLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readTorguard(r reader) (err error) {
|
||||
settings.Name = constants.Torguard
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -50,5 +47,5 @@ func (settings *Provider) readTorguard(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolAndPort(r.env)
|
||||
}
|
||||
|
||||
@@ -28,17 +28,14 @@ func (settings *Provider) vpnUnlimitedLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Stream servers only")
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readVPNUnlimited(r reader) (err error) {
|
||||
settings.Name = constants.VPNUnlimited
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -69,7 +66,7 @@ func (settings *Provider) readVPNUnlimited(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable STREAM_ONLY: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.ServerSelection.OpenVPN.readProtocolOnly(r.env)
|
||||
}
|
||||
|
||||
func (settings *OpenVPN) readVPNUnlimited(r reader) (err error) {
|
||||
|
||||
@@ -13,7 +13,12 @@ func Test_Provider_vpnUnlimitedLines(t *testing.T) {
|
||||
settings Provider
|
||||
lines []string
|
||||
}{
|
||||
"empty settings": {},
|
||||
"empty settings": {
|
||||
lines: []string{
|
||||
"|--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
"full settings": {
|
||||
settings: Provider{
|
||||
ServerSelection: ServerSelection{
|
||||
@@ -26,6 +31,8 @@ func Test_Provider_vpnUnlimitedLines(t *testing.T) {
|
||||
"|--Countries: A, B",
|
||||
"|--Cities: C, D",
|
||||
"|--Hostnames: E, F",
|
||||
"|--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -11,17 +11,14 @@ func (settings *Provider) vyprvpnLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
|
||||
}
|
||||
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (settings *Provider) readVyprvpn(r reader) (err error) {
|
||||
settings.Name = constants.Vyprvpn
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -2,9 +2,9 @@ package configuration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
func (settings *Provider) windscribeLines() (lines []string) {
|
||||
@@ -20,9 +20,7 @@ func (settings *Provider) windscribeLines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
||||
}
|
||||
|
||||
if settings.ServerSelection.CustomPort > 0 {
|
||||
lines = append(lines, lastIndent+"Custom port: "+strconv.Itoa(int(settings.ServerSelection.CustomPort)))
|
||||
}
|
||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
||||
|
||||
return lines
|
||||
}
|
||||
@@ -30,11 +28,6 @@ func (settings *Provider) windscribeLines() (lines []string) {
|
||||
func (settings *Provider) readWindscribe(r reader) (err error) {
|
||||
settings.Name = constants.Windscribe
|
||||
|
||||
settings.ServerSelection.TCP, err = readProtocol(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -55,7 +48,16 @@ func (settings *Provider) readWindscribe(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable SERVER_HOSTNAME: %w", err)
|
||||
}
|
||||
|
||||
settings.ServerSelection.CustomPort, err = readCustomPort(r.env, settings.ServerSelection.TCP,
|
||||
return settings.ServerSelection.OpenVPN.readWindscribe(r.env)
|
||||
}
|
||||
|
||||
func (settings *OpenVPNSelection) readWindscribe(env params.Env) (err error) {
|
||||
settings.TCP, err = readProtocol(env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.CustomPort, err = readCustomPort(env, settings.TCP,
|
||||
[]uint16{21, 22, 80, 123, 143, 443, 587, 1194, 3306, 8080, 54783},
|
||||
[]uint16{53, 80, 123, 443, 1194, 54783})
|
||||
if err != nil {
|
||||
|
||||
@@ -11,7 +11,7 @@ func (c *Cyberghost) GetOpenVPNConnection(selection configuration.ServerSelectio
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
const port = 443
|
||||
protocol := constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ var ErrGroupMismatchesProtocol = errors.New("server group does not match protoco
|
||||
func (c *Cyberghost) filterServers(selection configuration.ServerSelection) (
|
||||
servers []models.CyberghostServer, err error) {
|
||||
if len(selection.Groups) == 0 {
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
selection.Groups = tcpGroupChoices()
|
||||
} else {
|
||||
selection.Groups = udpGroupChoices()
|
||||
@@ -25,7 +25,7 @@ func (c *Cyberghost) filterServers(selection configuration.ServerSelection) (
|
||||
|
||||
// Check each group match the protocol
|
||||
groupsCheckFn := groupsAreAllUDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
groupsCheckFn = groupsAreAllTCP
|
||||
}
|
||||
if err := groupsCheckFn(selection.Groups); err != nil {
|
||||
|
||||
@@ -41,8 +41,10 @@ func Test_Cyberghost_filterServers(t *testing.T) {
|
||||
{Region: "d", Group: "Premium UDP Europe"},
|
||||
},
|
||||
selection: configuration.ServerSelection{
|
||||
OpenVPN: configuration.OpenVPNSelection{
|
||||
TCP: true,
|
||||
},
|
||||
},
|
||||
filteredServers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium TCP Asia"},
|
||||
{Region: "b", Group: "Premium TCP Europe"},
|
||||
|
||||
@@ -11,7 +11,7 @@ func (f *Fastestvpn) GetOpenVPNConnection(selection configuration.ServerSelectio
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
const port = 4443
|
||||
protocol := constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ func (f *Fastestvpn) filterServers(selection configuration.ServerSelection) (
|
||||
case
|
||||
utils.FilterByPossibilities(server.Country, selection.Countries),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ func (h *HideMyAss) GetOpenVPNConnection(selection configuration.ServerSelection
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
var port uint16 = 553
|
||||
protocol := constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
port = 8080
|
||||
}
|
||||
|
||||
if selection.CustomPort > 0 {
|
||||
port = selection.CustomPort
|
||||
if selection.OpenVPN.CustomPort > 0 {
|
||||
port = selection.OpenVPN.CustomPort
|
||||
}
|
||||
|
||||
servers, err := h.filterServers(selection)
|
||||
|
||||
@@ -14,8 +14,8 @@ func (h *HideMyAss) filterServers(selection configuration.ServerSelection) (
|
||||
utils.FilterByPossibilities(server.Country, selection.Countries),
|
||||
utils.FilterByPossibilities(server.City, selection.Cities),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func (i *Ipvanish) GetOpenVPNConnection(selection configuration.ServerSelection)
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
const port = 443
|
||||
const protocol = constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
return connection, ErrProtocolUnsupported
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ func (i *Ipvanish) filterServers(selection configuration.ServerSelection) (
|
||||
utils.FilterByPossibilities(server.Country, selection.Countries),
|
||||
utils.FilterByPossibilities(server.City, selection.Cities),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func (i *Ivpn) GetOpenVPNConnection(selection configuration.ServerSelection) (
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
const port = 2049
|
||||
const protocol = constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
return connection, ErrProtocolUnsupported
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ func (i *Ivpn) filterServers(selection configuration.ServerSelection) (
|
||||
utils.FilterByPossibilities(server.Country, selection.Countries),
|
||||
utils.FilterByPossibilities(server.City, selection.Cities),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ func (m *Mullvad) GetOpenVPNConnection(selection configuration.ServerSelection)
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
var port uint16 = 1194
|
||||
protocol := constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
port = 443
|
||||
protocol = constants.TCP
|
||||
}
|
||||
|
||||
if selection.CustomPort > 0 {
|
||||
port = selection.CustomPort
|
||||
if selection.OpenVPN.CustomPort > 0 {
|
||||
port = selection.OpenVPN.CustomPort
|
||||
}
|
||||
|
||||
servers, err := m.filterServers(selection)
|
||||
|
||||
@@ -11,7 +11,7 @@ func (n *Nordvpn) GetOpenVPNConnection(selection configuration.ServerSelection)
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
var port uint16 = 1194
|
||||
protocol := constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
port = 443
|
||||
protocol = constants.TCP
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ func (n *Nordvpn) filterServers(selection configuration.ServerSelection) (
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
utils.FilterByPossibilities(server.Name, selection.Names),
|
||||
utils.FilterByPossibilities(serverNumber, selectedNumbers),
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ func (p *Privado) GetOpenVPNConnection(selection configuration.ServerSelection)
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
const port = 1194
|
||||
const protocol = constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
return connection, fmt.Errorf("%w: TCP for provider Privado", ErrProtocolUnsupported)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ import (
|
||||
func (p *PIA) GetOpenVPNConnection(selection configuration.ServerSelection) (
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
protocol := constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
}
|
||||
|
||||
port, err := getPort(selection.TCP, selection.EncryptionPreset, selection.CustomPort)
|
||||
port, err := getPort(selection.OpenVPN)
|
||||
if err != nil {
|
||||
return connection, err
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ func (p *PIA) filterServers(selection configuration.ServerSelection) (
|
||||
utils.FilterByPossibilities(server.Region, selection.Regions),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
utils.FilterByPossibilities(server.ServerName, selection.Names),
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -4,20 +4,21 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
)
|
||||
|
||||
func getPort(tcp bool, encryptionPreset string, customPort uint16) (
|
||||
func getPort(openvpnSelection configuration.OpenVPNSelection) (
|
||||
port uint16, err error) {
|
||||
if customPort == 0 {
|
||||
return getDefaultPort(tcp, encryptionPreset), nil
|
||||
if openvpnSelection.CustomPort == 0 {
|
||||
return getDefaultPort(openvpnSelection.TCP, openvpnSelection.EncPreset), nil
|
||||
}
|
||||
|
||||
if err := checkPort(customPort, tcp); err != nil {
|
||||
if err := checkPort(openvpnSelection.CustomPort, openvpnSelection.TCP); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return customPort, nil
|
||||
return openvpnSelection.CustomPort, nil
|
||||
}
|
||||
|
||||
func getDefaultPort(tcp bool, encryptionPreset string) (port uint16) {
|
||||
|
||||
@@ -11,7 +11,7 @@ func (p *Privatevpn) GetOpenVPNConnection(selection configuration.ServerSelectio
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
protocol := constants.UDP
|
||||
var port uint16 = 1194
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
port = 443
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ import (
|
||||
func (p *Protonvpn) GetOpenVPNConnection(selection configuration.ServerSelection) (
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
protocol := constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
}
|
||||
|
||||
port, err := getPort(selection.TCP, selection.CustomPort)
|
||||
port, err := getPort(selection.OpenVPN.TCP, selection.OpenVPN.CustomPort)
|
||||
if err != nil {
|
||||
return connection, err
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ func (p *Purevpn) GetOpenVPNConnection(selection configuration.ServerSelection)
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
protocol := constants.UDP
|
||||
var port uint16 = 53
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
port = 80
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ func (p *Purevpn) filterServers(selection configuration.ServerSelection) (
|
||||
utils.FilterByPossibilities(server.Country, selection.Countries),
|
||||
utils.FilterByPossibilities(server.City, selection.Cities),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ func (s *Surfshark) GetOpenVPNConnection(selection configuration.ServerSelection
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
protocol := constants.UDP
|
||||
var port uint16 = 1194
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
port = 1443
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ func (s *Surfshark) filterServers(selection configuration.ServerSelection) (
|
||||
case
|
||||
utils.FilterByPossibilities(server.Region, selection.Regions),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
func (t *Torguard) GetOpenVPNConnection(selection configuration.ServerSelection) (
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
protocol := constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
}
|
||||
|
||||
var port uint16 = 1912
|
||||
if selection.CustomPort > 0 {
|
||||
port = selection.CustomPort
|
||||
if selection.OpenVPN.CustomPort > 0 {
|
||||
port = selection.OpenVPN.CustomPort
|
||||
}
|
||||
|
||||
servers, err := t.filterServers(selection)
|
||||
|
||||
@@ -14,8 +14,8 @@ func (t *Torguard) filterServers(selection configuration.ServerSelection) (
|
||||
utils.FilterByPossibilities(server.Country, selection.Countries),
|
||||
utils.FilterByPossibilities(server.City, selection.Cities),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func NoServerFoundError(selection configuration.ServerSelection) (err error) {
|
||||
var messageParts []string
|
||||
|
||||
protocol := constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
}
|
||||
messageParts = append(messageParts, "protocol "+protocol)
|
||||
@@ -113,8 +113,8 @@ func NoServerFoundError(selection configuration.ServerSelection) (err error) {
|
||||
messageParts = append(messageParts, part)
|
||||
}
|
||||
|
||||
if selection.EncryptionPreset != "" {
|
||||
part := "encryption preset " + selection.EncryptionPreset
|
||||
if selection.OpenVPN.EncPreset != "" {
|
||||
part := "encryption preset " + selection.OpenVPN.EncPreset
|
||||
messageParts = append(messageParts, part)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ func (p *Provider) GetOpenVPNConnection(selection configuration.ServerSelection)
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
const port = 1194
|
||||
const protocol = constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
return connection, ErrProtocolUnsupported
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ func (p *Provider) filterServers(selection configuration.ServerSelection) (
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
selection.FreeOnly && !server.Free,
|
||||
selection.StreamOnly && !server.Stream,
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ func (v *Vyprvpn) GetOpenVPNConnection(selection configuration.ServerSelection)
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
const port = 443
|
||||
const protocol = constants.UDP
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
return connection, fmt.Errorf("%w: TCP for provider VyprVPN", ErrProtocolUnsupported)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ func (v *Vyprvpn) filterServers(selection configuration.ServerSelection) (
|
||||
case
|
||||
utils.FilterByPossibilities(server.Region, selection.Regions),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
selection.OpenVPN.TCP && !server.TCP,
|
||||
!selection.OpenVPN.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ func (w *Windscribe) GetOpenVPNConnection(selection configuration.ServerSelectio
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
protocol := constants.UDP
|
||||
var port uint16 = 443
|
||||
if selection.TCP {
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
port = 1194
|
||||
}
|
||||
|
||||
if selection.CustomPort > 0 {
|
||||
port = selection.CustomPort
|
||||
if selection.OpenVPN.CustomPort > 0 {
|
||||
port = selection.OpenVPN.CustomPort
|
||||
}
|
||||
|
||||
servers, err := w.filterServers(selection)
|
||||
|
||||
Reference in New Issue
Block a user