mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-05 18:44:03 +08:00
🏅 Sync 2026-04-20 20:27:29
This commit is contained in:
1 parent
03109ea917
commit
ede68af29e
24 files changed
+2286
-2110
No files matched your search
@@ -1072,11 +1072,13 @@ start_socks() {
|
||||
[ "$log" == "0" ] && log_file=""
|
||||
local http_port=$(config_n_get $id http_port 0)
|
||||
local http_config_file="HTTP2SOCKS_${id}.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
|
||||
set_cache_var "socks_${id}" "$node"
|
||||
|
||||
#自动切换逻辑
|
||||
local enable_autoswitch=$(config_n_get $id enable_autoswitch 0)
|
||||
[ "$enable_autoswitch" = "1" ] && [ -z "$(config_n_get $id autoswitch_backup_node)" ] && enable_autoswitch=0
|
||||
local no_rec=0
|
||||
[ "$enable_autoswitch" = "1" ] && no_rec=1
|
||||
NO_REC_PROCESS=$no_rec $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
|
||||
set_cache_var "socks_${id}" "$node"
|
||||
#自动切换逻辑
|
||||
[ "$enable_autoswitch" = "1" ] && $APP_PATH/socks_auto_switch.sh ${id} > /dev/null 2>&1 &
|
||||
done
|
||||
}
|
||||
|
||||
@@ -93,10 +93,10 @@ test_auto_switch() {
|
||||
test_node ${main_node}
|
||||
[ $? -eq 0 ] && {
|
||||
#主节点正常,切换到主节点
|
||||
echolog "Socks切换检测:${id}主节点【$(config_n_get $main_node type):[$(config_n_get $main_node remarks)]】正常,切换到主节点!"
|
||||
$APP_FILE socks_node_switch flag=${id} new_node=${main_node}
|
||||
echolog "Socks切换检测:端口[${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 ] && {
|
||||
echolog "Socks切换检测:${id}节点切换完毕!"
|
||||
echolog "Socks切换检测:端口[${socks_port}] 节点切换完毕!"
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -123,7 +123,7 @@ test_auto_switch() {
|
||||
new_node=$([ "$now_node" = "$main_node" ] && echo "$b_nodes" || echo "$main_node")
|
||||
msg="切换到$([ "$now_node" = "$main_node" ] && echo 备用节点 || echo 主节点)检测!"
|
||||
fi
|
||||
echolog "Socks切换检测:${id}【$(config_n_get $now_node type):[$(config_n_get $now_node remarks)]】异常,$msg"
|
||||
echolog "Socks切换检测:端口[${socks_port}]【$(config_n_get $now_node type):[$(config_n_get $now_node remarks)]】异常,$msg"
|
||||
test_node ${new_node}
|
||||
if [ $? -eq 0 ]; then
|
||||
# [ "$restore_switch" = "0" ] && {
|
||||
@@ -131,10 +131,10 @@ test_auto_switch() {
|
||||
# [ -z "$(echo $b_nodes | grep $main_node)" ] && uci add_list $CONFIG.${id}.autoswitch_backup_node=$main_node
|
||||
# uci commit $CONFIG
|
||||
# }
|
||||
echolog "Socks切换检测:${id}【$(config_n_get $new_node type):[$(config_n_get $new_node remarks)]】正常,切换到此节点!"
|
||||
$APP_FILE socks_node_switch flag=${id} new_node=${new_node}
|
||||
echolog "Socks切换检测:端口[${socks_port}]【$(config_n_get $new_node type):[$(config_n_get $new_node remarks)]】正常,切换到此节点!"
|
||||
NO_REC_PROCESS=1 $APP_FILE socks_node_switch flag=${id} new_node=${new_node}
|
||||
[ $? -eq 0 ] && {
|
||||
echolog "Socks切换检测:${id}节点切换完毕!"
|
||||
echolog "Socks切换检测:端口[${socks_port}] 节点切换完毕!"
|
||||
}
|
||||
return 0
|
||||
else
|
||||
|
||||
@@ -49,7 +49,30 @@ local core_has = {
|
||||
["hysteria2"] = has_hysteria2
|
||||
}
|
||||
-- 判断是否过滤节点关键字
|
||||
local function is_filter_keyword(mode, discard_list, keep_list, value)
|
||||
local function is_filter_keyword(sub_cfg, value)
|
||||
local mode = DEFAULT_FILTER_KEYWORD_MODE
|
||||
local discard_list = DEFAULT_FILTER_KEYWORD_DISCARD_LIST
|
||||
local keep_list = DEFAULT_FILTER_KEYWORD_KEEP_LIST
|
||||
if sub_cfg then
|
||||
local filter_keyword_mode = sub_cfg.filter_keyword_mode or "5" -- 5 is global
|
||||
if filter_keyword_mode == "0" then
|
||||
mode = "0"
|
||||
elseif filter_keyword_mode == "1" then
|
||||
mode = "1"
|
||||
discard_list = sub_cfg.filter_discard_list or {}
|
||||
elseif filter_keyword_mode == "2" then
|
||||
mode = "2"
|
||||
keep_list = sub_cfg.filter_keep_list or {}
|
||||
elseif filter_keyword_mode == "3" then
|
||||
mode = "3"
|
||||
keep_list = sub_cfg.filter_keep_list or {}
|
||||
discard_list = sub_cfg.filter_discard_list or {}
|
||||
elseif filter_keyword_mode == "4" then
|
||||
mode = "4"
|
||||
keep_list = sub_cfg.filter_keep_list or {}
|
||||
discard_list = sub_cfg.filter_discard_list or {}
|
||||
end
|
||||
end
|
||||
if mode == "1" then
|
||||
for k,v in ipairs(discard_list) do
|
||||
if value:find(v, 1, true) then
|
||||
@@ -472,9 +495,6 @@ end
|
||||
local function processData(szType, content, add_mode, group, sub_cfg)
|
||||
--log(2, content, add_mode, group)
|
||||
local default_allowinsecure = DEFAULT_ALLOWINSECURE
|
||||
default_filter_keyword_mode = DEFAULT_FILTER_KEYWORD_MODE
|
||||
default_filter_keyword_discard_list = DEFAULT_FILTER_KEYWORD_DISCARD_LIST
|
||||
default_filter_keyword_keep_list = DEFAULT_FILTER_KEYWORD_KEEP_LIST
|
||||
local default_ss_type = DEFAULT_SS_TYPE
|
||||
local default_trojan_type = DEFAULT_TROJAN_TYPE
|
||||
local default_vmess_type = DEFAULT_VMESS_TYPE
|
||||
@@ -484,24 +504,6 @@ local function processData(szType, content, add_mode, group, sub_cfg)
|
||||
if sub_cfg.allowInsecure and sub_cfg.allowInsecure ~= "1" then
|
||||
default_allowinsecure = nil
|
||||
end
|
||||
local filter_keyword_mode = sub_cfg.filter_keyword_mode or "5" -- 5 is global
|
||||
if filter_keyword_mode == "0" then
|
||||
default_filter_keyword_mode = "0"
|
||||
elseif filter_keyword_mode == "1" then
|
||||
default_filter_keyword_mode = "1"
|
||||
default_filter_keyword_discard_list = sub_cfg.filter_discard_list or {}
|
||||
elseif filter_keyword_mode == "2" then
|
||||
default_filter_keyword_mode = "2"
|
||||
default_filter_keyword_keep_list = sub_cfg.filter_keep_list or {}
|
||||
elseif filter_keyword_mode == "3" then
|
||||
default_filter_keyword_mode = "3"
|
||||
default_filter_keyword_keep_list = sub_cfg.filter_keep_list or {}
|
||||
default_filter_keyword_discard_list = sub_cfg.filter_discard_list or {}
|
||||
elseif filter_keyword_mode == "4" then
|
||||
default_filter_keyword_mode = "4"
|
||||
default_filter_keyword_keep_list = sub_cfg.filter_keep_list or {}
|
||||
default_filter_keyword_discard_list = sub_cfg.filter_discard_list or {}
|
||||
end
|
||||
local ss_type = sub_cfg.ss_type or "global"
|
||||
if ss_type ~= "global" and core_has[ss_type] then
|
||||
default_ss_type = ss_type
|
||||
@@ -2055,7 +2057,7 @@ local function parse_link(raw, add_mode, group, sub_cfg)
|
||||
log('丢弃节点:' .. result.remarks .. " ,原因:" .. result.error_msg)
|
||||
elseif not result.type then
|
||||
log('丢弃节点:' .. result.remarks .. " ,找不到可使用二进制。")
|
||||
elseif (add_mode == "2" and is_filter_keyword(default_filter_keyword_mode, default_filter_keyword_discard_list, default_filter_keyword_keep_list, result.remarks)) or not result.address or result.remarks == "NULL" or result.address == "127.0.0.1" or
|
||||
elseif (add_mode == "2" and is_filter_keyword(sub_cfg, result.remarks)) or not result.address or result.remarks == "NULL" or result.address == "127.0.0.1" or
|
||||
(not datatypes.hostname(result.address) and not (api.is_ip(result.address))) then
|
||||
log('丢弃过滤节点:' .. result.type .. ' 节点,' .. result.remarks)
|
||||
else
|
||||
|
||||
@@ -456,7 +456,7 @@ ln_run() {
|
||||
${file_func:-echolog " - ${ln_name}"} "$@" 2>&1 | logger -t PASSWALL_${protocol}_${ln_name} &
|
||||
fi
|
||||
fi
|
||||
[ -n "$NO_REC_PROCESS" ] && return
|
||||
[ "$NO_REC_PROCESS" = "1" ] && return
|
||||
process_count=$(ls $TMP_SCRIPT_FUNC_PATH | wc -l)
|
||||
process_count=$((process_count + 1))
|
||||
echo "${file_func:-echolog " - ${ln_name}"} $@ >${output}" > $TMP_SCRIPT_FUNC_PATH/$process_count
|
||||
|
||||
Reference in new issue
Block a user