Maintenance: remove some type aliases
This commit is contained in:
@@ -143,6 +143,6 @@ func (c *cyberghost) BuildConf(connection models.OpenVPNConnection,
|
||||
|
||||
func (c *cyberghost) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
syncState func(port uint16) (pfFilepath models.Filepath)) {
|
||||
syncState func(port uint16) (pfFilepath string)) {
|
||||
panic("port forwarding is not supported for cyberghost")
|
||||
}
|
||||
|
||||
@@ -137,6 +137,6 @@ func (m *mullvad) BuildConf(connection models.OpenVPNConnection,
|
||||
|
||||
func (m *mullvad) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
syncState func(port uint16) (pfFilepath models.Filepath)) {
|
||||
syncState func(port uint16) (pfFilepath string)) {
|
||||
panic("port forwarding is not supported for mullvad")
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func newNordvpn(servers []models.NordvpnServer, timeNow timeNowFunc) *nordvpn {
|
||||
}
|
||||
}
|
||||
|
||||
func (n *nordvpn) filterServers(regions []string, protocol models.NetworkProtocol, numbers []uint16) (
|
||||
func (n *nordvpn) filterServers(regions []string, protocol string, numbers []uint16) (
|
||||
servers []models.NordvpnServer) {
|
||||
numbersStr := make([]string, len(numbers))
|
||||
for i := range numbers {
|
||||
@@ -151,6 +151,6 @@ func (n *nordvpn) BuildConf(connection models.OpenVPNConnection,
|
||||
|
||||
func (n *nordvpn) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
syncState func(port uint16) (pfFilepath models.Filepath)) {
|
||||
syncState func(port uint16) (pfFilepath string)) {
|
||||
panic("port forwarding is not supported for nordvpn")
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ func (p *pia) BuildConf(connection models.OpenVPNConnection,
|
||||
//nolint:gocognit
|
||||
func (p *pia) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
syncState func(port uint16) (pfFilepath models.Filepath)) {
|
||||
syncState func(port uint16) (pfFilepath string)) {
|
||||
commonName := p.activeServer.ServerName
|
||||
if !p.activeServer.PortForward {
|
||||
pfLogger.Error("The server %s (region %s) does not support port forwarding",
|
||||
@@ -267,7 +267,7 @@ func (p *pia) PortForward(ctx context.Context, client *http.Client,
|
||||
return
|
||||
}
|
||||
|
||||
filepath := string(syncState(data.Port))
|
||||
filepath := syncState(data.Port)
|
||||
pfLogger.Info("Writing port to %s", filepath)
|
||||
if err := writePortForwardedToFile(openFile, filepath, data.Port); err != nil {
|
||||
pfLogger.Error(err)
|
||||
@@ -322,7 +322,7 @@ func (p *pia) PortForward(ctx context.Context, client *http.Client,
|
||||
}
|
||||
filepath := syncState(data.Port)
|
||||
pfLogger.Info("Writing port to %s", filepath)
|
||||
if err := writePortForwardedToFile(openFile, string(filepath), data.Port); err != nil {
|
||||
if err := writePortForwardedToFile(openFile, filepath, data.Port); err != nil {
|
||||
pfLogger.Error(err)
|
||||
}
|
||||
if err := bindPIAPort(ctx, client, gateway, data); err != nil {
|
||||
@@ -337,7 +337,7 @@ func (p *pia) PortForward(ctx context.Context, client *http.Client,
|
||||
}
|
||||
}
|
||||
|
||||
func filterPIAServers(servers []models.PIAServer, regions []string, protocol models.NetworkProtocol) (
|
||||
func filterPIAServers(servers []models.PIAServer, regions []string, protocol string) (
|
||||
filtered []models.PIAServer) {
|
||||
for _, server := range servers {
|
||||
switch {
|
||||
@@ -417,8 +417,7 @@ type piaPortForwardData struct {
|
||||
}
|
||||
|
||||
func readPIAPortForwardData(openFile os.OpenFileFunc) (data piaPortForwardData, err error) {
|
||||
const filepath = string(constants.PIAPortForward)
|
||||
file, err := openFile(filepath, os.O_RDONLY, 0)
|
||||
file, err := openFile(constants.PIAPortForward, os.O_RDONLY, 0)
|
||||
if os.IsNotExist(err) {
|
||||
return data, nil
|
||||
} else if err != nil {
|
||||
@@ -435,8 +434,7 @@ func readPIAPortForwardData(openFile os.OpenFileFunc) (data piaPortForwardData,
|
||||
}
|
||||
|
||||
func writePIAPortForwardData(openFile os.OpenFileFunc, data piaPortForwardData) (err error) {
|
||||
const filepath = string(constants.PIAPortForward)
|
||||
file, err := openFile(filepath,
|
||||
file, err := openFile(constants.PIAPortForward,
|
||||
os.O_CREATE|os.O_TRUNC|os.O_WRONLY,
|
||||
0644)
|
||||
if err != nil {
|
||||
@@ -518,8 +516,7 @@ func fetchPIAToken(ctx context.Context, openFile os.OpenFileFunc,
|
||||
}
|
||||
|
||||
func getOpenvpnCredentials(openFile os.OpenFileFunc) (username, password string, err error) {
|
||||
const filepath = string(constants.OpenVPNAuthConf)
|
||||
file, err := openFile(filepath, os.O_RDONLY, 0)
|
||||
file, err := openFile(constants.OpenVPNAuthConf, os.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("cannot read openvpn auth file: %s", err)
|
||||
}
|
||||
|
||||
@@ -128,6 +128,6 @@ func (s *privado) BuildConf(connection models.OpenVPNConnection,
|
||||
|
||||
func (s *privado) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
syncState func(port uint16) (pfFilepath models.Filepath)) {
|
||||
syncState func(port uint16) (pfFilepath string)) {
|
||||
panic("port forwarding is not supported for privado")
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ type Provider interface {
|
||||
BuildConf(connection models.OpenVPNConnection, username string, settings configuration.OpenVPN) (lines []string)
|
||||
PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
syncState func(port uint16) (pfFilepath models.Filepath))
|
||||
syncState func(port uint16) (pfFilepath string))
|
||||
}
|
||||
|
||||
func New(provider models.VPNProvider, allServers models.AllServers, timeNow timeNowFunc) Provider {
|
||||
func New(provider string, allServers models.AllServers, timeNow timeNowFunc) Provider {
|
||||
switch provider {
|
||||
case constants.PrivateInternetAccess:
|
||||
return newPrivateInternetAccess(allServers.Pia.Servers, timeNow)
|
||||
|
||||
@@ -160,6 +160,6 @@ func (p *purevpn) BuildConf(connection models.OpenVPNConnection,
|
||||
|
||||
func (p *purevpn) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
syncState func(port uint16) (pfFilepath models.Filepath)) {
|
||||
syncState func(port uint16) (pfFilepath string)) {
|
||||
panic("port forwarding is not supported for purevpn")
|
||||
}
|
||||
|
||||
@@ -149,6 +149,6 @@ func (s *surfshark) BuildConf(connection models.OpenVPNConnection,
|
||||
|
||||
func (s *surfshark) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
syncState func(port uint16) (pfFilepath models.Filepath)) {
|
||||
syncState func(port uint16) (pfFilepath string)) {
|
||||
panic("port forwarding is not supported for surfshark")
|
||||
}
|
||||
|
||||
@@ -129,6 +129,6 @@ func (v *vyprvpn) BuildConf(connection models.OpenVPNConnection,
|
||||
|
||||
func (v *vyprvpn) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
syncState func(port uint16) (pfFilepath models.Filepath)) {
|
||||
syncState func(port uint16) (pfFilepath string)) {
|
||||
panic("port forwarding is not supported for vyprvpn")
|
||||
}
|
||||
|
||||
@@ -143,6 +143,6 @@ func (w *windscribe) BuildConf(connection models.OpenVPNConnection,
|
||||
|
||||
func (w *windscribe) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
syncState func(port uint16) (pfFilepath models.Filepath)) {
|
||||
syncState func(port uint16) (pfFilepath string)) {
|
||||
panic("port forwarding is not supported for windscribe")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user