chore(provider): add Name() method per provider

This commit is contained in:
Quentin McGaw
2022-06-07 16:58:08 +00:00
parent 79f213d97a
commit e37f557cd5
42 changed files with 106 additions and 40 deletions

View File

@@ -17,3 +17,7 @@ func New() *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Custom),
}
}
func (p *Provider) Name() string {
return providers.Custom
}

View File

@@ -2,7 +2,6 @@ package cyberghost
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(443, 443, 0) //nolint:gomnd
return utils.GetConnection(providers.Cyberghost,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Cyberghost),
}
}
func (p *Provider) Name() string {
return providers.Cyberghost
}

View File

@@ -2,7 +2,6 @@ package expressvpn
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(0, 1195, 0) //nolint:gomnd
return utils.GetConnection(providers.Expressvpn,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Expressvpn),
}
}
func (p *Provider) Name() string {
return providers.Expressvpn
}

View File

@@ -2,7 +2,6 @@ package fastestvpn
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(4443, 4443, 0) //nolint:gomnd
return utils.GetConnection(providers.Fastestvpn,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Fastestvpn),
}
}
func (p *Provider) Name() string {
return providers.Fastestvpn
}

View File

@@ -2,7 +2,6 @@ package hidemyass
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(8080, 553, 0) //nolint:gomnd
return utils.GetConnection(providers.HideMyAss,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.HideMyAss),
}
}
func (p *Provider) Name() string {
return providers.HideMyAss
}

View File

@@ -2,7 +2,6 @@ package ipvanish
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(0, 443, 0) //nolint:gomnd
return utils.GetConnection(providers.Ipvanish,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Ipvanish),
}
}
func (p *Provider) Name() string {
return providers.Ipvanish
}

View File

@@ -2,7 +2,6 @@ package ivpn
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(443, 1194, 58237) //nolint:gomnd
return utils.GetConnection(providers.Ivpn,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Ivpn),
}
}
func (p *Provider) Name() string {
return providers.Ivpn
}

View File

@@ -2,7 +2,6 @@ package mullvad
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(443, 1194, 51820) //nolint:gomnd
return utils.GetConnection(providers.Mullvad,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Mullvad),
}
}
func (p *Provider) Name() string {
return providers.Mullvad
}

View File

@@ -2,7 +2,6 @@ package nordvpn
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(443, 1194, 0) //nolint:gomnd
return utils.GetConnection(providers.Nordvpn,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Nordvpn),
}
}
func (p *Provider) Name() string {
return providers.Nordvpn
}

View File

@@ -2,7 +2,6 @@ package perfectprivacy
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(443, 443, 0) //nolint:gomnd
return utils.GetConnection(providers.Perfectprivacy,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Perfectprivacy),
}
}
func (p *Provider) Name() string {
return providers.Perfectprivacy
}

View File

@@ -2,7 +2,6 @@ package privado
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(0, 1194, 0) //nolint:gomnd
return utils.GetConnection(providers.Privado,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Privado),
}
}
func (p *Provider) Name() string {
return providers.Privado
}

View File

@@ -2,7 +2,6 @@ package privateinternetaccess
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/privateinternetaccess/presets"
"github.com/qdm12/gluetun/internal/provider/utils"
@@ -21,6 +20,6 @@ func (p *Provider) GetConnection(selection settings.ServerSelection) (
defaults.OpenVPNUDPPort = 1197
}
return utils.GetConnection(providers.PrivateInternetAccess,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -5,6 +5,7 @@ import (
"time"
"github.com/qdm12/gluetun/internal/constants/openvpn"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/provider/common"
)
@@ -28,3 +29,7 @@ func New(storage common.Storage, randSource rand.Source,
authFilePath: openvpn.AuthConf,
}
}
func (p *Provider) Name() string {
return providers.PrivateInternetAccess
}

View File

@@ -2,7 +2,6 @@ package privatevpn
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(443, 1194, 0) //nolint:gomnd
return utils.GetConnection(providers.Privatevpn,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Privatevpn),
}
}
func (p *Provider) Name() string {
return providers.Privatevpn
}

View File

@@ -2,7 +2,6 @@ package protonvpn
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(443, 1194, 0) //nolint:gomnd
return utils.GetConnection(providers.Protonvpn,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Protonvpn),
}
}
func (p *Provider) Name() string {
return providers.Protonvpn
}

View File

@@ -39,6 +39,7 @@ import (
type Provider interface {
GetConnection(selection settings.ServerSelection) (connection models.Connection, err error)
OpenVPNConfig(connection models.Connection, settings settings.OpenVPN) (lines []string)
Name() string
PortForwarder
}

View File

@@ -2,7 +2,6 @@ package purevpn
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(80, 53, 0) //nolint:gomnd
return utils.GetConnection(providers.Purevpn,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Purevpn),
}
}
func (p *Provider) Name() string {
return providers.Purevpn
}

View File

@@ -2,7 +2,6 @@ package surfshark
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(1443, 1194, 0) //nolint:gomnd
return utils.GetConnection(providers.Surfshark,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Surfshark),
}
}
func (p *Provider) Name() string {
return providers.Surfshark
}

View File

@@ -2,7 +2,6 @@ package torguard
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(1912, 1912, 0) //nolint:gomnd
return utils.GetConnection(providers.Torguard,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Torguard),
}
}
func (p *Provider) Name() string {
return providers.Torguard
}

View File

@@ -2,7 +2,6 @@ package vpnunlimited
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(0, 1194, 0) //nolint:gomnd
return utils.GetConnection(providers.VPNUnlimited,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.VPNUnlimited),
}
}
func (p *Provider) Name() string {
return providers.VPNUnlimited
}

View File

@@ -2,7 +2,6 @@ package vyprvpn
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(0, 443, 0) //nolint:gomnd
return utils.GetConnection(providers.Vyprvpn,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Vyprvpn),
}
}
func (p *Provider) Name() string {
return providers.Vyprvpn
}

View File

@@ -2,7 +2,6 @@ package wevpn
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(1195, 1194, 0) //nolint:gomnd
return utils.GetConnection(providers.Wevpn,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Wevpn),
}
}
func (p *Provider) Name() string {
return providers.Wevpn
}

View File

@@ -2,7 +2,6 @@ package windscribe
import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
@@ -10,6 +9,6 @@ import (
func (p *Provider) GetConnection(selection settings.ServerSelection) (
connection models.Connection, err error) {
defaults := utils.NewConnectionDefaults(443, 1194, 1194) //nolint:gomnd
return utils.GetConnection(providers.Windscribe,
return utils.GetConnection(p.Name(),
p.storage, selection, defaults, p.randSource)
}

View File

@@ -21,3 +21,7 @@ func New(storage common.Storage, randSource rand.Source) *Provider {
NoPortForwarder: utils.NewNoPortForwarding(providers.Windscribe),
}
}
func (p *Provider) Name() string {
return providers.Windscribe
}