Преглед на файлове

Merge pull request #197 from 1715173329/new-naive

luci-app-ssr-plus: enable multiple threads for naiveproxy
coolsnowwolf преди 5 години
родител
ревизия
316135f1f3

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

@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=luci-app-ssr-plus
 PKG_VERSION:=180
-PKG_RELEASE:=8
+PKG_RELEASE:=9
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -21,6 +21,7 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_Trojan
 
 config PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy
 	bool "Include NaiveProxy"
+	depends on !(arc||armeb||mips||mips64||powerpc)
 	default n
 
 config PACKAGE_$(PKG_NAME)_INCLUDE_Redsocks2

+ 4 - 3
luci-app-ssr-plus/root/etc/init.d/shadowsocksr

@@ -204,7 +204,8 @@ gen_config_file() {
 		cat <<-EOF >/var/etc/naive-ssr-$FILE_NAME.json
 			{
 			"listen": "$PROTO://0.0.0.0:$3",
-			"proxy": "https://$(uci_get_by_name $1 username):$(uci_get_by_name $1 password)@$(uci_get_by_name $1 server):$(uci_get_by_name $1 server_port)"
+			"proxy": "https://$(uci_get_by_name $1 username):$(uci_get_by_name $1 password)@$(uci_get_by_name $1 server):$(uci_get_by_name $1 server_port)",
+			"concurrency": "${4:-1}"
 			}
 		EOF
 		;;
@@ -342,12 +343,12 @@ start_redir_tcp() {
 		-l :$server_port $password $kcp_param
 		kcp_enable_flag=1
 	fi
-	gen_config_file $GLOBAL_SERVER 0 $(uci_get_by_name $GLOBAL_SERVER local_port 1234)
 	if [ "$(uci_get_by_type global threads 0)" == "0" ]; then
 		threads=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
 	else
 		threads=$(uci_get_by_type global threads)
 	fi
+	gen_config_file $GLOBAL_SERVER 0 $(uci_get_by_name $GLOBAL_SERVER local_port 1234) $threads
 	case "$type" in
 	ss | ssr)
 		local last_config_file=$CONFIG_FILE
@@ -370,7 +371,7 @@ start_redir_tcp() {
 		;;
 	naiveproxy)
 		$bin /var/etc/naive-ssr-retcp.json >/dev/null 2>&1 &
-		echo "$(date "+%Y-%m-%d %H:%M:%S") Main node:$($bin --version 2>&1 | head -1) Started!" >>/tmp/ssrplus.log
+		echo "$(date "+%Y-%m-%d %H:%M:%S") Main node:$($bin --version 2>&1 | head -1) , $threads Threads Started!" >>/tmp/ssrplus.log
 		;;
 	socks5)
 		/usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-retcp.conf" socks5 tcp $(uci_get_by_name $GLOBAL_SERVER local_port) \

+ 7 - 9
naiveproxy/Makefile

@@ -7,12 +7,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=naiveproxy
-PKG_VERSION:=85.0.4183.83-3
+PKG_VERSION:=85.0.4183.83-4
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/klzgrad/naiveproxy/tar.gz/v$(PKG_VERSION)?
-PKG_HASH:=66a8f275a9aa0fa04649062fb141a10add9bd76855f32ee65e6ee60a7fc4649c
+PKG_HASH:=68b3ec22aba04a671ddb14a1f55dc7425c73adf781cbe87a95097c782f269a07
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
 
 PKG_LICENSE:=BSD 3-Clause
@@ -36,13 +36,17 @@ endif
 
 include $(INCLUDE_DIR)/package.mk
 
+define Package/naiveproxy/config
+	depends on !(arc||armeb||mips||mips64||powerpc)
+endef
+
 define Package/naiveproxy
 	SECTION:=net
 	CATEGORY:=Network
 	SUBMENU:=Web Servers/Proxies
 	URL:=https://github.com/klzgrad/naiveproxy
 	TITLE:=Make a fortune quietly
