浏览代码

Merge pull request #426 from 1715173329/ss-rust

shadowsocks-rust: add new package
coolsnowwolf 4 年之前
父节点
当前提交
69e671241f

+ 9 - 2
luci-app-ssr-plus/Makefile

@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=luci-app-ssr-plus
 PKG_VERSION:=183
-PKG_RELEASE:=8
+PKG_RELEASE:=9
 
 define Package/$(PKG_NAME)/conffiles
 /etc/config/shadowsocksr
@@ -14,10 +14,15 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks
 	bool "Include Shadowsocks"
 	default y if i386||x86_64||arm||aarch64
 
+config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Rust
+	bool "Include Shadowsocks Rust (AEAD ciphers only)"
+	depends on aarch64||arm||i386||mips||mipsel||x86_64
+	default y if x86_64||aarch64
+
 config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_plugin
 	bool "Include Shadowsocks V2ray Plugin"
 	default n
-	
+
 config PACKAGE_$(PKG_NAME)_INCLUDE_Xray
 	bool "Include Xray (V2RAY/Trojan-GO implemented)"
 	default y if i386||x86_64||arm||aarch64
@@ -51,6 +56,8 @@ LUCI_DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsm
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-local \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-redir \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:simple-obfs \
+	+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Rust:shadowsocks-rust-sslocal \
+	+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Rust:simple-obfs \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_plugin:v2ray-plugin \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Xray:xray-core \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:trojan \

+ 1 - 1
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua

@@ -149,7 +149,7 @@ end
 if is_finded("ssr-redir") then
 	o:value("ssr", translate("ShadowsocksR"))
 end
-if is_finded("ss-redir") then
+if is_finded("sslocal") or is_finded("ss-redir") then
 	o:value("ss", translate("Shadowsocks New Version"))
 end
 if is_finded("trojan") then

+ 16 - 5
luci-app-ssr-plus/root/etc/init.d/shadowsocksr

@@ -339,7 +339,10 @@ start_udp() {
 	case "$type" in
 	ss | ssr)
 		gen_config_file $UDP_RELAY_SERVER $type 2 $tmp_udp_port
-		ln_start_bin $(first_type ${type}-redir) ${type}-redir -c $udp_config_file -U
+		ss_program="$(first_type ${type}local ${type}-redir)"
+		[ "$(printf '%s' "$ss_program" | awk -F '/' '{print $NF}')" = "${type}local" ] && \
+			ss_extra_arg="--protocol redir -u" || ss_extra_arg="-U"
+		ln_start_bin $ss_program ${type}-redir -c $udp_config_file $ss_extra_arg
 		echolog "UDP TPROXY Relay:$(get_name $type) Started!"
 		;;
 	v2ray)
@@ -380,12 +383,14 @@ start_shunt() {
 	case "$type" in
 	ss | ssr)
 		gen_config_file $SHUNT_SERVER $type 3 $tmp_shunt_port
-		ln_start_bin $(first_type ${type}-redir) ${type}-redir -c $shunt_config_file
+		ss_program="$(first_type ${type}local ${type}-redir)"
+		[ "$(printf '%s' "$ss_program" | awk -F '/' '{print $NF}')" = "${type}local" ] && ss_extra_arg="--protocol redir"
+		ln_start_bin $ss_program ${type}-redir -c $shunt_config_file $ss_extra_arg
 		if [ -n "$tmp_local_port" ]; then
 			local tmp_port=$tmp_local_port
 		else
 			local tmp_port=$tmp_shunt_local_port
-			ln_start_bin $(first_type ${type}-local) ${type}-local -c $shunt_dns_config_file
+			ln_start_bin $(first_type ${type}local ${type}-local) ${type}-local -c $shunt_dns_config_file
 		fi
 		ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
 		echolog "shunt:$(get_name $type) Started!"
@@ -465,7 +470,10 @@ start_local() {
 	case "$type" in
 	ss | ssr)
 		gen_config_file $LOCAL_SERVER $type 4 $local_port
