diff --git a/config/Config-devel.in b/config/Config-devel.in index fd7c3ead1e..52176e7304 100644 --- a/config/Config-devel.in +++ b/config/Config-devel.in @@ -65,7 +65,7 @@ menuconfig DEVEL config CCACHE bool "Use ccache" if DEVEL - default n + default y help Compiler cache; see https://ccache.samba.org/ diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index ea04d17d0b..91396fb75d 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -20,7 +20,6 @@ generate_static_network() { uci -q batch <<-EOF delete network.globals set network.globals='globals' - set network.globals.ula_prefix='auto' EOF } diff --git a/package/ctcgfw/naiveproxy/Makefile b/package/ctcgfw/naiveproxy/Makefile index f3cf2d291e..550db80010 100644 --- a/package/ctcgfw/naiveproxy/Makefile +++ b/package/ctcgfw/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 diff --git a/package/ctcgfw/naiveproxy/patches/001-Remove-concurrency-limit.patch b/package/ctcgfw/naiveproxy/patches/001-Remove-concurrency-limit.patch new file mode 100644 index 0000000000..e246b12e93 --- /dev/null +++ b/package/ctcgfw/naiveproxy/patches/001-Remove-concurrency-limit.patch @@ -0,0 +1,44 @@ +From f1a49736010170a70123db07ca41256ba92c0002 Mon Sep 17 00:00:00 2001 +From: klzgrad +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 + #include + + #include "base/bind.h" +@@ -35,7 +34,7 @@ NaiveProxy::NaiveProxy(std::unique_ptr 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, ¶ms->concurrency) || +- params->concurrency < 1 || params->concurrency > 4) { ++ params->concurrency < 1) { + std::cerr << "Invalid concurrency" << std::endl; + return false; + } diff --git a/package/ctcgfw/naiveproxy/patches/002-build-add-mips-x86-OpenWrt-toolchain-definitions.patch b/package/ctcgfw/naiveproxy/patches/002-build-add-mips-x86-OpenWrt-toolchain-definitions.patch deleted file mode 100644 index 393c2de69f..0000000000 --- a/package/ctcgfw/naiveproxy/patches/002-build-add-mips-x86-OpenWrt-toolchain-definitions.patch +++ /dev/null @@ -1,79 +0,0 @@ -From fd4f8c65ecbbdd15d71a04d213314de056107a31 Mon Sep 17 00:00:00 2001 -From: CN_SZTL -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 - diff --git a/package/ctcgfw/naiveproxy/patches/001-build-add-OpenWrt-staging-libraries.patch b/package/ctcgfw/naiveproxy/patches/100-build-add-OpenWrt-staging-libraries.patch similarity index 96% rename from package/ctcgfw/naiveproxy/patches/001-build-add-OpenWrt-staging-libraries.patch rename to package/ctcgfw/naiveproxy/patches/100-build-add-OpenWrt-staging-libraries.patch index 5ec1f4faca..0ace73477f 100644 --- a/package/ctcgfw/naiveproxy/patches/001-build-add-OpenWrt-staging-libraries.patch +++ b/package/ctcgfw/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 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 ++++ diff --git a/package/ctcgfw/naiveproxy/patches/003-build-drop-useless-deps-simd_asm.patch b/package/ctcgfw/naiveproxy/patches/101-build-drop-useless-deps-simd_asm.patch similarity index 94% rename from package/ctcgfw/naiveproxy/patches/003-build-drop-useless-deps-simd_asm.patch rename to package/ctcgfw/naiveproxy/patches/101-build-drop-useless-deps-simd_asm.patch index f5c94733d6..2bfb115784 100644 --- a/package/ctcgfw/naiveproxy/patches/003-build-drop-useless-deps-simd_asm.patch +++ b/package/ctcgfw/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 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: diff --git a/package/firmware/linux-firmware/Makefile b/package/firmware/linux-firmware/Makefile index 7dbcbdd8a3..d167400014 100644 --- a/package/firmware/linux-firmware/Makefile +++ b/package/firmware/linux-firmware/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=linux-firmware -PKG_VERSION:=20200817 -PKG_RELEASE:=2 +PKG_VERSION:=20200918 +PKG_RELEASE:=1 PKG_SOURCE_URL:=@KERNEL/linux/kernel/firmware PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz -PKG_HASH:=76d05d5f1eff268d3b80675245fa596f557bd55ee2e16ddd54d18ffeae943887 +PKG_HASH:=e2787907e0892e0b1a3c06f1def6fd3cdc0eff850b0919c7f21b5bda7563d2d8 PKG_MAINTAINER:=Felix Fietkau diff --git a/package/lean/default-settings/files/openwrt_banner b/package/lean/default-settings/files/openwrt_banner index 5d273b15ce..1b6c14339f 100644 --- a/package/lean/default-settings/files/openwrt_banner +++ b/package/lean/default-settings/files/openwrt_banner @@ -8,5 +8,5 @@ │ # │ │ " │ │─────────────────────────────────────────────────│ -│ OpenWrt 18.06 by Lean | Mod 20.09 By CTCGFW │ +│ OpenWrt 18.06 by Lean | Mod 20.10 By CTCGFW │ └─────────────────────────────────────────────────┘ diff --git a/package/lean/default-settings/files/zzz-default-settings b/package/lean/default-settings/files/zzz-default-settings index 0756870fe8..b28de3d809 100755 --- a/package/lean/default-settings/files/zzz-default-settings +++ b/package/lean/default-settings/files/zzz-default-settings @@ -41,7 +41,7 @@ sed -i '/option disabled/d' /etc/config/wireless sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh sed -i '/DISTRIB_REVISION/d' /etc/openwrt_release -echo "DISTRIB_REVISION='| Mod20.09 by CTCGFW'" >> /etc/openwrt_release +echo "DISTRIB_REVISION='| Mod20.10 by CTCGFW'" >> /etc/openwrt_release sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release echo "DISTRIB_DESCRIPTION='OpenWrt 18.06 by Lean '" >> /etc/openwrt_release diff --git a/package/lean/libtorrent-rasterbar/Makefile b/package/lean/libtorrent-rasterbar/Makefile index 7d23e4b736..ff9546747a 100644 --- a/package/lean/libtorrent-rasterbar/Makefile +++ b/package/lean/libtorrent-rasterbar/Makefile @@ -1,14 +1,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libtorrent-rasterbar -PKG_VERSION:=1.2.7 +PKG_VERSION:=1.2.10 PKG_RELEASE=1 -PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=https://github.com/arvidn/libtorrent.git -PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_VERSION:=8e710151c80e655ee0513ca37c367f75a448c6bd -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE:=$(PKG_NAME)-libtorrent-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://codeload.github.com/arvidn/libtorrent/tar.gz/libtorrent-$(PKG_VERSION)? +PKG_HASH:=e0fedb583f1e7bdcc0eb80a9df064a1e6fb0b825d8423e64bdb0f7a35879a09e + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(firstword $(subst -, ,$(PKG_NAME)))-libtorrent-$(PKG_VERSION) PKG_LICENSE:=BSD PKG_LICENSE_FILES:=COPYING diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index 23e5204e5a..0ab2581c7a 100644 --- a/package/lean/luci-app-ssr-plus/Makefile +++ b/package/lean/luci-app-ssr-plus/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus PKG_VERSION:=180 -PKG_RELEASE:=7 +PKG_RELEASE:=8 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 y if i386||x86_64||arm||aarch64 config PACKAGE_$(PKG_NAME)_INCLUDE_Redsocks2 @@ -60,4 +61,4 @@ LUCI_DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsm include $(TOPDIR)/feeds/luci/luci.mk -# call BuildPackage - OpenWrt buildroot signature \ No newline at end of file +# call BuildPackage - OpenWrt buildroot signature diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua index 533daea78c..a9da19f4a7 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua @@ -398,6 +398,12 @@ o = s:option(Value, "tls_host", translate("TLS Host")) o:depends("tls", "1") o.rmempty = true +-- XTLS +o = s:option(Flag, "xtls", translate("XTLS")) +o.rmempty = true +o.default = "0" +o:depends({type="vless", tls="1"}) + -- [[ Mux ]]-- o = s:option(Flag, "mux", translate("Mux")) o.rmempty = true diff --git a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 5dd9860c7a..2de3f10dbf 100755 --- a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/package/lean/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) \ diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genvlessconfig.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genvlessconfig.lua index 1630b7761a..35e1e93c42 100644 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genvlessconfig.lua +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genvlessconfig.lua @@ -5,6 +5,16 @@ local proto = arg[2] local local_port = arg[3] or "0" local socks_port = arg[4] or "0" local server = ucursor:get_all("shadowsocksr", server_section) +local outbound_security = "none" + +if (server.xtls == '1') +then + outbound_security = "xtls" +elseif (server.tls == '1') +then + outbound_security = "tls" +end + local vless = { log = { -- error = "/var/ssrplus.log", @@ -45,6 +55,7 @@ outbound = { users = { { id = server.vmess_id, + flow = (server.xtls == '1') and "xtls-rprx-origin" or nil, encryption = server.vless_encryption } } @@ -54,8 +65,9 @@ outbound = { -- 底层传输配置 streamSettings = { network = server.transport, - security = (server.tls == '1') and "tls" or "none", - tlsSettings = {allowInsecure = (server.insecure ~= "0") and true or false,serverName=server.tls_host,}, + security = outbound_security, + tlsSettings = (outbound_security == "tls") and {allowInsecure = (server.insecure ~= "0") and true or false,serverName=server.tls_host,} or nil, + xtlsSettings = (outbound_security == "xtls") and {allowInsecure = (server.insecure ~= "0") and true or false,serverName=server.tls_host,} or nil, tcpSettings = (server.transport == "tcp") and { header = { type = server.tcp_guise, diff --git a/package/lean/qBittorrent-Enhanced-Edition/Makefile b/package/lean/qBittorrent-Enhanced-Edition/Makefile index 7da29351b1..9889179d0c 100644 --- a/package/lean/qBittorrent-Enhanced-Edition/Makefile +++ b/package/lean/qBittorrent-Enhanced-Edition/Makefile @@ -1,14 +1,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=qBittorrent-Enhanced-Edition -PKG_VERSION:=4.2.5.13 +PKG_VERSION:=4.2.5.16 PKG_RELEASE=1 PKG_SOURCE:=$(PKG_NAME)-release-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/c0re100/qBittorrent-Enhanced-Edition/tar.gz/release-$(PKG_VERSION)? -PKG_HASH:=e032ea5b7e8d974081c12201f20f06e47bc959a72d5898561736cdfdf46cafaf +PKG_HASH:=ebae940c93bca2cdaf4fc353f1fe7177006e4ac25a921b42403b6296d4dc9d3e -PKG_BUILD_DIR:=$(BUILD_DIR)/qBittorrent-Enhanced-Edition-release-$(PKG_VERSION) +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-release-$(PKG_VERSION) PKG_LICENSE:=GPL-2.0+ PKG_LICENSE_FILES:=COPYING @@ -54,8 +54,6 @@ define Build/Prepare endef define Package/$(PKG_NAME)/install - $(INSTALL_DIR) $(1)/usr/man/man1 - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/man/man1/qbittorrent-nox.1 $(1)/usr/man/man1/qbittorrent-nox.1 $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/qbittorrent-nox $(1)/usr/bin $(INSTALL_DIR) $(1)/etc/qBittorrent diff --git a/package/lienol/luci-app-passwall/Makefile b/package/lienol/luci-app-passwall/Makefile index c1097a4eea..444634704b 100644 --- a/package/lienol/luci-app-passwall/Makefile +++ b/package/lienol/luci-app-passwall/Makefile @@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall PKG_VERSION:=3.9 -PKG_RELEASE:=65 -PKG_DATE:=20201003 +PKG_RELEASE:=66 +PKG_DATE:=20201004 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_naiveproxy.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_naiveproxy.lua index 06bad70c7d..f45ca60cb9 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_naiveproxy.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_naiveproxy.lua @@ -4,8 +4,14 @@ local node_section = arg[1] local run_type = arg[2] local local_addr = arg[3] local local_port = arg[4] +local relay_port = arg[5] local node = ucursor:get_all("passwall", node_section) +if relay_port and relay_port ~= "nil" then + node.address = "127.0.0.1" + node.port = tonumber(relay_port) +end + local config = { listen = run_type .. "://" .. local_addr .. ":" .. local_port, proxy = node.protocol .. "://" .. node.username .. ":" .. node.password .. "@" .. node.address .. ":" .. node.port diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_trojan.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_trojan.lua index c8fd459899..a8e75f5dd8 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_trojan.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_trojan.lua @@ -4,6 +4,7 @@ local node_section = arg[1] local run_type = arg[2] local local_addr = arg[3] local local_port = arg[4] +local relay_port = arg[5] local node = ucursor:get_all("passwall", node_section) local cipher = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA" @@ -22,7 +23,7 @@ local trojan = { cert = node.trojan_cert_path, cipher = cipher, cipher_tls13 = cipher13, - sni = node.tls_serverName, + sni = node.tls_serverName or node.address, alpn = {"h2", "http/1.1"}, reuse_session = true, session_ticket = (node.tls_sessionTicket and node.tls_sessionTicket == "1") and true or false, @@ -67,4 +68,8 @@ if node.type == "Trojan-Go" then password = node.ss_aead_pwd or "" } or nil end +if relay_port and relay_port ~= "nil" then + trojan.remote_addr = "127.0.0.1" + trojan.remote_port = tonumber(relay_port) +end print(json.stringify(trojan, 1)) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua index 5b5f0222bd..52495f2fc3 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua @@ -11,8 +11,18 @@ local inbounds = {} local outbounds = {} local network = proto local routing = nil +local new_port -local function gen_outbound(node, tag) +local function get_new_port() + if new_port then + new_port = tonumber(sys.exec(string.format("echo -n $(/usr/share/%s/app.sh get_new_port %s tcp)", appname, new_port + 1))) + else + new_port = tonumber(sys.exec(string.format("echo -n $(/usr/share/%s/app.sh get_new_port auto tcp)", appname))) + end + return new_port +end + +local function gen_outbound(node, tag, relay_port) local result = nil if node then local node_id = node[".name"] @@ -25,15 +35,17 @@ local function gen_outbound(node, tag) node.transport = "tcp" else local node_type = (proto and proto ~= "nil") and proto or "socks" - local new_port = sys.exec(string.format("echo -n $(/usr/share/%s/app.sh get_new_port auto tcp)", appname)) + new_port = get_new_port() node.port = new_port - sys.call(string.format("/usr/share/%s/app.sh run_socks %s %s %s %s %s > /dev/null", + sys.call(string.format('/usr/share/%s/app.sh run_socks "%s" "%s" "%s" "%s" "%s" "%s"> /dev/null', appname, node_id, "127.0.0.1", new_port, string.format("/var/etc/%s/v2_%s_%s.json", appname, node_type, node_id), - "4") + "4", + relay_port and tostring(relay_port) or "" + ) ) node.protocol = "socks" node.transport = "tcp" @@ -140,7 +152,7 @@ end if socks_proxy_port ~= "nil" then table.insert(inbounds, { listen = "0.0.0.0", - port = socks_proxy_port, + port = tonumber(socks_proxy_port), protocol = "socks", settings = {auth = "noauth", udp = true, ip = "127.0.0.1"} }) @@ -149,7 +161,7 @@ end if redir_port ~= "nil" then table.insert(inbounds, { - port = redir_port, + port = tonumber(redir_port), protocol = "dokodemo-door", settings = {network = proto, followRedirect = true}, sniffing = {enabled = true, destOverride = {"http", "tls"}} @@ -175,14 +187,39 @@ end if node.protocol == "_shunt" then local rules = {} - ucursor:foreach(appname, "shunt_rules", function(e) - local _node_id = node[e[".name"]] or nil + local name = e[".name"] + local _node_id = node[name] or nil if _node_id and _node_id ~= "nil" then local _node = ucursor:get_all(appname, _node_id) - local _outbound = gen_outbound(_node, e[".name"]) + local is_proxy = node[name .. "_proxy"] + local relay_port + if is_proxy and is_proxy == "1" then + new_port = get_new_port() + relay_port = new_port + table.insert(inbounds, { + tag = "proxy_" .. name, + listen = "127.0.0.1", + port = new_port, + protocol = "dokodemo-door", + settings = {network = "tcp,udp", address = _node.address, port = tonumber(_node.port)} + }) + if _node.tls_serverName == nil then + _node.tls_serverName = _node.address + end + _node.address = "127.0.0.1" + _node.port = new_port + end + local _outbound = gen_outbound(_node, name, relay_port) if _outbound then table.insert(outbounds, _outbound) + if is_proxy and is_proxy == "1" then + table.insert(rules, { + type = "field", + inboundTag = {"proxy_" .. name}, + outboundTag = "default" + }) + end if e.domain_list then local _domain = {} string.gsub(e.domain_list, '[^' .. "\r\n" .. ']+', function(w) @@ -190,7 +227,7 @@ if node.protocol == "_shunt" then end) table.insert(rules, { type = "field", - outboundTag = e[".name"], + outboundTag = name, domain = _domain }) end @@ -201,7 +238,7 @@ if node.protocol == "_shunt" then end) table.insert(rules, { type = "field", - outboundTag = e[".name"], + outboundTag = name, ip = _ip }) end diff --git a/package/lienol/luci-app-passwall/root/etc/config/passwall b/package/lienol/luci-app-passwall/root/etc/config/passwall index c96dc855ed..b95c03068b 100644 --- a/package/lienol/luci-app-passwall/root/etc/config/passwall +++ b/package/lienol/luci-app-passwall/root/etc/config/passwall @@ -80,14 +80,25 @@ gvt2.com' config shunt_rules 'netflix' option remarks '奈飞' - option domain_list 'netflix + option domain_list 'fast.com +netflix netflix.com +netflix.net nflxso.net nflxext.com nflximg.com nflximg.net nflxvideo.net -fast.com' +netflixdnstest0.com +netflixdnstest1.com +netflixdnstest2.com +netflixdnstest3.com +netflixdnstest4.com +netflixdnstest5.com +netflixdnstest6.com +netflixdnstest7.com +netflixdnstest8.com +netflixdnstest9.com' config shunt_rules 'TVB' option remarks 'TVB' diff --git a/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh b/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh index 161c341762..22005f34fa 100755 --- a/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh @@ -218,12 +218,12 @@ ln_start_bin() { shift 2; if [ "${file_func%%/*}" != "${file_func}" ]; then [ ! -L "${file_func}" ] && { - ln -s "${file_func}" "${TMP_BIN_PATH}/${ln_name}" + ln -s "${file_func}" "${TMP_BIN_PATH}/${ln_name}" >/dev/null 2>&1 file_func="${TMP_BIN_PATH}/${ln_name}" } [ -x "${file_func}" ] || echolog " - $(readlink ${file_func}) 没有执行权限,无法启动:${file_func} $*" fi - echo "${file_func} $*" >&2 + #echo "${file_func} $*" >&2 [ -n "${file_func}" ] || echolog " - 找不到 ${ln_name},无法启动..." ${file_func:-echolog " - ${ln_name}"} "$@" >/dev/null 2>&1 & } @@ -310,10 +310,16 @@ run_socks() { local bind=$2 local local_port=$3 local config_file=$4 + local relay_port=$6 local type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z') local remarks=$(config_n_get $node remarks) local server_host=$(config_n_get $node address) local port=$(config_n_get $node port) + [ -n "$relay_port" ] && { + server_host="127.0.0.1" + port=$relay_port + echo $relay_port + } local msg tmp if [ -n "$server_host" ] && [ -n "$port" ]; then @@ -347,15 +353,15 @@ run_socks() { ln_start_bin "$(first_type $(config_t_get global_app v2ray_file notset)/v2ray v2ray)" v2ray -config="$config_file" ;; trojan-go) - lua $API_GEN_TROJAN $node client $bind $local_port > $config_file + lua $API_GEN_TROJAN $node client $bind $local_port $port > $config_file ln_start_bin "$(first_type $(config_t_get global_app trojan_go_file notset) trojan-go)" trojan-go -config "$config_file" ;; trojan*) - lua $API_GEN_TROJAN $node client $bind $local_port > $config_file + lua $API_GEN_TROJAN $node client $bind $local_port $port > $config_file ln_start_bin "$(first_type ${type})" "${type}" -c "$config_file" ;; naiveproxy) - lua $API_GEN_NAIVE $node socks $bind $local_port > $config_file + lua $API_GEN_NAIVE $node socks $bind $local_port $port > $config_file ln_start_bin "$(first_type naive)" naive "$config_file" ;; brook) @@ -367,7 +373,7 @@ run_socks() { ln_start_bin "$(first_type $(config_t_get global_app brook_file notset) brook)" "brook_SOCKS_$5" "$protocol" --socks5 "$bind:$local_port" -s "$server_host:$port" -p "$(config_n_get $node password)" ;; ss|ssr) - lua $API_GEN_SS $node $local_port > $config_file + lua $API_GEN_SS $node $local_port $server_host $port > $config_file ln_start_bin "$(first_type ${type}-local)" "${type}-local" -c "$config_file" -b "$bind" -u ;; esac @@ -863,6 +869,16 @@ add_dnsmasq() { echolog " - [$?]中国域名表(chnroute):${fwd_dns:-默认}" } } + + #分流规则 + fwd_dns="${TUN_DNS}" + #如果使用chnlist直接使用默认DNS + [ "${USE_CHNLIST}" = "1" ] && unset fwd_dns + local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}') + for shunt_id in $shunt_ids; do + config_n_get $shunt_id domain_list | tr -s "\r\n" "\n" | gen_dnsmasq_items "shuntlist" "${fwd_dns}" "${TMP_DNSMASQ_PATH}/shunt_host.conf" + echolog " - [$?]$shunt_id分流规则(shuntlist):${fwd_dns:-默认}" + done #始终使用远程DNS解析代理(黑名单)列表 fwd_dns="${TUN_DNS}" @@ -1184,21 +1200,23 @@ stop() { echolog "清空并关闭相关程序和缓存完成。" } -case $1 in +arg1=$1 +shift +case $arg1 in get_new_port) - get_new_port $2 $3 + get_new_port $@ ;; run_socks) - run_socks $2 $3 $4 $5 $6 + run_socks $@ ;; run_redir) - run_redir $2 $3 $4 $5 $6 $7 + run_redir $@ ;; node_switch) - node_switch $2 $3 $4 $5 + node_switch $@ ;; stop) - [ "$2" = "force" ] && force_stop + [ "$1" = "force" ] && force_stop stop ;; start) diff --git a/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh b/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh index d03f8d6f30..3ec658cf73 100755 --- a/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh +++ b/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh @@ -2,6 +2,7 @@ IPSET_LANIPLIST="laniplist" IPSET_VPSIPLIST="vpsiplist" +IPSET_SHUNTLIST="shuntlist" IPSET_GFW="gfwlist" #IPSET_GFW6="gfwlist6" IPSET_CHN="chnroute" @@ -163,6 +164,7 @@ load_acl() { msg2="${msg2}[$?]除${tcp_no_redir_ports}外的" } msg2="${msg2}所有端口" + $ipt_tmp -A PSW $(comment "$remarks") -p tcp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $tcp_redir_ports "-m multiport --dport") $(dst $IPSET_SHUNTLIST) $(REDIRECT $tcp_port $is_tproxy) $ipt_tmp -A PSW $(comment "$remarks") -p tcp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $tcp_redir_ports "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $tcp_port $is_tproxy) $ipt_tmp -A PSW $(comment "$remarks") -p tcp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $tcp_redir_ports "-m multiport --dport") $(get_redirect_ipt $tcp_proxy_mode $tcp_port $is_tproxy) } @@ -180,6 +182,7 @@ load_acl() { msg2="${msg2}[$?]除${udp_no_redir_ports}外的" } msg2="${msg2}所有端口" + $ipt_m -A PSW $(comment "$remarks") -p udp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_SHUNTLIST) $(REDIRECT $udp_port TPROXY) $ipt_m -A PSW $(comment "$remarks") -p udp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $udp_port TPROXY) $ipt_m -A PSW $(comment "$remarks") -p udp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(get_redirect_ipt $udp_proxy_mode $udp_port TPROXY) } @@ -247,6 +250,7 @@ load_acl() { fi [ "$TCP_NO_REDIR_PORTS" != "disable" ] && msg="${msg}除${TCP_NO_REDIR_PORTS}外的" msg="${msg}所有端口" + $ipt_tmp -A PSW $(comment "默认") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_SHUNTLIST) $(REDIRECT $TCP_REDIR_PORT1 $is_tproxy) $ipt_tmp -A PSW $(comment "默认") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $TCP_REDIR_PORT1 $is_tproxy) $ipt_tmp -A PSW $(comment "默认") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(get_redirect_ipt $TCP_PROXY_MODE $TCP_REDIR_PORT1 $is_tproxy) echolog "${msg}" @@ -276,6 +280,7 @@ load_acl() { msg="UDP默认代理:使用UDP节点1 [$(get_action_chain_name $UDP_PROXY_MODE)](TPROXY:${UDP_REDIR_PORT1})代理" [ "$UDP_NO_REDIR_PORTS" != "disable" ] && msg="${msg}除${TCP_NO_REDIR_PORTS}外的" msg="${msg}所有端口" + $ipt_m -A PSW $(comment "默认") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_SHUNTLIST) $(REDIRECT $UDP_REDIR_PORT1 TPROXY) $ipt_m -A PSW $(comment "默认") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $UDP_REDIR_PORT1 TPROXY) $ipt_m -A PSW $(comment "默认") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(get_redirect_ipt $UDP_PROXY_MODE $UDP_REDIR_PORT1 TPROXY) echolog "${msg}" @@ -353,10 +358,17 @@ filter_node() { local proxy_protocol=$(config_n_get $proxy_node protocol) local proxy_type=$(echo $(config_n_get $proxy_node type nil) | tr 'A-Z' 'a-z') [ "$proxy_type" == "nil" ] && echolog " - 节点配置不正常,略过!:${proxy_node}" && return 0 - if [ "$proxy_protocol" == "_shunt" ]; then + if [ "$proxy_protocol" == "_balancing" ]; then + #echolog " - 多节点负载均衡(${proxy_type})..." + proxy_node=$(config_n_get $proxy_node balancing_node) + for _node in $proxy_node; do + filter_rules "$_node" "$stream" + done + elif [ "$proxy_protocol" == "_shunt" ]; then #echolog " - 按请求目的地址分流(${proxy_type})..." local default_node=$(config_n_get $proxy_node default_node nil) filter_rules $default_node $stream +:</dev/null 2>&1 && ipset -X $IPSET_LANIPLIST >/dev/null 2>&1 & ipset -F $IPSET_VPSIPLIST >/dev/null 2>&1 && ipset -X $IPSET_VPSIPLIST >/dev/null 2>&1 & + #ipset -F $IPSET_SHUNTLIST >/dev/null 2>&1 && ipset -X $IPSET_SHUNTLIST >/dev/null 2>&1 & #ipset -F $IPSET_GFW >/dev/null 2>&1 && ipset -X $IPSET_GFW >/dev/null 2>&1 & #ipset -F $IPSET_GFW6 >/dev/null 2>&1 && ipset -X $IPSET_GFW6 >/dev/null 2>&1 & #ipset -F $IPSET_CHN >/dev/null 2>&1 && ipset -X $IPSET_CHN >/dev/null 2>&1 & @@ -661,6 +676,7 @@ del_firewall_rule() { flush_ipset() { ipset -F $IPSET_LANIPLIST >/dev/null 2>&1 && ipset -X $IPSET_LANIPLIST >/dev/null 2>&1 & ipset -F $IPSET_VPSIPLIST >/dev/null 2>&1 && ipset -X $IPSET_VPSIPLIST >/dev/null 2>&1 & + ipset -F $IPSET_SHUNTLIST >/dev/null 2>&1 && ipset -X $IPSET_SHUNTLIST >/dev/null 2>&1 & ipset -F $IPSET_GFW >/dev/null 2>&1 && ipset -X $IPSET_GFW >/dev/null 2>&1 & #ipset -F $IPSET_GFW6 >/dev/null 2>&1 && ipset -X $IPSET_GFW6 >/dev/null 2>&1 & ipset -F $IPSET_CHN >/dev/null 2>&1 && ipset -X $IPSET_CHN >/dev/null 2>&1 & diff --git a/target/sdk/files/Config.in b/target/sdk/files/Config.in index 4393daab5b..2b8add64d0 100644 --- a/target/sdk/files/Config.in +++ b/target/sdk/files/Config.in @@ -56,7 +56,7 @@ menu "Advanced configuration options (for developers)" config CCACHE bool "Use ccache" - default n + default y help Compiler cache; see https://ccache.samba.org/