diff --git a/ShadowsocksX-NG.xcodeproj/project.pbxproj b/ShadowsocksX-NG.xcodeproj/project.pbxproj index d3f372c..e93ba98 100755 --- a/ShadowsocksX-NG.xcodeproj/project.pbxproj +++ b/ShadowsocksX-NG.xcodeproj/project.pbxproj @@ -47,6 +47,8 @@ 9B5832071E7421B2009D5B7D /* virtual-server-icon-3.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B5832061E7421B2009D5B7D /* virtual-server-icon-3.png */; }; 9B58320B1E7422DB009D5B7D /* http.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B58320A1E7422DB009D5B7D /* http.png */; }; 9B5AA0AC209C43C200E8B659 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 9B5AA0AB209C43C200E8B659 /* Credits.rtf */; }; + 9B5D13292154A57C00F99F03 /* kcptun_client in Resources */ = {isa = PBXBuildFile; fileRef = 9B5D13282154A57C00F99F03 /* kcptun_client */; }; + 9B5D132A2154A62600F99F03 /* install_kcptun.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9B5D13272154A50700F99F03 /* install_kcptun.sh */; }; 9B6BF9541E27B2570061B9A7 /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B6BF9531E27B2570061B9A7 /* ServiceManagement.framework */; }; 9B7297E7214D69C300FD24AA /* libmbedcrypto.2.12.0.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 9B7297E5214D68F800FD24AA /* libmbedcrypto.2.12.0.dylib */; }; 9B7297EA214D7C6B00FD24AA /* ShareServerProfilesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B7297E8214D7C6B00FD24AA /* ShareServerProfilesWindowController.swift */; }; @@ -199,6 +201,8 @@ 9B5AA09F209C100C00E8B659 /* libsodium.23.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libsodium.23.dylib; sourceTree = ""; }; 9B5AA0A2209C103900E8B659 /* libcares.2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libcares.2.dylib; sourceTree = ""; }; 9B5AA0AB209C43C200E8B659 /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = ""; }; + 9B5D13272154A50700F99F03 /* install_kcptun.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = install_kcptun.sh; sourceTree = ""; }; + 9B5D13282154A57C00F99F03 /* kcptun_client */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = kcptun_client; sourceTree = ""; }; 9B6BF9531E27B2570061B9A7 /* ServiceManagement.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ServiceManagement.framework; path = System/Library/Frameworks/ServiceManagement.framework; sourceTree = SDKROOT; }; 9B7297E5214D68F800FD24AA /* libmbedcrypto.2.12.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libmbedcrypto.2.12.0.dylib; sourceTree = ""; }; 9B7297E8214D7C6B00FD24AA /* ShareServerProfilesWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareServerProfilesWindowController.swift; sourceTree = ""; }; @@ -300,6 +304,7 @@ 9B07EFB01D048E900052D9DF /* Support Files */ = { isa = PBXGroup; children = ( + 9B5D13252154A4B400F99F03 /* kcptun */, 9B5AA0A9209C41EC00E8B659 /* ss-local */, 1C82DBA31FA96C7400B32551 /* simple-obfs */, 9B16E5991F99FD0700E54DC5 /* icons8-Blind Filled-50.png */, @@ -455,6 +460,15 @@ name = privoxy; sourceTree = ""; }; + 9B5D13252154A4B400F99F03 /* kcptun */ = { + isa = PBXGroup; + children = ( + 9B5D13282154A57C00F99F03 /* kcptun_client */, + 9B5D13272154A50700F99F03 /* install_kcptun.sh */, + ); + path = kcptun; + sourceTree = ""; + }; 9B9F13A21E8A282C00DE4794 /* Products */ = { isa = PBXGroup; children = ( @@ -608,6 +622,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9B5D132A2154A62600F99F03 /* install_kcptun.sh in Resources */, 9B7297E7214D69C300FD24AA /* libmbedcrypto.2.12.0.dylib in Resources */, 9BCB1D6C20A15B0E005BABE7 /* libsodium.23.dylib in Resources */, 9BCB1D6D20A15B0E005BABE7 /* libcares.2.dylib in Resources */, @@ -638,6 +653,7 @@ 9BAFE2E21E83ED7F00F71CCE /* PreferencesWinController.xib in Resources */, 9B0BFFEB1D0460A70040E62B /* Assets.xcassets in Resources */, 08FCA0FF1E24BE1A0070984F /* example-gui-config.json in Resources */, + 9B5D13292154A57C00F99F03 /* kcptun_client in Resources */, 1C82DBA81FA96C7500B32551 /* obfs-local in Resources */, 9B938D9D1E864B38005F5636 /* menu_p_icon.png in Resources */, 9B938D9B1E864B38005F5636 /* menu_m_icon.png in Resources */, diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index a7e0cf7..b2222c6 100755 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -83,6 +83,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele InstallSSLocal() InstallPrivoxy() InstallSimpleObfs() + InstallKcptun() + // Prepare defaults let defaults = UserDefaults.standard defaults.register(defaults: [ diff --git a/ShadowsocksX-NG/LaunchAgentUtils.swift b/ShadowsocksX-NG/LaunchAgentUtils.swift index 0ef1af9..9c0b258 100644 --- a/ShadowsocksX-NG/LaunchAgentUtils.swift +++ b/ShadowsocksX-NG/LaunchAgentUtils.swift @@ -210,6 +210,26 @@ func InstallSimpleObfs() { } } +// -------------------------------------------------------------------------------- +// MARK: kcptun + +func InstallKcptun() { + let fileMgr = FileManager.default + let homeDir = NSHomeDirectory() + let appSupportDir = homeDir+APP_SUPPORT_DIR + if !fileMgr.fileExists(atPath: appSupportDir + "kcptun_\(KCPTUN_CLIENT_VERSION)/kcptun_client") { + let bundle = Bundle.main + let installerPath = bundle.path(forResource: "install_kcptun", ofType: "sh") + let task = Process.launchedProcess(launchPath: "/bin/sh", arguments: [installerPath!]) + task.waitUntilExit() + if task.terminationStatus == 0 { + NSLog("Install kcptun succeeded.") + } else { + NSLog("Install kcptun failed.") + } + } +} + // -------------------------------------------------------------------------------- // MARK: privoxy diff --git a/ShadowsocksX-NG/kcptun/install_kcptun.sh b/ShadowsocksX-NG/kcptun/install_kcptun.sh new file mode 100644 index 0000000..5f43fa5 --- /dev/null +++ b/ShadowsocksX-NG/kcptun/install_kcptun.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# install_kcptun.sh +# ShadowsocksX-NG +# +# Created by 邱宇舟 on 2018/9/21. +# Copyright © 2018年 qiuyuzhou. All rights reserved. + +# https://github.com/shadowsocks/kcptun/releases + +VERSION="v20170718" + +cd `dirname "${BASH_SOURCE[0]}"` + +mkdir -p "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_$VERSION" +cp -f kcptun_client "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_$VERSION/" + +ln -sfh "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_$VERSION/kcptun_client" "$HOME/Library/Application Support/ShadowsocksX-NG/plugins/kcptun" + +echo "install kcptun done" diff --git a/ShadowsocksX-NG/kcptun/kcptun_client b/ShadowsocksX-NG/kcptun/kcptun_client new file mode 100755 index 0000000..ccb973e Binary files /dev/null and b/ShadowsocksX-NG/kcptun/kcptun_client differ