Skip to content

Commit

Permalink
Merge branch 'meta-dev' into meta
Browse files Browse the repository at this point in the history
  • Loading branch information
mrFq1 committed Apr 23, 2024
2 parents a9ed6f4 + 988c0cf commit b62ddd7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 21 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ on:

jobs:
build:
runs-on: macos-13
runs-on: macos-14
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: download meta core
uses: robinraju/release-downloader@v1.9
uses: robinraju/release-downloader@v1.10
with:
repository: 'MetaCubeX/mihomo'
tag: "v1.18.3"
Expand Down Expand Up @@ -93,7 +97,7 @@ jobs:
path: "*.zip"

- name: upload build to github
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
7 changes: 6 additions & 1 deletion ClashX/Actions/TerminalCleanUpAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ enum TerminalConfirmAction {
}
let group = DispatchGroup()
var shouldWait = false

ConfigManager.shared.restoreTunProxy = ConfigManager.shared.isTunModeVariable.value

PrivilegedHelperManager.shared.helper()?.stopMeta()
PrivilegedHelperManager.shared.helper()?.updateTun(state: false)
Expand All @@ -27,13 +29,16 @@ enum TerminalConfirmAction {
if ConfigManager.shared.proxyPortAutoSet && !ConfigManager.shared.isProxySetByOtherVariable.value || NetworkChangeNotifier.isCurrentSystemSetToClash(looser: true) ||
NetworkChangeNotifier.hasInterfaceProxySetToClash() {
Logger.log("ClashX quit need clean proxy setting")
ConfigManager.shared.restoreSystemProxy = true
shouldWait = true
group.enter()

SystemProxyManager.shared.disableProxy(forceDisable: ConfigManager.shared.isProxySetByOtherVariable.value) {
group.leave()
}
}
} else {
ConfigManager.shared.restoreSystemProxy = false
}

if !shouldWait {
Logger.log("ClashX quit without clean waiting")
Expand Down
31 changes: 14 additions & 17 deletions ClashX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func setupData() {
SSIDSuspendTool.shared.setup()
ConfigManager.shared
.showNetSpeedIndicatorObservable.skip(1)
.bind {
Expand Down Expand Up @@ -308,21 +307,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
startProxyCore()
}


if !PrivilegedHelperManager.shared.isHelperCheckFinished.value &&
ConfigManager.shared.proxyPortAutoSet {
PrivilegedHelperManager.shared.isHelperCheckFinished
.filter { $0 }
.take(1)
.take(while: { _ in ConfigManager.shared.proxyPortAutoSet })
.observe(on: MainScheduler.instance)
.bind(onNext: { _ in
SystemProxyManager.shared.enableProxy()
}).disposed(by: disposeBag)
} else if ConfigManager.shared.proxyPortAutoSet {
SystemProxyManager.shared.enableProxy()
}

LaunchAtLogin.shared
.isEnableVirable
.asObservable()
Expand Down Expand Up @@ -588,7 +572,20 @@ extension AppDelegate: ClashProcessDelegate {
}

func clashConfigUpdated() {
syncConfigWithTun(true)
if ConfigManager.shared.restoreSystemProxy {
SystemProxyManager.shared.enableProxy()
}

if ConfigManager.shared.restoreTunProxy {
ApiRequest.updateTun(enable: true) {
PrivilegedHelperManager.shared.helper()?.updateTun(state: true)
}
} else {
syncConfigWithTun(true)
}

SSIDSuspendTool.shared.setup()

resetStreamApi()
runAfterConfigReload?()
runAfterConfigReload = nil
Expand Down
18 changes: 18 additions & 0 deletions ClashX/General/Managers/ConfigManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,24 @@ class ConfigManager {
UserDefaults.standard.set(newValue, forKey: "proxyPortAutoSet")
}
}

var restoreSystemProxy: Bool {
get {
return UserDefaults.standard.bool(forKey: "restoreSystemProxy")
}
set {
UserDefaults.standard.set(newValue, forKey: "restoreSystemProxy")
}
}

var restoreTunProxy: Bool {
get {
return UserDefaults.standard.bool(forKey: "restoreTunProxy")
}
set {
UserDefaults.standard.set(newValue, forKey: "restoreTunProxy")
}
}

let proxyPortAutoSetObservable = UserDefaults.standard.rx.observe(Bool.self, "proxyPortAutoSet").map { $0 ?? false }

Expand Down

0 comments on commit b62ddd7

Please sign in to comment.