Improve panic message for empty connection
This commit is contained in:
@@ -5,10 +5,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type OpenVPNConnection struct {
|
type OpenVPNConnection struct {
|
||||||
IP net.IP
|
IP net.IP `json:"ip"`
|
||||||
Port uint16
|
Port uint16 `json:"port"`
|
||||||
Protocol NetworkProtocol
|
Protocol NetworkProtocol `json:"protocol"`
|
||||||
Hostname string // Privado for tls verification
|
Hostname string `json:"hostname"` // Privado for tls verification
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OpenVPNConnection) Equal(other OpenVPNConnection) bool {
|
func (o *OpenVPNConnection) Equal(other OpenVPNConnection) bool {
|
||||||
|
|||||||
@@ -13,6 +13,18 @@ type AllServers struct {
|
|||||||
Windscribe WindscribeServers `json:"windscribe"`
|
Windscribe WindscribeServers `json:"windscribe"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AllServers) Count() int {
|
||||||
|
return len(a.Cyberghost.Servers) +
|
||||||
|
len(a.Mullvad.Servers) +
|
||||||
|
len(a.Nordvpn.Servers) +
|
||||||
|
len(a.Pia.Servers) +
|
||||||
|
len(a.Privado.Servers) +
|
||||||
|
len(a.Purevpn.Servers) +
|
||||||
|
len(a.Surfshark.Servers) +
|
||||||
|
len(a.Vyprvpn.Servers) +
|
||||||
|
len(a.Windscribe.Servers)
|
||||||
|
}
|
||||||
|
|
||||||
type CyberghostServers struct {
|
type CyberghostServers struct {
|
||||||
Version uint16 `json:"version"`
|
Version uint16 `json:"version"`
|
||||||
Timestamp int64 `json:"timestamp"`
|
Timestamp int64 `json:"timestamp"`
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package openvpn
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -119,7 +121,15 @@ func (l *looper) Run(ctx context.Context, wg *sync.WaitGroup) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if connection.IP == nil {
|
if connection.IP == nil {
|
||||||
panic("PLEASE CREATE AN ISSUE with this log: https://github.com/qdm12/gluetun/issues")
|
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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user