-		ln_start_bin $(first_type ${type}-local) ${type}-local -c $local_config_file -u
+		ss_program="$(first_type ${type}local ${type}-redir)"
+		[ "$(printf '%s' "$ss_program" | awk -F '/' '{print $NF}')" = "${type}local" ] && \
+			ss_extra_arg="-U" || ss_extra_arg="-u"
+		ln_start_bin $ss_program ${type}-local -c $local_config_file $ss_extra_arg
 		echolog "Global_Socks5:$(get_name $type) Started!"
 		;;
 	v2ray)
@@ -525,8 +533,11 @@ Start_Run() {
 	case "$type" in
 	ss | ssr)
 		gen_config_file $GLOBAL_SERVER $type 1 $tcp_port
+		ss_program="$(first_type ${type}local ${type}-redir)"
+		[ "$(printf '%s' "$ss_program" | awk -F '/' '{print $NF}')" = "${type}local" ] && \
+			{ ss_extra_arg="--protocol redir"; case ${ARG_OTA} in '-u') ARG_OTA='-U';; '-U') ARG_OTA='-u';; esac; }
 		for i in $(seq 1 $threads); do
-			ln_start_bin "$(first_type ${type}-redir)" ${type}-redir -c $tcp_config_file $ARG_OTA
+			ln_start_bin "$ss_program" ${type}-redir -c $tcp_config_file $ARG_OTA $ss_extra_arg
 		done
 		echolog "Main node:$(get_name $type) $threads Threads Started!"
 		;;

+ 112 - 0
shadowsocks-rust/Makefile

