diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c223c1f..7c226d82 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,24 @@ jobs: runs-on: macos-10.15 steps: - - uses: actions/checkout@v1 - - name: Run unit test - run: | - set -o pipefail && xcodebuild test -workspace ShadowsocksX-NG.xcworkspace -scheme ShadowsocksX-NG|xcpretty + + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 + + - name: Build + run: | + brew install automake + make debug + make debug-dmg + shasum -a 256 build/Debug/ShadowsocksX-NG.dmg > build/Debug/ShadowsocksX-NG.dmg.checksum + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ShadowsocksX-NG + path: | + build/Debug/ShadowsocksX-NG.dmg + build/Debug/ShadowsocksX-NG.dmg.checksum diff --git a/.gitignore b/.gitignore index c8e7652c..27cd50c6 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,9 @@ deps/dist deps/pcre* deps/libev* deps/privoxy* + +ShadowsocksX-NG/kcptun/client +ShadowsocksX-NG/privoxy/privoxy +ShadowsocksX-NG/simple-obfs/obfs-local +ShadowsocksX-NG/ss-local/ss-local +ShadowsocksX-NG/v2ray-plugin/v2ray-plugin diff --git a/.gitmodules b/.gitmodules index 0fb1613c..c8500022 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,3 +28,6 @@ [submodule "deps/kcptun"] path = deps/kcptun url = https://github.com/xtaci/kcptun +[submodule "deps/simple-obfs"] + path = deps/simple-obfs + url = https://github.com/shadowsocks/simple-obfs diff --git a/Makefile b/Makefile index d8d848f8..88f98f3a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ .PHONY: all all: debug - echo "Deps build done" .PHONY: debug debug: deps/dist diff --git a/ShadowsocksX-NG/LaunchAgentUtils.swift b/ShadowsocksX-NG/LaunchAgentUtils.swift index e7a47943..a0efb3ec 100644 --- a/ShadowsocksX-NG/LaunchAgentUtils.swift +++ b/ShadowsocksX-NG/LaunchAgentUtils.swift @@ -8,11 +8,6 @@ import Foundation -//let SS_LOCAL_VERSION = "3.2.5" -//let KCPTUN_CLIENT_VERSION = "v20190905_1" -//let V2RAY_PLUGIN_VERSION = "v1.3.1-9-gddd7ab4" -//let PRIVOXY_VERSION = "3.0.26.static" -let SIMPLE_OBFS_VERSION = "0.0.5_1" let APP_SUPPORT_DIR = "/Library/Application Support/ShadowsocksX-NG/" let USER_CONFIG_DIR = "/.ShadowsocksX-NG/" let LAUNCH_AGENT_DIR = "/Library/LaunchAgents/" @@ -64,7 +59,7 @@ func generateSSLocalLauchAgentPlist() -> Bool { let dyld_library_paths = [ NSHomeDirectory() + APP_SUPPORT_DIR + "ss-local/", NSHomeDirectory() + APP_SUPPORT_DIR + "plugins/", - ] + ] let dict: NSMutableDictionary = [ "Label": "com.qiuyuzhou.shadowsocksX-NG.local", @@ -113,24 +108,31 @@ func InstallSSLocal() { let fileMgr = FileManager.default let homeDir = NSHomeDirectory() let appSupportDir = homeDir+APP_SUPPORT_DIR - if !fileMgr.fileExists(atPath: appSupportDir + "ss-local/ss-local") { - let bundle = Bundle.main - let installerPath = bundle.path(forResource: "install_ss_local.sh", ofType: nil) - let task = Process.launchedProcess(launchPath: installerPath!, arguments: [""]) - task.waitUntilExit() - if task.terminationStatus == 0 { - NSLog("Install ss-local succeeded.") - } else { - NSLog("Install ss-local failed.") + if fileMgr.fileExists(atPath: appSupportDir + "ss-local/ss-local") { + do { + try fileMgr.removeItem(atPath: appSupportDir + "ss-local/ss-local") + } catch { + NSLog("Remove old ss-local error") } } + + let bundle = Bundle.main + let installerPath = bundle.path(forResource: "install_ss_local.sh", ofType: nil) + let task = Process.launchedProcess(launchPath: installerPath!, arguments: [""]) + task.waitUntilExit() + if task.terminationStatus == 0 { + NSLog("Install ss-local succeeded.") + } else { + NSLog("Install ss-local failed.") + } + } func writeSSLocalConfFile(_ conf:[String:AnyObject]) -> Bool { do { let filepath = NSHomeDirectory() + APP_SUPPORT_DIR + "ss-local-config.json" var data: Data = try JSONSerialization.data(withJSONObject: conf, options: .prettyPrinted) - + // https://github.com/shadowsocks/ShadowsocksX-NG/issues/1104 // This is NSJSONSerialization.dataWithJSONObject that likes to insert additional backslashes. // Escaped forward slashes is also valid json. @@ -182,7 +184,7 @@ func SyncSSLocal() { execute: { () in StartSSLocal() - }) + }) } else { StartSSLocal() } @@ -204,18 +206,24 @@ func InstallSimpleObfs() { let fileMgr = FileManager.default let homeDir = NSHomeDirectory() let appSupportDir = homeDir + APP_SUPPORT_DIR - if !fileMgr.fileExists(atPath: appSupportDir + "simple-obfs-\(SIMPLE_OBFS_VERSION)/obfs-local") - || !fileMgr.fileExists(atPath: appSupportDir + "plugins/obfs-local") { - let bundle = Bundle.main - let installerPath = bundle.path(forResource: "install_simple_obfs.sh", ofType: nil) - let task = Process.launchedProcess(launchPath: "/bin/sh", arguments: [installerPath!]) - task.waitUntilExit() - if task.terminationStatus == 0 { - NSLog("Install simple-obfs succeeded.") - } else { - NSLog("Install simple-obfs failed.") + if fileMgr.fileExists(atPath: appSupportDir + "simple-obfs/obfs-local") { + do { + try fileMgr.removeItem(atPath: appSupportDir + "simple-obfs/obfs-local") + } catch { + NSLog("Remove old simple-obfs error") } } + + let bundle = Bundle.main + let installerPath = bundle.path(forResource: "install_simple_obfs.sh", ofType: nil) + let task = Process.launchedProcess(launchPath: "/bin/sh", arguments: [installerPath!]) + task.waitUntilExit() + if task.terminationStatus == 0 { + NSLog("Install simple-obfs succeeded.") + } else { + NSLog("Install simple-obfs failed.") + } + } // -------------------------------------------------------------------------------- @@ -225,17 +233,22 @@ func InstallKcptun() { let fileMgr = FileManager.default let homeDir = NSHomeDirectory() let appSupportDir = homeDir+APP_SUPPORT_DIR - if !fileMgr.fileExists(atPath: appSupportDir + "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.") + if fileMgr.fileExists(atPath: appSupportDir + "kcptun/client") { + do { + try fileMgr.removeItem(atPath: appSupportDir + "kcptun/client") + } catch { + NSLog("Remove old kcptun client error") } } + 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.") + } } // -------------------------------------------------------------------------------- @@ -245,24 +258,29 @@ func InstallV2rayPlugin() { let fileMgr = FileManager.default let homeDir = NSHomeDirectory() let appSupportDir = homeDir+APP_SUPPORT_DIR - if !fileMgr.fileExists(atPath: appSupportDir + "v2ray-plugin/v2ray-plugin") { - let bundle = Bundle.main - let installerPath = bundle.path(forResource: "install_v2ray_plugin", ofType: "sh") - let task = Process.launchedProcess(launchPath: "/bin/sh", arguments: [installerPath!]) - task.waitUntilExit() - if task.terminationStatus == 0 { - NSLog("Install v2ray-plugin succeeded.") - } else { - NSLog("Install v2ray-plugin failed.") + if fileMgr.fileExists(atPath: appSupportDir + "v2ray-plugin/v2ray-plugin") { + do { + try fileMgr.removeItem(atPath: appSupportDir + "v2ray-plugin/v2ray-plugin") + } catch { + NSLog("Remove old v2ray-plugin error") } } + let bundle = Bundle.main + let installerPath = bundle.path(forResource: "install_v2ray_plugin", ofType: "sh") + let task = Process.launchedProcess(launchPath: "/bin/sh", arguments: [installerPath!]) + task.waitUntilExit() + if task.terminationStatus == 0 { + NSLog("Install v2ray-plugin succeeded.") + } else { + NSLog("Install v2ray-plugin failed.") + } } // -------------------------------------------------------------------------------- // MARK: privoxy func generatePrivoxyLauchAgentPlist() -> Bool { - let privoxyPath = NSHomeDirectory() + APP_SUPPORT_DIR + "privoxy" + let privoxyPath = NSHomeDirectory() + APP_SUPPORT_DIR + "privoxy/privoxy" let logFilePath = NSHomeDirectory() + "/Library/Logs/privoxy.log" let launchAgentDirPath = NSHomeDirectory() + LAUNCH_AGENT_DIR let plistFilepath = launchAgentDirPath + LAUNCH_AGENT_CONF_PRIVOXY_NAME @@ -322,25 +340,31 @@ func InstallPrivoxy() { let fileMgr = FileManager.default let homeDir = NSHomeDirectory() let appSupportDir = homeDir+APP_SUPPORT_DIR - if !fileMgr.fileExists(atPath: appSupportDir + "privoxy/privoxy") { - let bundle = Bundle.main - let installerPath = bundle.path(forResource: "install_privoxy.sh", ofType: nil) - let task = Process.launchedProcess(launchPath: installerPath!, arguments: [""]) - task.waitUntilExit() - if task.terminationStatus == 0 { - NSLog("Install privoxy succeeded.") - } else { - NSLog("Install privoxy failed.") + if fileMgr.fileExists(atPath: appSupportDir + "privoxy/privoxy") { + do { + try fileMgr.removeItem(atPath: appSupportDir + "privoxy/privoxy") + } catch { + NSLog("Remove old privoxy error") } } + let bundle = Bundle.main + let installerPath = bundle.path(forResource: "install_privoxy.sh", ofType: nil) + let task = Process.launchedProcess(launchPath: installerPath!, arguments: [""]) + task.waitUntilExit() + if task.terminationStatus == 0 { + NSLog("Install privoxy succeeded.") + } else { + NSLog("Install privoxy failed.") + } + let userConfigDir = homeDir + USER_CONFIG_DIR // Make dir: '~/.ShadowsocksX-NG' if !fileMgr.fileExists(atPath: userConfigDir) { try! fileMgr.createDirectory(atPath: userConfigDir - , withIntermediateDirectories: true, attributes: nil) + , withIntermediateDirectories: true, attributes: nil) } - + // Install empty `user-privoxy.config` file. let userConfigPath = userConfigDir + "user-privoxy.config" if !fileMgr.fileExists(atPath: userConfigPath) { @@ -410,7 +434,7 @@ func SyncPrivoxy() { execute: { () in StartPrivoxy() - }) + }) } else { StartPrivoxy() } diff --git a/ShadowsocksX-NG/privoxy/install_privoxy.sh b/ShadowsocksX-NG/privoxy/install_privoxy.sh index 9d2884d8..5044bf34 100755 --- a/ShadowsocksX-NG/privoxy/install_privoxy.sh +++ b/ShadowsocksX-NG/privoxy/install_privoxy.sh @@ -11,7 +11,5 @@ cd "$(dirname "${BASH_SOURCE[0]}")" mkdir -p "$HOME/Library/Application Support/ShadowsocksX-NG/privoxy" cp -f privoxy "$HOME/Library/Application Support/ShadowsocksX-NG/privoxy/" -rm -f "$HOME/Library/Application Support/ShadowsocksX-NG/privoxy" -ln -s "$HOME/Library/Application Support/ShadowsocksX-NG/privoxy/privoxy" "$HOME/Library/Application Support/ShadowsocksX-NG/privoxy" echo done diff --git a/ShadowsocksX-NG/simple-obfs/install_simple_obfs.sh b/ShadowsocksX-NG/simple-obfs/install_simple_obfs.sh index 5ea3aa64..07b59703 100644 --- a/ShadowsocksX-NG/simple-obfs/install_simple_obfs.sh +++ b/ShadowsocksX-NG/simple-obfs/install_simple_obfs.sh @@ -5,7 +5,7 @@ FILE_DIR=`dirname "${BASH_SOURCE[0]}"` cd "$FILE_DIR" NGDir="$HOME/Library/Application Support/ShadowsocksX-NG" -TargetDir="$NGDir/simple-obfs-0.0.5_1" +TargetDir="$NGDir/simple-obfs" PluginDir="$NGDir/plugins" echo ngdir: ${NGDir} diff --git a/ShadowsocksX-NG/simple-obfs/obfs-local b/ShadowsocksX-NG/simple-obfs/obfs-local deleted file mode 100755 index e1976a3e..00000000 Binary files a/ShadowsocksX-NG/simple-obfs/obfs-local and /dev/null differ diff --git a/deps/Makefile b/deps/Makefile index 1c9faf81..ff51bd3f 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -1,13 +1,12 @@ ARCH ?= $(shell uname -m) +ifeq ($(ARCH),arm64) +ARCH := aarch64 +endif TARGET := $(ARCH)-apple-macos10.12 JOBS := $(shell getconf _NPROCESSORS_ONLN) GOROOT := $${PWD}/../dist/go GO := $(GOROOT)/bin/go -ifeq ($(ARCH),arm64) -ARCH := aarch64 -endif - ifeq ($(ARCH),x86_64) GOARCH := amd64 else @@ -16,8 +15,8 @@ endif .PHONY: all all: - $(MAKE) ARCH=x86_64 shadowsocks-libev privoxy v2ray-plugin kcptun - $(MAKE) ARCH=aarch64 shadowsocks-libev privoxy v2ray-plugin kcptun + $(MAKE) ARCH=x86_64 shadowsocks-libev privoxy simple-obfs v2ray-plugin kcptun + $(MAKE) ARCH=aarch64 shadowsocks-libev privoxy simple-obfs v2ray-plugin kcptun $(MAKE) universal .PHONY: universal @@ -40,6 +39,15 @@ universal: -output $${PWD}/dist/universal/privoxy/sbin/privoxy cp $${PWD}/dist/universal/privoxy/sbin/privoxy $${PWD}/../ShadowsocksX-NG/privoxy/ + # simple-obfs + mkdir -p $${PWD}/dist/universal/simple-obfs/bin + lipo \ + $${PWD}/dist/x86_64/simple-obfs/bin/obfs-local \ + $${PWD}/dist/aarch64/simple-obfs/bin/obfs-local \ + -create \ + -output $${PWD}/dist/universal/simple-obfs/bin/obfs-local + cp $${PWD}/dist/universal/simple-obfs/bin/obfs-local $${PWD}/../ShadowsocksX-NG/simple-obfs/ + # v2ray-plugin mkdir -p $${PWD}/dist/universal/v2ray-plugin/bin lipo \ @@ -95,15 +103,17 @@ libev: .PHONY: privoxy privoxy: - [ -f privoxy.tar.gz ] || curl -L -o privoxy.tar.gz 'https://www.privoxy.org/sf-download-mirror/Sources/3.0.28%20%28stable%29/privoxy-3.0.28-stable-src.tar.gz' + [ -f privoxy.tar.gz ] || curl -L -o privoxy.tar.gz 'https://www.privoxy.org/sf-download-mirror/Sources/3.0.33%20%28stable%29/privoxy-3.0.33-stable-src.tar.gz' tar -xf privoxy.tar.gz - cd privoxy-3.0.28-stable \ + cd privoxy-3.0.33-stable \ + && patch -Ru configure.in < $${PWD}/../patch/privoxy/configure.in.patch \ && autoreconf -fi \ - && LDFLAGS="-target $(TARGET)" CFLAGS="-target $(TARGET)" ./configure --prefix $${PWD}/../dist/$(ARCH)/privoxy \ + && LDFLAGS="-target $(TARGET) -L$${PWD}/../dist/$(ARCH)/pcre/lib" \ + CPPFLAGS="-target $(TARGET) -Dunix" \ + CFLAGS="-target $(TARGET) -Dunix" \ + ./configure --prefix $${PWD}/../dist/$(ARCH)/privoxy \ --host=$(TARGET) \ - --disable-dependency-tracking \ - --enable-static \ - --disable-shared \ + --disable-debug \ && make -j$(JOBS) \ && make install \ && make clean @@ -159,6 +169,20 @@ shadowsocks-libev: pcre libev c-ares libsodium mbedtls && make install \ && make clean +.PHONY: simple-obfs +simple-obfs: + cd simple-obfs \ + && ./autogen.sh \ + && CXXFLAGS="-target $(TARGET)" CFLAGS="-target $(TARGET)" ./configure --prefix=$${PWD}/../dist/$(ARCH)/simple-obfs \ + --host=$(TARGET) \ + --disable-dependency-tracking \ + --enable-static \ + --disable-shared \ + --with-ev=$${PWD}/../dist/$(ARCH)/libev \ + && make -j$(JOBS) \ + && make install \ + && make clean + .PHONY: v2ray-plugin v2ray-plugin: go cd v2ray-plugin \ diff --git a/deps/patch/privoxy/configure.in.patch b/deps/patch/privoxy/configure.in.patch new file mode 100644 index 00000000..f721c773 --- /dev/null +++ b/deps/patch/privoxy/configure.in.patch @@ -0,0 +1,11 @@ +--- configure.in 2023-01-05 14:37:57 ++++ configure.in.1 2023-01-05 14:37:40 +@@ -1090,7 +1090,7 @@ + fi + fi + +-use_static_pcre="yes" ++ + # If we have libpcre and either we also have pcreposix or + # we don't need pcreposix, then link pcre dynamically; else + # build it and link statically diff --git a/deps/simple-obfs b/deps/simple-obfs new file mode 160000 index 00000000..486bebd9 --- /dev/null +++ b/deps/simple-obfs @@ -0,0 +1 @@ +Subproject commit 486bebd9208539058e57e23a12f23103016e09b4 diff --git a/deps/v2ray-plugin b/deps/v2ray-plugin index ddd7ab46..b9717056 160000 --- a/deps/v2ray-plugin +++ b/deps/v2ray-plugin @@ -1 +1 @@ -Subproject commit ddd7ab46b4aeee0ca8b272efed9d7da3e3a6e52c +Subproject commit b9717056b251747149cacb44458fe02e420b9d9b