diff options
Diffstat (limited to 'WireGuard/WireGuard/ZipArchive')
-rw-r--r-- | WireGuard/WireGuard/ZipArchive/ZipExporter.swift | 4 | ||||
-rw-r--r-- | WireGuard/WireGuard/ZipArchive/ZipImporter.swift | 8 |
2 files changed, 4 insertions, 8 deletions
diff --git a/WireGuard/WireGuard/ZipArchive/ZipExporter.swift b/WireGuard/WireGuard/ZipArchive/ZipExporter.swift index 33d62fd..052242a 100644 --- a/WireGuard/WireGuard/ZipArchive/ZipExporter.swift +++ b/WireGuard/WireGuard/ZipArchive/ZipExporter.swift @@ -22,8 +22,8 @@ class ZipExporter { var inputsToArchiver: [(fileName: String, contents: Data)] = [] var lastTunnelName: String = "" for tunnelConfiguration in tunnelConfigurations { - if let contents = WgQuickConfigFileWriter.writeConfigFile(from: tunnelConfiguration) { - let name = tunnelConfiguration.interface.name + if let contents = tunnelConfiguration.asWgQuickConfig().data(using: .utf8) { + let name = tunnelConfiguration.interface.name ?? "" if name.isEmpty || name == lastTunnelName { continue } inputsToArchiver.append((fileName: "\(name).conf", contents: contents)) lastTunnelName = name diff --git a/WireGuard/WireGuard/ZipArchive/ZipImporter.swift b/WireGuard/WireGuard/ZipArchive/ZipImporter.swift index 0178ca0..a8819e2 100644 --- a/WireGuard/WireGuard/ZipArchive/ZipImporter.swift +++ b/WireGuard/WireGuard/ZipArchive/ZipImporter.swift @@ -43,12 +43,8 @@ class ZipImporter { if index > 0 && file == unarchivedFiles[index - 1] { continue } - guard let fileContents = String(data: file.contents, encoding: .utf8) else { - continue - } - guard let tunnelConfig = try? WgQuickConfigFileParser.parse(fileContents, name: file.fileBaseName) else { - continue - } + guard let fileContents = String(data: file.contents, encoding: .utf8) else { continue } + guard let tunnelConfig = try? TunnelConfiguration(fileContents, name: file.fileBaseName) else { continue } configs[index] = tunnelConfig } DispatchQueue.main.async { completion(.success(configs)) } |