@@ -0,0 +1,112 @@
+#
+# Copyright (C) 2017-2020 Yousong Zhou <[email protected]>
+#
+# Copyright (C) 2021 ImmortalWrt
+# <https://immortalwrt.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=shadowsocks-rust
+PKG_VERSION:=1.9.2
+PKG_RELEASE:=1
+
+PKG_SOURCE_HEADER:=shadowsocks-v$(PKG_VERSION)
+PKG_SOURCE_BODY:=unknown-linux-musl
+PKG_SOURCE_FOOTER:=tar.xz
+PKG_SOURCE_URL:=https://github.com/shell-script/openwrt-shadowsocks-rust/releases/download/v$(PKG_VERSION)/
+
+ifeq ($(ARCH),aarch64)
+  PKG_SOURCE:=$(PKG_SOURCE_HEADER).aarch64-$(PKG_SOURCE_BODY).$(PKG_SOURCE_FOOTER)
+  PKG_HASH:=318e0538386e52025448e7dc1e67b71bd399981e386ba0a54802ff3c13b25016
+else ifeq ($(ARCH),arm)
+  # Referred to golang/golang-values.mk
+  ARM_CPU_FEATURES:=$(word 2,$(subst +,$(space),$(call qstrip,$(CONFIG_CPU_TYPE))))
+  ifeq ($(ARM_CPU_FEATURES),)
+    PKG_SOURCE:=$(PKG_SOURCE_HEADER).arm-$(PKG_SOURCE_BODY)eabi.$(PKG_SOURCE_FOOTER)
+    PKG_HASH:=38d15003799d91ebecb89be61eccb1f3b31ca4e11d6d5ecfcbd367e10cc42319
+  else ifneq ($(filter $(ARM_CPU_FEATURES),vfp vfpv2),)
+    PKG_SOURCE:=$(PKG_SOURCE_HEADER).arm-$(PKG_SOURCE_BODY)eabihf.$(PKG_SOURCE_FOOTER)
+    PKG_HASH:=e31bfbba903ac171b133b897b2a0e183833002b141db74b95d94873d32c07d49
+  else
+    PKG_SOURCE:=$(PKG_SOURCE_HEADER).armv7-$(PKG_SOURCE_BODY)eabihf.$(PKG_SOURCE_FOOTER)
+    PKG_HASH:=e1ed14d86b4e7f6b88da3ff5b99431a707eb7a23f0e063ada86e85e7e84a8ec1
+  endif
+else ifeq ($(ARCH),i386)
+  ifeq ($(CONFIG_TARGET_x86_geode)$(CONFIG_TARGET_x86_legacy),y)
+    PKG_SOURCE:=$(PKG_SOURCE_HEADER).i586-$(PKG_SOURCE_BODY).$(PKG_SOURCE_FOOTER)
+    PKG_HASH:=f08f6ab355495f5553e388b347f7bf70502ae3f53f3979267fcfe1dd6a7a565f
+  else
+    PKG_SOURCE:=$(PKG_SOURCE_HEADER).i686-$(PKG_SOURCE_BODY).$(PKG_SOURCE_FOOTER)
+    PKG_HASH:=a5021533dad53a877d6265677dea6f5a6f500f135d47327c98beeb85642180ce
+  endif
+else ifeq ($(ARCH),mips)
+  PKG_SOURCE:=$(PKG_SOURCE_HEADER).mips-$(PKG_SOURCE_BODY).$(PKG_SOURCE_FOOTER)
+  PKG_HASH:=f76de3d0c4b2e3703faabfb730d817b5b5610ec3701827282c18ca44c84f6a28
+else ifeq ($(ARCH),mipsel)
+  PKG_SOURCE:=$(PKG_SOURCE_HEADER).mipsel-$(PKG_SOURCE_BODY).$(PKG_SOURCE_FOOTER)
+  PKG_HASH:=953d2feb430906edcb5ed6994510b3bded141ae8abb3b77dd6bfc80aac8740d1
+else ifeq ($(ARCH),x86_64)
+  PKG_SOURCE:=$(PKG_SOURCE_HEADER).x86_64-$(PKG_SOURCE_BODY).$(PKG_SOURCE_FOOTER)
+  PKG_HASH:=adc68983961209cdf3c7a465911bdfabc52e7e08132a6dbcd0db77eaa924ec3f
+# Set the default value to make OpenWrt Package Checker happy
+else
+  PKG_SOURCE:=dummy
+  PKG_HASH:=dummy
+endif
+
+PKG_MAINTAINER:=Tianling Shen <[email protected]>
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE
+
+include $(INCLUDE_DIR)/package.mk
+
+TAR_CMD:=$(HOST_TAR) -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
+
+define Package/shadowsocks-rust/Default
+  PKG_CONFIG_DEPENDS+=CONFIG_SHADOWSOCKS_RUST_$(1)_COMPRESS_UPX
+
+  define Package/shadowsocks-rust-$(1)
+    SECTION:=net
+    CATEGORY:=Network
+    SUBMENU:=Web Servers/Proxies
+    TITLE:=shadowsocks-rust $(1)
+    URL:=https://github.com/shadowsocks/shadowsocks-rust
+    DEPENDS:=@(aarch64||arm||i386||mips||mipsel||x86_64) @USE_MUSL
+  endef
+
+  define Package/shadowsocks-rust-$(1)/config
+    config SHADOWSOCKS_RUST_$(1)_COMPRESS_UPX
+      bool "Compress $(1) with UPX"
+      default y
+  endef
+
+  define Package/shadowsocks-rust-$(1)/install
+	$$(INSTALL_DIR) $$(1)/usr/bin
+	$$(INSTALL_BIN) $$(PKG_BUILD_DIR)/$(1) $$(1)/usr/bin
+  endef
+endef
+
+PKG_CONFIG_DEPENDS:=
+SHADOWSOCKS_COMPONENTS:=sslocal ssmanager ssserver ssurl
+define shadowsocks-rust/templates
+  $(foreach component,$(SHADOWSOCKS_COMPONENTS),
+    $(call Package/shadowsocks-rust/Default,$(component))
+  )
+endef
+$(eval $(call shadowsocks-rust/templates))
+
+define Build/Compile
+$(foreach component,$(SHADOWSOCKS_COMPONENTS),
+  ifneq ($(CONFIG_SHADOWSOCKS_RUST_$(component)_COMPRESS_UPX),)
+	$(STAGING_DIR_HOST)/bin/upx --lzma --best $(PKG_BUILD_DIR)/$(component)
+  endif
+)
+endef
+
+$(foreach component,$(SHADOWSOCKS_COMPONENTS), \
+  $(eval $(call BuildPackage,shadowsocks-rust-$(component))) \
+)