From 3f97199f681ca7c9d68acd3d1c650cd8d794a4a7 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Mon, 29 Oct 2018 01:58:21 +0530 Subject: [PATCH] Import config: Directly add config, don't open up the editor Signed-off-by: Roopesh Chander --- .../UI/iOS/TunnelsListTableViewController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift index b760176..ee5e3ac 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift @@ -141,7 +141,15 @@ extension TunnelsListTableViewController: UIDocumentPickerDelegate { func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { if let url = urls.first { if (url.pathExtension == "conf") { - openForEditing(configFileURL: url) + let fileBaseName = url.deletingPathExtension().lastPathComponent + if let fileContents = try? String(contentsOf: url), + let tunnelConfiguration = try? WgQuickConfigFileParser.parse(fileContents, name: fileBaseName) { + tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (tunnel, error) in + if (error != nil) { + print("Error adding configuration: \(tunnelConfiguration.interface.name)") + } + } + } } else if (url.pathExtension == "zip") { var unarchivedFiles: [(fileName: String, contents: Data)] = [] do {