From d4e18ee799871a1d065d965437dd8f573d10306d Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 15 Nov 2024 17:30:15 +0100 Subject: [PATCH 1/2] Separate XRay and V2Ray key in wizard, add V2Ray/XRay UDP activation in Wizard page --- .../luasrc/controller/openmptcprouter.lua | 20 +++++++++---- .../luasrc/view/openmptcprouter/wizard.htm | 30 +++++++++++++++++-- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua index 51aa986d6d..31e8031617 100644 --- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua +++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua @@ -1076,6 +1076,14 @@ function wizard_add() luci.sys.call("/etc/init.d/shadowsocks-rust rules_down >/dev/null 2>/dev/null") end + -- Enable/disable v2ray/xray udp + local v2rayudp = luci.http.formvalue("v2rayudp") or "0" + ucic:set("v2ray","main_transparent_proxy","redirect_udp",v2rayudp) + ucic:save("v2ray") + ucic:commit("v2ray") + ucic:set("xray","main_transparent_proxy","redirect_udp",v2rayudp) + ucic:save("xray") + ucic:commit("xray") local v2ray_user = luci.http.formvalue("v2ray_user") ucic:set("v2ray","omrout","s_vmess_user_id",v2ray_user) @@ -1084,13 +1092,15 @@ function wizard_add() ucic:set("v2ray","omrout","s_socks_user_id",v2ray_user) ucic:save("v2ray") ucic:commit("v2ray") - ucic:set("xray","omrout","s_vmess_user_id",v2ray_user) - ucic:set("xray","omrout","s_vless_user_id",v2ray_user) - ucic:set("xray","omrout","s_vless_reality_user_id",v2ray_user) - ucic:set("xray","omrout","s_trojan_user_id",v2ray_user) - ucic:set("xray","omrout","s_socks_user_id",v2ray_user) + local xray_user = luci.http.formvalue("xray_user") + ucic:set("xray","omrout","s_vmess_user_id",xray_user) + ucic:set("xray","omrout","s_vless_user_id",xray_user) + ucic:set("xray","omrout","s_vless_reality_user_id",xray_user) + ucic:set("xray","omrout","s_trojan_user_id",xray_user) + ucic:set("xray","omrout","s_socks_user_id",xray_user) ucic:save("xray") ucic:commit("xray") + ucic:save("shadowsocks-libev") ucic:commit("shadowsocks-libev") ucic:save("shadowsocks-rust") diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm index 0d715c0276..1959140a29 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm @@ -321,18 +321,42 @@

<%=servername%>

<% end %> - <% if nixio.fs.access("/etc/init.d/v2ray") or nixio.fs.access("/etc/init.d/xray") then %> + <% if nixio.fs.access("/etc/init.d/v2ray") then %>
- +
" />
- <%:Key is retrieved from server API by default.%> <%:V2Ray is used for TCP and UDP.%> + <%:Key is retrieved from server API by default.%>
<% end %> + <% if nixio.fs.access("/etc/init.d/xray") then %> +
+ +
+ " /> +
+
+ <%:Key is retrieved from server API by default.%> +
+
+
+ <% end %> + <% if nixio.fs.access("/etc/init.d/xray") or nixio.fs.access("/etc/init.d/v2ray") then %> +
+ +
+ checked<% end %>> +
+
+ <%:When proxy V2Ray/XRay VLESS, VMESS or Trojan is used, use it for UDP%> +
+
+
+ <% end %>
From 7a89fb070a6f73e95518bd2a69ad82233c9c8046 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 15 Nov 2024 17:31:15 +0100 Subject: [PATCH 2/2] Add Link Quality check support for httping in OMR-Tracker --- omr-tracker/files/bin/omr-tracker | 35 +++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/omr-tracker/files/bin/omr-tracker b/omr-tracker/files/bin/omr-tracker index d2c629a00a..0bcec97853 100755 --- a/omr-tracker/files/bin/omr-tracker +++ b/omr-tracker/files/bin/omr-tracker @@ -164,6 +164,7 @@ _ping() { "${host}" 2>&1 ) loss=$(echo "$ret" | awk '/packet loss/ {gsub("%","");print $6}' | tr -d '\n') + if [ -n "$loss" ] && [ "$loss" != "100" ]; then if [ "$localip" = "yes" ]; then latency=$(echo "$ret" | awk -F/ '/rtt/ {print int($5)}' | tr -d '\n') @@ -205,7 +206,7 @@ _ping() { fi false } - +#' _httping() { local host=$1 local deviceip=$2 @@ -216,25 +217,41 @@ _httping() { -y "${deviceip}" \ -t "$OMR_TRACKER_TIMEOUT" \ -c "$OMR_TRACKER_COUNT" 2>&1 - ) && echo "$ret" | grep -sq "1 ok" && { + ) + bindcheck=$(echo "$ret" | grep "Address not available") + [ -n "$bindcheck" ] && OMR_TRACKER_NO_BIND=1 + loss=$(echo "$ret" | awk '/failed/ {gsub("%",""); print int($5)}' | tr -d '\n') + if [ -n "$loss" ] && [ "$loss" != "100" ]; then if [ "$localip" = "yes" ]; then - OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') - #_update_rto "$OMR_TRACKER_LATENCY" + latency=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') + [ -n "$latency" ] && { + OMR_TRACKER_LATENCY="$latency" + #_update_rto "$OMR_TRACKER_LATENCY" + } + OMR_TRACKER_LOSS="$loss" fi return - } + fi else ret=$(httping -l "${host}" \ -y "${deviceip}" \ -t "$OMR_TRACKER_TIMEOUT" \ -c "$OMR_TRACKER_COUNT" 2>&1 - ) && echo "$ret" | grep -sq "1 ok" && { + ) + bindcheck=$(echo "$ret" | grep "Address not available") + [ -n "$bindcheck" ] && OMR_TRACKER_NO_BIND=1 + loss=$(echo "$ret" | awk '/failed/ {gsub("%",""); print int($5)}' | tr -d '\n') + if [ -n "$loss" ] && [ "$loss" != "100" ]; then if [ "$localip" = "yes" ]; then - OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') - #_update_rto "$OMR_TRACKER_LATENCY" + latency=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') + [ -n "$latency" ] && { + OMR_TRACKER_LATENCY="$latency" + #_update_rto "$OMR_TRACKER_LATENCY" + } + OMR_TRACKER_LOSS="$loss" fi return - } + fi fi false }