Browse Source

luci-app-ssr-plus: add udp ping test node feature

coolsnowwolf 3 weeks ago
parent
commit
06c4fd41b4
3 changed files with 23 additions and 1 deletions
  1. 18 0
      .gitignore
  2. 1 1
      luci-app-ssr-plus/Makefile
  3. 4 0
      luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua

+ 18 - 0
.gitignore

@@ -0,0 +1,18 @@
+*.o
+.DS_Store
+.*.swp
+/.github/copilot-instructions.md
+/*.patch
+key-build*
+*.orig
+*.rej
+*~
+.#*
+*#
+.emacs.desktop*
+TAGS*~
+git-src
+.project
+.cproject
+.ccache
+.vscode*

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

@@ -40,7 +40,7 @@ LUCI_PKGARCH:=all
 LUCI_DEPENDS:= \
 	+coreutils +coreutils-base64 +dns2tcp +dnsmasq-full +@PACKAGE_dnsmasq_full_ipset +ipset +kmod-ipt-nat +jq \
 	+ip-full +iptables +iptables-mod-tproxy +lua +lua-neturl +libuci-lua +microsocks \
-	+tcping +resolveip +shadowsocksr-libev-ssr-check +curl \
+	+tcping +resolveip +shadowsocksr-libev-ssr-check +curl +nping \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:curl \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:v2ray-core \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Xray:curl \

+ 4 - 0
luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua

@@ -69,6 +69,10 @@ function act_ping()
 		e.ping = luci.sys.exec(string.format("echo -n $(tcping -q -c 1 -i 1 -t 2 -p %s %s 2>&1 | grep -o 'time=[0-9]*' | awk -F '=' '{print $2}') 2>/dev/null", port, domain))
 		if (e.ping == "") then
 			e.ping = luci.sys.exec("echo -n $(ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*' | awk -F '=' '{print $2}') 2>/dev/null" % domain)
+			if (e.ping == "") then
+				-- UDP ping test using nping
+				e.ping = luci.sys.exec(string.format("echo -n $(nping --udp -c 1 -p %s %s 2>/dev/null | grep -o 'Avg rtt: [0-9.]*ms' | awk '{print $3}' | sed 's/ms//' | head -1) 2>/dev/null", port, domain))
+			end
 		end
 	end
 	if (iret == 0) then