mirror of
https://github.com/qinyuhang/ShadowsocksX-NG-R.git
synced 2026-10-23 08:23:43 +00:00
bump up version
This commit is contained in:
Generated
+2
@@ -934,6 +934,7 @@
|
||||
PRODUCT_NAME = Alamofire;
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = "";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
@@ -965,6 +966,7 @@
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = "";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
083BF8371D82742200831C68 /* PingClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 083BF8351D82742200831C68 /* PingClient.swift */; };
|
||||
083BF8391D82759600831C68 /* StatusItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 083BF8381D82759600831C68 /* StatusItemView.swift */; };
|
||||
083BF83B1D8275A800831C68 /* SystemThemeChangeHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 083BF83A1D8275A800831C68 /* SystemThemeChangeHelper.swift */; };
|
||||
08805F191D878CA5009B53E7 /* PingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08805F181D878CA5009B53E7 /* PingTest.swift */; };
|
||||
0880CE401D6FE6D900BD39E2 /* example-gui-config.json in Resources */ = {isa = PBXBuildFile; fileRef = 0880CE3F1D6FE6D900BD39E2 /* example-gui-config.json */; };
|
||||
088EC3971D5F5B8600E40791 /* whitelist.pac in Resources */ = {isa = PBXBuildFile; fileRef = 088EC3961D5F5B8600E40791 /* whitelist.pac */; };
|
||||
088EC3991D5F5BA300E40791 /* whiteiplist.pac in Resources */ = {isa = PBXBuildFile; fileRef = 088EC3981D5F5BA300E40791 /* whiteiplist.pac */; };
|
||||
@@ -104,6 +105,7 @@
|
||||
083BF83A1D8275A800831C68 /* SystemThemeChangeHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SystemThemeChangeHelper.swift; sourceTree = "<group>"; };
|
||||
085641E91D7188C400116B27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
085641EB1D71A48700116B27 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/MainMenu.strings"; sourceTree = "<group>"; };
|
||||
08805F181D878CA5009B53E7 /* PingTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PingTest.swift; sourceTree = "<group>"; };
|
||||
0880CE3F1D6FE6D900BD39E2 /* example-gui-config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "example-gui-config.json"; sourceTree = "<group>"; };
|
||||
088EC3961D5F5B8600E40791 /* whitelist.pac */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = whitelist.pac; sourceTree = "<group>"; };
|
||||
088EC3981D5F5BA300E40791 /* whiteiplist.pac */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = whiteiplist.pac; sourceTree = "<group>"; };
|
||||
@@ -313,6 +315,7 @@
|
||||
9B3FFF201D08826E0019A709 /* PACUtils.swift */,
|
||||
083BF8341D82742200831C68 /* NetWorkMonitor.swift */,
|
||||
083BF8351D82742200831C68 /* PingClient.swift */,
|
||||
08805F181D878CA5009B53E7 /* PingTest.swift */,
|
||||
9B3FFF131D0705810019A709 /* Notifications.swift */,
|
||||
9B3FFF1D1D0732660019A709 /* Utils.m */,
|
||||
9B3FFF1F1D0734060019A709 /* Utils.h */,
|
||||
@@ -449,6 +452,7 @@
|
||||
TargetAttributes = {
|
||||
9B0BFFE41D0460A70040E62B = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
DevelopmentTeam = 2E8Q4BTFR2;
|
||||
};
|
||||
9B0BFFF31D0460A70040E62B = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
@@ -657,6 +661,7 @@
|
||||
9B3FFF171D072FDE0019A709 /* LaunchAtLoginController.m in Sources */,
|
||||
9B3FFF4F1D09D9D50019A709 /* ProxyConfHelper.m in Sources */,
|
||||
9BB706A71D1B982300551F0E /* SWBApplication.m in Sources */,
|
||||
08805F191D878CA5009B53E7 /* PingTest.swift in Sources */,
|
||||
9B3FFF1E1D0732660019A709 /* Utils.m in Sources */,
|
||||
9B3FFF321D08CEE40019A709 /* SWBQRCodeWindowController.m in Sources */,
|
||||
083BF8371D82742200831C68 /* PingClient.swift in Sources */,
|
||||
@@ -856,6 +861,7 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "Mac Developer";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/libcork/include/",
|
||||
@@ -883,6 +889,7 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "Mac Developer";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/libcork/include/",
|
||||
|
||||
@@ -51,32 +51,24 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
var statusItem: NSStatusItem?
|
||||
var speedMonitor:NetWorkMonitor?
|
||||
|
||||
// MARK: Application function
|
||||
|
||||
func setUpMenu(showSpeed:Bool){
|
||||
if statusItem == nil{
|
||||
statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(85)
|
||||
let image = NSImage(named: "menu_icon")
|
||||
image?.template = true
|
||||
statusItem!.image = image
|
||||
statusItemView = StatusItemView(statusItem: statusItem!, menu: statusMenu)
|
||||
statusItem!.view = statusItemView
|
||||
}
|
||||
if showSpeed{
|
||||
if speedMonitor == nil{
|
||||
speedMonitor = NetWorkMonitor(statusItemView: statusItemView)
|
||||
}
|
||||
statusItem?.length = 85
|
||||
speedMonitor?.start()
|
||||
}else{
|
||||
speedMonitor?.stop()
|
||||
speedMonitor = nil
|
||||
statusItem?.length = 20
|
||||
}
|
||||
}
|
||||
|
||||
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
||||
// Insert code here to initialize your application
|
||||
// PingServers.instance.ping()
|
||||
// let newInstance = PingTest.init(hostName: "www.baidu.com")
|
||||
// newInstance.start()
|
||||
let SerMgr = ServerProfileManager.instance
|
||||
let pingServerQueue : dispatch_queue_t = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
|
||||
|
||||
for profile in SerMgr.profiles {
|
||||
let host = profile.serverHost
|
||||
|
||||
dispatch_async(pingServerQueue, {
|
||||
// print(profile.serverHost)
|
||||
let pingInstance = PingTest.init(hostName: host)
|
||||
pingInstance.start()
|
||||
})}
|
||||
NSUserNotificationCenter.defaultUserNotificationCenter().delegate = self
|
||||
|
||||
// Prepare ss-local
|
||||
@@ -244,6 +236,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
|
||||
}
|
||||
|
||||
// MARK: interface functions
|
||||
|
||||
@IBAction func toggleRunning(sender: NSMenuItem) {
|
||||
let defaults = NSUserDefaults.standardUserDefaults()
|
||||
var isOn = defaults.boolForKey("ShadowsocksOn")
|
||||
@@ -452,6 +446,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: this function is use to update menu bar
|
||||
|
||||
func updateRunningModeMenu() {
|
||||
let defaults = NSUserDefaults.standardUserDefaults()
|
||||
let mode = defaults.stringForKey("ShadowsocksRunningMode")
|
||||
@@ -602,6 +598,30 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
|
||||
}
|
||||
|
||||
func setUpMenu(showSpeed:Bool){
|
||||
if statusItem == nil{
|
||||
statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(85)
|
||||
let image = NSImage(named: "menu_icon")
|
||||
image?.template = true
|
||||
statusItem!.image = image
|
||||
statusItemView = StatusItemView(statusItem: statusItem!, menu: statusMenu)
|
||||
statusItem!.view = statusItemView
|
||||
}
|
||||
if showSpeed{
|
||||
if speedMonitor == nil{
|
||||
speedMonitor = NetWorkMonitor(statusItemView: statusItemView)
|
||||
}
|
||||
statusItem?.length = 85
|
||||
speedMonitor?.start()
|
||||
}else{
|
||||
speedMonitor?.stop()
|
||||
speedMonitor = nil
|
||||
statusItem?.length = 20
|
||||
}
|
||||
}
|
||||
|
||||
// MARK:
|
||||
|
||||
func handleURLEvent(event: NSAppleEventDescriptor, withReplyEvent replyEvent: NSAppleEventDescriptor) {
|
||||
if let urlString = event.paramDescriptorForKeyword(AEKeyword(keyDirectObject))?.stringValue {
|
||||
if let url = NSURL(string: urlString) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.3.3-R5</string>
|
||||
<string>1.3.3-R6</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
//
|
||||
// PingTest.swift
|
||||
// ShadowsocksX-NG
|
||||
//
|
||||
// Created by 秦宇航 on 16/9/12.
|
||||
// Copyright © 2016年 qiuyuzhou. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class PingTest: NSObject, SimplePingDelegate {
|
||||
static let instance = PingTest(hostName: "")
|
||||
//then 写一个init函数,传入hostName来init
|
||||
var hostName = "jp10.hexiehao.pw"
|
||||
|
||||
var pinger: SimplePing?
|
||||
var sendTimer: NSTimer?
|
||||
var dateReference: NSDate?
|
||||
|
||||
/// Called by the table view selection delegate callback to start the ping.
|
||||
init(hostName:String) {
|
||||
self.hostName = hostName
|
||||
}
|
||||
func start() {
|
||||
|
||||
NSLog("start ping %@",self.hostName)
|
||||
|
||||
let pinger = SimplePing(hostName: self.hostName)
|
||||
self.pinger = pinger
|
||||
|
||||
pinger.delegate = self
|
||||
pinger.start()
|
||||
}
|
||||
|
||||
/// Called by the table view selection delegate callback to stop the ping.
|
||||
|
||||
func stop() {
|
||||
NSLog("stop")
|
||||
self.pinger?.stop()
|
||||
self.pinger = nil
|
||||
|
||||
self.sendTimer?.invalidate()
|
||||
self.sendTimer = nil
|
||||
}
|
||||
|
||||
/// Sends a ping.
|
||||
///
|
||||
/// Called to send a ping, both directly (as soon as the SimplePing object starts up) and
|
||||
/// via a timer (to continue sending pings periodically).
|
||||
|
||||
func sendPing() {
|
||||
self.pinger!.sendPingWithData(nil)
|
||||
}
|
||||
|
||||
// MARK: pinger delegate callback
|
||||
|
||||
func simplePing(pinger: SimplePing, didStartWithAddress address: NSData) {
|
||||
NSLog("pinging %@",hostName)
|
||||
|
||||
// Send the first ping straight away.
|
||||
|
||||
self.sendPing()
|
||||
|
||||
// And start a timer to send the subsequent pings.
|
||||
|
||||
assert(self.sendTimer == nil)
|
||||
self.sendTimer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(PingTest.sendPing), userInfo: nil, repeats: true)
|
||||
}
|
||||
|
||||
func simplePing(pinger: SimplePing, didFailWithError error: NSError) {
|
||||
NSLog("failed: %@", PingTest.shortErrorFromError(error))
|
||||
|
||||
self.stop()
|
||||
}
|
||||
|
||||
func simplePing(pinger: SimplePing, didSendPacket packet: NSData, sequenceNumber: UInt16) {
|
||||
NSLog("#%u sent", sequenceNumber)
|
||||
dateReference = NSDate()
|
||||
}
|
||||
|
||||
func simplePing(pinger: SimplePing, didFailToSendPacket packet: NSData, sequenceNumber: UInt16, error: NSError) {
|
||||
NSLog("#%u send failed: %@", sequenceNumber, PingTest.shortErrorFromError(error))
|
||||
}
|
||||
|
||||
func simplePing(pinger: SimplePing, didReceivePingResponsePacket packet: NSData, sequenceNumber: UInt16) {
|
||||
|
||||
pinger.stop()
|
||||
|
||||
guard let dateReference = dateReference else { return }
|
||||
|
||||
//timeIntervalSinceDate returns seconds, so we convert to milis
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
let latency = NSDate().timeIntervalSinceDate(dateReference) * 1000
|
||||
NSLog("#%u received, host=%@, size=%zu, latency=%.f", sequenceNumber, self.hostName , packet.length,latency)
|
||||
let userNote = NSUserNotification()
|
||||
userNote.title = "\(self.hostName) ping \(latency)".localized
|
||||
userNote.subtitle = "Address can't not be recognized".localized
|
||||
NSUserNotificationCenter.defaultUserNotificationCenter()
|
||||
.deliverNotification(userNote)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
func simplePing(pinger: SimplePing, didReceiveUnexpectedPacket packet: NSData) {
|
||||
NSLog("unexpected packet, size=%zu", packet.length)
|
||||
}
|
||||
|
||||
// MARK: utilities
|
||||
|
||||
/// Returns the string representation of the supplied address.
|
||||
///
|
||||
/// - parameter address: Contains a `(struct sockaddr)` with the address to render.
|
||||
///
|
||||
/// - returns: A string representation of that address.
|
||||
|
||||
static func displayAddressForAddress(address: NSData) -> String {
|
||||
var hostStr = [Int8](count: Int(NI_MAXHOST), repeatedValue: 0)
|
||||
|
||||
let success = getnameinfo(
|
||||
UnsafePointer(address.bytes),
|
||||
socklen_t(address.length),
|
||||
&hostStr,
|
||||
socklen_t(hostStr.count),
|
||||
nil,
|
||||
0,
|
||||
NI_NUMERICHOST
|
||||
) == 0
|
||||
let result: String
|
||||
if success {
|
||||
result = String.fromCString(hostStr)!
|
||||
} else {
|
||||
result = "?"
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/// Returns a short error string for the supplied error.
|
||||
///
|
||||
/// - parameter error: The error to render.
|
||||
///
|
||||
/// - returns: A short string representing that error.
|
||||
|
||||
static func shortErrorFromError(error: NSError) -> String {
|
||||
if error.domain == kCFErrorDomainCFNetwork as String && error.code == Int(CFNetworkErrors.CFHostErrorUnknown.rawValue) {
|
||||
if let failureObj = error.userInfo[kCFGetAddrInfoFailureKey] {
|
||||
if let failureNum = failureObj as? NSNumber {
|
||||
if failureNum.intValue != 0 {
|
||||
let f = gai_strerror(failureNum.intValue)
|
||||
if f != nil {
|
||||
return String.fromCString(f)!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let result = error.localizedFailureReason {
|
||||
return result
|
||||
}
|
||||
return error.localizedDescription
|
||||
}
|
||||
class func pingArray(){//hostList : [String]) -> [[String : String]]{
|
||||
// return [["apple.com":"20"],["baidu.com":"20"]]
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ServerProfileManager.swift
|
||||
// ShadowsocksX-NG
|
||||
//
|
||||
// Created by 邱宇舟 on 16/6/6.
|
||||
// Created by 邱宇舟 on 16/6/6. Modified by 秦宇航 16/9/12
|
||||
// Copyright © 2016年 qiuyuzhou. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
Reference in New Issue
Block a user