diff --git a/Passepartout/Sources/Services/InfrastructureFactory.swift b/Passepartout/Sources/Services/InfrastructureFactory.swift index 54aee817..197ba146 100644 --- a/Passepartout/Sources/Services/InfrastructureFactory.swift +++ b/Passepartout/Sources/Services/InfrastructureFactory.swift @@ -106,7 +106,12 @@ public class InfrastructureFactory { guard let data = try? Data(contentsOf: entry) else { continue } - guard let infra = try? decoder.decode(Infrastructure.self, from: data) else { + let infra: Infrastructure + do { + infra = try decoder.decode(Infrastructure.self, from: data) + } catch let e { + log.warning("Unable to load infrastructure \(entry.lastPathComponent): \(e)") + log.warning("\(String(data: data, encoding: .utf8)!)") continue } diff --git a/Passepartout/Sources/Services/InfrastructurePreset.swift b/Passepartout/Sources/Services/InfrastructurePreset.swift index 14529b66..d502ac7f 100644 --- a/Passepartout/Sources/Services/InfrastructurePreset.swift +++ b/Passepartout/Sources/Services/InfrastructurePreset.swift @@ -205,7 +205,13 @@ public struct InfrastructurePreset: Codable { try container.encode(id, forKey: .id) try container.encode(name, forKey: .name) try container.encode(comment, forKey: .comment) - try container.encodeIfPresent(external, forKey: .external) + if let external = external { + var rawExternal: [String: String] = [:] + for entry in external { + rawExternal[entry.key.rawValue] = entry.value + } + try container.encodeIfPresent(rawExternal, forKey: .external) + } var cfgContainer = container.nestedContainer(keyedBy: ConfigurationKeys.self, forKey: .configuration) try cfgContainer.encode(configuration.sessionConfiguration.cipher, forKey: .cipher)