diff --git a/ios/NebulaNetworkExtension/Site.swift b/ios/NebulaNetworkExtension/Site.swift index 9a965ba..7a8ba20 100644 --- a/ios/NebulaNetworkExtension/Site.swift +++ b/ios/NebulaNetworkExtension/Site.swift @@ -135,6 +135,7 @@ class Site: Codable { var managed: Bool // The following fields are present if managed = true var lastManagedUpdate: String? + var rawConfig: String? /// If true then this site needs to be migrated to the filesystem. Should be handled by the initiator of the site var needsToMigrateToFS: Bool = false @@ -255,6 +256,7 @@ class Site: Codable { mtu = incoming.mtu ?? 1300 managed = incoming.managed ?? false lastManagedUpdate = incoming.lastManagedUpdate + rawConfig = incoming.rawConfig if (managed && (try? getDNCredentials())?.invalid != false) { errors.append("Unable to fetch managed updates - please re-enroll the device") @@ -344,6 +346,7 @@ class Site: Codable { case mtu case managed case lastManagedUpdate + case rawConfig } } @@ -405,6 +408,7 @@ struct IncomingSite: Codable { // The following fields are present if managed = true var dnCredentials: DNCredentials? var lastManagedUpdate: String? + var rawConfig: String? func getConfig() throws -> Data { let encoder = JSONEncoder() diff --git a/ios/Runner/Sites.swift b/ios/Runner/Sites.swift index d0e14c3..ebf2b6e 100644 --- a/ios/Runner/Sites.swift +++ b/ios/Runner/Sites.swift @@ -125,7 +125,14 @@ class SiteUpdater: NSObject, FlutterStreamHandler { /// onListen is called when flutter code attaches an event listener func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { eventSink = events; + #if !targetEnvironment(simulator) + if site.manager == nil { + //TODO: The dn updater path seems to race to build a site that lacks a manager. The UI does not display this error + // and a another listen should occur and succeed. + return FlutterError(code: "Internal Error", message: "Flutter manager was not present", details: nil) + } + self.notification = NotificationCenter.default.addObserver(forName: NSNotification.Name.NEVPNStatusDidChange, object: site.manager!.connection , queue: nil) { n in let connected = self.site.connected self.site.status = statusString[self.site.manager!.connection.status]