1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-14 19:41:51 +00:00

Only display VPS available proxy

This commit is contained in:
Ycarus (Yannick Chabanois) 2023-12-06 18:04:53 +01:00
parent 9eca2b3ed7
commit 4a660fdd72
2 changed files with 54 additions and 0 deletions

View file

@ -232,6 +232,42 @@
<label class="cbi-value-title"><%:Default Proxy%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="default_proxy" size="1">
<%
local available_proxys = uci:get("openmptcprouter","vps","available_proxy") or ""
if available_proxys ~= "" then
if (type(available_proxys) ~= "table") then
available_proxys = {available_proxys}
end
for _, proxy in pairs(available_proxys) do
if proxy == "shadowsocks" then %>
<% if nixio.fs.access("/etc/init.d/shadowsocks-libev") then %><option value="shadowsocks" <% if uci:get("openmptcprouter","settings","shadowsocks") == "0" or uci:get("openmptcprouter","settings","proxy") == nil then %>selected="selected"<% end %>>Shadowsocks</option><% end %>
<% elseif proxy == "v2ray" then %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray" then %>selected="selected"<% end %>>V2Ray VLESS</option><% end %>
<% elseif proxy == "v2ray-vmess" then %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-vmess" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-vmess" then %>selected="selected"<% end %>>V2Ray VMESS</option><% end %>
<% elseif proxy == "v2ray-trojan" then %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-trojan" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-trojan" then %>selected="selected"<% end %>>V2Ray TROJAN</option><% end %>
<% elseif proxy == "v2ray-socks" then %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-socks" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-socks" then %>selected="selected"<% end %>>V2Ray SOCKS</option><% end %>
<% elseif proxy == "xray" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray" <% if uci:get("openmptcprouter","settings","proxy") == "xray" then %>selected="selected"<% end %>>XRay VLESS</option><% end %>
<% elseif proxy == "xray-vless-reality" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-vless-reality" <% if uci:get("openmptcprouter","settings","proxy") == "xray-vless-reality" then %>selected="selected"<% end %>>XRay VLESS Reality</option><% end %>
<% elseif proxy == "xray-vmess" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-vmess" <% if uci:get("openmptcprouter","settings","proxy") == "xray-vmess" then %>selected="selected"<% end %>>XRay VMESS</option><% end %>
<% elseif proxy == "xray-trojan" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-trojan" <% if uci:get("openmptcprouter","settings","proxy") == "xray-trojan" then %>selected="selected"<% end %>>XRay Trojan</option><% end %>
<% elseif proxy == "xray-socks" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-socks" <% if uci:get("openmptcprouter","settings","proxy") == "xray-socks" then %>selected="selected"<% end %>>XRay Socks</option><% end %>
<% elseif proxy == "xray-shadowsocks" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-shadowsocks" <% if uci:get("openmptcprouter","settings","proxy") == "xray-shadowsocks" then %>selected="selected"<% end %>>XRay Shadowsocks 2022</option><% end %>
<% elseif proxy == "shadowsocks-rust" then %>
<% if nixio.fs.access("/etc/init.d/shadowsocks-rust") then %><option value="shadowsocks-rust" <% if uci:get("openmptcprouter","settings","proxy") == "shadowsocks-rust" then %>selected="selected"<% end %>>Shadowsocks-Rust 2022</option><% end %>
<% end
end %>
<%
else
%>
<% if nixio.fs.access("/etc/init.d/shadowsocks-libev") then %><option value="shadowsocks" <% if uci:get("openmptcprouter","settings","shadowsocks") == "0" or uci:get("openmptcprouter","settings","proxy") == nil then %>selected="selected"<% end %>>Shadowsocks</option><% end %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray" then %>selected="selected"<% end %>>V2Ray VLESS</option><% end %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-vmess" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-vmess" then %>selected="selected"<% end %>>V2Ray VMESS</option><% end %>
@ -244,6 +280,9 @@
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-socks" <% if uci:get("openmptcprouter","settings","proxy") == "xray-socks" then %>selected="selected"<% end %>>XRay Socks</option><% end %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-shadowsocks" <% if uci:get("openmptcprouter","settings","proxy") == "xray-shadowsocks" then %>selected="selected"<% end %>>XRay Shadowsocks 2022</option><% end %>
<% if nixio.fs.access("/etc/init.d/shadowsocks-rust") then %><option value="shadowsocks-rust" <% if uci:get("openmptcprouter","settings","proxy") == "shadowsocks-rust" then %>selected="selected"<% end %>>Shadowsocks-Rust 2022</option><% end %>
<%
end
%>
<option value="none" <% if uci:get("openmptcprouter","settings","proxy") == "none" then %>selected="selected"<% end %>>None</option>
</select>
<br />

View file

@ -1936,8 +1936,10 @@ _set_config_from_vps() {
# Get available server
available_vpn="$(echo "$vps_config" | jsonfilter -q -e '@.vpn.available' | sed -e 's/\[ //' -e 's/ \]//' -e 's/,//g')"
available_proxy="$(echo "$vps_config" | jsonfilter -q -e '@.proxy.available' | sed -e 's/\[ //' -e 's/ \]//' -e 's/,//g')"
uci -q batch <<-EOF >/dev/null
del openmptcprouter.${servername}.available_vpn
del openmptcprouter.${servername}.available_proxy
EOF
if [ "$user_permission" = "ro" ]; then
@ -1947,6 +1949,12 @@ _set_config_from_vps() {
set openmptcprouter.${servername}.available_vpn=${current_vpn}
EOF
fi
current_proxy="$(echo "$vps_config" | jsonfilter -q -e '@.proxy.current')"
if [ -n "$current_proxy" ]; then
uci -q batch <<-EOF >/dev/null
set openmptcprouter.${servername}.available_proxy=${current_proxy}
EOF
fi
else
if [ -n "$available_vpn" ]; then
@ -1956,6 +1964,13 @@ _set_config_from_vps() {
EOF
done
fi
if [ -n "$available_proxy" ]; then
for proxy in $available_proxy; do
uci -q batch <<-EOF >/dev/null
add_list openmptcprouter.${servername}.available_proxy=$proxy
EOF
done
fi
fi
if [ "$noerror" = "1" ]; then
uci -q batch <<-EOF >/dev/null