Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
XinSSS committed Jul 14, 2020
1 parent 7a10548 commit a2fcfac
Show file tree
Hide file tree
Showing 37 changed files with 789 additions and 90 deletions.
22 changes: 14 additions & 8 deletions ClashX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
49722FF0211F338B00650A41 /* EventStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49722FEB211F338B00650A41 /* EventStream.swift */; };
49722FF1211F338B00650A41 /* Witness.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49722FEC211F338B00650A41 /* Witness.swift */; };
49761DA721C9497000AE13EF /* dashboard in Resources */ = {isa = PBXBuildFile; fileRef = 49761DA621C9497000AE13EF /* dashboard */; };
497F0DF320DE2FE50077AD41 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 497F0DF220DE2FE50077AD41 /* Icon.icns */; };
4981C88B216BAE4A008CC14A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4981C88D216BAE4A008CC14A /* Localizable.strings */; };
4982F51F2344A216008804B0 /* Cgo+Convert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4982F51E2344A216008804B0 /* Cgo+Convert.swift */; };
49862FA0218418C600A1D5EC /* ClashRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49862F9F218418C600A1D5EC /* ClashRule.swift */; };
Expand All @@ -55,6 +54,8 @@
49D176A72355FE680093DD7B /* NetworkChangeNotifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49D176A62355FE680093DD7B /* NetworkChangeNotifier.swift */; };
49D176A9235614340093DD7B /* ProxyGroupSpeedTestMenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49D176A8235614340093DD7B /* ProxyGroupSpeedTestMenuItem.swift */; };
49D176AB23575BB20093DD7B /* ProxyGroupMenuItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49D176AA23575BB20093DD7B /* ProxyGroupMenuItemView.swift */; };
6E17601124BD8E81009C0A83 /* RemoteControlManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E17601024BD8E81009C0A83 /* RemoteControlManager.swift */; };
6E17601324BD8E9D009C0A83 /* ExternalControlViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E17601224BD8E9D009C0A83 /* ExternalControlViewController.swift */; };
6E2A2C7C2455369D007BBE7D /* ProxyDelayHistoryMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2A2C7B2455369D007BBE7D /* ProxyDelayHistoryMenu.swift */; };
6E6B9F67245A65BE00F72A94 /* ClashStatusTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E6B9F66245A65BE00F72A94 /* ClashStatusTool.swift */; };
6E73DAF1248891410059D1C7 /* iCloudManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E73DAF0248891410059D1C7 /* iCloudManager.swift */; };
Expand Down Expand Up @@ -138,7 +139,6 @@
49722FEC211F338B00650A41 /* Witness.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Witness.swift; sourceTree = "<group>"; };
49722FED211F338B00650A41 /* Witness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Witness.h; sourceTree = "<group>"; };
49761DA621C9497000AE13EF /* dashboard */ = {isa = PBXFileReference; lastKnownFileType = folder; path = dashboard; sourceTree = "<group>"; };
497F0DF220DE2FE50077AD41 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = "<group>"; };
4981C887216BAB8A008CC14A /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = "<group>"; };
4981C88C216BAE4A008CC14A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
4981C88E216BAE4D008CC14A /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -173,6 +173,8 @@
49D176A8235614340093DD7B /* ProxyGroupSpeedTestMenuItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProxyGroupSpeedTestMenuItem.swift; sourceTree = "<group>"; };
49D176AA23575BB20093DD7B /* ProxyGroupMenuItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProxyGroupMenuItemView.swift; sourceTree = "<group>"; };
5217C006C5A22A1CEA24BFC1 /* Pods-ClashX.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ClashX.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ClashX/Pods-ClashX.debug.xcconfig"; sourceTree = "<group>"; };
6E17601024BD8E81009C0A83 /* RemoteControlManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteControlManager.swift; sourceTree = "<group>"; };
6E17601224BD8E9D009C0A83 /* ExternalControlViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExternalControlViewController.swift; sourceTree = "<group>"; };
6E2A2C7B2455369D007BBE7D /* ProxyDelayHistoryMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProxyDelayHistoryMenu.swift; sourceTree = "<group>"; };
6E6B9F66245A65BE00F72A94 /* ClashStatusTool.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClashStatusTool.swift; sourceTree = "<group>"; };
6E73DAF0248891410059D1C7 /* iCloudManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = iCloudManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -271,6 +273,7 @@
49CF3B6420CEE06C001EBF94 /* ConfigManager.swift */,
6E73DAF0248891410059D1C7 /* iCloudManager.swift */,
495BFB8721919B9800C8779D /* RemoteConfigManager.swift */,
6E17601024BD8E81009C0A83 /* RemoteControlManager.swift */,
4952C3BE2115C7CA004A4FA8 /* MenuItemFactory.swift */,
F935B2FB23085515009E4D33 /* SystemProxyManager.swift */,
F977FAAB2366790500C17F1F /* AutoUpgardeManager.swift */,
Expand Down Expand Up @@ -358,6 +361,7 @@
children = (
49BC061B212931F4005A0FE7 /* AboutViewController.swift */,
499976C721359F0400E7BF83 /* ClashWebViewContoller.swift */,
6E17601224BD8E9D009C0A83 /* ExternalControlViewController.swift */,
499A485322ED707300F6C675 /* RemoteConfigViewController.swift */,
);
path = ViewControllers;
Expand Down Expand Up @@ -410,7 +414,6 @@
49CF3B3A20CD783A001EBF94 /* Support Files */,
49CF3B2020CD7463001EBF94 /* AppDelegate.swift */,
49CF3B2420CD7465001EBF94 /* Assets.xcassets */,
497F0DF220DE2FE50077AD41 /* Icon.icns */,
49CF3B2620CD7465001EBF94 /* Main.storyboard */,
49CF3B2920CD7465001EBF94 /* Info.plist */,
49CF3B2A20CD7465001EBF94 /* ClashX.entitlements */,
Expand Down Expand Up @@ -572,7 +575,6 @@
49CF3B2820CD7465001EBF94 /* Main.storyboard in Resources */,
499A485A22ED781100F6C675 /* RemoteConfigAddView.xib in Resources */,
4989F98420D02D200001E564 /* Country.mmdb in Resources */,
497F0DF320DE2FE50077AD41 /* Icon.icns in Resources */,
4989F98E20D0AE990001E564 /* sampleConfig.yaml in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -686,6 +688,7 @@
49722FF0211F338B00650A41 /* EventStream.swift in Sources */,
499A486522EEA3FD00F6C675 /* Array+Safe.swift in Sources */,
F92D0B24236BC12000575E15 /* SavedProxyModel.swift in Sources */,
6E17601324BD8E9D009C0A83 /* ExternalControlViewController.swift in Sources */,
F92D0B2A236C759100575E15 /* NSTextField+Vibrancy.swift in Sources */,
F910AA24240134AF00116E95 /* ProxyGroupMenu.swift in Sources */,
4952C3BF2115C7CA004A4FA8 /* MenuItemFactory.swift in Sources */,
Expand All @@ -696,6 +699,7 @@
49B4575F244FD4D100463C39 /* PrivilegedHelperManager+Legacy.swift in Sources */,
4966E9E32118153A00A391FB /* NSUserNotificationCenter+Extension.swift in Sources */,
F9E754D2239CC28D00CEE7CC /* NSAlert+Extension.swift in Sources */,
6E17601124BD8E81009C0A83 /* RemoteControlManager.swift in Sources */,
499976C821359F0400E7BF83 /* ClashWebViewContoller.swift in Sources */,
49D176A9235614340093DD7B /* ProxyGroupSpeedTestMenuItem.swift in Sources */,
F976275C23634DF8000EDEFE /* LoginServiceKit.swift in Sources */,
Expand Down Expand Up @@ -876,11 +880,12 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 5217C006C5A22A1CEA24BFC1 /* Pods-ClashX.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development: shaoreceive@outlook.com (6VT57CBDXM)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.20.3.2;
CURRENT_PROJECT_VERSION = 1.20.4;
DEVELOPMENT_TEAM = J7P29E7C2F;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -902,7 +907,7 @@
"$(PROJECT_DIR)/ClashX/goClash",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.20.3.2;
MARKETING_VERSION = 1.20.4;
PRODUCT_BUNDLE_IDENTIFIER = com.shaox.ClashX;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -917,11 +922,12 @@
isa = XCBuildConfiguration;
baseConfigurationReference = A1485BCE642059532D01B8BA /* Pods-ClashX.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development: shaoreceive@outlook.com (6VT57CBDXM)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.20.3.2;
CURRENT_PROJECT_VERSION = 1.20.4;
DEVELOPMENT_TEAM = J7P29E7C2F;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -943,7 +949,7 @@
"$(PROJECT_DIR)/ClashX/goClash",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.20.3.2;
MARKETING_VERSION = 1.20.4;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.shaox.ClashX;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
45 changes: 31 additions & 14 deletions ClashX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet var buildApiModeMenuitem: NSMenuItem!
@IBOutlet var showProxyGroupCurrentMenuItem: NSMenuItem!
@IBOutlet var copyExportCommandMenuItem: NSMenuItem!
@IBOutlet var copyExportCommandExternalMenuItem: NSMenuItem!
@IBOutlet var experimentalMenu: NSMenu!
@IBOutlet var externalControlSeparator: NSMenuItem!

var disposeBag = DisposeBag()
var statusItemView: StatusItemView!
Expand All @@ -73,6 +75,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
statusItemView.frame = CGRect(x: 0, y: 0, width: statusItemLengthWithSpeed, height: 22)
statusMenu.delegate = self
setupStatusMenuItemData()
AppVersionUtil.showUpgradeAlert()
DispatchQueue.main.async {
self.postFinishLaunching()
}
Expand Down Expand Up @@ -128,9 +131,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
Logger.log("ClashX quit need clean proxy setting")
shouldWait = true
group.enter()
let port = ConfigManager.shared.currentConfig?.port ?? 0
let socketPort = ConfigManager.shared.currentConfig?.socketPort ?? 0
SystemProxyManager.shared.disableProxy(port: port, socksPort: socketPort) {
SystemProxyManager.shared.disableProxy {
group.leave()
}
}
Expand Down Expand Up @@ -232,19 +233,21 @@ class AppDelegate: NSObject, NSApplicationDelegate {

self.proxyModeMenuItem.title = "\(NSLocalizedString("Proxy Mode", comment: "")) (\(config.mode.name))"

if old?.port != config.port || old?.socketPort != config.socketPort {
Logger.log("port config updated,new: \(config.port),\(config.socketPort)")
if old?.usedHttpPort != config.usedHttpPort || old?.usedSocksPort != config.usedSocksPort {
Logger.log("port config updated,new: \(config.usedHttpPort),\(config.usedSocksPort)")
if ConfigManager.shared.proxyPortAutoSet {
SystemProxyManager.shared.enableProxy(port: config.port, socksPort: config.socketPort)
SystemProxyManager.shared.enableProxy(port: config.usedHttpPort, socksPort: config.usedSocksPort)
}
}

self.httpPortMenuItem.title = "Http Port: \(config.port)"
self.socksPortMenuItem.title = "Socks Port: \(config.socketPort)"
self.httpPortMenuItem.title = "Http Port: \(config.usedHttpPort)"
self.socksPortMenuItem.title = "Socks Port: \(config.usedSocksPort)"
self.apiPortMenuItem.title = "Api Port: \(ConfigManager.shared.apiPort)"
self.ipMenuItem.title = "IP: \(NetworkChangeNotifier.getPrimaryIPAddress() ?? "")"

if RemoteControlManager.selectConfig == nil {
ClashStatusTool.checkPortConfig(cfg: config)
}

}.disposed(by: disposeBag)
}
Expand Down Expand Up @@ -307,6 +310,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
Logger.log("proxy changed to no clashX setting: \(rawProxy)", level: .warning)
NSUserNotificationCenter.default.postProxyChangeByOtherAppNotice()
}.disposed(by: disposeBag)

NotificationCenter
.default
.rx
.notification(.systemNetworkStatusIPUpdate).map({ _ in
NetworkChangeNotifier.getPrimaryIPAddress(allowIPV6: false)
}).bind { [weak self] _ in
if RemoteControlManager.selectConfig != nil {
self?.resetStreamApi()
}
}.disposed(by: disposeBag)
}

func updateProxyList(withMenus menus: [NSMenuItem]) {
Expand Down Expand Up @@ -439,6 +453,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
AutoUpgardeManager.shared.setup()
AutoUpgardeManager.shared.addChanelMenuItem(&experimentalMenu)
updateExperimentalFeatureStatus()
RemoteControlManager.setupMenuItem(separator: externalControlSeparator)
}

func updateExperimentalFeatureStatus() {
Expand All @@ -456,6 +471,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
SystemProxyManager.shared.disableProxy()
SystemProxyManager.shared.enableProxy()
}

if RemoteControlManager.selectConfig != nil {
resetStreamApi()
}
}

@objc func healthHeckOnNetworkChange() {
Expand Down Expand Up @@ -535,24 +554,22 @@ extension AppDelegate {
} else {
ConfigManager.shared.proxyPortAutoSet = !ConfigManager.shared.proxyPortAutoSet
}
let port = ConfigManager.shared.currentConfig?.port ?? 0
let socketPort = ConfigManager.shared.currentConfig?.socketPort ?? 0

if ConfigManager.shared.proxyPortAutoSet {
if canSaveProxy {
SystemProxyManager.shared.saveProxy()
}
SystemProxyManager.shared.enableProxy(port: port, socksPort: socketPort)
SystemProxyManager.shared.enableProxy()
} else {
SystemProxyManager.shared.disableProxy(port: port, socksPort: socketPort)
SystemProxyManager.shared.disableProxy()
}
}

@IBAction func actionCopyExportCommand(_ sender: NSMenuItem) {
let pasteboard = NSPasteboard.general
pasteboard.clearContents()
let port = ConfigManager.shared.currentConfig?.port ?? 0
let socksport = ConfigManager.shared.currentConfig?.socketPort ?? 0
let port = ConfigManager.shared.currentConfig?.usedHttpPort ?? 0
let socksport = ConfigManager.shared.currentConfig?.usedSocksPort ?? 0
let localhost = "127.0.0.1"
let isLocalhostCopy = sender == copyExportCommandMenuItem
let ip = isLocalhostCopy ? localhost :
Expand Down
16 changes: 13 additions & 3 deletions ClashX/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,68 @@
{
"images" : [
{
"filename" : "icon_16x16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "icon_16x16@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "icon_32x32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "icon_32x32@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "icon_128x128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "icon_128x128@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "icon_256x256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "icon_256x256@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "icon_512x512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "icon_512x512@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a2fcfac

Please sign in to comment.