diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj index ebf20f6..4b2c642 100644 --- a/Pods/Pods.xcodeproj/project.pbxproj +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -653,7 +653,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; }; buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; compatibilityVersion = "Xcode 3.2"; @@ -785,7 +785,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = C18C5D68D2A979595D2A50A1D65A8AF2 /* Alamofire.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; @@ -845,7 +845,8 @@ isa = XCBuildConfiguration; baseConfigurationReference = 089EB7E66F64D3A19BB7681AFCE91031 /* Pods-ShadowsocksX-NG.release.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; @@ -918,14 +919,18 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGNING_REQUIRED = NO; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "POD_CONFIGURATION_RELEASE=1", "$(inherited)", @@ -939,6 +944,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.11; PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; STRIP_INSTALLED_PRODUCT = NO; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SYMROOT = "${SRCROOT}/../build"; VALIDATE_PRODUCT = YES; }; @@ -948,7 +954,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 9BA2A0099476E08B6CC8026BDF0C603E /* Pods-ShadowsocksX-NGTests.debug.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; @@ -986,7 +992,8 @@ isa = XCBuildConfiguration; baseConfigurationReference = 98522BF2EB25C0255284080F9CA3E195 /* Pods-ShadowsocksX-NG.debug.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; @@ -1035,15 +1042,19 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGNING_REQUIRED = NO; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "POD_CONFIGURATION_DEBUG=1", @@ -1069,7 +1080,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 24BCEE536E19B38E28CE6933A0D49A2D /* GCDWebServer.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; @@ -1128,7 +1139,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = F67191B1F87DA238C4D87250DFBE43DD /* Pods-ShadowsocksX-NGTests.release.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; @@ -1166,7 +1177,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 24BCEE536E19B38E28CE6933A0D49A2D /* GCDWebServer.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; @@ -1226,7 +1237,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = C18C5D68D2A979595D2A50A1D65A8AF2 /* Alamofire.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; diff --git a/README.md b/README.md index c481a68..2aac08e 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ Then I rewrite the GUI code by swift. ### Running -- Mac OS X 10.10 + +- Mac OS X 10.11 + ### Building -- XCode 7.3+ +- XCode 8.0+ - cocoapod 1.0.1+ ## Fetures diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index 6f2a3d1..eb2e55d 100644 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -50,7 +50,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele // MARK: Variables var statusItemView:StatusItemView! - var statusItem: NSStatusItem? var speedMonitor:NetWorkMonitor? @@ -95,9 +94,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele "AutoConfigureNetworkServices": NSNumber(value: true as Bool) ]) - setUpMenu(defaults.bool(forKey: "enable_showSpeed")) - + +// statusItem = NSStatusBar.system().statusItem(withLength: 20) +// let image = NSImage(named: "menu_icon") +// image?.isTemplate = true +// statusItem.image = image +// statusItem.menu = statusMenu let notifyCenter = NotificationCenter.default notifyCenter.addObserver(forName: NSNotification.Name(rawValue: NOTIFY_ADV_PROXY_CONF_CHANGED), object: nil, queue: nil @@ -191,8 +194,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele } } - - func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application StopSSLocal() @@ -284,6 +285,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele } // MARK: Server submenu function + @IBAction func showQRCodeForCurrentServer(_ sender: NSMenuItem) { var errMsg: String? if let profile = ServerProfileManager.instance.getActiveProfile() { @@ -455,6 +457,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele func updateRunningModeMenu() { let defaults = UserDefaults.standard let mode = defaults.string(forKey: "ShadowsocksRunningMode") +//<<<<<<< HEAD var serverMenuText = "Servers".localized let mgr = ServerProfileManager.instance @@ -468,10 +471,25 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele if let latency = p.latency{ serverMenuText += " - \(latency)ms" } +//======= +// +// var serverMenuText = "Servers".localized +// for v in defaults.array(forKey: "ServerProfiles")! { +// let profile = v as! [String:Any] +// if profile["Id"] as! String == defaults.string(forKey: "ActiveServerProfileId")! { +// var profileName :String +// if profile["Remark"] as! String != "" { +// profileName = profile["Remark"] as! String +// } else { +// profileName = profile["ServerHost"] as! String +//>>>>>>> shadowsocks/develop +// } +// serverMenuText = "\(serverMenuText) - \(profileName)" } } serversMenuItem.title = serverMenuText + if mode == "auto" { proxyMenuItem.title = "Proxy - Auto By PAC".localized autoModeMenuItem.state = 1 @@ -513,6 +531,22 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele whiteListDomainMenuItem.state = 0 whiteListIPMenuItem.state = 1 } + updateStatusItemUI() + } + + func updateStatusItemUI() { + let defaults = UserDefaults.standard + let mode = defaults.string(forKey: "ShadowsocksRunningMode") + if mode == "auto" { + statusItem?.title = "Auto".localized + } else if mode == "global" { + statusItem?.title = "Global".localized + } else if mode == "manual" { + statusItem?.title = "Manual".localized + } + let titleWidth = statusItem?.title!.size(withAttributes: [NSFontAttributeName: statusItem?.button!.font!]).width + let imageWidth:CGFloat = 22 + statusItem?.length = titleWidth! + imageWidth } func updateMainMenu() { @@ -625,7 +659,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele } // MARK: - + func handleURLEvent(_ event: NSAppleEventDescriptor, withReplyEvent replyEvent: NSAppleEventDescriptor) { if let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue { if let url = URL(string: urlString) { diff --git a/ShadowsocksX-NG/Base.lproj/Localizable.strings b/ShadowsocksX-NG/Base.lproj/Localizable.strings index bdbb480..7efac8f 100644 --- a/ShadowsocksX-NG/Base.lproj/Localizable.strings +++ b/ShadowsocksX-NG/Base.lproj/Localizable.strings @@ -80,3 +80,6 @@ "It's failed to update PAC by User Rules." = "It's failed to update PAC by User Rules."; +"Proxy - Manual" = "Proxy - Manual"; + +"Servers" = "Servers"; diff --git a/ShadowsocksX-NG/PACUtils.swift b/ShadowsocksX-NG/PACUtils.swift index ee3d3b9..d07d21e 100644 --- a/ShadowsocksX-NG/PACUtils.swift +++ b/ShadowsocksX-NG/PACUtils.swift @@ -40,7 +40,9 @@ func SyncPac() { } if needGenerate { - let _ = GeneratePACFile() + if !GeneratePACFile() { + NSLog("GeneratePACFile failed!") + } } } @@ -79,6 +81,7 @@ func GeneratePACFile() -> Bool { if !fileMgr.fileExists(atPath: WhiteListIPPACFilePath) { let src = Bundle.main.path(forResource: "whiteiplist", ofType: "pac") try! fileMgr.copyItem(atPath: src!, toPath: WhiteListIPPACFilePath) + } let socks5Port = UserDefaults.standard.integer(forKey: "LocalSocks5.ListenPort") diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 7d3d34a..f3ba664 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -379,14 +379,12 @@ class PreferencesWindowController: NSWindowController let shakeAnimation = CAKeyframeAnimation() let shakePath = CGMutablePath() - shakePath.move(to: CGPoint.init(x: NSMinX(frame), y: NSMinY(frame)), transform: CGAffineTransform.init()) -// CGPathMoveToPoint(shakePath, nil, NSMinX(frame), NSMinY(frame)) + + shakePath.move(to: CGPoint(x:NSMinX(frame), y:NSMinY(frame))) for _ in 1...numberOfShakes{ - shakePath.addLine(to: CGPoint.init(x: NSMinX(frame) - frame.size.width * CGFloat(vigourOfShake), y: NSMinY(frame))) - shakePath.addLine(to: CGPoint.init(x: NSMinX(frame) + frame.size.width * CGFloat(vigourOfShake), y: NSMinY(frame))) -// CGPathAddLineToPoint(shakePath, nil, NSMinX(frame) - frame.size.width * CGFloat(vigourOfShake), NSMinY(frame)) -// CGPathAddLineToPoint(shakePath, nil, NSMinX(frame) + frame.size.width * CGFloat(vigourOfShake), NSMinY(frame)) + shakePath.addLine(to: CGPoint(x: NSMinX(frame) - frame.size.width * CGFloat(vigourOfShake), y: NSMinY(frame))) + shakePath.addLine(to: CGPoint(x: NSMinX(frame) + frame.size.width * CGFloat(vigourOfShake), y: NSMinY(frame))) } shakePath.closeSubpath() diff --git a/ShadowsocksX-NG/ProxyConfHelper.m b/ShadowsocksX-NG/ProxyConfHelper.m index d292621..f836ab1 100644 --- a/ShadowsocksX-NG/ProxyConfHelper.m +++ b/ShadowsocksX-NG/ProxyConfHelper.m @@ -159,6 +159,7 @@ GCDWebServer *webServer = nil; [self addArguments4ManualSpecifyNetworkServices:args]; [self callHelper:args]; + [self stopPACServer]; } + (void)disableProxy:(NSString*) PACFilePath { @@ -201,12 +202,14 @@ GCDWebServer *webServer = nil; NSString * address = [defaults stringForKey:@"PacServer.ListenAddress"]; int port = (short)[defaults integerForKey:@"PacServer.ListenPort"]; - NSMutableDictionary* options = [NSMutableDictionary dictionary]; - [options setObject:[NSNumber numberWithInteger:port] forKey:GCDWebServerOption_Port]; - [options setObject:@YES forKey:@"BindToLocalhost"]; - - [webServer startWithOptions:options error:NULL]; -// [webServer startWithPort:port bonjourName:@"webserver"]; +// NSMutableDictionary* options = [NSMutableDictionary dictionary]; +// [options setObject:[NSNumber numberWithInteger:port] forKey:GCDWebServerOption_Port]; +// [options setObject:@YES forKey:@"BindToLocalhost"]; +// +// [webServer startWithOptions:options error:NULL]; + + [webServer startWithOptions:@{@"BindToLocalhost":@YES, @"Port":@(port)} error:nil]; + return [NSString stringWithFormat:@"%@%@:%d%@",@"http://",address,port,routerPath]; } diff --git a/ShadowsocksX-NG/ServerProfile.swift b/ShadowsocksX-NG/ServerProfile.swift index cbd396b..138d37d 100644 --- a/ShadowsocksX-NG/ServerProfile.swift +++ b/ShadowsocksX-NG/ServerProfile.swift @@ -101,6 +101,7 @@ class ServerProfile: NSObject { conf["local_address"] = defaults.string(forKey: "LocalSocks5.ListenAddress") as AnyObject? conf["timeout"] = NSNumber(value: UInt32(defaults.integer(forKey: "LocalSocks5.Timeout")) as UInt32) conf["auth"] = NSNumber(value: ota as Bool) + if(!ssrObfs.isEmpty){ conf["protocol"] = ssrProtocol as AnyObject? conf["protocol_param"] = ssrProtocolParam as AnyObject? diff --git a/ShadowsocksX-NG/zh-Hans.lproj/AdvPreferencesWindowController.strings b/ShadowsocksX-NG/zh-Hans.lproj/AdvPreferencesWindowController.strings index c26222d..bcde501 100644 --- a/ShadowsocksX-NG/zh-Hans.lproj/AdvPreferencesWindowController.strings +++ b/ShadowsocksX-NG/zh-Hans.lproj/AdvPreferencesWindowController.strings @@ -1,6 +1,6 @@ -/* Class = "NSButtonCell"; title = "启用 Udp Replay"; ObjectID = "1C3-4s-Apd"; */ -"1C3-4s-Apd.title" = "启用 Udp Replay"; +/* Class = "NSButtonCell"; title = "启用 Udp Relay"; ObjectID = "1C3-4s-Apd"; */ +"1C3-4s-Apd.title" = "启用 Udp Relay"; /* Class = "NSTextFieldCell"; title = "Don't change these preferences if you have no idea what are they."; ObjectID = "8wL-qv-5nD"; */ "8wL-qv-5nD.title" = "如果你不明白这些选项是什么,请不要修改"; diff --git a/ShadowsocksX-NG/zh-Hans.lproj/Localizable.strings b/ShadowsocksX-NG/zh-Hans.lproj/Localizable.strings index 7037028..63f7148 100644 --- a/ShadowsocksX-NG/zh-Hans.lproj/Localizable.strings +++ b/ShadowsocksX-NG/zh-Hans.lproj/Localizable.strings @@ -82,3 +82,4 @@ "It's failed to update PAC by User Rules." = "It's failed to update PAC by User Rules."; +"Servers" = "服务器";