Browse Source

Merge pull request #589 from 1715173329/obfs

luci-app-ssr-plus: adapt simple-obfs plugin
coolsnowwolf 4 years ago
parent
commit
bc95330048

+ 11 - 3
luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua

@@ -24,6 +24,7 @@ local proxy = ucic:get_first(name, 'server_subscribe', 'proxy', '0')
 local switch = ucic:get_first(name, 'server_subscribe', 'switch', '1')
 local subscribe_url = ucic:get_first(name, 'server_subscribe', 'subscribe_url', {})
 local filter_words = ucic:get_first(name, 'server_subscribe', 'filter_words', '过期时间/剩余流量')
+local v2_ss = luci.sys.exec('type -t -p ss-redir sslocal') ~= "" and "ss" or "v2ray"
 local v2_tj = luci.sys.exec('type -t -p trojan') ~= "" and "trojan" or "v2ray"
 local log = function(...)
 	print(os.date("%Y-%m-%d %H:%M:%S ") .. table.concat({...}, " "))
@@ -220,7 +221,8 @@ local function processData(szType, content)
 		local method = userinfo:sub(1, userinfo:find(":") - 1)
 		local password = userinfo:sub(userinfo:find(":") + 1, #userinfo)
 		result.alias = UrlDecode(alias)
-		result.type = "ss"
+		result.type = v2_ss
+		result.v2ray_protocol = "shadowsocks"
 		result.server = host[1]
 		if host[2]:find("/%?") then
 			local query = split(host[2], "/%?")
@@ -239,6 +241,10 @@ local function processData(szType, content)
 				else
 					result.plugin = plugin_info
 				end
+				-- 部分机场下发的插件名为 simple-obfs,这里应该改为 obfs-local
+				if result.plugin == "simple-obfs" then
+					result.plugin = "obfs-local"
+				end
 			end
 		else
 			result.server_port = host[2]
@@ -251,7 +257,8 @@ local function processData(szType, content)
 			result.server = nil
 		end
 	elseif szType == "ssd" then
-		result.type = "ss"
+		result.type = v2_ss
+		result.v2ray_protocol = "shadowsocks"
 		result.server = content.server
 		result.server_port = content.port
 		result.password = content.password
@@ -260,8 +267,9 @@ local function processData(szType, content)
 		result.plugin_opts = content.plugin_options
 		result.alias = "[" .. content.airport .. "] " .. content.remarks
 		if checkTabValue(encrypt_methods_ss)[result.encrypt_method_ss] then
-			-- 1202 年了还不支持 SS AEAD 的屑机场
 			result.server = nil
+		elseif result.plugin == "simple-obfs" then
+			result.plugin = "obfs-local"
 		end
 	elseif szType == "trojan" then
 		local idx_sp = 0

+ 22 - 22
naiveproxy/Makefile

@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=naiveproxy
 PKG_VERSION:=91.0.4472.77-1
-PKG_RELEASE:=1
+PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/klzgrad/naiveproxy/tar.gz/v$(PKG_VERSION)?
@@ -16,19 +16,19 @@ PKG_LICENSE:=BSD 3-Clause
 PKG_LICENSE_FILES:=LICENSE
 PKG_MAINTAINER:=Tianling Shen <[email protected]>
 
-PKG_BUILD_DEPENDS:=ninja/host python3/host
+PKG_BUILD_DEPENDS:=python3/host
 PKG_USE_MIPS16:=0
 PKG_BUILD_PARALLEL:=1
 
 ifneq ($(CONFIG_CPU_TYPE)," ")
-	CPU_TYPE:=$(word 1, $(subst +," ,$(CONFIG_CPU_TYPE)))
-	CPU_SUBTYPE:=$(word 2, $(subst +, ",$(CONFIG_CPU_TYPE)))
-	ifeq ($(CPU_SUBTYPE),)
-		CPU_SUBTYPE:=""
-	endif
+  CPU_TYPE:=$(word 1, $(subst +," ,$(CONFIG_CPU_TYPE)))
+  CPU_SUBTYPE:=$(word 2, $(subst +, ",$(CONFIG_CPU_TYPE)))
+  ifeq ($(CPU_SUBTYPE),)
+    CPU_SUBTYPE:=""
+  endif
 else
-	CPU_TYPE:=""
-	CPU_SUBTYPE:=""
+  CPU_TYPE:=""
+  CPU_SUBTYPE:=""
 endif
 
 include $(INCLUDE_DIR)/package.mk
@@ -53,10 +53,10 @@ define Package/naiveproxy/description
 endef
 
 ifneq ($(CONFIG_CCACHE),)
-	export CCACHE_SLOPPINESS=time_macros
-	export CCACHE_BASEDIR=$(PKG_BUILD_DIR)/src
-	export CCACHE_CPP2=yes
-	export naive_ccache_flags=cc_wrapper="$(CCACHE)"
+  export CCACHE_SLOPPINESS=time_macros
+  export CCACHE_BASEDIR=$(PKG_BUILD_DIR)/src
+  export CCACHE_CPP2=yes
+  export naive_ccache_flags=cc_wrapper="$(CCACHE)"
 endif
 
 CLANG_VER:=llvmorg-13-init-6429-g0e92cbd6-2
@@ -102,14 +102,14 @@ define Build/Prepare
 endef
 
 define Build/Compile
-( \
-	cd "$(PKG_BUILD_DIR)/src" ; \
-	. ../init_env.sh "$(ARCH)" "$(BOARD)" $(CPU_TYPE) $(CPU_SUBTYPE) "$(TOOLCHAIN_DIR)" ; \
-	export naive_flags="$$$${naive_flags} $$$${naive_ccache_flags}" ; \
-	mkdir -p "out" ; \
-	./gn/out/gn gen "out/Release" --args="$$$${naive_flags}" --script-executable="$(STAGING_DIR_HOSTPKG)/bin/python3" ; \
-	$(STAGING_DIR_HOSTPKG)/bin/ninja -C "out/Release" naive ; \
-)
+	( \
+		cd "$(PKG_BUILD_DIR)/src" ; \
+		. ../init_env.sh "$(ARCH)" $(CPU_TYPE) $(CPU_SUBTYPE) "$(TOOLCHAIN_DIR)" ; \
+		export naive_flags+=" $$$${naive_ccache_flags}" ; \
+		mkdir -p "out" ; \
+		./gn/out/gn gen "out/Release" --args="$$$${naive_flags}" --script-executable="$(PYTHON)" ; \
+	)
+	+$(NINJA) -C "$(PKG_BUILD_DIR)/src/out/Release" naive
 endef
 
 define Package/naiveproxy/install
@@ -121,4 +121,4 @@ $(eval $(call Download,CLANG))
 $(eval $(call Download,GN_TOOL))
 $(eval $(call Download,PGO_PROF))
 
-$(eval $(call BuildPackage,naiveproxy))
+$(eval $(call BuildPackage,naiveproxy))

+ 1 - 1
naiveproxy/patches/001-Remove-concurrency-limit.patch

@@ -29,7 +29,7 @@ Subject: [PATCH] Remove concurrency limit
        net_log_(
 --- a/src/net/tools/naive/naive_proxy_bin.cc
 +++ b/src/net/tools/naive/naive_proxy_bin.cc
-@@ -299,7 +299,7 @@ bool ParseCommandLine(const CommandLine&
+@@ -296,7 +296,7 @@ bool ParseCommandLine(const CommandLine&
  
    if (!cmdline.concurrency.empty()) {
      if (!base::StringToInt(cmdline.concurrency, &params->concurrency) ||

+ 34 - 20
naiveproxy/src/init_env.sh

@@ -7,17 +7,25 @@
 
 # Read args from shell
 target_arch="$1"
-target_board="$2"
-cpu_type="$3"
-cpu_subtype="$4"
-toolchain_dir="$5"
+cpu_type="$2"
+cpu_subtype="$3"
+toolchain_dir="$4"
 
 # Set arch info
-naive_arch="${target_arch}"
-[ "${target_arch}" == "i386" ] && naive_arch="x86"
-[ "${target_arch}" == "x86_64" ] && naive_arch="x64"
-[ "${target_arch}" == "aarch64" ] && naive_arch="arm64"
-# ldso_path="/lib/$(find "${toolchain_dir}/" | grep -Eo "ld-musl-[a-z0-9_-]+\\.so\\.1")"
+case "${target_arch}" in
+"aarch64")
+	naive_arch="arm64"
+	;;
+"i386")
+	naive_arch="x86"
+	;;
+"x86_64")
+	naive_arch="x64"
+	;;
+*)
+	naive_arch="${target_arch}"
+	;;
+esac
 
 # OS detection
 [ "$(uname)" != "Linux" -o "$(uname -m)" != "x86_64" ] && { echo -e "Support Linux AMD64 only."; exit 1; }
@@ -62,17 +70,23 @@ include_transport_security_state_preload_list=false
 target_os=\"openwrt\"
 target_cpu=\"${naive_arch}\"
 target_sysroot=\"${toolchain_dir}\""
-# ldso_path=\"${ldso_path}\""
-[ "${target_arch}" == "arm" ] && {
-	naive_flags="${naive_flags} arm_version=0 arm_cpu=\"${cpu_type}\""
+
+case "${target_arch}" in
+"arm")
+	naive_flags+=" arm_version=0 arm_cpu=\"${cpu_type}\""
 	if [ -n "${cpu_subtype}" ]; then
-		echo "${cpu_subtype}" | grep -q "neon" && neon_flag="arm_use_neon=true" || neon_flag="arm_use_neon=false"
-		naive_flags="${naive_flags} arm_fpu=\"${cpu_subtype}\" arm_float_abi=\"hard\" ${neon_flag}"
+		if grep -q "neon" <<< "${cpu_subtype}"; then
+			neon_flag="arm_use_neon=true"
+		else
+			neon_flag="arm_use_neon=false"
+		fi
+		naive_flags+=" arm_fpu=\"${cpu_subtype}\" arm_float_abi=\"hard\" ${neon_flag}"
 	else
-		naive_flags="${naive_flags} arm_float_abi=\"soft\" arm_use_neon=false"
+		naive_flags+=" arm_float_abi=\"soft\" arm_use_neon=false"
 	fi
-}
-[[ "mips mips64 mipsel mips64el" =~ (^|[[:space:]])"${target_arch}"($|[[:space:]]) ]] && {
-	naive_flags="${naive_flags} use_gold=false is_cfi=false use_cfi_icall=false use_thin_lto=false mips_arch_variant=\"r2\""
-	[[ "${target_arch}" =~ ^"mips"$|^"mipsel"$ ]] && naive_flags="${naive_flags} mips_float_abi=\"soft\" mips_tune=\"${cpu_type}\""
-}
+	;;
+"mips"|"mips64"|"mipsel"|"mips64el")
+	naive_flags+=" use_gold=false is_cfi=false use_cfi_icall=false use_thin_lto=false mips_arch_variant=\"r2\""
+	[[ "${target_arch}" =~ "mips"|"mipsel" ]] && naive_flags+=" mips_float_abi=\"soft\" mips_tune=\"${cpu_type}\""
+	;;
+esac