@@ -109,21 +109,23 @@ private class DebugBundleBuilder {
109109 let bundleTimestamp = Date ( )
110110 let jsonEncoder = JSONEncoder ( )
111111 let logStartTimestamp : Date
112+ let appState : AppState ?
112113
113114 let dispatchQueue = DispatchQueue . global ( qos: . userInitiated)
114115 var lock = NSLock ( )
115116 var pendingTasks = PendingTasks ( )
116117 var tasks : [ String : TaskResult ] = [ : ]
117118
118- init ( ) throws {
119+ init ( appState: AppState ? ) throws {
120+ self . appState = appState
119121 self . tmpFolder = try FileManager . default. url (
120122 for: FileManager . SearchPathDirectory. itemReplacementDirectory,
121123 in: FileManager . SearchPathDomainMask. userDomainMask,
122124 appropriateFor: FileManager . default. temporaryDirectory,
123125 create: true
124126 )
125127 self . archiveFolder = self . tmpFolder. appending (
126- component: " Obscura Debuging Archive \( utcDateFormat. string ( from: self . bundleTimestamp) ) "
128+ component: " Obscura Debugging Archive \( utcDateFormat. string ( from: self . bundleTimestamp) ) "
127129 )
128130 try FileManager . default. createDirectory (
129131 at: self . archiveFolder,
@@ -371,6 +373,24 @@ private class DebugBundleBuilder {
371373 }
372374 }
373375
376+ func bundleNEDebugInfo( ) async {
377+ guard let manager = self . appState? . manager else {
378+ self . writeError ( name: " ne-debug-info " , error: " appState or manager is nil " )
379+ return
380+ }
381+ do {
382+ let neDebugInfoJsonString = try await runNeJsonCommand ( manager, NeManagerCmd . getDebugInfo. json ( ) , attemptTimeout: . seconds( 10 ) )
383+ let value = try JSONSerialization . jsonObject ( with: Data ( neDebugInfoJsonString. utf8) )
384+ let json = try JSONSerialization . data (
385+ withJSONObject: value,
386+ options: [ . fragmentsAllowed, . prettyPrinted, . sortedKeys]
387+ )
388+ try self . writeFile ( name: " ne-debug-info.json " , data: json)
389+ } catch {
390+ self . writeError ( name: " ne-debug-info " , error: error)
391+ }
392+ }
393+
374394 func bundleTask( _ name: String , _ block: @escaping ( BundleTask ) async throws -> Void ) {
375395 BundleTask ( self , name, block)
376396 }
@@ -395,6 +415,7 @@ private class DebugBundleBuilder {
395415 }
396416
397417 self . bundleTask ( " extensions " ) { _task in try await self . bundleExtensions ( ) }
418+ self . bundleTask ( " ne-debug-info " ) { _task in await self . bundleNEDebugInfo ( ) }
398419 self . bundleTask ( " info " ) { _task in try self . bundleInfo ( ) }
399420
400421 self . bundleCmd ( " arp " , [ " /usr/sbin/arp " , " -na " ] )
@@ -556,7 +577,7 @@ public class DebugBundleRC {
556577 }
557578}
558579
559- func _createDebuggingArchive( ) async throws -> String {
580+ func _createDebuggingArchive( appState : AppState ? ) async throws -> String {
560581 let _activity = ProcessInfo . processInfo. beginActivity (
561582 options: [
562583 . automaticTerminationDisabled,
@@ -569,7 +590,7 @@ func _createDebuggingArchive() async throws -> String {
569590
570591 var start = SuspendingClock . now
571592
572- let builder = try DebugBundleBuilder ( )
593+ let builder = try DebugBundleBuilder ( appState : appState )
573594 await builder. bundleAll ( )
574595 let zipPath = try builder. createArchive ( )
575596
@@ -587,7 +608,7 @@ func createDebuggingArchive(appState: AppState?) async throws -> String {
587608 _debugBundleRc = DebugBundleRC ( appState)
588609 }
589610 do {
590- let path = try await _createDebuggingArchive ( )
611+ let path = try await _createDebuggingArchive ( appState : appState )
591612 _ = appState? . osStatus. update { value in
592613 value. debugBundleStatus. setPath ( path)
593614 }
0 commit comments