Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync #568

Merged
merged 2 commits into from
Nov 16, 2024
Merged

sync #568

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand Down
30 changes: 27 additions & 3 deletions luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,42 @@ <h3><%=servername%></h3>
</div>
</div>
<% 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 %>
<div class="cbi-value">
<label class="cbi-value-title"><%:V2Ray/XRay user id%></label>
<label class="cbi-value-title"><%:V2Ray user id%></label>
<div class="cbi-value-field">
<input type="text" name="v2ray_user" placeholder="<%:V2Ray user%>" class="cbi-input-text" value="<%=uci:get("v2ray","omrout","s_vmess_user_id")%>" />
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%> <%:V2Ray is used for TCP and UDP.%>
<%:Key is retrieved from server API by default.%>
</div>
</div>
</div>
<% end %>
<% if nixio.fs.access("/etc/init.d/xray") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:XRay user id%></label>
<div class="cbi-value-field">
<input type="text" name="xray_user" placeholder="<%:XRay user%>" class="cbi-input-text" value="<%=uci:get("xray","omrout","s_vmess_user_id")%>" />
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%>
</div>
</div>
</div>
<% end %>
<% if nixio.fs.access("/etc/init.d/xray") or nixio.fs.access("/etc/init.d/v2ray") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:V2Ray/XRay UDP%></label>
<div class="cbi-value-field">
<input type="checkbox" name="v2rayudp" class="cbi-input-checkbox" value="1" <% if luci.model.uci.cursor():get("v2ray","main_transparent_proxy","redirect_udp") == "1" or luci.model.uci.cursor():get("xray","main_transparent_proxy","redirect_udp") == "1" then %>checked<% end %>>
<br />
<div class="cbi-value-description">
<%:When proxy V2Ray/XRay VLESS, VMESS or Trojan is used, use it for UDP%>
</div>
</div>
</div>
<% end %>
<div class="cbi-value">
<label class="cbi-value-title"><%:Encryption%></label>
<div class="cbi-value-field">
Expand Down
35 changes: 26 additions & 9 deletions omr-tracker/files/bin/omr-tracker
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -205,7 +206,7 @@ _ping() {
fi
false
}

#'
_httping() {
local host=$1
local deviceip=$2
Expand All @@ -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
}
Expand Down