Remove feature ping which may make app crashed.
This commit is contained in:
@ -110,7 +110,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
image.isTemplate = true
|
||||
statusItem.image = image
|
||||
statusItem.menu = statusMenu
|
||||
ServerProfileManager.instance.refreshPing()
|
||||
|
||||
let notifyCenter = NotificationCenter.default
|
||||
|
||||
@ -556,7 +555,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
|
||||
if isChanged {
|
||||
mgr.save()
|
||||
ServerProfileManager.instance.refreshPing()
|
||||
self.updateServersMenu()
|
||||
} else {
|
||||
sendNotify("Not found valid qrcode of shadowsocks profile.", "", "")
|
||||
|
@ -160,7 +160,6 @@ class PreferencesWindowController: NSWindowController
|
||||
}
|
||||
}
|
||||
profileMgr.save()
|
||||
ServerProfileManager.instance.refreshPing()
|
||||
window?.performClose(nil)
|
||||
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import XYPingUtil
|
||||
|
||||
|
||||
class ServerProfile: NSObject, NSCopying {
|
||||
@ -24,8 +23,6 @@ class ServerProfile: NSObject, NSCopying {
|
||||
@objc var enabledKcptun: Bool = false
|
||||
@objc var kcptunProfile = KcptunProfile()
|
||||
|
||||
@objc var ping:Int = 0
|
||||
|
||||
override init() {
|
||||
uuid = UUID().uuidString
|
||||
}
|
||||
@ -129,7 +126,6 @@ class ServerProfile: NSObject, NSCopying {
|
||||
|
||||
copy.enabledKcptun = self.enabledKcptun
|
||||
copy.kcptunProfile = self.kcptunProfile.copy() as! KcptunProfile
|
||||
copy.ping = self.ping
|
||||
return copy;
|
||||
}
|
||||
|
||||
@ -152,9 +148,6 @@ class ServerProfile: NSObject, NSCopying {
|
||||
if let kcptunData = data["KcptunProfile"] {
|
||||
profile.kcptunProfile = KcptunProfile.fromDictionary(kcptunData as! [String:Any?])
|
||||
}
|
||||
if let ping = data["Ping"] as? NSNumber {
|
||||
profile.ping = ping.intValue
|
||||
}
|
||||
}
|
||||
|
||||
if let id = data["Id"] as? String {
|
||||
@ -179,7 +172,6 @@ class ServerProfile: NSObject, NSCopying {
|
||||
d["OTA"] = ota as AnyObject?
|
||||
d["EnabledKcptun"] = NSNumber(value: enabledKcptun)
|
||||
d["KcptunProfile"] = kcptunProfile.toDictionary() as AnyObject
|
||||
d["Ping"] = NSNumber(value: ping)
|
||||
return d
|
||||
}
|
||||
|
||||
@ -323,22 +315,11 @@ class ServerProfile: NSObject, NSCopying {
|
||||
}
|
||||
|
||||
func title() -> String {
|
||||
var ping = self.ping == 0 ? "" : "(\(self.ping)ms)"
|
||||
if self.ping == -1 {
|
||||
ping = "(\("Timeout".localized))"
|
||||
}
|
||||
if remark.isEmpty {
|
||||
return "\(serverHost):\(serverPort)\(ping)"
|
||||
return "\(serverHost):\(serverPort)"
|
||||
} else {
|
||||
return "\(remark) (\(serverHost):\(serverPort))\(ping)"
|
||||
return "\(remark) (\(serverHost):\(serverPort))"
|
||||
}
|
||||
}
|
||||
|
||||
func refreshPing() {
|
||||
PingUtil.pingHost(serverHost, success: { (ping) in
|
||||
self.ping = ping
|
||||
}, failure: {
|
||||
NSLog("Ping %@ fail", self.serverHost)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -58,12 +58,6 @@ class ServerProfileManager: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
func refreshPing() {
|
||||
for profile in profiles {
|
||||
profile.refreshPing()
|
||||
}
|
||||
}
|
||||
|
||||
func getActiveProfile() -> ServerProfile? {
|
||||
if let id = activeProfileId {
|
||||
for p in profiles {
|
||||
@ -112,7 +106,6 @@ class ServerProfileManager: NSObject {
|
||||
|
||||
self.profiles.append(profile)
|
||||
self.save()
|
||||
self.refreshPing()
|
||||
}
|
||||
NotificationCenter.default.post(name: NOTIFY_SERVER_PROFILES_CHANGED, object: nil)
|
||||
let configsCount = (jsonArr1.object(forKey: "configs") as! [[String: AnyObject]]).count
|
||||
|
Reference in New Issue
Block a user