Add iPad support, auto-pinning, and comprehensive logging
- Adaptive iPhone/iPad layout with NavigationSplitView sidebar - Auto-detect SSL-pinned domains, fall back to passthrough - Certificate install via local HTTP server (Safari profile flow) - App Group-backed CA, per-domain leaf cert LRU cache - DB-backed config repository, Darwin notification throttling - Rules engine, breakpoint rules, pinned domain tracking - os.Logger instrumentation across tunnel/proxy/mitm/capture/cert/rules/db/ipc/ui - Fix dyld framework embed, race conditions, thread safety
This commit is contained in:
32
ProxyCore/Sources/Shared/NotificationThrottle.swift
Normal file
32
ProxyCore/Sources/Shared/NotificationThrottle.swift
Normal file
@@ -0,0 +1,32 @@
|
||||
import Foundation
|
||||
|
||||
/// Throttles Darwin notification posting to at most once per 0.5 seconds.
|
||||
/// Prevents flooding the main app with hundreds of "new traffic" notifications.
|
||||
public final class NotificationThrottle: @unchecked Sendable {
|
||||
public static let shared = NotificationThrottle()
|
||||
|
||||
private let lock = NSLock()
|
||||
private var pending = false
|
||||
private let interval: TimeInterval = 0.5
|
||||
|
||||
private init() {}
|
||||
|
||||
public func throttle() {
|
||||
lock.lock()
|
||||
if pending {
|
||||
lock.unlock()
|
||||
ProxyLogger.ipc.debug("NotificationThrottle: suppressed newTraffic while pending")
|
||||
return
|
||||
}
|
||||
pending = true
|
||||
lock.unlock()
|
||||
|
||||
DispatchQueue.global().asyncAfter(deadline: .now() + interval) { [weak self] in
|
||||
self?.lock.lock()
|
||||
self?.pending = false
|
||||
self?.lock.unlock()
|
||||
ProxyLogger.ipc.debug("NotificationThrottle: emitting throttled newTraffic")
|
||||
IPCManager.shared.post(.newTrafficCaptured)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user