From 78f91179da57a8c6ecd418430dbe5ca1606e8911 Mon Sep 17 00:00:00 2001 From: soandsoso <51219603+soandsoso@users.noreply.github.com> Date: Fri, 20 Mar 2020 13:03:44 +0800 Subject: [PATCH 1/4] luci-app-ssr-plus: reset the behavior of btns in server list (#3891) * luci-app-ssr-plus: feat server list draggable * luci-app-ssr-plus: reset the behavior of up btn Reset the behavior of up btn in server list to move to top. * luci-app-ssr-plus: reset the behaviors of the btns up: move to top --- .../luasrc/view/shadowsocksr/server_list.htm | 52 +++++++++++++++---- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm index f1eb640d16..5d8f47656c 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm +++ b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm @@ -49,8 +49,7 @@ local dsp = require "luci.dispatcher" thread() } - // move - function cbi_row_drop(fromId, toId, store) { + function cbi_row_drop(fromId, toId, store, isToBottom) { var fromNode = document.getElementById(fromId); var toNode = document.getElementById(toId); if (!fromNode || !toNode) return false; @@ -61,13 +60,13 @@ local dsp = require "luci.dispatcher" if (!table) return false; var ids = []; - for (var idx = 2; idx < table.rows.length; idx++) { - if (table.rows[idx] === fromNode) { - toNode.parentNode.insertBefore(toNode, fromNode); - } else if (table.rows[idx] === toNode) { - fromNode.parentNode.insertBefore(fromNode, toNode); - } + if (isToBottom) { + toNode.parentNode.appendChild(fromNode); + } else { + fromNode.parentNode.insertBefore(fromNode, toNode); + } + for (var idx = 2; idx < table.rows.length; idx++) { table.rows[idx].className = table.rows[idx].className.replace( /cbi-rowstyle-[12]/, "cbi-rowstyle-" + (1 + (idx % 2)) @@ -82,10 +81,13 @@ local dsp = require "luci.dispatcher" return false; } - + // set tr draggable function enableDragForTable(table_selecter, store) { var trs = document.querySelectorAll(table_selecter + " tr"); + if (!trs || trs.length.length < 3) { + return; + } function ondragstart(ev) { ev.dataTransfer.setData("Text", ev.target.id); @@ -101,14 +103,46 @@ local dsp = require "luci.dispatcher" ev.dataTransfer.dropEffect = "move"; } + function moveToTop(id) { + var top = document.querySelectorAll(table_selecter + " tr")[2]; + cbi_row_drop(id, top.id, store); + } + + function moveToBottom(id) { + console.log('moveToBottom:', id); + var trList = document.querySelectorAll(table_selecter + " tr"); + var bottom = trList[trList.length - 1]; + cbi_row_drop(id, bottom.id, store, true); + } + for (let index = 2; index < trs.length; index++) { const el = trs[index]; el.setAttribute("draggable", true); el.ondragstart = ondragstart; el.ondrop = ondrop; el.ondragover = ondragover; + + // reset the behaviors of the btns + var upBtns = el.querySelectorAll(".cbi-button.cbi-button-up"); + if (upBtns && upBtns.length > 0) { + upBtns.forEach(function (_el) { + _el.onclick = function () { + moveToTop(el.id); + }; + }); + } + + var downBtns = el.querySelectorAll(".cbi-button.cbi-button-down"); + if (downBtns && downBtns.length > 0) { + downBtns.forEach(function (_el) { + _el.onclick = function () { + moveToBottom(el.id); + }; + }); + } } } + // enable enableDragForTable( "#cbi-shadowsocksr-servers table", From 667d594da4a06e83bb5c362ec201213fc126714a Mon Sep 17 00:00:00 2001 From: lean Date: Fri, 20 Mar 2020 14:14:03 +0800 Subject: [PATCH 2/4] Revert "mt7621: TCP and UDP traffic is forwarded correctly by HWNAT (1% CPU usage)" This reverts commit cd59b49863ee273705153b8918f79ba574e13028. --- ...w_table_hw-fix-incorrect-ethernet-ds.patch | 87 ------------------- ...w_table_hw-check-the-status-of-dst_n.patch | 32 ------- 2 files changed, 119 deletions(-) delete mode 100644 target/linux/generic/pending-4.14/647-netfilter-nf_flow_table_hw-fix-incorrect-ethernet-ds.patch delete mode 100644 target/linux/generic/pending-4.14/648-netfilter-nf_flow_table_hw-check-the-status-of-dst_n.patch diff --git a/target/linux/generic/pending-4.14/647-netfilter-nf_flow_table_hw-fix-incorrect-ethernet-ds.patch b/target/linux/generic/pending-4.14/647-netfilter-nf_flow_table_hw-fix-incorrect-ethernet-ds.patch deleted file mode 100644 index a81445bb95..0000000000 --- a/target/linux/generic/pending-4.14/647-netfilter-nf_flow_table_hw-fix-incorrect-ethernet-ds.patch +++ /dev/null @@ -1,87 +0,0 @@ -From: Konstantin Vasin -Date: Mon, 9 Mar 2020 18:38:54 +0300 -Subject: [PATCH] netfilter: nf_flow_table_hw: fix incorrect ethernet dst - address - -Ethernet destination for original traffic takes the source ethernet -address in the reply direction. For reply traffic, this takes -the source ethernet address of the original destination. - -This fix is based on the upstream commit 1b67e506: -("netfilter: nf_flow_table_offload: fix incorrect ethernet dst address") -from wenxu - -Signed-off-by: Konstantin Vasin ---- - ---- a/net/netfilter/nf_flow_table_hw.c -+++ b/net/netfilter/nf_flow_table_hw.c -@@ -24,17 +24,23 @@ struct flow_offload_hw { - struct flow_offload_hw_path dest; - }; - --static void flow_offload_check_ethernet(struct flow_offload_tuple *tuple, -+static void flow_offload_check_ethernet(struct flow_offload *flow, -+ enum flow_offload_tuple_dir dir, - struct flow_offload_hw_path *path) - { - struct net_device *dev = path->dev; - struct neighbour *n; -+ const void *daddr; -+ const struct dst_entry *dst_cache; - - if (dev->type != ARPHRD_ETHER) - return; - - memcpy(path->eth_src, path->dev->dev_addr, ETH_ALEN); -- n = dst_neigh_lookup(tuple->dst_cache, &tuple->src_v4); -+ -+ daddr = &flow->tuplehash[dir].tuple.src_v4; -+ dst_cache = flow->tuplehash[!dir].tuple.dst_cache; -+ n = dst_neigh_lookup(dst_cache, daddr); - if (!n) - return; - -@@ -44,17 +50,18 @@ static void flow_offload_check_ethernet(struct flow_offload_tuple *tuple, - } - - static int flow_offload_check_path(struct net *net, -- struct flow_offload_tuple *tuple, -+ struct flow_offload *flow, -+ enum flow_offload_tuple_dir dir, - struct flow_offload_hw_path *path) - { - struct net_device *dev; - -- dev = dev_get_by_index_rcu(net, tuple->iifidx); -+ dev = dev_get_by_index_rcu(net, flow->tuplehash[dir].tuple.iifidx); - if (!dev) - return -ENOENT; - - path->dev = dev; -- flow_offload_check_ethernet(tuple, path); -+ flow_offload_check_ethernet(flow, dir, path); - - if (dev->netdev_ops->ndo_flow_offload_check) - return dev->netdev_ops->ndo_flow_offload_check(path); -@@ -133,17 +140,14 @@ flow_offload_hw_prepare(struct net *net, struct flow_offload *flow) - { - struct flow_offload_hw_path src = {}; - struct flow_offload_hw_path dest = {}; -- struct flow_offload_tuple *tuple; - struct flow_offload_hw *offload = NULL; - - rcu_read_lock_bh(); - -- tuple = &flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple; -- if (flow_offload_check_path(net, tuple, &src)) -+ if (flow_offload_check_path(net, flow, FLOW_OFFLOAD_DIR_ORIGINAL, &src)) - goto out; - -- tuple = &flow->tuplehash[FLOW_OFFLOAD_DIR_REPLY].tuple; -- if (flow_offload_check_path(net, tuple, &dest)) -+ if (flow_offload_check_path(net, flow, FLOW_OFFLOAD_DIR_REPLY, &dest)) - goto out; - - if (!src.dev->netdev_ops->ndo_flow_offload) - diff --git a/target/linux/generic/pending-4.14/648-netfilter-nf_flow_table_hw-check-the-status-of-dst_n.patch b/target/linux/generic/pending-4.14/648-netfilter-nf_flow_table_hw-check-the-status-of-dst_n.patch deleted file mode 100644 index ed4a1e3a3e..0000000000 --- a/target/linux/generic/pending-4.14/648-netfilter-nf_flow_table_hw-check-the-status-of-dst_n.patch +++ /dev/null @@ -1,32 +0,0 @@ -From: Konstantin Vasin -Date: Mon, 9 Mar 2020 17:41:22 +0300 -Subject: [PATCH] netfilter: nf_flow_table_hw: check the status of - dst_neigh - -It's better to check the nud_state is VALID. -If there is not neigh previos, the lookup will -create a non NUD_VALID with 00:00:00:00:00:00 mac. - -This fix is based on the upstream commit f31ad71c44 -("netfilter: nf_flow_table_offload: check the status of dst_neigh") -from wenxu - -Signed-off-by: Konstantin Vasin ---- - -index e831c8830e91..1238d675a316 100644 ---- a/net/netfilter/nf_flow_table_hw.c -+++ b/net/netfilter/nf_flow_table_hw.c -@@ -44,8 +44,10 @@ static void flow_offload_check_ethernet(struct flow_offload *flow, - if (!n) - return; - -- memcpy(path->eth_dest, n->ha, ETH_ALEN); -- path->flags |= FLOW_OFFLOAD_PATH_ETHERNET; -+ if (n->nud_state & NUD_VALID) { -+ memcpy(path->eth_dest, n->ha, ETH_ALEN); -+ path->flags |= FLOW_OFFLOAD_PATH_ETHERNET; -+ } - neigh_release(n); - } - From c854c3f65973b967cf8e82d09edb4d5ba85788ed Mon Sep 17 00:00:00 2001 From: lean Date: Fri, 20 Mar 2020 14:43:15 +0800 Subject: [PATCH 3/4] luci-app-flowoffload: slient boot message --- package/lean/luci-app-flowoffload/Makefile | 2 +- .../luci-app-flowoffload/root/etc/init.d/flowoffload | 6 +++--- .../root/usr/share/dnscache-watchdog.sh | 9 --------- package/lean/luci-app-ssr-plus/Makefile | 2 +- 4 files changed, 5 insertions(+), 14 deletions(-) delete mode 100755 package/lean/luci-app-flowoffload/root/usr/share/dnscache-watchdog.sh diff --git a/package/lean/luci-app-flowoffload/Makefile b/package/lean/luci-app-flowoffload/Makefile index e63d75f76e..76d03a284a 100644 --- a/package/lean/luci-app-flowoffload/Makefile +++ b/package/lean/luci-app-flowoffload/Makefile @@ -9,7 +9,7 @@ LUCI_TITLE:=LuCI support for Flow Offload LUCI_DEPENDS:=+kmod-ipt-offload +pdnsd-alt +kmod-tcp-bbr @!LINUX_4_9 LUCI_PKGARCH:=all PKG_VERSION:=1.0 -PKG_RELEASE:=13 +PKG_RELEASE:=15 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-flowoffload/root/etc/init.d/flowoffload b/package/lean/luci-app-flowoffload/root/etc/init.d/flowoffload index 4c1e22ee29..e3925f692e 100755 --- a/package/lean/luci-app-flowoffload/root/etc/init.d/flowoffload +++ b/package/lean/luci-app-flowoffload/root/etc/init.d/flowoffload @@ -173,7 +173,7 @@ start_service(){ uci commit firewall if [ "$DNSMASQ_RESTART" = N ]; then /etc/init.d/dnsmasq restart && echo "DNSMASQ change" - /etc/init.d/firewall restart + /etc/init.d/firewall restart >/dev/null 2>&1 fi } @@ -185,7 +185,7 @@ stop_service(){ uci commit firewall if [ "$DNSMASQ_RESTART" = N ]; then /etc/init.d/dnsmasq restart && echo "DNSMASQ revert" - /etc/init.d/firewall restart + /etc/init.d/firewall restart >/dev/null 2>&1 fi } @@ -194,6 +194,6 @@ restart(){ stop start /etc/init.d/dnsmasq restart && echo "DNSMASQ restart" - /etc/init.d/firewall restart + /etc/init.d/firewall restart >/dev/null 2>&1 } diff --git a/package/lean/luci-app-flowoffload/root/usr/share/dnscache-watchdog.sh b/package/lean/luci-app-flowoffload/root/usr/share/dnscache-watchdog.sh deleted file mode 100755 index bf5161aeeb..0000000000 --- a/package/lean/luci-app-flowoffload/root/usr/share/dnscache-watchdog.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -dns_enable=$(uci flowoffload.@flow[0].dns 2>/dev/null) - -if [ $dns_enable -eq 1 ]; then - if ! pidof dnscache>/dev/null; then - /etc/init.d/flowoffload restart - fi -fi diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index 2f916ffeb6..e69964779f 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:=171 -PKG_RELEASE:=3 +PKG_RELEASE:=5 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) From 65cdb1918bf8ab2e880acf952c46b92d139df97d Mon Sep 17 00:00:00 2001 From: lean Date: Fri, 20 Mar 2020 14:55:55 +0800 Subject: [PATCH 4/4] luci-app-ssr-plus: combined v2nfconfig.lua --- package/lean/luci-app-ssr-plus/Makefile | 2 +- .../model/cbi/shadowsocksr/advanced.lua | 8 +- .../root/etc/init.d/shadowsocksr | 2 +- .../usr/share/shadowsocksr/genv2config.lua | 40 ++++--- .../usr/share/shadowsocksr/genv2nfconfig.lua | 106 ------------------ 5 files changed, 32 insertions(+), 126 deletions(-) delete mode 100644 package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2nfconfig.lua diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index e69964779f..75114593ce 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:=171 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua index 66cf22e78d..27c261d139 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua @@ -32,15 +32,15 @@ o.default = "https://ispip.clang.cn/all_cn.txt" o = s:option(Flag, "adblock", translate("Enable adblock")) o.rmempty = false +o = s:option(Value, "nfip_url", translate("nfip_url")) +o.default = "https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt" +o.description = translate("Customize Netflix IP Url") + o = s:option(Value, "adblock_url", translate("adblock_url")) o.default = "https://gitee.com/privacy-protection-tools/anti-ad/raw/master/anti-ad-for-dnsmasq.conf" o:depends("adblock", "1") o.description = translate("Support AdGuardHome and DNSMASQ format list") -o = s:option(Value, "nfip_url", translate("nfip_url")) -o.default = "https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt" -o.description = translate("Customize Netflix IP Url") - -- [[ SOCKS Proxy ]]-- if nixio.fs.access("/usr/bin/microsocks") then s = m:section(TypedSection, "socks5_proxy", translate("SOCKS5 Proxy Server Settings")) 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 1ec86bdac4..ae838ac9b0 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 @@ -409,7 +409,7 @@ start_redir() { dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 & $ncmd -c /var/etc/shadowsocksr_n.json $ARG_OTA -f /var/run/ssr-netflix.pid >/dev/null 2>&1 elif [ "$ntype" == "v2ray" ]; then - lua /usr/share/shadowsocksr/genv2nfconfig.lua $NETFLIX_SERVER tcp 4321 >/var/etc/v2-ssr-netflix.json + lua /usr/share/shadowsocksr/genv2config.lua $NETFLIX_SERVER tcp 4321 1088 >/var/etc/v2-ssr-netflix.json $ncmd -config /var/etc/v2-ssr-netflix.json >/dev/null 2>&1 & dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 & elif [ "$ntype" == "trojan" ]; then diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2config.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2config.lua index 175180516e..a485dc9cc8 100644 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2config.lua +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2config.lua @@ -3,6 +3,7 @@ local json = require "luci.jsonc" local server_section = arg[1] local proto = arg[2] local local_port = arg[3] +local socks_port = arg[4] or "0" local server = ucursor:get_all("shadowsocksr", server_section) @@ -11,20 +12,31 @@ log = { -- error = "/var/ssrplus.log", loglevel = "warning" }, - -- 传入连接 - inbound = { - port = local_port, - protocol = "dokodemo-door", - settings = { - network = proto, - followRedirect = true - }, - sniffing = { - enabled = true, - destOverride = { "http", "tls" } - } - }, - -- 传出连接 + -- 传入连接 + inbound = { + port = local_port, + protocol = "dokodemo-door", + settings = { + network = proto, + followRedirect = true + }, + sniffing = { + enabled = true, + destOverride = { "http", "tls" } + } + }, + -- 同时开启 socks 代理 + inboundDetour = (proto == "tcp" and socks_port ~= "0") and { + { + protocol = "socks", + port = 1088, + settings = { + auth = "noauth", + udp = true + } + } + } or nil, + -- 传出连接 outbound = { protocol = "vmess", settings = { diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2nfconfig.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2nfconfig.lua deleted file mode 100644 index c37eb3509e..0000000000 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2nfconfig.lua +++ /dev/null @@ -1,106 +0,0 @@ -local ucursor = require "luci.model.uci".cursor() -local json = require "luci.jsonc" -local server_section = arg[1] -local proto = arg[2] -local local_port = arg[3] - -local server = ucursor:get_all("shadowsocksr", server_section) - -local v2ray = { -log = { - -- error = "/var/ssrplus.log", - loglevel = "warning" -}, - -- 传入连接 - inbound = { - port = local_port, - protocol = "dokodemo-door", - settings = { - network = proto, - followRedirect = true - }, - sniffing = { - enabled = true, - destOverride = { "http", "tls" } - } - }, - -- 同时开启 socks 代理 - inboundDetour = (proto == "tcp") and { - { - protocol = "socks", - port = 1088, - settings = { - auth = "noauth", - udp = true - } - } - } or nil, - -- 传出连接 - outbound = { - protocol = "vmess", - settings = { - vnext = { - { - address = server.server, - port = tonumber(server.server_port), - users = { - { - id = server.vmess_id, - alterId = tonumber(server.alter_id), - security = server.security - } - } - } - } - }, - -- 底层传输配置 - 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,}, - kcpSettings = (server.transport == "kcp") and { - mtu = tonumber(server.mtu), - tti = tonumber(server.tti), - uplinkCapacity = tonumber(server.uplink_capacity), - downlinkCapacity = tonumber(server.downlink_capacity), - congestion = (server.congestion == "1") and true or false, - readBufferSize = tonumber(server.read_buffer_size), - writeBufferSize = tonumber(server.write_buffer_size), - header = { - type = server.kcp_guise - } - } or nil, - wsSettings = (server.transport == "ws") and (server.ws_path ~= nil or server.ws_host ~= nil) and { - path = server.ws_path, - headers = (server.ws_host ~= nil) and { - Host = server.ws_host - } or nil, - } or nil, - httpSettings = (server.transport == "h2") and { - path = server.h2_path, - host = server.h2_host, - } or nil, - quicSettings = (server.transport == "quic") and { - security = server.quic_security, - key = server.quic_key, - header = { - type = server.quic_guise - } - } or nil - }, - mux = { - enabled = (server.mux == "1") and true or false, - concurrency = tonumber(server.concurrency) - } - }, - - -- 额外传出连接 - outboundDetour = { - { - protocol = "freedom", - tag = "direct", - settings = { keep = "" } - } - } -} -print(json.stringify(v2ray, 1))