mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-30 04:55:13 +08:00
update 2026-09-15 17:08:00
This commit is contained in:
1 parent
bb8ab7ae16
commit
b109228443
13 files changed
+128
-132
No files matched your search
@@ -1,17 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Devices without a hardware RTC boot with a wrong system clock: sysfixtime can
|
||||
# only restore the mtime of the newest file under /etc, so the clock is usually
|
||||
# hours behind after a cold boot. passwall2 is then started by
|
||||
# /etc/hotplug.d/iface/98-passwall2 on ifup, which typically happens before NTP
|
||||
# has corrected the time, and time-sensitive handshakes (VMess AEAD, TLS) fail.
|
||||
#
|
||||
# Nothing restarts passwall2 once the clock is corrected, so it stays broken
|
||||
# until the user restarts it manually. Restart once when ntpd reports that the
|
||||
# time is valid -- the same approach dnsmasq uses for DNSSEC in
|
||||
# /etc/hotplug.d/ntp/25-dnsmasqsec.
|
||||
[ "$ACTION" = "step" ] || exit 0
|
||||
|
||||
[ "$ACTION" = "stratum" ] || exit 0
|
||||
offset=${offset#-}
|
||||
offset=${offset%.*}
|
||||
|
||||
# Skip service restart if the time adjustment is less than 120 seconds.
|
||||
[ "$offset" -lt 120 ] && exit 0
|
||||
|
||||
. /usr/share/passwall2/utils.sh
|
||||
|
||||
@@ -23,5 +18,5 @@ NTP_LOCK_FILE="${LOCK_PATH}/${CONFIG}_ntp.lock"
|
||||
echo $$ > ${NTP_LOCK_FILE}
|
||||
|
||||
/etc/init.d/${CONFIG} restart >/dev/null 2>&1 &
|
||||
logger -p notice -t network -s "${CONFIG}: restart after NTP time became valid"
|
||||
logger -p notice -t network -s "${CONFIG}: restart after NTP time step (${offset}s)"
|
||||
}
|
||||
@@ -856,8 +856,8 @@ acl_node() {
|
||||
local DNSMASQ_LOCAL_DNS="${LOCAL_DNS:-${AUTO_DNS}}"
|
||||
[ -n "${DIRECT_DNS_DNSMASQ_SERVER}" ] && DNSMASQ_LOCAL_DNS="${DIRECT_DNS_DNSMASQ_SERVER}"
|
||||
if [ "${flag}" = "acl_default" ]; then
|
||||
set_cache_var "GLOBAL_SOCKS_server" "127.0.0.1:$socks_port"
|
||||
set_cache_var "ACL_GLOBAL_node" "$node"
|
||||
set_cache_var "ACL_${flag}_node" "$node"
|
||||
set_cache_var "ACL_${flag}_node_socks_port" "$socks_port"
|
||||
run_new_dnsmasq=$(config_n_get @global[0] dns_redirect 1)
|
||||
if [ "${run_new_dnsmasq}" != "1" ]; then
|
||||
#Rewrite the default DNS service configuration
|
||||
@@ -865,15 +865,15 @@ acl_node() {
|
||||
lua $APP_PATH/helper_dnsmasq.lua stretch
|
||||
json_init
|
||||
json_add_string "FLAG" "${flag}"
|
||||
json_add_string "TMP_DNSMASQ_PATH" "${GLOBAL_DNSMASQ_CONF_PATH}"
|
||||
json_add_string "DNSMASQ_CONF_FILE" "${GLOBAL_DNSMASQ_CONF}"
|
||||
json_add_string "TMP_DNSMASQ_PATH" "${DEFAULT_DNSMASQ_CONF_PATH}"
|
||||
json_add_string "DNSMASQ_CONF_FILE" "${DEFAULT_DNSMASQ_CONF}"
|
||||
json_add_string "DEFAULT_DNS" "${DNSMASQ_DEFAULT_DNS}"
|
||||
json_add_string "LOCAL_DNS" "${DNSMASQ_LOCAL_DNS}"
|
||||
json_add_string "TUN_DNS" "${DNSMASQ_TUN_DNS}"
|
||||
json_add_string "NFTFLAG" "${nftflag:-0}"
|
||||
json_add_string "NO_LOGIC_LOG" "${NO_LOGIC_LOG:-0}"
|
||||
lua $APP_PATH/helper_dnsmasq.lua add_rule "$(json_dump)"
|
||||
uci -q add_list dhcp.@dnsmasq[0].addnmount=${GLOBAL_DNSMASQ_CONF_PATH}
|
||||
uci -q add_list dhcp.@dnsmasq[0].addnmount=${DEFAULT_DNSMASQ_CONF_PATH}
|
||||
uci -q commit dhcp
|
||||
|
||||
lua $APP_PATH/helper_dnsmasq.lua logic_restart
|
||||
@@ -973,8 +973,8 @@ stop() {
|
||||
unset XRAY_LOCATION_ASSET
|
||||
unset SS_SYSTEM_DNS_RESOLVER_FORCE_BUILTIN
|
||||
stop_crontab
|
||||
rm -rf $GLOBAL_DNSMASQ_CONF
|
||||
rm -rf $GLOBAL_DNSMASQ_CONF_PATH
|
||||
rm -rf $DEFAULT_DNSMASQ_CONF
|
||||
rm -rf $DEFAULT_DNSMASQ_CONF_PATH
|
||||
[ "1" = "1" ] && {
|
||||
#restore logic
|
||||
bak_dnsmasq_dns_redirect=$(config_n_get @global[0] dnsmasq_dns_redirect)
|
||||
@@ -985,7 +985,7 @@ stop() {
|
||||
uci -q commit ${CONFIG}
|
||||
}
|
||||
if [ -z "${ACL_default_dns_port}" ] || [ -n "${bak_dnsmasq_dns_redirect}" ]; then
|
||||
uci -q del_list dhcp.@dnsmasq[0].addnmount="${GLOBAL_DNSMASQ_CONF_PATH}"
|
||||
uci -q del_list dhcp.@dnsmasq[0].addnmount="${DEFAULT_DNSMASQ_CONF_PATH}"
|
||||
uci -q commit dhcp
|
||||
|
||||
json_init
|
||||
@@ -1061,8 +1061,8 @@ get_config() {
|
||||
DNSMASQ_CONF_DIR=${DEFAULT_DNSMASQ_CONF_DIR}
|
||||
fi
|
||||
fi
|
||||
set_cache_var GLOBAL_DNSMASQ_CONF ${DNSMASQ_CONF_DIR}/dnsmasq-${CONFIG}.conf
|
||||
set_cache_var GLOBAL_DNSMASQ_CONF_PATH ${TMP_ACL_PATH}/acl_default_dnsmasq.d
|
||||
set_cache_var DEFAULT_DNSMASQ_CONF ${DNSMASQ_CONF_DIR}/dnsmasq-${CONFIG}.conf
|
||||
set_cache_var DEFAULT_DNSMASQ_CONF_PATH ${TMP_ACL_PATH}/acl_default_dnsmasq.d
|
||||
|
||||
QUEUE_RUN=1
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ gen_shunt_list() {
|
||||
}
|
||||
[ -n "${_SHUNT_LIST4}" ] && eval ${shunt_list4_var_name}=\"${_SHUNT_LIST4}\"
|
||||
[ -n "${_SHUNT_LIST6}" ] && eval ${shunt_list6_var_name}=\"${_SHUNT_LIST6}\"
|
||||
set_cache_var "gen_shunt_list_${node}" "1"
|
||||
set_cache_var "node_${node}_gen_shunt_list" "1"
|
||||
}
|
||||
|
||||
add_shunt_t_rule() {
|
||||
@@ -261,7 +261,7 @@ load_acl() {
|
||||
for sid in $(jsonfilter -s "${ACL_JSON}" -e '$.acl[*].flag'); do
|
||||
eval local $(cat "${TMP_ACL_PATH}/${sid}/var")
|
||||
|
||||
[ -z "$(get_cache_var "gen_shunt_list_${node}")" ] && [ -n "${node}" ] && gen_shunt_list "${node}" shunt_list4 shunt_list6
|
||||
[ -z "$(get_cache_var "node_${node}_gen_shunt_list")" ] && [ -n "${node}" ] && gen_shunt_list "${node}" shunt_list4 shunt_list6
|
||||
[ -n "${use}" ] && local dns_redirect_port=$(get_cache_var "ACL_${use}_dns_port")
|
||||
|
||||
local ipt_tmp=$ipt_n
|
||||
|
||||
@@ -271,7 +271,7 @@ gen_shunt_list() {
|
||||
}
|
||||
[ -n "${_SHUNT_LIST4}" ] && eval ${shunt_list4_var_name}=\"${_SHUNT_LIST4}\"
|
||||
[ -n "${_SHUNT_LIST6}" ] && eval ${shunt_list6_var_name}=\"${_SHUNT_LIST6}\"
|
||||
set_cache_var "gen_shunt_list_${node}" "1"
|
||||
set_cache_var "node_${node}_gen_shunt_list" "1"
|
||||
}
|
||||
|
||||
add_shunt_t_rule() {
|
||||
@@ -299,7 +299,7 @@ load_acl() {
|
||||
for sid in $(jsonfilter -s "${ACL_JSON}" -e '$.acl[*].flag'); do
|
||||
eval $(cat "${TMP_ACL_PATH}/${sid}/var")
|
||||
|
||||
[ -z "$(get_cache_var "gen_shunt_list_${node}")" ] && [ -n "${node}" ] && gen_shunt_list "${node}" shunt_list4 shunt_list6
|
||||
[ -z "$(get_cache_var "node_${node}_gen_shunt_list")" ] && [ -n "${node}" ] && gen_shunt_list "${node}" shunt_list4 shunt_list6
|
||||
[ -n "${use}" ] && local dns_redirect_port=$(get_cache_var "ACL_${use}_dns_port")
|
||||
|
||||
[ "${local_proxy}" = "1" ] && {
|
||||
|
||||
Reference in new issue
Block a user