Maint: simplify provider configuration logging
This commit is contained in:
@@ -6,22 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) cyberghostLines() (lines []string) {
|
|
||||||
lines = append(lines, lastIndent+"Server groups: "+commaJoin(settings.ServerSelection.Groups))
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Regions) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readCyberghost(r reader) (err error) {
|
||||||
settings.Name = constants.Cyberghost
|
settings.Name = constants.Cyberghost
|
||||||
|
|
||||||
|
|||||||
@@ -6,20 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) fastestvpnLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readFastestvpn(r reader) (err error) {
|
||||||
settings.Name = constants.Fastestvpn
|
settings.Name = constants.Fastestvpn
|
||||||
|
|
||||||
|
|||||||
@@ -6,28 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) hideMyAssLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Regions) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readHideMyAss(r reader) (err error) {
|
||||||
settings.Name = constants.HideMyAss
|
settings.Name = constants.HideMyAss
|
||||||
|
|
||||||
|
|||||||
@@ -6,24 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) ipvanishLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readIpvanish(r reader) (err error) {
|
||||||
settings.Name = constants.Ipvanish
|
settings.Name = constants.Ipvanish
|
||||||
|
|
||||||
|
|||||||
@@ -12,48 +12,6 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_Provider_ipvanishLines(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
testCases := map[string]struct {
|
|
||||||
settings Provider
|
|
||||||
lines []string
|
|
||||||
}{
|
|
||||||
"empty settings": {
|
|
||||||
lines: []string{
|
|
||||||
"|--OpenVPN selection:",
|
|
||||||
" |--Protocol: udp",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"full settings": {
|
|
||||||
settings: Provider{
|
|
||||||
ServerSelection: ServerSelection{
|
|
||||||
Countries: []string{"A", "B"},
|
|
||||||
Cities: []string{"C", "D"},
|
|
||||||
Hostnames: []string{"E", "F"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
lines: []string{
|
|
||||||
"|--Countries: A, B",
|
|
||||||
"|--Cities: C, D",
|
|
||||||
"|--Hostnames: E, F",
|
|
||||||
"|--OpenVPN selection:",
|
|
||||||
" |--Protocol: udp",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for name, testCase := range testCases {
|
|
||||||
testCase := testCase
|
|
||||||
t.Run(name, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
lines := testCase.settings.ipvanishLines()
|
|
||||||
|
|
||||||
assert.Equal(t, testCase.lines, lines)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_Provider_readIpvanish(t *testing.T) {
|
func Test_Provider_readIpvanish(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
@@ -6,24 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) ivpnLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readIvpn(r reader) (err error) {
|
||||||
settings.Name = constants.Ivpn
|
settings.Name = constants.Ivpn
|
||||||
|
|
||||||
|
|||||||
@@ -12,48 +12,6 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_Provider_ivpnLines(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
testCases := map[string]struct {
|
|
||||||
settings Provider
|
|
||||||
lines []string
|
|
||||||
}{
|
|
||||||
"empty settings": {
|
|
||||||
lines: []string{
|
|
||||||
"|--OpenVPN selection:",
|
|
||||||
" |--Protocol: udp",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"full settings": {
|
|
||||||
settings: Provider{
|
|
||||||
ServerSelection: ServerSelection{
|
|
||||||
Countries: []string{"A", "B"},
|
|
||||||
Cities: []string{"C", "D"},
|
|
||||||
Hostnames: []string{"E", "F"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
lines: []string{
|
|
||||||
"|--Countries: A, B",
|
|
||||||
"|--Cities: C, D",
|
|
||||||
"|--Hostnames: E, F",
|
|
||||||
"|--OpenVPN selection:",
|
|
||||||
" |--Protocol: udp",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for name, testCase := range testCases {
|
|
||||||
testCase := testCase
|
|
||||||
t.Run(name, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
lines := testCase.settings.ivpnLines()
|
|
||||||
|
|
||||||
assert.Equal(t, testCase.lines, lines)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_Provider_readIvpn(t *testing.T) {
|
func Test_Provider_readIvpn(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
@@ -7,28 +7,6 @@ import (
|
|||||||
"github.com/qdm12/golibs/params"
|
"github.com/qdm12/golibs/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) mullvadLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.ISPs) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"ISPs: "+commaJoin(settings.ServerSelection.ISPs))
|
|
||||||
}
|
|
||||||
|
|
||||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
|
||||||
|
|
||||||
return lines
|
|
||||||
}
|
|
||||||
|
|
||||||
func (settings *Provider) readMullvad(r reader) (err error) {
|
func (settings *Provider) readMullvad(r reader) (err error) {
|
||||||
settings.Name = constants.Mullvad
|
settings.Name = constants.Mullvad
|
||||||
|
|
||||||
|
|||||||
@@ -8,32 +8,6 @@ import (
|
|||||||
"github.com/qdm12/golibs/params"
|
"github.com/qdm12/golibs/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) nordvpnLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Regions) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Names) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Names: "+commaJoin(settings.ServerSelection.Hostnames))
|
|
||||||
}
|
|
||||||
|
|
||||||
if numbersUint16 := settings.ServerSelection.Numbers; len(numbersUint16) > 0 {
|
|
||||||
numbersString := make([]string, len(numbersUint16))
|
|
||||||
for i, numberUint16 := range numbersUint16 {
|
|
||||||
numbersString[i] = strconv.Itoa(int(numberUint16))
|
|
||||||
}
|
|
||||||
lines = append(lines, lastIndent+"Numbers: "+commaJoin(numbersString))
|
|
||||||
}
|
|
||||||
|
|
||||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
|
||||||
|
|
||||||
return lines
|
|
||||||
}
|
|
||||||
|
|
||||||
func (settings *Provider) readNordvpn(r reader) (err error) {
|
func (settings *Provider) readNordvpn(r reader) (err error) {
|
||||||
settings.Name = constants.Nordvpn
|
settings.Name = constants.Nordvpn
|
||||||
|
|
||||||
|
|||||||
@@ -6,28 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) privadoLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Regions) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readPrivado(r reader) (err error) {
|
||||||
settings.Name = constants.Privado
|
settings.Name = constants.Privado
|
||||||
|
|
||||||
|
|||||||
@@ -7,31 +7,6 @@ import (
|
|||||||
"github.com/qdm12/golibs/params"
|
"github.com/qdm12/golibs/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) privateinternetaccessLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Regions) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Names) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Names: "+commaJoin(settings.ServerSelection.Names))
|
|
||||||
}
|
|
||||||
|
|
||||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
|
||||||
|
|
||||||
if settings.PortForwarding.Enabled {
|
|
||||||
lines = append(lines, lastIndent+"Port forwarding:")
|
|
||||||
for _, line := range settings.PortForwarding.lines() {
|
|
||||||
lines = append(lines, indent+line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lines
|
|
||||||
}
|
|
||||||
|
|
||||||
func (settings *Provider) readPrivateInternetAccess(r reader) (err error) {
|
func (settings *Provider) readPrivateInternetAccess(r reader) (err error) {
|
||||||
settings.Name = constants.PrivateInternetAccess
|
settings.Name = constants.PrivateInternetAccess
|
||||||
|
|
||||||
|
|||||||
@@ -6,24 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) privatevpnLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readPrivatevpn(r reader) (err error) {
|
||||||
settings.Name = constants.Privatevpn
|
settings.Name = constants.Privatevpn
|
||||||
|
|
||||||
|
|||||||
@@ -7,36 +7,6 @@ import (
|
|||||||
"github.com/qdm12/golibs/params"
|
"github.com/qdm12/golibs/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) protonvpnLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Regions) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Names) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Names: "+commaJoin(settings.ServerSelection.Names))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
|
||||||
}
|
|
||||||
|
|
||||||
if settings.ServerSelection.FreeOnly {
|
|
||||||
lines = append(lines, lastIndent+"Free only: yes")
|
|
||||||
}
|
|
||||||
|
|
||||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
|
||||||
|
|
||||||
return lines
|
|
||||||
}
|
|
||||||
|
|
||||||
func (settings *Provider) readProtonvpn(r reader) (err error) {
|
func (settings *Provider) readProtonvpn(r reader) (err error) {
|
||||||
settings.Name = constants.Protonvpn
|
settings.Name = constants.Protonvpn
|
||||||
|
|
||||||
|
|||||||
@@ -24,57 +24,17 @@ func (settings *Provider) lines() (lines []string) {
|
|||||||
|
|
||||||
lines = append(lines, lastIndent+strings.Title(settings.Name)+" settings:")
|
lines = append(lines, lastIndent+strings.Title(settings.Name)+" settings:")
|
||||||
|
|
||||||
selection := settings.ServerSelection
|
for _, line := range settings.ServerSelection.toLines() {
|
||||||
|
|
||||||
if selection.TargetIP != nil {
|
|
||||||
lines = append(lines, indent+lastIndent+"Target IP address: "+selection.TargetIP.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
var providerLines []string
|
|
||||||
switch strings.ToLower(settings.Name) {
|
|
||||||
case "cyberghost":
|
|
||||||
providerLines = settings.cyberghostLines()
|
|
||||||
case "fastestvpn":
|
|
||||||
providerLines = settings.fastestvpnLines()
|
|
||||||
case "hidemyass":
|
|
||||||
providerLines = settings.hideMyAssLines()
|
|
||||||
case "ipvanish":
|
|
||||||
providerLines = settings.ipvanishLines()
|
|
||||||
case "ivpn":
|
|
||||||
providerLines = settings.ivpnLines()
|
|
||||||
case "mullvad":
|
|
||||||
providerLines = settings.mullvadLines()
|
|
||||||
case "nordvpn":
|
|
||||||
providerLines = settings.nordvpnLines()
|
|
||||||
case "privado":
|
|
||||||
providerLines = settings.privadoLines()
|
|
||||||
case "privatevpn":
|
|
||||||
providerLines = settings.privatevpnLines()
|
|
||||||
case "private internet access":
|
|
||||||
providerLines = settings.privateinternetaccessLines()
|
|
||||||
case "protonvpn":
|
|
||||||
providerLines = settings.protonvpnLines()
|
|
||||||
case "purevpn":
|
|
||||||
providerLines = settings.purevpnLines()
|
|
||||||
case "surfshark":
|
|
||||||
providerLines = settings.surfsharkLines()
|
|
||||||
case "torguard":
|
|
||||||
providerLines = settings.torguardLines()
|
|
||||||
case strings.ToLower(constants.VPNUnlimited):
|
|
||||||
providerLines = settings.vpnUnlimitedLines()
|
|
||||||
case "vyprvpn":
|
|
||||||
providerLines = settings.vyprvpnLines()
|
|
||||||
case "windscribe":
|
|
||||||
providerLines = settings.windscribeLines()
|
|
||||||
default:
|
|
||||||
panic(`Missing lines method for provider "` +
|
|
||||||
settings.Name + `"! Please create a Github issue.`)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, line := range providerLines {
|
|
||||||
lines = append(lines, indent+line)
|
lines = append(lines, indent+line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if settings.PortForwarding.Enabled { // PIA
|
||||||
|
lines = append(lines, indent+lastIndent+"Port forwarding:")
|
||||||
|
for _, line := range settings.PortForwarding.lines() {
|
||||||
|
lines = append(lines, indent+indent+line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ func Test_Provider_lines(t *testing.T) {
|
|||||||
},
|
},
|
||||||
lines: []string{
|
lines: []string{
|
||||||
"|--Fastestvpn settings:",
|
"|--Fastestvpn settings:",
|
||||||
" |--Hostnames: a, b",
|
|
||||||
" |--Countries: c, d",
|
" |--Countries: c, d",
|
||||||
|
" |--Hostnames: a, b",
|
||||||
" |--OpenVPN selection:",
|
" |--OpenVPN selection:",
|
||||||
" |--Protocol: udp",
|
" |--Protocol: udp",
|
||||||
},
|
},
|
||||||
@@ -192,8 +192,8 @@ func Test_Provider_lines(t *testing.T) {
|
|||||||
" |--Countries: a, b",
|
" |--Countries: a, b",
|
||||||
" |--Regions: c, d",
|
" |--Regions: c, d",
|
||||||
" |--Cities: e, f",
|
" |--Cities: e, f",
|
||||||
" |--Names: g, h",
|
|
||||||
" |--Hostnames: i, j",
|
" |--Hostnames: i, j",
|
||||||
|
" |--Names: g, h",
|
||||||
" |--OpenVPN selection:",
|
" |--OpenVPN selection:",
|
||||||
" |--Protocol: udp",
|
" |--Protocol: udp",
|
||||||
},
|
},
|
||||||
@@ -233,8 +233,8 @@ func Test_Provider_lines(t *testing.T) {
|
|||||||
},
|
},
|
||||||
lines: []string{
|
lines: []string{
|
||||||
"|--Purevpn settings:",
|
"|--Purevpn settings:",
|
||||||
" |--Regions: a, b",
|
|
||||||
" |--Countries: c, d",
|
" |--Countries: c, d",
|
||||||
|
" |--Regions: a, b",
|
||||||
" |--Cities: e, f",
|
" |--Cities: e, f",
|
||||||
" |--OpenVPN selection:",
|
" |--OpenVPN selection:",
|
||||||
" |--Protocol: udp",
|
" |--Protocol: udp",
|
||||||
@@ -287,9 +287,9 @@ func Test_Provider_lines(t *testing.T) {
|
|||||||
"|--Vpn Unlimited settings:",
|
"|--Vpn Unlimited settings:",
|
||||||
" |--Countries: a, b",
|
" |--Countries: a, b",
|
||||||
" |--Cities: c, d",
|
" |--Cities: c, d",
|
||||||
" |--Hostnames: e, f",
|
|
||||||
" |--Free servers only",
|
" |--Free servers only",
|
||||||
" |--Stream servers only",
|
" |--Stream servers only",
|
||||||
|
" |--Hostnames: e, f",
|
||||||
" |--OpenVPN selection:",
|
" |--OpenVPN selection:",
|
||||||
" |--Protocol: udp",
|
" |--Protocol: udp",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,28 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) purevpnLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Regions) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readPurevpn(r reader) (err error) {
|
||||||
settings.Name = constants.Purevpn
|
settings.Name = constants.Purevpn
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,60 @@ type ServerSelection struct { //nolint:maligned
|
|||||||
OpenVPN OpenVPNSelection `json:"openvpn"`
|
OpenVPN OpenVPNSelection `json:"openvpn"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (selection ServerSelection) toLines() (lines []string) {
|
||||||
|
if selection.TargetIP != nil {
|
||||||
|
lines = append(lines, lastIndent+"Target IP address: "+selection.TargetIP.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(selection.Groups) > 0 {
|
||||||
|
lines = append(lines, lastIndent+"Server groups: "+commaJoin(selection.Groups))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(selection.Countries) > 0 {
|
||||||
|
lines = append(lines, lastIndent+"Countries: "+commaJoin(selection.Countries))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(selection.Regions) > 0 {
|
||||||
|
lines = append(lines, lastIndent+"Regions: "+commaJoin(selection.Regions))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(selection.Cities) > 0 {
|
||||||
|
lines = append(lines, lastIndent+"Cities: "+commaJoin(selection.Cities))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(selection.ISPs) > 0 {
|
||||||
|
lines = append(lines, lastIndent+"ISPs: "+commaJoin(selection.ISPs))
|
||||||
|
}
|
||||||
|
|
||||||
|
if selection.FreeOnly {
|
||||||
|
lines = append(lines, lastIndent+"Free servers only")
|
||||||
|
}
|
||||||
|
|
||||||
|
if selection.StreamOnly {
|
||||||
|
lines = append(lines, lastIndent+"Stream servers only")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(selection.Hostnames) > 0 {
|
||||||
|
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(selection.Hostnames))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(selection.Names) > 0 {
|
||||||
|
lines = append(lines, lastIndent+"Names: "+commaJoin(selection.Names))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(selection.Numbers) > 0 {
|
||||||
|
numbersString := make([]string, len(selection.Numbers))
|
||||||
|
for i, numberUint16 := range selection.Numbers {
|
||||||
|
numbersString[i] = fmt.Sprint(numberUint16)
|
||||||
|
}
|
||||||
|
lines = append(lines, lastIndent+"Numbers: "+commaJoin(numbersString))
|
||||||
|
}
|
||||||
|
|
||||||
|
lines = append(lines, selection.OpenVPN.lines()...)
|
||||||
|
|
||||||
|
return lines
|
||||||
|
}
|
||||||
|
|
||||||
type OpenVPNSelection struct {
|
type OpenVPNSelection struct {
|
||||||
TCP bool `json:"tcp"` // UDP if TCP is false
|
TCP bool `json:"tcp"` // UDP if TCP is false
|
||||||
CustomPort uint16 `json:"custom_port"` // HideMyAss, Mullvad, PIA, ProtonVPN, Windscribe
|
CustomPort uint16 `json:"custom_port"` // HideMyAss, Mullvad, PIA, ProtonVPN, Windscribe
|
||||||
|
|||||||
@@ -6,20 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) surfsharkLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Regions) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readSurfshark(r reader) (err error) {
|
||||||
settings.Name = constants.Surfshark
|
settings.Name = constants.Surfshark
|
||||||
|
|
||||||
|
|||||||
@@ -6,24 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) torguardLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readTorguard(r reader) (err error) {
|
||||||
settings.Name = constants.Torguard
|
settings.Name = constants.Torguard
|
||||||
|
|
||||||
|
|||||||
@@ -7,32 +7,6 @@ import (
|
|||||||
"github.com/qdm12/golibs/params"
|
"github.com/qdm12/golibs/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) vpnUnlimitedLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Countries) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
|
||||||
}
|
|
||||||
|
|
||||||
if settings.ServerSelection.FreeOnly {
|
|
||||||
lines = append(lines, lastIndent+"Free servers only")
|
|
||||||
}
|
|
||||||
|
|
||||||
if settings.ServerSelection.StreamOnly {
|
|
||||||
lines = append(lines, lastIndent+"Stream servers only")
|
|
||||||
}
|
|
||||||
|
|
||||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
|
||||||
|
|
||||||
return lines
|
|
||||||
}
|
|
||||||
|
|
||||||
func (settings *Provider) readVPNUnlimited(r reader) (err error) {
|
func (settings *Provider) readVPNUnlimited(r reader) (err error) {
|
||||||
settings.Name = constants.VPNUnlimited
|
settings.Name = constants.VPNUnlimited
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
package configuration
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Test_Provider_vpnUnlimitedLines(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
testCases := map[string]struct {
|
|
||||||
settings Provider
|
|
||||||
lines []string
|
|
||||||
}{
|
|
||||||
"empty settings": {
|
|
||||||
lines: []string{
|
|
||||||
"|--OpenVPN selection:",
|
|
||||||
" |--Protocol: udp",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"full settings": {
|
|
||||||
settings: Provider{
|
|
||||||
ServerSelection: ServerSelection{
|
|
||||||
Countries: []string{"A", "B"},
|
|
||||||
Cities: []string{"C", "D"},
|
|
||||||
Hostnames: []string{"E", "F"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
lines: []string{
|
|
||||||
"|--Countries: A, B",
|
|
||||||
"|--Cities: C, D",
|
|
||||||
"|--Hostnames: E, F",
|
|
||||||
"|--OpenVPN selection:",
|
|
||||||
" |--Protocol: udp",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for name, testCase := range testCases {
|
|
||||||
testCase := testCase
|
|
||||||
t.Run(name, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
lines := testCase.settings.vpnUnlimitedLines()
|
|
||||||
|
|
||||||
assert.Equal(t, testCase.lines, lines)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,16 +6,6 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) vyprvpnLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Regions) > 0 {
|
|
||||||
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) {
|
func (settings *Provider) readVyprvpn(r reader) (err error) {
|
||||||
settings.Name = constants.Vyprvpn
|
settings.Name = constants.Vyprvpn
|
||||||
|
|
||||||
|
|||||||
@@ -7,24 +7,6 @@ import (
|
|||||||
"github.com/qdm12/golibs/params"
|
"github.com/qdm12/golibs/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (settings *Provider) windscribeLines() (lines []string) {
|
|
||||||
if len(settings.ServerSelection.Regions) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Cities) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(settings.ServerSelection.Hostnames) > 0 {
|
|
||||||
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
|
|
||||||
}
|
|
||||||
|
|
||||||
lines = append(lines, settings.ServerSelection.OpenVPN.lines()...)
|
|
||||||
|
|
||||||
return lines
|
|
||||||
}
|
|
||||||
|
|
||||||
func (settings *Provider) readWindscribe(r reader) (err error) {
|
func (settings *Provider) readWindscribe(r reader) (err error) {
|
||||||
settings.Name = constants.Windscribe
|
settings.Name = constants.Windscribe
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user