mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-28 07:57:38 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a505d04215 | ||
|
|
95953ca0e9 | ||
|
|
3b9b45a06f | ||
|
|
ac277aa6eb | ||
|
|
7926452661 | ||
|
|
dfb01c2ae5 |
@@ -48,6 +48,90 @@
|
||||
remoteGlobalIDString = BF58047A246A28F7008AE704;
|
||||
remoteInfo = AltBackup;
|
||||
};
|
||||
A802C9F82F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C5DA2F525B910049FE2B /* libfragmentzip.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 87B8C3401E0E9C37002F817D;
|
||||
remoteInfo = "fragmentzip-cli-macOS";
|
||||
};
|
||||
A802C9FA2F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C5DA2F525B910049FE2B /* libfragmentzip.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = B315FDB02866CCF8002E243C;
|
||||
remoteInfo = "fragmentzip-cli-iOS";
|
||||
};
|
||||
A802C9FC2F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C5DA2F525B910049FE2B /* libfragmentzip.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = B315FDB52866CD91002E243C;
|
||||
remoteInfo = "fragmentzip-macOS";
|
||||
};
|
||||
A802C9FE2F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C5DA2F525B910049FE2B /* libfragmentzip.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = B315FDCE2866CDD3002E243C;
|
||||
remoteInfo = "fragmentzip-iOS";
|
||||
};
|
||||
A802CA012F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C5B62F525B910049FE2B /* libgeneral.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 87977F6F227C4B71004F31DA;
|
||||
remoteInfo = libgeneral;
|
||||
};
|
||||
A802CA062F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C95A2F525B910049FE2B /* Roxas.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = BFADAFF819AE7BB70050CF31;
|
||||
remoteInfo = Roxas;
|
||||
};
|
||||
A802CA082F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C95A2F525B910049FE2B /* Roxas.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = BF8624801BB742E700C12EEE;
|
||||
remoteInfo = RoxasTV;
|
||||
};
|
||||
A802CA0A2F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C95A2F525B910049FE2B /* Roxas.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = BFADB00319AE7BB80050CF31;
|
||||
remoteInfo = RoxasTests;
|
||||
};
|
||||
A802CA0E2F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C8B62F525B910049FE2B /* SampleApp.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 44B1EE7C23DB90D5004E2E29;
|
||||
remoteInfo = SampleApp;
|
||||
};
|
||||
A802CA102F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C8B62F525B910049FE2B /* SampleApp.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 445A906A2400612800B487B4;
|
||||
remoteInfo = "NSAttributedString+MarkdownTests";
|
||||
};
|
||||
A802CA132F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C8CF2F525B910049FE2B /* SampleApp.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 44E8FA8923D90632009E1D13;
|
||||
remoteInfo = SampleApp;
|
||||
};
|
||||
A802CA162F525C030049FE2B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A802C8DB2F525B910049FE2B /* SwiftSampleApp.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 44962FDA23E7A54A00E2A598;
|
||||
remoteInfo = SwiftSampleApp;
|
||||
};
|
||||
A81173222F4B8DBD0013ABD0 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A811720B2F4B8BA80013ABD0 /* em_proxy.xcodeproj */;
|
||||
@@ -2355,6 +2439,12 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
191E5FAB290A5D92001A3B7C /* libminimuxer_swift.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libminimuxer_swift.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A802C5B62F525B910049FE2B /* libgeneral.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = libgeneral.xcodeproj; sourceTree = "<group>"; };
|
||||
A802C5DA2F525B910049FE2B /* libfragmentzip.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = libfragmentzip.xcodeproj; sourceTree = "<group>"; };
|
||||
A802C8B62F525B910049FE2B /* SampleApp.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = SampleApp.xcodeproj; sourceTree = "<group>"; };
|
||||
A802C8CF2F525B910049FE2B /* SampleApp.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = SampleApp.xcodeproj; sourceTree = "<group>"; };
|
||||
A802C8DB2F525B910049FE2B /* SwiftSampleApp.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = SwiftSampleApp.xcodeproj; sourceTree = "<group>"; };
|
||||
A802C95A2F525B910049FE2B /* Roxas.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = Roxas.xcodeproj; sourceTree = "<group>"; };
|
||||
A8116EAD2F4B8BA80013ABD0 /* libgeneral.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = libgeneral.xcodeproj; sourceTree = "<group>"; };
|
||||
A8116ED12F4B8BA80013ABD0 /* libfragmentzip.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = libfragmentzip.xcodeproj; sourceTree = "<group>"; };
|
||||
A81171432F4B8BA80013ABD0 /* SampleApp.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = SampleApp.xcodeproj; sourceTree = "<group>"; };
|
||||
@@ -2809,6 +2899,7 @@
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
EMProxyWrapper.swift,
|
||||
IfManager.swift,
|
||||
MinimuxerWrapper.swift,
|
||||
Utils/common/AbstractClassError.swift,
|
||||
Utils/common/BuildInfo.swift,
|
||||
@@ -2944,6 +3035,60 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
A802C5E12F525B910049FE2B /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A802C9F92F525C030049FE2B /* libfragmentzip */,
|
||||
A802C9FB2F525C030049FE2B /* libfragmentzip */,
|
||||
A802C9FD2F525C030049FE2B /* libfragmentzip.a */,
|
||||
A802C9FF2F525C030049FE2B /* libfragmentzip.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A802C5E32F525B910049FE2B /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A802CA022F525C030049FE2B /* libgeneral */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A802C8E32F525B910049FE2B /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A802CA142F525C030049FE2B /* SampleApp.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A802C8E52F525B910049FE2B /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A802CA0F2F525C030049FE2B /* SampleApp.app */,
|
||||
A802CA112F525C030049FE2B /* NSAttributedString+MarkdownTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A802C8E72F525B910049FE2B /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A802CA172F525C030049FE2B /* SwiftSampleApp.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A802C95B2F525B910049FE2B /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A802CA072F525C030049FE2B /* Roxas.framework */,
|
||||
A802CA092F525C030049FE2B /* Roxas.framework */,
|
||||
A802CA0B2F525C030049FE2B /* RoxasTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A811720E2F4B8BA80013ABD0 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -4988,6 +5133,10 @@
|
||||
ProductGroup = A8CCC2482F4B654400B0089A /* Products */;
|
||||
ProjectRef = A8CCBF072F4B654400B0089A /* libfragmentzip.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A802C5E12F525B910049FE2B /* Products */;
|
||||
ProjectRef = A802C5DA2F525B910049FE2B /* libfragmentzip.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A811973F2F4C1C710013ABD0 /* Products */;
|
||||
ProjectRef = A81194062F4C1C710013ABD0 /* libfragmentzip.xcodeproj */;
|
||||
@@ -5040,6 +5189,10 @@
|
||||
ProductGroup = A8A5B06C2F4C347700572B4A /* Products */;
|
||||
ProjectRef = A8A5B03E2F4C347700572B4A /* libgeneral.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A802C5E32F525B910049FE2B /* Products */;
|
||||
ProjectRef = A802C5B62F525B910049FE2B /* libgeneral.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A8CCD22A2F4B6B0000B0089A /* Products */;
|
||||
ProjectRef = A8CCCEBF2F4B6B0000B0089A /* libgeneral.xcodeproj */;
|
||||
@@ -5224,6 +5377,10 @@
|
||||
ProductGroup = A8FACF9D2F4B5CD40061A851 /* Products */;
|
||||
ProjectRef = A8FACF932F4B5CD40061A851 /* Roxas.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A802C95B2F525B910049FE2B /* Products */;
|
||||
ProjectRef = A802C95A2F525B910049FE2B /* Roxas.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A85A27CA2F4B370D002E2E11 /* Products */;
|
||||
ProjectRef = A85A27C02F4B370D002E2E11 /* Roxas.xcodeproj */;
|
||||
@@ -5388,6 +5545,10 @@
|
||||
ProductGroup = A8FAC0632F4B50D10061A851 /* Products */;
|
||||
ProjectRef = A8FABF722F4B50D10061A851 /* SampleApp.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A802C8E52F525B910049FE2B /* Products */;
|
||||
ProjectRef = A802C8B62F525B910049FE2B /* SampleApp.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A8F3FAED2F4E96D7006BC252 /* Products */;
|
||||
ProjectRef = A8F3FAD92F4E96D7006BC252 /* SampleApp.xcodeproj */;
|
||||
@@ -5436,6 +5597,10 @@
|
||||
ProductGroup = A8CCD2222F4B6B0000B0089A /* Products */;
|
||||
ProjectRef = A8CCD1552F4B6B0000B0089A /* SampleApp.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A802C8E32F525B910049FE2B /* Products */;
|
||||
ProjectRef = A802C8CF2F525B910049FE2B /* SampleApp.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A8CCC2502F4B654400B0089A /* Products */;
|
||||
ProjectRef = A8CCC1922F4B654400B0089A /* SampleApp.xcodeproj */;
|
||||
@@ -5536,6 +5701,10 @@
|
||||
ProductGroup = A8A5B6C02F4C4C8600572B4A /* Products */;
|
||||
ProjectRef = A8A5B6B42F4C4C8600572B4A /* SwiftSampleApp.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A802C8E72F525B910049FE2B /* Products */;
|
||||
ProjectRef = A802C8DB2F525B910049FE2B /* SwiftSampleApp.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A8A5ACE52F4C339400572B4A /* Products */;
|
||||
ProjectRef = A8A5ACDC2F4C339400572B4A /* SwiftSampleApp.xcodeproj */;
|
||||
@@ -5559,6 +5728,90 @@
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXReferenceProxy section */
|
||||
A802C9F92F525C030049FE2B /* libfragmentzip */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = "compiled.mach-o.executable";
|
||||
path = libfragmentzip;
|
||||
remoteRef = A802C9F82F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802C9FB2F525C030049FE2B /* libfragmentzip */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = "compiled.mach-o.executable";
|
||||
path = libfragmentzip;
|
||||
remoteRef = A802C9FA2F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802C9FD2F525C030049FE2B /* libfragmentzip.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libfragmentzip.a;
|
||||
remoteRef = A802C9FC2F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802C9FF2F525C030049FE2B /* libfragmentzip.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libfragmentzip.a;
|
||||
remoteRef = A802C9FE2F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802CA022F525C030049FE2B /* libgeneral */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = "compiled.mach-o.executable";
|
||||
path = libgeneral;
|
||||
remoteRef = A802CA012F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802CA072F525C030049FE2B /* Roxas.framework */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.framework;
|
||||
path = Roxas.framework;
|
||||
remoteRef = A802CA062F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802CA092F525C030049FE2B /* Roxas.framework */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.framework;
|
||||
path = Roxas.framework;
|
||||
remoteRef = A802CA082F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802CA0B2F525C030049FE2B /* RoxasTests.xctest */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.cfbundle;
|
||||
path = RoxasTests.xctest;
|
||||
remoteRef = A802CA0A2F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802CA0F2F525C030049FE2B /* SampleApp.app */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.application;
|
||||
path = SampleApp.app;
|
||||
remoteRef = A802CA0E2F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802CA112F525C030049FE2B /* NSAttributedString+MarkdownTests.xctest */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.cfbundle;
|
||||
path = "NSAttributedString+MarkdownTests.xctest";
|
||||
remoteRef = A802CA102F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802CA142F525C030049FE2B /* SampleApp.app */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.application;
|
||||
path = SampleApp.app;
|
||||
remoteRef = A802CA132F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A802CA172F525C030049FE2B /* SwiftSampleApp.app */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.application;
|
||||
path = SwiftSampleApp.app;
|
||||
remoteRef = A802CA162F525C030049FE2B /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A81173232F4B8DBD0013ABD0 /* libem_proxy_static.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
|
||||
2
Dependencies/minimuxer
vendored
2
Dependencies/minimuxer
vendored
Submodule Dependencies/minimuxer updated: 9035aa25ae...9ceaaf01ea
132
SideStore/IfManager.swift
Normal file
132
SideStore/IfManager.swift
Normal file
@@ -0,0 +1,132 @@
|
||||
//
|
||||
// IfManager.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by ny on 2/27/26.
|
||||
// Copyright © 2026 SideStore. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Network
|
||||
|
||||
fileprivate func uti(_ uint: UInt32) -> String? {
|
||||
var buf = [CChar](repeating: 0, count: Int(NI_MAXHOST))
|
||||
var addr = in_addr(s_addr: uint.bigEndian)
|
||||
guard inet_ntop(AF_INET, &addr, &buf, UInt32(INET_ADDRSTRLEN)) != nil,
|
||||
let str = String(utf8String: buf) else { return nil }
|
||||
return str
|
||||
}
|
||||
|
||||
fileprivate func socktouint(_ sock: inout sockaddr) -> UInt32 {
|
||||
var buf = [CChar](repeating: 0, count: Int(NI_MAXHOST))
|
||||
guard getnameinfo(&sock, socklen_t(sock.sa_len), &buf, socklen_t(buf.count), nil, socklen_t(0), NI_NUMERICHOST) == 0,
|
||||
let name = String(utf8String: buf) else {
|
||||
return 0
|
||||
}
|
||||
var addr = in_addr()
|
||||
guard name.withCString({ cString in
|
||||
inet_pton(AF_INET, cString, &addr)
|
||||
}) == 1 else { return 0 }
|
||||
return addr.s_addr.bigEndian
|
||||
}
|
||||
|
||||
public struct NetInfo: Hashable, CustomStringConvertible {
|
||||
public let name: String
|
||||
public let hostIP: String
|
||||
public let destIP: String
|
||||
public let maskIP: String
|
||||
|
||||
private let host: UInt32
|
||||
private let dest: UInt32
|
||||
private let mask: UInt32
|
||||
|
||||
init(name: String, host: UInt32, dest: UInt32, mask: UInt32) {
|
||||
self.name = name
|
||||
self.host = host
|
||||
self.dest = dest
|
||||
self.mask = mask
|
||||
self.hostIP = uti(host) ?? "10.7.0.0"
|
||||
self.destIP = uti(dest) ?? "10.7.0.1"
|
||||
self.maskIP = uti(mask) ?? "255.255.255.0"
|
||||
}
|
||||
|
||||
init?(_ ifaddr: ifaddrs) {
|
||||
guard
|
||||
let ianame = String(utf8String: ifaddr.ifa_name)
|
||||
else { return nil }
|
||||
|
||||
let host = socktouint(&ifaddr.ifa_addr.pointee)
|
||||
let dest = socktouint(&ifaddr.ifa_dstaddr.pointee)
|
||||
let mask = socktouint(&ifaddr.ifa_netmask.pointee)
|
||||
|
||||
self.init(name: ianame, host: host, dest: dest, mask: mask)
|
||||
}
|
||||
|
||||
// computed networking values (still numeric internally)
|
||||
public var minIP: UInt32 { host & mask }
|
||||
public var maxIP: UInt32 { host | ~mask }
|
||||
|
||||
public var minIPString: String { uti(minIP) ?? "nil" }
|
||||
public var maxIPString: String { uti(maxIP) ?? "nil" }
|
||||
|
||||
public var description: String {
|
||||
"\(name) | ip=\(hostIP) dest=\(destIP) mask=\(maskIP) range=\(minIPString)-\(maxIPString)"
|
||||
}
|
||||
}
|
||||
|
||||
final class IfManager: Sendable {
|
||||
public static let shared = IfManager()
|
||||
nonisolated(unsafe) private(set) var addrs: Set<NetInfo> = Set()
|
||||
|
||||
private init() {
|
||||
self.addrs = IfManager.query()
|
||||
}
|
||||
|
||||
|
||||
public func query() {
|
||||
addrs = IfManager.query()
|
||||
}
|
||||
|
||||
private static func query() -> Set<NetInfo> {
|
||||
var addrs = Set<NetInfo>()
|
||||
var head: UnsafeMutablePointer<ifaddrs>? = nil
|
||||
guard getifaddrs(&head) == 0, let first = head else { return addrs }
|
||||
defer { freeifaddrs(head) }
|
||||
|
||||
var cursor: UnsafeMutablePointer<ifaddrs>? = first
|
||||
while let current = cursor {
|
||||
// we only want v4 interfaces that aren't loopback and aren't masked 255.255.255.255
|
||||
let entry = current.pointee
|
||||
let flags = Int32(entry.ifa_flags)
|
||||
|
||||
let isIPv4 = entry.ifa_addr.pointee.sa_family == UInt8(AF_INET)
|
||||
let isActive = (flags & (IFF_UP | IFF_RUNNING | IFF_LOOPBACK)) == (IFF_UP | IFF_RUNNING)
|
||||
|
||||
if isIPv4, isActive, let info = NetInfo(entry), info.maskIP != "255.255.255.255" {
|
||||
addrs.insert(info)
|
||||
}
|
||||
|
||||
cursor = entry.ifa_next
|
||||
}
|
||||
return addrs
|
||||
}
|
||||
|
||||
private var nextLAN: NetInfo? {
|
||||
addrs.first { $0.name.starts(with: "en") }
|
||||
}
|
||||
|
||||
var nextProbableSideVPN: NetInfo? {
|
||||
// try old 10.7.0.1 first, then fallback to next v4
|
||||
// user should only be connected to StosVPN/LocalDevVPN
|
||||
addrs.first {
|
||||
$0.hostIP == "10.7.0.1" ||
|
||||
$0.name.starts(with: "utun")
|
||||
}
|
||||
}
|
||||
|
||||
var sideVPNPatched: Bool {
|
||||
nextLAN?.maskIP == nextProbableSideVPN?.maskIP &&
|
||||
nextLAN?.maxIP == nextProbableSideVPN?.maxIP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,15 +13,24 @@ var isMinimuxerReady: Bool {
|
||||
print("isMinimuxerReady property is always true on simulator")
|
||||
return true
|
||||
#else
|
||||
return minimuxer.ready()
|
||||
IfManager.shared.query()
|
||||
let dest = IfManager.shared.nextProbableSideVPN?.destIP
|
||||
if #available(iOS 26.4, *) {
|
||||
return minimuxer.ready(dest) && IfManager.shared.sideVPNPatched
|
||||
} else {
|
||||
return minimuxer.ready(dest)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
func minimuxerStartWithLogger(_ pairingFile: String,_ logPath: String,_ loggingEnabled: Bool) throws {
|
||||
func minimuxerStartWithLogger(_ pairingFile: String, _ logPath: String, _ loggingEnabled: Bool) throws {
|
||||
#if targetEnvironment(simulator)
|
||||
print("minimuxerStartWithLogger(\(pairingFile), \(logPath), \(loggingEnabled) is no-op on simulator")
|
||||
print("minimuxerStartWithLogger(\(pairingFile), \(logPath), \(loggingEnabled)) is no-op on simulator")
|
||||
#else
|
||||
try minimuxer.startWithLogger(pairingFile, logPath, loggingEnabled)
|
||||
IfManager.shared.query()
|
||||
let dest = IfManager.shared.nextProbableSideVPN?.destIP
|
||||
print("minimuxerStartWithLogger(\(pairingFile), \(logPath), \(dest), \(loggingEnabled)) is no-op on simulator")
|
||||
try minimuxer.startWithLogger(pairingFile, logPath, dest, loggingEnabled)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user