mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
vpn: just try and import all types on errors
This commit is contained in:
@@ -880,29 +880,24 @@ 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()
|
var output []byte
|
||||||
|
var err error
|
||||||
|
for _, vpnType := range vpnTypes {
|
||||||
|
args := []string{"connection", "import", "type", vpnType, "file", filePath}
|
||||||
|
cmd := exec.Command("nmcli", args...)
|
||||||
|
output, err = cmd.CombinedOutput()
|
||||||
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
outputStr := string(output)
|
return &VPNImportResult{
|
||||||
if strings.Contains(outputStr, "vpnc") || strings.Contains(outputStr, "unknown connection type") {
|
Success: false,
|
||||||
for _, vpnType := range []string{"vpnc", "pptp", "l2tp", "openconnect", "strongswan", "wireguard"} {
|
Error: fmt.Sprintf("import failed: %s", strings.TrimSpace(string(output))),
|
||||||
args = []string{"connection", "import", "type", vpnType, "file", filePath}
|
}, nil
|
||||||
cmd = exec.Command("nmcli", args...)
|
|
||||||
output, err = cmd.CombinedOutput()
|
|
||||||
if err == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return &VPNImportResult{
|
|
||||||
Success: false,
|
|
||||||
Error: fmt.Sprintf("import failed: %s", strings.TrimSpace(string(output))),
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outputStr := string(output)
|
outputStr := string(output)
|
||||||
|
|||||||
Reference in New Issue
Block a user