File tree Expand file tree Collapse file tree 5 files changed +28
-6
lines changed Expand file tree Collapse file tree 5 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -22,9 +22,9 @@ final class AttributesProvider {
2222 return attributesSources. map ( \. immutable) . merging ( )
2323 } ( )
2424
25- init ( ) {
25+ init ( reportHostName : Bool = false ) {
2626 faultInfo = FaultInfo ( )
27- attributesSources = [ ProcessorInfo ( ) ,
27+ attributesSources = [ ProcessorInfo ( reportHostName : reportHostName ) ,
2828 Device ( ) ,
2929 ScreenInfo ( ) ,
3030 LocaleInfo ( ) ,
Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ final class FaultInfo: AttributesSource {
1111
1212struct ProcessorInfo : AttributesSource {
1313
14+ private let reportHostName : Bool
15+
16+ init ( reportHostName: Bool = false ) {
17+ self . reportHostName = reportHostName
18+ }
19+
1420 var mutable : [ String : Any ? ] {
1521 let processor = try ? Processor ( )
1622 let processInfo = ProcessInfo . processInfo
@@ -55,8 +61,8 @@ struct ProcessorInfo: AttributesSource {
5561 var immutable : [ String : Any ? ] {
5662 return [
5763 " cpu.boottime " : try ? System . boottime ( ) ,
58- // hostanme
59- " hostname " : ProcessInfo . processInfo. hostName,
64+ // hostname
65+ " hostname " : self . reportHostName ? ProcessInfo . processInfo. hostName : " " ,
6066 // descriptor
6167 " descriptor.count " : getdtablesize ( ) ,
6268 " process.starttime " : try ? ProcessInfo . startTime ( )
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ final class BacktraceReporter {
2828 credentials: credentials,
2929 repository: try PersistentRepository < BacktraceReport > ( settings: dbSettings) )
3030 self . repository = try PersistentRepository < BacktraceReport > ( settings: dbSettings)
31- let attributesProvider = AttributesProvider ( )
31+ let attributesProvider = AttributesProvider ( reportHostName : dbSettings . reportHostName )
3232 self . attributesProvider = attributesProvider
3333 self . backtraceOomWatcher = BacktraceOomWatcher (
3434 repository: self . repository,
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ import Foundation
2020
2121 /// Retry order. Default `RetryOder.queue`.
2222 @objc public var retryOrder : RetryOrder = . queue
23+
24+ /// Enable the hostname to be reported. This will cause the end-user to get the Local Network permissions pop-up.
25+ @objc public var reportHostName : Bool = false
2326
2427 internal var maxDatabaseSizeInBytes : Int {
2528 return maxDatabaseSize * 1024 * 1024
Original file line number Diff line number Diff line change @@ -44,7 +44,20 @@ final class AttributesTests: QuickSpec {
4444 expect { attributes. immutable } . toNot ( beNil ( ) )
4545 }
4646 }
47-
47+
48+ describe ( " Processor Info " ) {
49+ it ( " can disable hostname " ) {
50+ let attributes = ProcessorInfo ( )
51+ let hostname = attributes. immutable [ " hostname " ] as? String
52+ expect { hostname } . to ( beEmpty ( ) )
53+ }
54+ it ( " can enable hostname " ) {
55+ let attributes = ProcessorInfo ( reportHostName: true )
56+ let hostname = attributes. immutable [ " hostname " ] as? String
57+ expect { hostname } . toNot ( beEmpty ( ) )
58+ }
59+ }
60+
4861 describe ( " C API " ) {
4962 it ( " sets vm_statistics64 information " ) {
5063 expect { try Statistics . vmStatistics64 ( ) } . toNot ( be ( vm_statistics64 ( ) ) )
You can’t perform that action at this time.
0 commit comments