mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-06 09:47:22 +01:00
.
This commit is contained in:
@@ -6,19 +6,39 @@ private let logger = Logger(subsystem: "com.maxgoedjen.secretive.secretagent.Age
|
||||
|
||||
func handleRequest(_ request: XPCListener.IncomingSessionRequest) -> XPCListener.IncomingSessionRequest.Decision {
|
||||
logger.log("Parser received inbound request")
|
||||
return request.accept { message in
|
||||
logger.log("Parser accepted inbound request")
|
||||
do {
|
||||
let result = try SSHAgentInputParser().parse(data: message)
|
||||
logger.log("Parser parsed message as type \(result.debugDescription)")
|
||||
return result
|
||||
} catch {
|
||||
logger.error("Parser failed with error \(error)")
|
||||
return nil
|
||||
return request.accept { xpcDictionary in
|
||||
xpcDictionary.handoffReply(to: .global(qos: .userInteractive)) {
|
||||
logger.log("Parser accepted inbound request")
|
||||
do {
|
||||
let parser = SSHAgentInputParser()
|
||||
let result = try parser.parse(data: xpcDictionary.decode(as: Data.self))
|
||||
logger.log("Parser parsed message as type \(result.debugDescription)")
|
||||
xpcDictionary.reply(result)
|
||||
} catch let error as SSHAgentInputParser.AgentParsingError {
|
||||
logger.error("Parser failed with error \(error)")
|
||||
xpcDictionary.reply(error)
|
||||
} catch {
|
||||
// This should never actually happen because SSHAgentInputParser is a typed thrower, but the type system doesn't seem to know that across framework boundaries?
|
||||
logger.error("Parser failed with unknown error \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct WrappedError<Wrapped: Codable & Error>: Codable {
|
||||
|
||||
public struct DescriptionOnlyError: Error, Codable {
|
||||
let localizedDescription: String
|
||||
}
|
||||
|
||||
public let wrapped: Wrapped
|
||||
|
||||
public init(_ error: Wrapped) {
|
||||
wrapped = error
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
do {
|
||||
if #available(macOS 26.0, *) {
|
||||
_ = try XPCListener(
|
||||
|
||||
Reference in New Issue
Block a user