3
0
Fork 0

Store the raw dn managed config to be consumed by nebula later (#127)

This commit is contained in:
Nate Brown 2023-05-16 10:25:24 -05:00 committed by GitHub
parent 450e7c714c
commit 69d0641874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -135,6 +135,7 @@ class Site: Codable {
var managed: Bool var managed: Bool
// The following fields are present if managed = true // The following fields are present if managed = true
var lastManagedUpdate: String? 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 /// 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 var needsToMigrateToFS: Bool = false
@ -255,6 +256,7 @@ class Site: Codable {
mtu = incoming.mtu ?? 1300 mtu = incoming.mtu ?? 1300
managed = incoming.managed ?? false managed = incoming.managed ?? false
lastManagedUpdate = incoming.lastManagedUpdate lastManagedUpdate = incoming.lastManagedUpdate
rawConfig = incoming.rawConfig
if (managed && (try? getDNCredentials())?.invalid != false) { if (managed && (try? getDNCredentials())?.invalid != false) {
errors.append("Unable to fetch managed updates - please re-enroll the device") errors.append("Unable to fetch managed updates - please re-enroll the device")
@ -344,6 +346,7 @@ class Site: Codable {
case mtu case mtu
case managed case managed
case lastManagedUpdate case lastManagedUpdate
case rawConfig
} }
} }
@ -405,6 +408,7 @@ struct IncomingSite: Codable {
// The following fields are present if managed = true // The following fields are present if managed = true
var dnCredentials: DNCredentials? var dnCredentials: DNCredentials?
var lastManagedUpdate: String? var lastManagedUpdate: String?
var rawConfig: String?
func getConfig() throws -> Data { func getConfig() throws -> Data {
let encoder = JSONEncoder() let encoder = JSONEncoder()

View File

@ -125,7 +125,14 @@ class SiteUpdater: NSObject, FlutterStreamHandler {
/// onListen is called when flutter code attaches an event listener /// onListen is called when flutter code attaches an event listener
func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
eventSink = events; eventSink = events;
#if !targetEnvironment(simulator) #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 self.notification = NotificationCenter.default.addObserver(forName: NSNotification.Name.NEVPNStatusDidChange, object: site.manager!.connection , queue: nil) { n in
let connected = self.site.connected let connected = self.site.connected
self.site.status = statusString[self.site.manager!.connection.status] self.site.status = statusString[self.site.manager!.connection.status]