update 2026-09-07 01:57:13

This commit is contained in:
action
2026-09-07 01:57:13 +08:00
parent 7b5d12b8ec
commit 4a4dfac1a2
27 changed files with 796 additions and 102 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=daed
PKG_VERSION:=2026.08.28
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_SOURCE:=daed-src-2026.08.28-73f01b995c34.tar.gz
PKG_SOURCE_URL:=https://github.com/kenzok8/openwrt-daede/releases/download/daed-src
+66 -1
View File
@@ -2,16 +2,68 @@
. /usr/share/daed/cleanup.sh
STATE="/var/run/daede-daed.ready"
LOG="/var/log/daed/daed.log"
READY="Reload: Finished"
PID="$$"
watcher_pid=
mark_state() {
local value="$1" tmp="${STATE}.${PID}"
printf '%s %s\n' "$PID" "$value" > "$tmp" && mv -f "$tmp" "$STATE"
}
watch_ready() {
local offset size
offset="$(wc -c < "$LOG" 2>/dev/null || echo 0)"
(
while kill -0 "$PID" 2>/dev/null; do
size="$(wc -c < "$LOG" 2>/dev/null || echo 0)"
[ "$size" -lt "$offset" ] && offset=0
if [ -r "$LOG" ] && tail -c "+$((offset + 1))" "$LOG" 2>/dev/null | grep -Fq "$READY"; then
[ "$(cat "$STATE" 2>/dev/null)" = "$PID starting" ] && mark_state ready
exit 0
fi
sleep 1
done
) >/dev/null 2>&1 &
watcher_pid=$!
}
stop_watcher() {
[ -n "$watcher_pid" ] || return 0
kill "$watcher_pid" 2>/dev/null
wait "$watcher_pid" 2>/dev/null
watcher_pid=
}
mark_state starting
if ! daed_cleanup_runtime; then
echo "daed: stale network state could not be removed" >&2
exit 1
fi
watch_ready
# Keep daed as a child so a panic or unexpected exit is followed by an
# immediate teardown of all kernel/runtime state before procd can respawn us.
child_pid=
term_requested=0
cleanup_child() {
[ -n "$child_pid" ] && kill "$child_pid" 2>/dev/null
term_requested=1
[ -n "$child_pid" ] || return 0
kill "$child_pid" 2>/dev/null
# Do not let an interrupted wait leave a daed child behind. Four one-second
# polls give a graceful TERM about four seconds before the bounded KILL.
local attempt=0
while kill -0 "$child_pid" 2>/dev/null && [ "$attempt" -lt 4 ]; do
sleep 1
attempt=$((attempt + 1))
done
if kill -0 "$child_pid" 2>/dev/null; then
kill -9 "$child_pid" 2>/dev/null
fi
}
trap cleanup_child TERM INT
@@ -19,8 +71,21 @@ trap cleanup_child TERM INT
child_pid=$!
wait "$child_pid"
status=$?
# A signal can interrupt ash's wait even though the trap has already asked the
# child to exit. Confirm the process is gone and reap it a second time before
# publishing stopping or running cleanup.
if [ "$term_requested" = 1 ]; then
cleanup_child
wait "$child_pid" 2>/dev/null
reap_status=$?
[ "$status" -eq 0 ] && status="$reap_status"
fi
child_pid=
trap - TERM INT
# The watcher may have observed the marker at the same time as the child
# exited. Reap it before publishing stopping so it cannot overwrite that state.
stop_watcher
mark_state stopping
if ! daed_cleanup_runtime; then
echo "daed: runtime cleanup after exit failed" >&2
+3 -1
View File
@@ -21,7 +21,6 @@ start_service() {
config_get listen_addr "config" "listen_addr" "0.0.0.0:2023"
config_get log_maxbackups "config" "log_maxbackups" "1"
config_get log_maxsize "config" "log_maxsize" "5"
procd_open_instance "$CONF"
procd_set_param env DAE_LOCATION_ASSET="/usr/share/v2ray" TZ="$(uci -q get system.@system[0].zonename)"
procd_set_param command "$PROG" run
@@ -45,6 +44,9 @@ start_service() {
stop_service() {
rm -f "$LOG"
daed_cleanup_runtime
local status=$?
rm -f /var/run/daede-daed.ready /var/run/daede-daed.ready.*
return "$status"
}
restart() {