Fix: empty connection for NordVPN and Windscribe

This commit is contained in:
Quentin McGaw
2021-01-31 18:45:58 +00:00
parent 982c50c756
commit dd5a9c6067
4 changed files with 3 additions and 20 deletions

View File

@@ -121,9 +121,6 @@ func (c *configurator) acceptEstablishedRelatedTraffic(ctx context.Context, remo
func (c *configurator) acceptOutputTrafficToVPN(ctx context.Context, func (c *configurator) acceptOutputTrafficToVPN(ctx context.Context,
defaultInterface string, connection models.OpenVPNConnection, remove bool) error { defaultInterface string, connection models.OpenVPNConnection, remove bool) error {
if connection.IP == nil {
panic("PLEASE CREATE AN ISSUE with this log: https://github.com/qdm12/gluetun/issues")
}
return c.runIptablesInstruction(ctx, return c.runIptablesInstruction(ctx,
fmt.Sprintf("%s OUTPUT -d %s -o %s -p %s -m %s --dport %d -j ACCEPT", fmt.Sprintf("%s OUTPUT -d %s -o %s -p %s -m %s --dport %d -j ACCEPT",
appendOrDelete(remove), connection.IP, defaultInterface, connection.Protocol, connection.Protocol, connection.Port)) appendOrDelete(remove), connection.IP, defaultInterface, connection.Protocol, connection.Protocol, connection.Port))

View File

@@ -2,8 +2,6 @@ package openvpn
import ( import (
"context" "context"
"encoding/json"
"fmt"
"net" "net"
"net/http" "net/http"
"strings" "strings"
@@ -120,17 +118,6 @@ func (l *looper) Run(ctx context.Context, wg *sync.WaitGroup) {
l.cancel() l.cancel()
return return
} }
if connection.IP == nil {
serverSelectionJSON, _ := json.Marshal(settings.Provider.ServerSelection)
connectionJSON, _ := json.Marshal(connection)
message := fmt.Sprintf(`
PLEASE CREATE AN ISSUE with this log: https://github.com/qdm12/gluetun/issues
Server selection: %s
AllServers count: %d
connection: %s
`, string(serverSelectionJSON), allServers.Count(), string(connectionJSON))
panic(message)
}
lines := providerConf.BuildConf(connection, l.username, settings) lines := providerConf.BuildConf(connection, l.username, settings)
if err := writeOpenvpnConf(lines, l.openFile); err != nil { if err := writeOpenvpnConf(lines, l.openFile); err != nil {

View File

@@ -73,8 +73,7 @@ func (n *nordvpn) GetOpenVPNConnection(selection models.ServerSelection) (
connections := make([]models.OpenVPNConnection, len(servers)) connections := make([]models.OpenVPNConnection, len(servers))
for i := range servers { for i := range servers {
connection := models.OpenVPNConnection{IP: servers[i].IP, Port: port, Protocol: selection.Protocol} connections[i] = models.OpenVPNConnection{IP: servers[i].IP, Port: port, Protocol: selection.Protocol}
connections = append(connections, connection)
} }
return pickRandomConnection(connections, n.randSource), nil return pickRandomConnection(connections, n.randSource), nil

View File

@@ -67,8 +67,8 @@ func (w *windscribe) GetOpenVPNConnection(selection models.ServerSelection) (con
} }
connections := make([]models.OpenVPNConnection, len(servers)) connections := make([]models.OpenVPNConnection, len(servers))
for _, server := range servers { for i := range servers {
connections = append(connections, models.OpenVPNConnection{IP: server.IP, Port: port, Protocol: selection.Protocol}) connections[i] = models.OpenVPNConnection{IP: servers[i].IP, Port: port, Protocol: selection.Protocol}
} }
return pickRandomConnection(connections, w.randSource), nil return pickRandomConnection(connections, w.randSource), nil