mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-10 15:23:27 +01:00
Supports installing/refreshings apps w/o computer on jailbroken devices
AltStore will use AltDaemon as a local AltServer if it’s installed and running. AltStore remains a regular sandboxed app, but AltDaemon has private entitlements necessary to perform AltServer operations without a computer.
This commit is contained in:
@@ -10,22 +10,6 @@ import Network
|
||||
|
||||
import AltKit
|
||||
|
||||
extension ALTServerError
|
||||
{
|
||||
init<E: Error>(_ error: E)
|
||||
{
|
||||
switch error
|
||||
{
|
||||
case let error as ALTServerError: self = error
|
||||
case is DecodingError: self = ALTServerError(.invalidResponse)
|
||||
case is EncodingError: self = ALTServerError(.invalidRequest)
|
||||
default:
|
||||
assertionFailure("Caught unknown error type")
|
||||
self = ALTServerError(.unknown)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum ConnectionError: LocalizedError
|
||||
{
|
||||
case serverNotFound
|
||||
@@ -42,13 +26,23 @@ enum ConnectionError: LocalizedError
|
||||
}
|
||||
}
|
||||
|
||||
extension Server
|
||||
{
|
||||
enum ConnectionType
|
||||
{
|
||||
case wireless
|
||||
case wired
|
||||
case local
|
||||
}
|
||||
}
|
||||
|
||||
struct Server: Equatable
|
||||
{
|
||||
var identifier: String? = nil
|
||||
var service: NetService? = nil
|
||||
|
||||
var isPreferred = false
|
||||
var isWiredConnection = false
|
||||
var connectionType: ConnectionType = .wireless
|
||||
}
|
||||
|
||||
extension Server
|
||||
|
||||
@@ -94,12 +94,18 @@ extension ServerManager
|
||||
connection.start(queue: self.dispatchQueue)
|
||||
}
|
||||
|
||||
if let incomingConnectionsSemaphore = self.incomingConnectionsSemaphore, server.isWiredConnection
|
||||
if let incomingConnectionsSemaphore = self.incomingConnectionsSemaphore, server.connectionType != .wireless
|
||||
{
|
||||
print("Waiting for new wired connection...")
|
||||
print("Waiting for incoming connection...")
|
||||
|
||||
let notificationCenter = CFNotificationCenterGetDarwinNotifyCenter()
|
||||
CFNotificationCenterPostNotification(notificationCenter, .wiredServerConnectionStartRequest, nil, nil, true)
|
||||
|
||||
switch server.connectionType
|
||||
{
|
||||
case .wired: CFNotificationCenterPostNotification(notificationCenter, .wiredServerConnectionStartRequest, nil, nil, true)
|
||||
case .local: CFNotificationCenterPostNotification(notificationCenter, .localServerConnectionStartRequest, nil, nil, true)
|
||||
case .wireless: break
|
||||
}
|
||||
|
||||
_ = incomingConnectionsSemaphore.wait(timeout: .now() + 10.0)
|
||||
|
||||
@@ -114,7 +120,17 @@ extension ServerManager
|
||||
}
|
||||
else if let service = server.service
|
||||
{
|
||||
let connection = NWConnection(to: .service(name: service.name, type: service.type, domain: service.domain, interface: nil), using: .tcp)
|
||||
print("Connecting to service:", service)
|
||||
|
||||
let parameters = NWParameters.tcp
|
||||
|
||||
if server.connectionType == .local
|
||||
{
|
||||
// Prevent AltStore from initiating connections over multiple interfaces simultaneously 🤷♂️
|
||||
parameters.requiredInterfaceType = .loopback
|
||||
}
|
||||
|
||||
let connection = NWConnection(to: .service(name: service.name, type: service.type, domain: service.domain, interface: nil), using: parameters)
|
||||
start(connection)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user