-	DEPENDS:=@!(arc||armeb||powerpc) +libatomic +libnss
+	DEPENDS:=+libatomic +libnss
 endef
 
 define Package/naiveproxy/description
@@ -71,15 +75,9 @@ define Build/Compile
 )
 endef
 
-define Package/naiveproxy/conffiles
-/etc/chromium/policies/managed/proxy.json
-endef
-
 define Package/naiveproxy/install
 	$(INSTALL_DIR) $(1)/usr/bin
 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/out/Release/naive $(1)/usr/bin/naive
-	$(INSTALL_DIR) $(1)/etc/chromium/policies/managed
-	$(INSTALL_CONF) $(CURDIR)/files/proxy.json $(1)/etc/chromium/policies/managed/proxy.json
 endef
 
 $(eval $(call BuildPackage,naiveproxy))

+ 0 - 1
naiveproxy/files/proxy.json

@@ -1 +0,0 @@
-{ "MaxConnectionsPerProxy": 99 }

+ 44 - 0
naiveproxy/patches/001-Remove-concurrency-limit.patch

@@ -0,0 +1,44 @@
+From f1a49736010170a70123db07ca41256ba92c0002 Mon Sep 17 00:00:00 2001
+From: klzgrad <[email protected]>
+Date: Sat, 3 Oct 2020 08:54:59 +0800
+Subject: [PATCH] Remove concurrency limit
+
+---
+ src/net/tools/naive/naive_proxy.cc     | 3 +--
+ src/net/tools/naive/naive_proxy_bin.cc | 2 +-
+ 2 files changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/src/net/tools/naive/naive_proxy.cc b/src/net/tools/naive/naive_proxy.cc
+index b4d5feee6..a38f79124 100644
+--- a/src/net/tools/naive/naive_proxy.cc
++++ b/src/net/tools/naive/naive_proxy.cc
+@@ -5,7 +5,6 @@
+ 
+ #include "net/tools/naive/naive_proxy.h"
+ 
+-#include <algorithm>
+ #include <utility>
+ 
+ #include "base/bind.h"
+@@ -35,7 +34,7 @@ NaiveProxy::NaiveProxy(std::unique_ptr<ServerSocket> listen_socket,
+                        const NetworkTrafficAnnotationTag& traffic_annotation)
+     : listen_socket_(std::move(listen_socket)),
+       protocol_(protocol),
+-      concurrency_(std::min(4, std::max(1, concurrency))),
++      concurrency_(concurrency),
+       resolver_(resolver),
+       session_(session),
+       net_log_(
+diff --git a/src/net/tools/naive/naive_proxy_bin.cc b/src/net/tools/naive/naive_proxy_bin.cc
+index 4ba08712d..00acd7756 100644
+--- a/src/net/tools/naive/naive_proxy_bin.cc
++++ b/src/net/tools/naive/naive_proxy_bin.cc
+@@ -289,7 +289,7 @@ bool ParseCommandLine(const CommandLine& cmdline, Params* params) {
+ 
+   if (!cmdline.concurrency.empty()) {
+     if (!base::StringToInt(cmdline.concurrency, &params->concurrency) ||
+-        params->concurrency < 1 || params->concurrency > 4) {
++        params->concurrency < 1) {
+       std::cerr << "Invalid concurrency" << std::endl;
+       return false;
+     }

+ 0 - 79
naiveproxy/patches/002-build-add-mips-x86-OpenWrt-toolchain-definitions.patch

@@ -1,79 +0,0 @@
-From fd4f8c65ecbbdd15d71a04d213314de056107a31 Mon Sep 17 00:00:00 2001
-From: CN_SZTL <[email protected]>
-Date: Tue, 18 Aug 2020 20:47:40 +0000
-Subject: [PATCH 2/3] build: add mips & x86 OpenWrt toolchain definitions
-
----
- src/build/toolchain/linux/BUILD.gn | 42 ++++++++++++++++++++++++++++++
- 1 file changed, 42 insertions(+)
-
-diff --git a/src/build/toolchain/linux/BUILD.gn b/src/build/toolchain/linux/BUILD.gn
-index 2e7913a4f..cc8084eac 100644
---- a/src/build/toolchain/linux/BUILD.gn
-+++ b/src/build/toolchain/linux/BUILD.gn
-@@ -95,6 +95,18 @@ clang_toolchain("clang_x86") {
-   }
- }
- 
-+clang_toolchain("clang_x86_openwrt") {
-+  # Output linker map files for binary size analysis.
-+  enable_linker_map = true
-+  extra_cppflags = "--target=i386-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
-+  extra_ldflags = "--target=i386-openwrt-linux-musl"
-+
-+  toolchain_args = {
-+    current_cpu = "x86"
-+    current_os = "linux"
-+  }
-+}
-+
- clang_toolchain("clang_x86_v8_arm") {
-   toolchain_args = {
-     current_cpu = "x86"
-@@ -203,6 +215,26 @@ gcc_toolchain("x64") {
-   }
- }
- 
-+clang_toolchain("clang_mips_openwrt") {
-+  extra_cppflags = "--target=mips-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
-+  extra_ldflags = "--target=mips-openwrt-linux-musl"
-+
-+  toolchain_args = {
-+    current_cpu = "mips"
-+    current_os = "linux"
-+  }
-+}
-+
-+clang_toolchain("clang_mips64_openwrt") {
-+  extra_cppflags = "--target=mips64-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
-+  extra_ldflags = "--target=mips64-openwrt-linux-musl"
-+
-+  toolchain_args = {
-+    current_cpu = "mips64"
-+    current_os = "linux"
-+  }
-+}
-+
- clang_toolchain("clang_mipsel") {
-   toolchain_args = {
-     current_cpu = "mipsel"
-@@ -227,6 +259,16 @@ clang_toolchain("clang_mips64el") {
-   }
- }
- 
-+clang_toolchain("clang_mips64el_openwrt") {
-+  extra_cppflags = "--target=mips64el-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
-+  extra_ldflags = "--target=mips64el-openwrt-linux-musl"
-+
-+  toolchain_args = {
-+    current_cpu = "mips64el"
-+    current_os = "linux"
-+  }
-+}
-+
- gcc_toolchain("mipsel") {
-   toolprefix = "mipsel-linux-gnu-"
- 
--- 
-2.17.1
-

+ 1 - 1
naiveproxy/patches/001-build-add-OpenWrt-staging-libraries.patch → naiveproxy/patches/100-build-add-OpenWrt-staging-libraries.patch

@@ -1,7 +1,7 @@
 From 5b476d92f8dbee8b83061faa8cd18a46e5ab4aae Mon Sep 17 00:00:00 2001
 From: CN_SZTL <[email protected]>
 Date: Tue, 18 Aug 2020 20:36:39 +0000
-Subject: [PATCH 1/3] build: add OpenWrt staging libraries
+Subject: [PATCH] build: add OpenWrt staging libraries
 
 ---
  src/build/config/posix/BUILD.gn | 4 ++++

+ 1 - 1
naiveproxy/patches/003-build-drop-useless-deps-simd_asm.patch → naiveproxy/patches/101-build-drop-useless-deps-simd_asm.patch

@@ -1,7 +1,7 @@
 From dd07b78f561914ccc6cbe076ae66c380304bf92c Mon Sep 17 00:00:00 2001
 From: CN_SZTL <[email protected]>
 Date: Wed, 19 Aug 2020 12:42:45 +0000
-Subject: [PATCH 3/3] build: drop useless deps simd_asm
+Subject: [PATCH] build: drop useless deps simd_asm
 
 libjpeg_turbo itself has alreadly set the dependency "simd_asm",
 and this will cause cross-compile failed: