import Foundation import UltraMeshCore struct DaemonConfig: Codable { var aliases: [String: MeshAddress] = [:] var firewall: Set = [] var lsaSequence: UInt64? static func load(from url: URL) -> DaemonConfig { guard let data = try? Data(contentsOf: url), let value = try? JSONDecoder().decode(Self.self, from: data) else { return .init() } return value } func save(to url: URL) throws { let encoder = JSONEncoder(); encoder.outputFormatting = [.prettyPrinted, .sortedKeys] try encoder.encode(self).write(to: url, options: .atomic) try FileManager.default.setAttributes([.posixPermissions: 0o600], ofItemAtPath: url.path) } }