aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-11-07 00:35:37 +0530
committerRoopesh Chander <roop@roopc.net>2018-11-07 00:35:37 +0530
commitf9dcfc1b9da363d3437c7d61792ecfcc7d394eba (patch)
tree4a4357146d6069d84477045062d7eb076ebedc92 /WireGuard/WireGuard
parentDNSResolver: No need to resolve if the endpoint is already an IP address (diff)
downloadwireguard-apple-f9dcfc1b9da363d3437c7d61792ecfcc7d394eba.tar.xz
wireguard-apple-f9dcfc1b9da363d3437c7d61792ecfcc7d394eba.zip
Importing: Assume imported files without .conf or .zip extensions to be a config file
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard')
-rw-r--r--WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift10
1 files changed, 5 insertions, 5 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift
index b6c25ae..b822f2b 100644
--- a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift
@@ -175,9 +175,9 @@ class TunnelsListTableViewController: UIViewController {
self.present(alert, animated: true, completion: nil)
}
- func importFromFile(url: URL) {
+ func importFromFile(url: URL, shouldConsiderAsConfigEvenWithoutExtensionMatch: Bool = false) {
// Import configurations from a .conf or a .zip file
- if (url.pathExtension == "conf") {
+ if (url.pathExtension == "conf" || shouldConsiderAsConfigEvenWithoutExtensionMatch) {
let fileBaseName = url.deletingPathExtension().lastPathComponent.trimmingCharacters(in: .whitespacesAndNewlines)
if let fileContents = try? String(contentsOf: url),
let tunnelConfiguration = try? WgQuickConfigFileParser.parse(fileContents, name: fileBaseName) {
@@ -254,9 +254,9 @@ extension TunnelsListTableViewController: UIDocumentPickerDelegate {
if (url.pathExtension == "conf" || url.pathExtension == "zip") {
importFromFile(url: url)
} else {
- // What if a file provider extension didn't respect our 'documentTypes' parameter
- self.showErrorAlert(title: "Invalid file extension",
- message: "Please select a WireGuard configuration file (.conf) or a zip archive (.zip) for importing")
+ // In case a file provider extension didn't respect our 'documentTypes' parameter,
+ // we'll still assume it's a config file.
+ importFromFile(url: url, shouldConsiderAsConfigEvenWithoutExtensionMatch: true)
}
}
}