diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile
index c1fab606c..916295204 100644
--- a/luci-app-passwall/Makefile
+++ b/luci-app-passwall/Makefile
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=26.9.9
-PKG_RELEASE:=271
+PKG_RELEASE:=272
PKG_PO_VERSION:=$(PKG_VERSION)
PKG_CONFIG_DEPENDS:= \
diff --git a/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm b/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm
index 09c7fd0e4..f2f692b59 100644
--- a/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm
+++ b/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm
@@ -1402,6 +1402,7 @@ table td, .table .td {
var node_tr_html = "";
for (var i = 0; i < group_nodes[group].length; i++) {
let o = group_nodes[group][i]
+ let _port = o["port"] || o["hysteria_hop"] || o["hysteria2_hop"];
var newDom = node_template.cloneNode(true);
newDom.classList.add("cbi-rowstyle-" + (i % 2 + 1));
var innerHTML = newDom.innerHTML;
@@ -1415,17 +1416,15 @@ table td, .table .td {
} else {
innerHTML = innerHTML.split("{{tcping}}").join('---');
}
- let is_realm = (o.type === "Hysteria2" || o.protocol === 'hysteria2') && o.hysteria2_realms || false;
- if (o["protocol"] === '_shunt' || is_realm) {
- innerHTML = innerHTML.split("{{url_test}}").join('---');
- } else {
+ if (o["address"] && _port) {
innerHTML = innerHTML.split("{{url_test}}").join('<%:Test%>');
+ } else {
+ innerHTML = innerHTML.split("{{url_test}}").join('---');
}
innerHTML = innerHTML.split("{{id}}").join(o[".name"]);
innerHTML = innerHTML.split("{{group}}").join(o["group"] || "");
let node_remarks = get_remarks_name(o);
if (show_node_info == "1") {
- let _port = o["port"] || o["hysteria_hop"] || o["hysteria2_hop"];
if (_port) _port = _port.replace(/:/g, '-');
if (o["address"] && _port) {
let _address = o["address"]
diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh
index 92beb69b7..cee2811be 100755
--- a/luci-app-passwall/root/usr/share/passwall/app.sh
+++ b/luci-app-passwall/root/usr/share/passwall/app.sh
@@ -489,8 +489,6 @@ run_socks() {
;;
esac
- set_cache_var "node_${node}_socks_port" "${socks_port}"
-
# http to socks
[ -z "$http_flag" ] && [ "$http_port" != "0" ] && [ -n "$http_config_file" ] && [ "$type" != "sing-box" ] && [ "$type" != "xray" ] && [ "$type" != "socks" ] && {
json_init
@@ -829,7 +827,6 @@ start_global() {
set_cache_var "GLOBAL_SOCKS_server" "${GLOBAL_SOCKS_server}"
}
[ "$type" != "sing-box" ] && [ "$type" != "xray" ] && echo "${NODE}" >> $TMP_PATH/direct_node_list
- set_cache_var "node_${NODE}_redir_port" "$REDIR_PORT"
set_cache_var "ACL_GLOBAL_node" "$NODE"
set_cache_var "ACL_GLOBAL_redir_port" "$REDIR_PORT"
}
@@ -1578,9 +1575,9 @@ acl_app() {
#dhcp.leases to hosts
$APP_PATH/lease2hosts.sh > /dev/null 2>&1 &
}
- local _redir_port=$(get_cache_var "node_${node}_redir_port")
- local _socks_port=$(get_cache_var "node_${node}_socks_port")
- local _enable_log=$(get_cache_var "node_${node}_enable_log")
+ local _redir_port=$(get_cache_var "acl_node_${node}_redir_port")
+ local _socks_port=$(get_cache_var "acl_node_${node}_socks_port")
+ local _enable_log=$(get_cache_var "acl_node_${node}_enable_log")
local _dns_port
if [ -n "${_socks_port}" ] && [ -n "${_redir_port}" ] && [ "${_enable_log}" != "1" ] && [ "${log}" != "1" ]; then
socks_port=${_socks_port}
@@ -1589,14 +1586,14 @@ acl_app() {
run_dns ${_dns_port}
else
socks_port=$(get_new_port $(expr $socks_port + 1))
- set_cache_var "node_${node}_socks_port" "${socks_port}"
+ set_cache_var "acl_node_${node}_socks_port" "${socks_port}"
redir_port=$(get_new_port $(expr $redir_port + 1))
- set_cache_var "node_${node}_redir_port" "${redir_port}"
+ set_cache_var "acl_node_${node}_redir_port" "${redir_port}"
node_port=$redir_port
local log_file="/dev/null"
[ "${log}" = "1" ] && {
log_file="${TMP_ACL_PATH}/${sid}/node.log"
- set_cache_var "node_${node}_enable_log" "1"
+ set_cache_var "acl_node_${node}_enable_log" "1"
}
if [ "${type}" = "sing-box" ] || [ "${type}" = "xray" ]; then
diff --git a/luci-app-passwall/root/usr/share/passwall/utils.sh b/luci-app-passwall/root/usr/share/passwall/utils.sh
index cc8eb5c1a..7a06d7e9e 100755
--- a/luci-app-passwall/root/usr/share/passwall/utils.sh
+++ b/luci-app-passwall/root/usr/share/passwall/utils.sh
@@ -60,6 +60,63 @@ config_t_get() {
echo "${ret:=${3}}"
}
+eval_set_val() {
+ for i in $@; do
+ for j in $i; do
+ eval $j
+ done
+ done
+}
+
+eval_unset_val() {
+ for i in $@; do
+ for j in $i; do
+ eval unset $j
+ done
+ done
+}
+
+lua_api() {
+ local func=${1}
+ [ -z "${func}" ] && {
+ echo "nil"
+ return
+ }
+ echo $(lua -e "local api = require 'luci.passwall.api' print(api.${func})")
+}
+
+eval_cache_var() {
+ [ -s "$TMP_PATH/var" ] && eval $(cat "$TMP_PATH/var")
+}
+
+del_cache_var() {
+ local key="${1}"
+ [ -n "${key}" ] && [ -f "${TMP_PATH}/var" ] && {
+ sed -i "/${key}=/d" $TMP_PATH/var >/dev/null 2>&1
+ }
+}
+
+set_cache_var() {
+ local key="${1}"
+ shift 1
+ [ -n "${key}" ] && {
+ del_cache_var ${key}
+ local val="$@"
+ [ -n "${val}" ] && {
+ [ ! -d $TMP_PATH ] && mkdir -p $TMP_PATH
+ echo "${key}=\"${val}\"" >> $TMP_PATH/var
+ eval ${key}=\"${val}\"
+ }
+ }
+}
+
+get_cache_var() {
+ local key="${1}"
+ [ -n "${key}" ] && [ -s "$TMP_PATH/var" ] && {
+ echo $(cat $TMP_PATH/var | grep "^${key}=" | awk -F '=' '{print $2}' | tail -n 1 | awk -F'"' '{print $2}')
+ }
+}
+
first_type() {
[ "${1#/}" != "$1" ] && [ -x "$1" ] && echo "$1" && return
for p in "/bin/$1" "/usr/bin/$1" "${TMP_BIN_PATH:-/tmp}/$1"; do
@@ -283,53 +340,42 @@ get_new_port() {
local default_start_port=2001
local min_port=1025
local max_port=49151
- local port="$1"
+ local port="$1" # Required parameter; please pass "auto" if you want it to be automatic.
local protocol=$(echo "$2" | tr 'A-Z' 'a-z')
- local LOCK_FILE="${LOCK_PATH}/${CONFIG}_get_prot.lock"
- while ! mkdir "$LOCK_FILE" 2>/dev/null; do
- sleep 0.05
- done
+ local is_auto
if [ "$port" = "auto" ]; then
- local now last_time diff last_port
- now=$(date +%s 2>/dev/null)
- last_time=$(get_cache_var "last_get_new_port_time")
- if [ -n "$now" ] && [ -n "$last_time" ]; then
- diff=$(expr "$now" - "$last_time")
- [ "$diff" -lt 0 ] && diff=$(expr 0 - "$diff")
+ is_auto=1
+ local last_get_new_port_auto=$(get_cache_var "last_get_new_port_auto")
+ if [ -n "$last_get_new_port_auto" ]; then
+ port=$(expr "$last_get_new_port_auto" + 1)
else
- diff=999
- fi
- if [ "$diff" -gt 10 ]; then
port=$default_start_port
- else
- last_port=$(get_cache_var "last_get_new_port_auto")
- if [ -n "$last_port" ]; then
- port=$(expr "$last_port" + 1)
- else
- port=$default_start_port
- fi
fi
fi
- [ "$port" -lt $min_port ] || [ "$port" -gt $max_port ] && port=$default_start_port
- local start_port="$port"
+ ([ "$port" -lt "$min_port" ] || [ "$port" -gt "$max_port" ]) && port=$default_start_port
while :; do
- if [ "$(check_port_exists "$port" "$protocol")" = 0 ]; then
- break
+ local result=$(check_port_exists "$port" "$protocol")
+ if [ "$is_auto" = "1" ] && [ -n "$(get_cache_var "get_port_${port}")" ]; then
+ # The port has already been allocated, continue to the next port.
+ result=1
fi
- port=$(expr "$port" + 1)
- if [ "$port" -gt $max_port ]; then
- port=$min_port
+ [ "$result" = "0" ] && break
+ if [ "$port" -lt "$max_port" ]; then
+ # If the port is smaller than the maximum port, increment by 1 and continue.
+ port=$(expr "$port" + 1)
+ elif [ "$port" -gt "$min_port" ]; then
+ # If the port is greater than the minimum port, decrement by 1 and continue.
+ port=$(expr "$port" - 1)
+ else
+ # Otherwise, reassign the default starting port.
+ port=$default_start_port
fi
- [ "$port" = "$start_port" ] && {
- rmdir "$LOCK_FILE" 2>/dev/null
- return 1
- }
done
- if [ "$1" = "auto" ]; then
+ if [ "$is_auto" = "1" ]; then
+ # Set cache to prevent the port from being allocated again.
+ set_cache_var "get_port_${port}" "1"
set_cache_var "last_get_new_port_auto" "$port"
- [ -n "$now" ] && set_cache_var "last_get_new_port_time" "$now"
fi
- rmdir "$LOCK_FILE" 2>/dev/null
echo "$port"
}
@@ -359,64 +405,6 @@ check_ver() {
echo 255
}
-eval_set_val() {
- for i in $@; do
- for j in $i; do
- eval $j
- done
- done
-}
-
-eval_unset_val() {
- for i in $@; do
- for j in $i; do
- eval unset $j
- done
- done
-}
-
-lua_api() {
- local func=${1}
- [ -z "${func}" ] && {
- echo "nil"
- return
- }
- echo $(lua -e "local api = require 'luci.passwall.api' print(api.${func})")
-}
-
-
-del_cache_var() {
- local key="${1}"
- [ -n "${key}" ] && [ -f "${TMP_PATH}/var" ] && {
- sed -i "/${key}=/d" $TMP_PATH/var >/dev/null 2>&1
- }
-}
-
-set_cache_var() {
- local key="${1}"
- shift 1
- [ -n "${key}" ] && {
- del_cache_var ${key}
- local val="$@"
- [ -n "${val}" ] && {
- [ ! -d $TMP_PATH ] && mkdir -p $TMP_PATH
- echo "${key}=\"${val}\"" >> $TMP_PATH/var
- eval ${key}=\"${val}\"
- }
- }
-}
-
-get_cache_var() {
- local key="${1}"
- [ -n "${key}" ] && [ -s "$TMP_PATH/var" ] && {
- echo $(cat $TMP_PATH/var | grep "^${key}=" | awk -F '=' '{print $2}' | tail -n 1 | awk -F'"' '{print $2}')
- }
-}
-
-eval_cache_var() {
- [ -s "$TMP_PATH/var" ] && eval $(cat "$TMP_PATH/var")
-}
-
has_1_65535() {
local val="$1"
val=${val//:/-}
diff --git a/luci-mod-status/Makefile b/luci-mod-status/Makefile
index 98607861b..9a1f49fc3 100644
--- a/luci-mod-status/Makefile
+++ b/luci-mod-status/Makefile
@@ -7,9 +7,9 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI Status Pages
-LUCI_DEPENDS:=+luci-base +libiwinfo +rpcd-mod-iwinfo +ucode +ucode-mod-fs +ucode-mod-ubus
+LUCI_DEPENDS:=+luci-base +libiwinfo +rpcd-mod-iwinfo +ucode +ucode-mod-fs +ucode-mod-ubus +luci-app-oui
-PKG_RELEASE:=7
+PKG_RELEASE:=8
PKG_BUILD_DEPENDS:=iwinfo
PKG_LICENSE:=Apache-2.0