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 Aug 14, 2023
2 parents 144be01 + 94e666b commit aa7feaa
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: robinraju/release-downloader@v1.8
with:
repository: 'MetaCubeX/Clash.Meta'
tag: "v1.15.0"
tag: "v1.15.1"
fileName: ".*darwin.*64-v.*.gz"

# releaseId: "62870807"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Alamofire/Alamofire",
"state" : {
"revision" : "78424be314842833c04bc3bef5b72e85fff99204",
"version" : "5.6.4"
"revision" : "bc268c28fb170f494de9e9927c371b8342979ece",
"version" : "5.7.1"
}
},
{
Expand All @@ -15,7 +15,7 @@
"location" : "https://github.com/mrFq1/ClashX-Dashboard",
"state" : {
"branch" : "dev",
"revision" : "c9e23067c908de6131671c6ff59ced91b97695a9"
"revision" : "b6b8515f488d2fefcf7a29d0726db51de131eea1"
}
},
{
Expand Down Expand Up @@ -68,8 +68,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/sindresorhus/KeyboardShortcuts",
"state" : {
"revision" : "018e445b340dac78dfc2a4c97c45d9571507c3b5",
"version" : "1.11.0"
"revision" : "8b1a9ce78c2f35c8a55dcc95897573abd2cc4f6e",
"version" : "1.13.0"
}
},
{
Expand Down Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/ReactiveX/RxSwift",
"state" : {
"revision" : "b4307ba0b6425c0ba4178e138799946c3da594f8",
"version" : "6.5.0"
"revision" : "9dcaa4b333db437b0fbfaf453fad29069044a8b4",
"version" : "6.6.0"
}
},
{
Expand All @@ -122,8 +122,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
"version" : "1.5.2"
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version" : "1.5.3"
}
},
{
Expand All @@ -138,10 +138,10 @@
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect.git",
"location" : "https://github.com/siteline/swiftui-introspect",
"state" : {
"revision" : "67e2a59be1cf1c6dc4bb7a861cbea888d423bb78",
"version" : "0.5.2"
"revision" : "ccb973cfff703cba53fb88197413485c060eb26b",
"version" : "0.10.0"
}
},
{
Expand All @@ -158,8 +158,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams",
"state" : {
"revision" : "f47ba4838c30dbd59998a4e4c87ab620ff959e8a",
"version" : "5.0.5"
"revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3",
"version" : "5.0.6"
}
}
],
Expand Down
25 changes: 25 additions & 0 deletions ClashX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
var runAfterConfigReload: (() -> Void)?

var helperStatusTimer: Timer?
var updateGeoTimer: Timer?

func applicationWillFinishLaunching(_ notification: Notification) {
Logger.log("applicationWillFinishLaunching")
Expand Down Expand Up @@ -1288,8 +1289,32 @@ extension AppDelegate {
}

@IBAction func updateGEO(_ sender: NSMenuItem) {
guard updateGeoTimer == nil else { return }
updateGeoTimer = Timer.scheduledTimer(withTimeInterval: 500, repeats: true) { [weak self] timer in

timer.fireDate = .init(timeIntervalSinceNow: 5)

ApiRequest.getRules { rules in
guard self?.updateGeoTimer != nil else { return }
if let rule = rules.first,
rule.payload == ClashMetaConfig.initRulePayload {
Logger.log("Update GEO Finished.")
self?.updateConfig(showNotification: false) { _ in
NSUserNotificationCenter.default.post(title: "Update GEO Databases Finished.", info: "")
}

timer.invalidate()
self?.updateGeoTimer = nil
} else {
timer.fireDate = .init(timeIntervalSinceNow: 0.5)
}
}
}

ApiRequest.updateGEO { _ in
NSUserNotificationCenter.default.post(title: NSLocalizedString("Updating GEO Databases...", comment: ""), info: NSLocalizedString("Good luck to you 🙃", comment: ""))

self.updateGeoTimer?.fire()
}
}

Expand Down
6 changes: 5 additions & 1 deletion ClashX/General/ClashMetaConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Cocoa
import Yams

class ClashMetaConfig: NSObject {
static let initRulePayload = "ClashXMetaInitConfigQWERTYUIOP".lowercased()

struct Config: Codable {
var externalUI: String? = {
Expand All @@ -27,6 +28,8 @@ class ClashMetaConfig: NSObject {
var geoxUrl: [String: String]?

var logLevel = ConfigManager.selectLoggingApiLevel.rawValue

var rules = ["DOMAIN-KEYWORD,\(initRulePayload),REJECT"]

var path: String {
get {
Expand All @@ -48,7 +51,8 @@ class ClashMetaConfig: NSObject {
logLevel = "log-level",
geodataMode = "geodata-mode",
geoxUrl = "geox-url",
secret
secret,
rules
}

mutating func loadDefaultConfigFile(_ path: String) {
Expand Down

0 comments on commit aa7feaa

Please sign in to comment.