xdp-dns UI: change running state check

Status relies on checking if xdp_dns_log is running,
but xdp_dns_log could mysteriously disappear at some point,
which result in XDP DNS Blocklist shows Stopped,
let /etc/rc.d/init.d/xdpdns status relies on if the
xdp_dns_denylist XDP program is still attached
to green0 interface.

two related issues

https://github.com/vincentmli/BPFire/issues/50
https://github.com/vincentmli/BPFire/issues/49

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
This commit is contained in:
Vincent Li
2024-10-05 23:08:30 +00:00
parent 4c2fd11de2
commit 4d6f8d68a3
2 changed files with 11 additions and 2 deletions

View File

@@ -184,7 +184,7 @@ my $sactive = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourr
my @status = &General::system_output('/usr/local/bin/xdpdnsctrl', 'status'); my @status = &General::system_output('/usr/local/bin/xdpdnsctrl', 'status');
if (grep(/is running/, @status)){ if (grep(/is attached/, @status)){
$sactive = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourgreen}' width='50%'><tr><td align='center'><b><font color='#FFFFFF'>$Lang::tr{'running'}</font></b></td></tr></table>"; $sactive = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourgreen}' width='50%'><tr><td align='center'><b><font color='#FFFFFF'>$Lang::tr{'running'}</font></b></td></tr></table>";
} }

View File

@@ -55,6 +55,15 @@ unload_dnsblock () {
fi fi
} }
is_xdpdns_attached () {
/usr/sbin/xdp-loader status green0 | grep -w 'xdp_dns_denylist' >> /dev/null
if [ $? -eq 0 ]; then
echo "xdp_dns_denylist is attached to green0"
else
echo "xdp_dns_denylist is not attached to green0"
fi
}
case "$1" in case "$1" in
start) start)
@@ -74,7 +83,7 @@ case "$1" in
;; ;;
status) status)
statusproc /usr/sbin/xdp_dns_log is_xdpdns_attached
;; ;;
restart) restart)