1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-30 00:12:50 -05:00

vpn: just try and import all types on errors

This commit is contained in:
bbedward
2025-12-13 10:02:57 -05:00
parent 4ffa06945a
commit 830ca10b45

View File

@@ -880,22 +880,18 @@ func (b *NetworkManagerBackend) ImportVPN(filePath string, name string) (*VPNImp
} }
func (b *NetworkManagerBackend) importVPNWithNmcli(filePath string, name string) (*VPNImportResult, error) { func (b *NetworkManagerBackend) importVPNWithNmcli(filePath string, name string) (*VPNImportResult, error) {
args := []string{"connection", "import", "type", "openvpn", "file", filePath} vpnTypes := []string{"openvpn", "wireguard", "vpnc", "pptp", "l2tp", "openconnect", "strongswan"}
cmd := exec.Command("nmcli", args...)
output, err := cmd.CombinedOutput()
if err != nil { var output []byte
outputStr := string(output) var err error
if strings.Contains(outputStr, "vpnc") || strings.Contains(outputStr, "unknown connection type") { for _, vpnType := range vpnTypes {
for _, vpnType := range []string{"vpnc", "pptp", "l2tp", "openconnect", "strongswan", "wireguard"} { args := []string{"connection", "import", "type", vpnType, "file", filePath}
args = []string{"connection", "import", "type", vpnType, "file", filePath} cmd := exec.Command("nmcli", args...)
cmd = exec.Command("nmcli", args...)
output, err = cmd.CombinedOutput() output, err = cmd.CombinedOutput()
if err == nil { if err == nil {
break break
} }
} }
}
if err != nil { if err != nil {
return &VPNImportResult{ return &VPNImportResult{
@@ -903,7 +899,6 @@ func (b *NetworkManagerBackend) importVPNWithNmcli(filePath string, name string)
Error: fmt.Sprintf("import failed: %s", strings.TrimSpace(string(output))), Error: fmt.Sprintf("import failed: %s", strings.TrimSpace(string(output))),
}, nil }, nil
} }
}
outputStr := string(output) outputStr := string(output)
var connUUID, connName string var connUUID, connName string