diff --git a/AltDaemon/XPCConnectionHandler.swift b/AltDaemon/XPCConnectionHandler.swift
index b6a4b2ef..d6ee4202 100644
--- a/AltDaemon/XPCConnectionHandler.swift
+++ b/AltDaemon/XPCConnectionHandler.swift
@@ -15,7 +15,7 @@ class XPCConnectionHandler: NSObject, ConnectionHandler
var disconnectionHandler: ((Connection) -> Void)?
private let dispatchQueue = DispatchQueue(label: "io.altstore.XPCConnectionListener", qos: .utility)
- private let listener = NSXPCListener.makeListener(machServiceName: XPCConnection.machServiceName)
+ private let listeners = XPCConnection.machServiceNames.map { NSXPCListener.makeListener(machServiceName: $0) }
deinit
{
@@ -24,13 +24,16 @@ class XPCConnectionHandler: NSObject, ConnectionHandler
func startListening()
{
- self.listener.delegate = self
- self.listener.resume()
+ for listener in self.listeners
+ {
+ listener.delegate = self
+ listener.resume()
+ }
}
func stopListening()
{
- self.listener.suspend()
+ self.listeners.forEach { $0.suspend() }
}
}
diff --git a/AltDaemon/package/Library/LaunchDaemons/com.rileytestut.altdaemon.plist b/AltDaemon/package/Library/LaunchDaemons/com.rileytestut.altdaemon.plist
index 5b954186..7808ca12 100644
--- a/AltDaemon/package/Library/LaunchDaemons/com.rileytestut.altdaemon.plist
+++ b/AltDaemon/package/Library/LaunchDaemons/com.rileytestut.altdaemon.plist
@@ -21,6 +21,8 @@
cy:io.altstore.altdaemon
+ lh:io.altstore.altdaemon
+
diff --git a/AltStore/Operations/FindServerOperation.swift b/AltStore/Operations/FindServerOperation.swift
index 12654eeb..35d8727d 100644
--- a/AltStore/Operations/FindServerOperation.swift
+++ b/AltStore/Operations/FindServerOperation.swift
@@ -25,7 +25,7 @@ class FindServerOperation: ResultOperation
let context: OperationContext
private var isWiredServerConnectionAvailable = false
- private var isLocalServerConnectionAvailable = false
+ private var localServerMachServiceName: String?
init(context: OperationContext = OperationContext())
{
@@ -61,10 +61,10 @@ class FindServerOperation: ResultOperation
// Wait for either callback or timeout.
DispatchQueue.global().asyncAfter(deadline: .now() + 1.0) {
- if self.isLocalServerConnectionAvailable
+ if let machServiceName = self.localServerMachServiceName
{
// Prefer background daemon, if it exists and is running.
- let server = Server(connectionType: .local)
+ let server = Server(connectionType: .local, machServiceName: machServiceName)
self.finish(.success(server))
}
else if self.isWiredServerConnectionAvailable
@@ -105,12 +105,17 @@ fileprivate extension FindServerOperation
{
func discoverLocalServer()
{
- let connection = XPCConnection()
- connection.connect { (result) in
- switch result
- {
- case .failure(let error): print("Could not connect to AltDaemon XPC service.", error)
- case .success: self.isLocalServerConnectionAvailable = true
+ for machServiceName in XPCConnection.machServiceNames
+ {
+ let xpcConnection = NSXPCConnection.makeConnection(machServiceName: machServiceName)
+
+ let connection = XPCConnection(xpcConnection)
+ connection.connect { (result) in
+ switch result
+ {
+ case .failure(let error): print("Could not connect to AltDaemon XPC service \(machServiceName).", error)
+ case .success: self.localServerMachServiceName = machServiceName
+ }
}
}
}
diff --git a/AltStore/Server/Server.swift b/AltStore/Server/Server.swift
index 71da7c5f..4314c1df 100644
--- a/AltStore/Server/Server.swift
+++ b/AltStore/Server/Server.swift
@@ -41,6 +41,8 @@ struct Server: Equatable
var isPreferred = false
var connectionType: ConnectionType = .wireless
+
+ var machServiceName: String?
}
extension Server
diff --git a/AltStore/Server/ServerManager.swift b/AltStore/Server/ServerManager.swift
index 91b76991..abc88c43 100644
--- a/AltStore/Server/ServerManager.swift
+++ b/AltStore/Server/ServerManager.swift
@@ -76,7 +76,7 @@ extension ServerManager
switch server.connectionType
{
- case .local: self.connectToLocalServer(completion: finish(_:))
+ case .local: self.connectToLocalServer(server, completion: finish(_:))
case .wired:
guard let incomingConnectionsSemaphore = self.incomingConnectionsSemaphore else { return finish(.failure(ALTServerError(.connectionFailed))) }
@@ -190,14 +190,18 @@ private extension ServerManager
connection.start(queue: self.dispatchQueue)
}
- func connectToLocalServer(completion: @escaping (Result) -> Void)
+ func connectToLocalServer(_ server: Server, completion: @escaping (Result) -> Void)
{
- let connection = XPCConnection()
+ guard let machServiceName = server.machServiceName else { return completion(.failure(ConnectionError.connectionFailed)) }
+
+ let xpcConnection = NSXPCConnection.makeConnection(machServiceName: machServiceName)
+
+ let connection = XPCConnection(xpcConnection)
connection.connect { (result) in
switch result
{
case .failure(let error):
- print("Could not connect to AltDaemon XPC service.", error)
+ print("Could not connect to AltDaemon XPC service \(machServiceName).", error)
completion(.failure(error))
case .success: completion(.success(connection))
diff --git a/Shared/Connections/XPCConnection.swift b/Shared/Connections/XPCConnection.swift
index eb044f16..978cccb9 100644
--- a/Shared/Connections/XPCConnection.swift
+++ b/Shared/Connections/XPCConnection.swift
@@ -16,7 +16,10 @@ import Foundation
extension XPCConnection
{
- public static let machServiceName = "cy:io.altstore.altdaemon"
+ public static let unc0verMachServiceName = "cy:io.altstore.altdaemon"
+ public static let odysseyMachServiceName = "lh:io.altstore.altdaemon"
+
+ public static let machServiceNames = [unc0verMachServiceName, odysseyMachServiceName]
}
public class XPCConnection: NSObject, Connection
@@ -30,7 +33,7 @@ public class XPCConnection: NSObject, Connection
private var error: Error?
- public init(_ xpcConnection: NSXPCConnection = .makeConnection(machServiceName: XPCConnection.machServiceName))
+ public init(_ xpcConnection: NSXPCConnection)
{
let proxyInterface = NSXPCInterface(with: XPCConnectionProxy.self)
xpcConnection.remoteObjectInterface = proxyInterface