mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-03 04:23:56 +08:00
🎄 Sync 2026-10-17 22:14:00
This commit is contained in:
1 parent
c9ccf6f883
commit
94fcee8f81
13 files changed
+137
-90
No files matched your search
@@ -22,11 +22,11 @@ PKG_NAME:=luci-app-amlogic
|
||||
# DD = day (01 = 1st)
|
||||
# NN = daily release sequence (01 = first release of the day, 02 = second, ...)
|
||||
# Example below: 26.10.0101 = October 1, 2026, 1st release of the day
|
||||
PKG_VERSION:=26.10.1602
|
||||
PKG_VERSION:=26.10.1603
|
||||
# PKG_RELEASE marks the LuCI variant; onekey-install.sh relies on it (do NOT bump)
|
||||
# 1 = Lua version (lua branch) → tag: 26.10.0101
|
||||
# 2 = JS version (main branch) → tag: 26.10.0101-js
|
||||
PKG_RELEASE:=22
|
||||
PKG_RELEASE:=23
|
||||
|
||||
PKG_LICENSE:=GPL-2.0 License
|
||||
PKG_MAINTAINER:=ophub <https://github.com/ophub/luci-app-amlogic>
|
||||
|
||||
@@ -44,6 +44,17 @@ return view.extend({
|
||||
'<br />' + _('Tip: The same files as the current OpenWrt system\'s BOARD (such as rock5b) and kernel (such as 5.10) will be downloaded.'));
|
||||
const o = m.section(form.NamedSection, 'config', 'amlogic');
|
||||
|
||||
// Load the derived default ourselves whenever the stored value is blank.
|
||||
const orDefault = function (option, defval) {
|
||||
option.default = defval;
|
||||
option.load = function (section_id) {
|
||||
const v = uci.get(this.uciconfig ?? 'amlogic',
|
||||
this.ucisection ?? section_id,
|
||||
this.ucioption ?? this.option);
|
||||
return (v == null || v === '') ? defval : v;
|
||||
};
|
||||
};
|
||||
|
||||
// 1. Display device platform
|
||||
const dev = o.option(form.DummyValue, 'mydevice', _('Current Device:'),
|
||||
_('Display the PLATFORM classification of the device.'));
|
||||
@@ -93,32 +104,38 @@ return view.extend({
|
||||
knownTags.kernel_flippy = 'kernel_flippy [Mainline Stable Kernel by Flippy]';
|
||||
knownTags.kernel_beta = 'kernel_beta [Beta Kernel]';
|
||||
}
|
||||
// Determine default tag from saved config or kernel_release uname string.
|
||||
let kernelTagDefault = uci.get('amlogic', 'config', 'amlogic_kernel_tags') || '';
|
||||
if (!kernelTagDefault) {
|
||||
const u = state.kernel_release || '';
|
||||
if (u.indexOf('-rk3588') >= 0) kernelTagDefault = 'kernel_rk3588';
|
||||
else if (u.indexOf('-rk35xx') >= 0) kernelTagDefault = 'kernel_rk35xx';
|
||||
else if (u.indexOf('-beta') >= 0) kernelTagDefault = 'kernel_beta';
|
||||
else kernelTagDefault = 'kernel_stable';
|
||||
}
|
||||
// Derive the default tag from the kernel_release uname string. A value already
|
||||
// saved in UCI wins; orDefault() below only kicks in when that value is blank.
|
||||
const uname = state.kernel_release || '';
|
||||
let kernelTagDefault = 'kernel_stable';
|
||||
if (uname.indexOf('-rk3588') >= 0) kernelTagDefault = 'kernel_rk3588';
|
||||
else if (uname.indexOf('-rk35xx') >= 0) kernelTagDefault = 'kernel_rk35xx';
|
||||
else if (uname.indexOf('-beta') >= 0) kernelTagDefault = 'kernel_beta';
|
||||
const ktags = o.option(form.Value, 'amlogic_kernel_tags',
|
||||
_('Kernel download tags:'),
|
||||
_('Set the kernel files download tags on github.com in [Online Download Update].'));
|
||||
Object.keys(knownTags).forEach(function (k) { ktags.value(k, _(knownTags[k])); });
|
||||
// kernel_beta is only offered for ophub/kernel, but a beta kernel may still be
|
||||
// running, so keep the derived value selectable even when it is not listed.
|
||||
if (!knownTags[kernelTagDefault]) ktags.value(kernelTagDefault, kernelTagDefault);
|
||||
ktags.default = kernelTagDefault;
|
||||
orDefault(ktags, kernelTagDefault);
|
||||
ktags.rmempty = false;
|
||||
|
||||
// 7. Kernel branch
|
||||
const kbranch = o.option(form.ListValue, 'amlogic_kernel_branch',
|
||||
const kbranches = ['5.10', '5.15', '6.1', '6.6', '6.12', '6.18'];
|
||||
const kbranch = o.option(form.Value, 'amlogic_kernel_branch',
|
||||
_('Set version branch:'),
|
||||
_('Set the version branch of the OpenWrt files and kernel selected in [Online Download Update].'));
|
||||
['5.10', '5.15', '6.1', '6.6', '6.12', '6.18'].forEach(function (b) {
|
||||
kbranch.value(b, _(b));
|
||||
|
||||
// Extract the major.minor version from the kernel uname string to determine the default branch.
|
||||
const km = uname.match(/^(\d+\.\d+)/);
|
||||
const kbranchDefault = km ? km[1] : kbranches[0];
|
||||
// If the derived default branch is not in the list, add it so it can be selected.
|
||||
if (kbranches.indexOf(kbranchDefault) < 0) kbranches.push(kbranchDefault);
|
||||
kbranches.forEach(function (b) {
|
||||
kbranch.value(b, b);
|
||||
});
|
||||
const m2 = (state.kernel_release || '').match(/^(\d+\.\d+)/);
|
||||
kbranch.default = m2 ? m2[1] : '5.10';
|
||||
orDefault(kbranch, kbranchDefault);
|
||||
kbranch.rmempty = false;
|
||||
|
||||
// 8. Plugin branch
|
||||
@@ -140,14 +157,14 @@ return view.extend({
|
||||
fcfg.default = '1';
|
||||
fcfg.rmempty = false;
|
||||
|
||||
// 9. Write bootloader
|
||||
// 10. Write bootloader
|
||||
const wb = o.option(form.Flag, 'amlogic_write_bootloader',
|
||||
_('Auto write bootloader:'),
|
||||
_('[Recommended choice] Set whether to auto write bootloader during install and update OpenWrt.'));
|
||||
wb.default = '0';
|
||||
wb.rmempty = false;
|
||||
|
||||
// 10. Shared partition fs type
|
||||
// 11. Shared partition fs type
|
||||
const fst = o.option(form.ListValue, 'amlogic_shared_fstype',
|
||||
_('Set the file system type:'),
|
||||
_('[Default ext4] Set the file system type of the shared partition (/mnt/mmcblk*p4) when install OpenWrt.'));
|
||||
|
||||
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=26.10.16
|
||||
PKG_RELEASE:=336
|
||||
PKG_RELEASE:=337
|
||||
PKG_PO_VERSION:=$(PKG_VERSION)
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
|
||||
@@ -1823,9 +1823,6 @@ stop() {
|
||||
[ -n "${bak_bridge_nf_ip6t}" ] && sysctl -w net.bridge.bridge-nf-call-ip6tables=${bak_bridge_nf_ip6t} >/dev/null 2>&1
|
||||
}
|
||||
rm -rf $TMP_PATH
|
||||
rm -f ${LOCK_PATH}/${CONFIG}_socks_auto_switch*
|
||||
rm -f ${LOCK_PATH}/${CONFIG}_lease2hosts*
|
||||
rm -f ${LOCK_PATH}/${CONFIG}_monitor*
|
||||
echolog "清空并关闭相关程序和缓存完成。"
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -93,6 +93,6 @@ while true; do
|
||||
rm -f "$TMP_FILE"
|
||||
fi
|
||||
|
||||
sleep 60
|
||||
sleep 60 9>&-
|
||||
|
||||
done 2>/dev/null
|
||||
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall2
|
||||
PKG_VERSION:=26.10.1
|
||||
PKG_RELEASE:=145
|
||||
PKG_RELEASE:=146
|
||||
PKG_PO_VERSION:=$(PKG_VERSION)
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
|
||||
@@ -2219,8 +2219,14 @@ msgstr "تشخیص تغییر وضعیت سوکتها: تغییر وضعیت
|
||||
msgid "Socks switch detection: Port [%s] [%s:[%s]] abnormal."
|
||||
msgstr "تشخیص وضعیت سوئیچ: پورت [%s] [%s:[%s]] غیرعادی است."
|
||||
|
||||
msgid "Socks switch detection: Port [%s] all nodes are unavailable!"
|
||||
msgstr "تشخیص تغییر وضعیت سوئیچ: در پورت [%s]، تمام گرهها در دسترس نیستند!"
|
||||
msgid "Socks switch detection: Port [%s] all nodes are unavailable or switching failed!"
|
||||
msgstr "بررسی تغییر گره SOCKS: پورت [%s]، همه گرهها در دسترس نیستند یا تغییر گره ناموفق بود!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] node switch failed, continue trying other nodes!"
|
||||
msgstr "بررسی تغییر گره SOCKS: پورت [%s]، تغییر گره ناموفق بود؛ تلاش با گرههای دیگر ادامه دارد!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] failed to restore the primary node!"
|
||||
msgstr "بررسی تغییر گره SOCKS: پورت [%s]، بازیابی گره اصلی ناموفق بود!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] Unknown error."
|
||||
msgstr "تشخیص وضعیت سوئیچ جوراب: پورت [%s] خطای ناشناخته."
|
||||
|
||||
@@ -2220,8 +2220,14 @@ msgstr "Обнаружение переключения соединений: п
|
||||
msgid "Socks switch detection: Port [%s] [%s:[%s]] abnormal."
|
||||
msgstr "Обнаружено переключение Socks: порт [%s] [%s:[%s]] работает некорректно."
|
||||
|
||||
msgid "Socks switch detection: Port [%s] all nodes are unavailable!"
|
||||
msgstr "Обнаружено переключение коммутатора: порт [%s], все узлы недоступны!"
|
||||
msgid "Socks switch detection: Port [%s] all nodes are unavailable or switching failed!"
|
||||
msgstr "Проверка переключения SOCKS: порт [%s], все узлы недоступны или переключение не удалось!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] node switch failed, continue trying other nodes!"
|
||||
msgstr "Проверка переключения SOCKS: порт [%s], переключить узел не удалось, пробуем другие узлы!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] failed to restore the primary node!"
|
||||
msgstr "Проверка переключения SOCKS: порт [%s], не удалось восстановить основной узел!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] Unknown error."
|
||||
msgstr "Обнаружение переключения разъема: порт [%s], неизвестная ошибка."
|
||||
|
||||
@@ -2205,8 +2205,14 @@ msgstr "Socks切换检测:端口 [%s] 节点切换完毕!"
|
||||
msgid "Socks switch detection: Port [%s] [%s:[%s]] abnormal."
|
||||
msgstr "Socks切换检测:端口 [%s] 异常。"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] all nodes are unavailable!"
|
||||
msgstr "Socks切换检测:端口 [%s] 所有节点均不可用!"
|
||||
msgid "Socks switch detection: Port [%s] all nodes are unavailable or switching failed!"
|
||||
msgstr "Socks切换检测:端口 [%s] 所有节点均不可用或切换失败!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] node switch failed, continue trying other nodes!"
|
||||
msgstr "Socks切换检测:端口 [%s] 节点切换失败,继续尝试其他节点!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] failed to restore the primary node!"
|
||||
msgstr "Socks切换检测:端口 [%s] 恢复主节点失败!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] Unknown error."
|
||||
msgstr "Socks切换检测:端口 [%s] 未知错误。"
|
||||
|
||||
@@ -2211,8 +2211,14 @@ msgstr "Socks切換偵測:連接埠 [%s] 節點切換完畢!"
|
||||
msgid "Socks switch detection: Port [%s] [%s:[%s]] abnormal."
|
||||
msgstr "Socks切換偵測:連接埠 [%s] 異常。"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] all nodes are unavailable!"
|
||||
msgstr "Socks切換偵測:連接埠 [%s] 所有節點均不可用!"
|
||||
msgid "Socks switch detection: Port [%s] all nodes are unavailable or switching failed!"
|
||||
msgstr "Socks切換偵測:連接埠 [%s] 所有節點均不可用或切換失敗!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] node switch failed, continue trying other nodes!"
|
||||
msgstr "Socks切換偵測:連接埠 [%s] 節點切換失敗,繼續嘗試其他節點!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] failed to restore the primary node!"
|
||||
msgstr "Socks切換偵測:連接埠 [%s] 恢復主節點失敗!"
|
||||
|
||||
msgid "Socks switch detection: Port [%s] Unknown error."
|
||||
msgstr "Socks切換偵測:連接埠 [%s] 未知錯誤。"
|
||||
|
||||
@@ -380,7 +380,7 @@ run_socks() {
|
||||
if [ -n "$server_host" ] && [ -n "$server_port" ]; then
|
||||
check_host $server_host
|
||||
[ $? != 0 ] && {
|
||||
log 1 "$(i18n "Socks node: [%s]%s is an invalid server address and cannot be started!" "${$remarks}" "${server_host}")"
|
||||
log 1 "$(i18n "Socks node: [%s]%s is an invalid server address and cannot be started!" "${remarks}" "${server_host}")"
|
||||
return 1
|
||||
}
|
||||
tmp="${server_host}:${server_port}"
|
||||
@@ -553,9 +553,12 @@ socks_node_switch() {
|
||||
local http_config_file="${flag}_http.json"
|
||||
LOG_FILE="/dev/null"
|
||||
run_socks flag=$flag node=$new_node bind=$bind socks_port=$port config_file=$config_file http_port=$http_port http_config_file=$http_config_file log_file=$log_file
|
||||
sleep 2s
|
||||
[ "$(check_port_exists "$port" tcp)" = "0" ] && return 1
|
||||
set_cache_var "${flag}" "$new_node"
|
||||
local USE_TABLES=$(get_cache_var "USE_TABLES")
|
||||
[ -n "$USE_TABLES" ] && source $APP_PATH/${USE_TABLES}.sh filter_direct_node_list
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,11 +582,15 @@ start_socks() {
|
||||
[ "$log" == "0" ] && log_file=""
|
||||
local http_port=$(config_n_get $id http_port 0)
|
||||
local http_config_file="${id}_http.json"
|
||||
run_socks flag=$id node=$node bind=$bind socks_port=$port config_file=$config_file http_port=$http_port http_config_file=$http_config_file log_file=$log_file
|
||||
local enable_autoswitch=$(config_n_get $id enable_autoswitch 0)
|
||||
if [ "$enable_autoswitch" = "1" ]; then
|
||||
NO_REC_PROCESS=1 $APP_PATH/app.sh run_socks flag=$id node=$node bind=$bind socks_port=$port config_file=$config_file http_port=$http_port http_config_file=$http_config_file log_file=$log_file
|
||||
else
|
||||
run_socks flag=$id node=$node bind=$bind socks_port=$port config_file=$config_file http_port=$http_port http_config_file=$http_config_file log_file=$log_file
|
||||
fi
|
||||
set_cache_var "${id}" "$node"
|
||||
|
||||
# Auto switch logic
|
||||
local enable_autoswitch=$(config_n_get $id enable_autoswitch 0)
|
||||
[ "$enable_autoswitch" = "1" ] && { $APP_PATH/socks_auto_switch.sh ${id} > /dev/null 2>&1 & }
|
||||
done
|
||||
}
|
||||
@@ -999,8 +1006,6 @@ stop() {
|
||||
[ -n "${bak_bridge_nf_ip6t}" ] && sysctl -w net.bridge.bridge-nf-call-ip6tables=${bak_bridge_nf_ip6t} >/dev/null 2>&1
|
||||
}
|
||||
rm -rf $TMP_PATH
|
||||
rm -f ${LOCK_PATH}/${CONFIG}_socks_auto_switch*
|
||||
rm -f ${LOCK_PATH}/${CONFIG}_lease2hosts*
|
||||
rm -f ${LOCK_PATH}/${CONFIG}_monitor*
|
||||
log_i18n 0 "Clearing and closing related programs and cache complete."
|
||||
exit 0
|
||||
|
||||
@@ -93,6 +93,6 @@ while true; do
|
||||
rm -f "$TMP_FILE"
|
||||
fi
|
||||
|
||||
sleep 60
|
||||
sleep 60 9>&-
|
||||
|
||||
done 2>/dev/null
|
||||
@@ -3,11 +3,9 @@
|
||||
. /usr/share/passwall2/utils.sh
|
||||
APP_FILE=${APP_PATH}/app.sh
|
||||
|
||||
flag=0
|
||||
|
||||
check_process() {
|
||||
while busybox pgrep -af "${CONFIG}/" | grep -E 'app\.sh.*(start|stop)|nftables\.sh|iptables\.sh|subscribe\.lua' >/dev/null; do
|
||||
sleep 6s
|
||||
sleep 6s 8>&- 9>&-
|
||||
done
|
||||
}
|
||||
|
||||
@@ -25,19 +23,21 @@ test_url() {
|
||||
fi
|
||||
[ "$curl_retry_all_errors" = "1" ] && extra_params="--retry-all-errors ${extra_params}"
|
||||
|
||||
local max_time=$((timeout * (try + 1) + try + 3))
|
||||
local max_time=$((timeout + 3))
|
||||
local retry_max_time=$((max_time * (try + 1) + try))
|
||||
curl_test() {
|
||||
/usr/bin/curl -skIL -o /dev/null ${extra_params} --max-time ${max_time} --connect-timeout ${timeout} --retry ${try} --retry-delay 1 -w "%{http_code}" "$url"
|
||||
/usr/bin/curl -skIL -o /dev/null ${extra_params} --max-time ${max_time} --connect-timeout ${timeout} --retry ${try} --retry-delay 1 --retry-max-time ${retry_max_time} -w "%{http_code}" "$url" 8>&- 9>&-
|
||||
}
|
||||
|
||||
local status=$(curl_test)
|
||||
local status
|
||||
status=$(curl_test) || status=000
|
||||
[ "$status" = "204" ] && status=200
|
||||
if [ "$status" = "200" ] && [ "$repeat" = "1" ]; then
|
||||
sleep 3s
|
||||
status=$(curl_test)
|
||||
sleep 3s 8>&- 9>&-
|
||||
status=$(curl_test) || status=000
|
||||
[ "$status" = "204" ] && status=200
|
||||
fi
|
||||
echo $status
|
||||
printf '%s' "$status"
|
||||
}
|
||||
|
||||
test_proxy() {
|
||||
@@ -51,7 +51,7 @@ test_proxy() {
|
||||
result=1
|
||||
else
|
||||
result=2
|
||||
ping -c 3 -W 1 223.5.5.5 > /dev/null 2>&1
|
||||
ping -c 3 -W 1 223.5.5.5 > /dev/null 2>&1 8>&- 9>&-
|
||||
[ $? -eq 0 ] && {
|
||||
result=1
|
||||
}
|
||||
@@ -62,24 +62,31 @@ test_proxy() {
|
||||
|
||||
test_node() {
|
||||
local node_id=$1
|
||||
local _type=$(echo $(config_n_get ${node_id} type) | tr 'A-Z' 'a-z')
|
||||
[ -n "${_type}" ] && {
|
||||
check_process
|
||||
local _tmp_port=$(get_new_port 48800 tcp,udp)
|
||||
NO_REC_PROCESS=1 $APP_FILE run_socks flag="test_node_${node_id}" node=${node_id} bind=127.0.0.1 socks_port=${_tmp_port} config_file=test_node_${node_id}.json
|
||||
sleep 2s
|
||||
local curlx="socks5h://127.0.0.1:${_tmp_port}"
|
||||
local _proxy_status=$(test_url "${probe_url}" ${retry_num} ${connect_timeout} "-x $curlx" 1)
|
||||
# Kill the SS plugin process
|
||||
local pid_file="${TMP_PATH}/test_node_${node_id}_plugin.pid"
|
||||
[ -s "$pid_file" ] && kill -9 "$(head -n 1 "$pid_file")" >/dev/null 2>&1
|
||||
busybox pgrep -af "test_node_${node_id}" | awk '! /socks_auto_switch\.sh/{print $1}' | xargs kill -9 >/dev/null 2>&1
|
||||
rm -rf ${TMP_PATH}/test_node_${node_id}*.*
|
||||
if [ "${_proxy_status}" -eq 200 ]; then
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
return 1
|
||||
local test_flag="test_node_${id}_${node_id}"
|
||||
local _type _tmp_port curlx _proxy_status pid_file
|
||||
(
|
||||
exec 9>&-
|
||||
exec 8>"${LOCK_PATH}/${CONFIG}_socks_auto_switch_test.lock"
|
||||
flock -x 8 || exit 1
|
||||
_type=$(echo $(config_n_get ${node_id} type) | tr 'A-Z' 'a-z')
|
||||
[ -n "${_type}" ] && {
|
||||
check_process
|
||||
_tmp_port=$(get_new_port 48800 tcp,udp) || exit 1
|
||||
NO_REC_PROCESS=1 "$APP_FILE" run_socks flag="$test_flag" node="$node_id" bind=127.0.0.1 socks_port="$_tmp_port" config_file="${test_flag}.json" 8>&- 9>&-
|
||||
sleep 2s 8>&- 9>&-
|
||||
curlx="socks5h://127.0.0.1:${_tmp_port}"
|
||||
_proxy_status=$(test_url "${probe_url}" ${retry_num} ${connect_timeout} "-x $curlx" 1)
|
||||
# Kill the SS plugin process.
|
||||
pid_file="${TMP_PATH}/${test_flag}_plugin.pid"
|
||||
[ -s "$pid_file" ] && kill -9 "$(head -n 1 "$pid_file")" >/dev/null 2>&1
|
||||
busybox pgrep -af "${TMP_PATH}/${test_flag}[._]" | awk '! /socks_auto_switch\.sh/{print $1}' | xargs -r kill -9 >/dev/null 2>&1
|
||||
rm -f "$TMP_PATH/${test_flag}"*.*
|
||||
if [ "${_proxy_status}" -eq 200 ]; then
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
exit 1
|
||||
)
|
||||
}
|
||||
|
||||
try_switch_backup() {
|
||||
@@ -122,23 +129,23 @@ try_switch_backup() {
|
||||
if test_node ${new_node}; then
|
||||
check_process
|
||||
log_i18n 0 "Socks switch detection: Port [%s] [%s:[%s]] normal, switch to this node!" "${socks_port}" "${node_type}" "${node_remarks}"
|
||||
NO_REC_PROCESS=1 $APP_FILE socks_node_switch flag=${id} new_node=${new_node}
|
||||
[ $? -eq 0 ] && {
|
||||
if NO_REC_PROCESS=1 "$APP_FILE" socks_node_switch flag="$id" new_node="$new_node" 9>&-; then
|
||||
log_i18n 0 "Socks switch detection: Port [%s] node switch complete!" "${socks_port}"
|
||||
}
|
||||
return 0
|
||||
return 0
|
||||
fi
|
||||
log_i18n 0 "Socks switch detection: Port [%s] node switch failed, continue trying other nodes!" "${socks_port}"
|
||||
else
|
||||
log_i18n 0 "Socks switch detection: Port [%s] [%s:[%s]] abnormal." "${socks_port}" "${node_type}" "${node_remarks}"
|
||||
fi
|
||||
log_i18n 0 "Socks switch detection: Port [%s] [%s:[%s]] abnormal." "${socks_port}" "${node_type}" "${node_remarks}"
|
||||
now_node="$new_node"
|
||||
tried=$((tried + 1))
|
||||
done
|
||||
|
||||
log_i18n 0 "Socks switch detection: Port [%s] all nodes are unavailable!" "${socks_port}"
|
||||
log_i18n 0 "Socks switch detection: Port [%s] all nodes are unavailable or switching failed!" "${socks_port}"
|
||||
return 1
|
||||
}
|
||||
|
||||
test_auto_switch() {
|
||||
flag=$((flag + 1))
|
||||
local b_nodes=$1
|
||||
local now_node=$2
|
||||
[ -z "$now_node" ] && {
|
||||
@@ -150,9 +157,7 @@ test_auto_switch() {
|
||||
fi
|
||||
}
|
||||
|
||||
[ $flag -le 1 ] && main_node=$now_node
|
||||
|
||||
local status=$(test_proxy)
|
||||
local status=$(test_proxy 9>&-)
|
||||
if [ "$status" = "2" ]; then
|
||||
log_i18n 0 "Socks switch detection: Port [%s] Unable to connect to the network. Please check if the network is working properly!" "${socks_port}"
|
||||
return 2
|
||||
@@ -163,13 +168,13 @@ test_auto_switch() {
|
||||
test_node ${main_node}
|
||||
[ $? -eq 0 ] && {
|
||||
check_process
|
||||
# The main node is working properly; switch to the main node.
|
||||
log_i18n 0 "Socks switch detection: Port [%s] Primary node [%s: [%s]] is normal. Switch to the primary node!" "${socks_port}" "$(config_n_get $main_node type)" "$(config_n_get $main_node remarks)"
|
||||
NO_REC_PROCESS=1 $APP_FILE socks_node_switch flag=${id} new_node=${main_node}
|
||||
[ $? -eq 0 ] && {
|
||||
if NO_REC_PROCESS=1 "$APP_FILE" socks_node_switch flag="$id" new_node="$main_node" 9>&-; then
|
||||
log_i18n 0 "Socks switch detection: Port [%s] node switch complete!" "${socks_port}"
|
||||
}
|
||||
return 0
|
||||
return 0
|
||||
fi
|
||||
log_i18n 0 "Socks switch detection: Port [%s] failed to restore the primary node!" "${socks_port}"
|
||||
status=1
|
||||
}
|
||||
fi
|
||||
|
||||
@@ -186,6 +191,8 @@ test_auto_switch() {
|
||||
start() {
|
||||
id=$1
|
||||
LOCK_FILE=${LOCK_PATH}/${CONFIG}_socks_auto_switch_${id}.lock
|
||||
exec 9>"$LOCK_FILE"
|
||||
flock -n 9 || return 0
|
||||
main_node=$(config_n_get $id node)
|
||||
socks_port=$(config_n_get $id port 0)
|
||||
delay=$(config_n_get $id autoswitch_testing_time 30)
|
||||
@@ -201,7 +208,10 @@ start() {
|
||||
[ "$main_node" = "$backup_node" ] && return
|
||||
elif [ "$backup_node_num" -gt 1 ]; then
|
||||
[ "$restore_switch" != "1" ] && {
|
||||
[ -z "$(echo $backup_node | grep -F "$main_node")" ] && backup_node="${backup_node} ${main_node}"
|
||||
case " $backup_node " in
|
||||
*" $main_node "*) ;;
|
||||
*) backup_node="${backup_node} ${main_node}" ;;
|
||||
esac
|
||||
}
|
||||
fi
|
||||
else
|
||||
@@ -209,15 +219,9 @@ start() {
|
||||
return
|
||||
fi
|
||||
while [ -n "$backup_node" ]; do
|
||||
[ -f "$LOCK_FILE" ] && {
|
||||
sleep 6s
|
||||
continue
|
||||
}
|
||||
check_process
|
||||
touch $LOCK_FILE
|
||||
test_auto_switch "$backup_node"
|
||||
rm -f $LOCK_FILE
|
||||
sleep ${delay}
|
||||
sleep ${delay} 9>&-
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user