Skip to content

Commit

Permalink
Fix Read iCloud profile before starting
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed May 3, 2024
1 parent 6a8fb11 commit 17eec08
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ApplicationLibrary/Service/UIProfileUpdateTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import Library
if profiles.isEmpty {
return
}
await ProfileUpdateTask.updateProfiles(profiles)
_ = await ProfileUpdateTask.updateProfiles(profiles)
}

private nonisolated static func getAndUpdateProfiles(_ task: BGTask) async {
Expand Down
1 change: 0 additions & 1 deletion ApplicationLibrary/Views/Dashboard/StartStopButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public struct StartStopButton: View {
private nonisolated func switchProfile(_ isEnabled: Bool) async {
do {
if isEnabled {
try await profile.read()
try await profile.start()
await environments.logClient.connect()
} else {
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibrary/Views/Setting/ServiceLogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public struct ServiceLogView: View {
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
var deviceInfo = await "Machine: " + machineName + "\n"
var deviceInfo = "Machine: " + machineName + "\n"
#if os(iOS)
await deviceInfo += "System: " + (UIDevice.current.systemName) + " " + (UIDevice.current.systemVersion) + "\n"
#elseif os(macOS)
Expand Down
11 changes: 11 additions & 0 deletions Library/Network/ExtensionProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class ExtensionProfile: ObservableObject {
}

public func start() async throws {
await fetchProfile()
manager.isEnabled = true
if await SharedPreferences.alwaysOn.get() {
manager.isOnDemandEnabled = true
Expand All @@ -76,6 +77,16 @@ public class ExtensionProfile: ObservableObject {
try manager.connection.startVPNTunnel()
}

public func fetchProfile() async {
do {
if let profile = try await ProfileManager.get(Int64(SharedPreferences.selectedProfileID.get())) {
if profile.type == .icloud {
_ = try profile.read()
}
}
} catch {}
}

public func stop() async throws {
if manager.isOnDemandEnabled {
manager.isOnDemandEnabled = false
Expand Down
24 changes: 12 additions & 12 deletions sing-box.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.8.11;
MARKETING_VERSION = 1.8.13;
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
PRODUCT_NAME = "sing-box";
SDKROOT = appletvos;
Expand Down Expand Up @@ -2044,7 +2044,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.8.11;
MARKETING_VERSION = 1.8.13;
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
PRODUCT_NAME = "sing-box";
SDKROOT = appletvos;
Expand Down Expand Up @@ -2282,7 +2282,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.8.11;
MARKETING_VERSION = 1.8.13;
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
PRODUCT_NAME = "sing-box";
Expand Down Expand Up @@ -2322,7 +2322,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.8.11;
MARKETING_VERSION = 1.8.13;
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
PRODUCT_NAME = "sing-box";
Expand All @@ -2345,7 +2345,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 213;
CURRENT_PROJECT_VERSION = 221;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = Z56Z6NYZN2;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -2361,7 +2361,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.8.11;
MARKETING_VERSION = 1.8.13;
OTHER_CODE_SIGN_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
PRODUCT_NAME = "sing-box";
Expand All @@ -2383,7 +2383,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 213;
CURRENT_PROJECT_VERSION = 221;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = Z56Z6NYZN2;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -2399,7 +2399,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.8.11;
MARKETING_VERSION = 1.8.13;
OTHER_CODE_SIGN_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
PRODUCT_NAME = "sing-box";
Expand Down Expand Up @@ -2541,7 +2541,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.8.11;
MARKETING_VERSION = 1.8.13;
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system;
PRODUCT_NAME = "$(inherited)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -2577,7 +2577,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.8.11;
MARKETING_VERSION = 1.8.13;
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system;
PRODUCT_NAME = "$(inherited)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -2617,7 +2617,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.8.11;
MARKETING_VERSION = 1.8.13;
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent;
PRODUCT_NAME = SFM;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -2656,7 +2656,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.8.11;
MARKETING_VERSION = 1.8.13;
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent;
PRODUCT_NAME = SFM;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down

0 comments on commit 17eec08

Please sign in to comment.