Skip to content

Commit

Permalink
Merge pull request #4 from nosignals/dev
Browse files Browse the repository at this point in the history
fix no connection after reboot (keri lekkk)
  • Loading branch information
nosignals authored Sep 1, 2024
2 parents 7090b85 + ab2ae8c commit 2afeab5
Showing 1 changed file with 36 additions and 22 deletions.
58 changes: 36 additions & 22 deletions luci-app-neko/root/etc/neko/core/reload
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ neko_checknewver(){
strversion="- New v.$new_version"
if [ $1 == "log" ]; then
echo "[ `date +%T` ] New Version detected. v.$new_version" >> $log

echo "[ `date +%T` ] New Version detected. v.$new_version"
fi
fi
}
Expand All @@ -37,40 +37,54 @@ neko_reload(){
if [ $status = true ]; then
iface=`echo $tmpdt | jq '.interface' | sed 's/"//g'`
uptime=`echo $tmpdt | jq '.uptime'`

if [[ ! -d "/tmp/iface" ]]; then
echo "creating tmp dir"
mkdir /tmp/iface
fi
if [ "$iface" == "loopback" -o "$iface" == "lan" ]; then
echo "Interfaces $iface is whitlisted"
else
if [[ ! -d "/tmp/iface" ]]; then
echo "creating tmp dir"
mkdir /tmp/iface
fi

if [ ! -e /tmp/iface/$iface ]; then
if [ ! -e /tmp/iface/$iface ]; then
echo $uptime > /tmp/iface/$iface
$firewall restart
echo "[ `date +%T` ] - Detected interfaces $iface changed, Reloading Firewall " >> $log
$tun_bin -ks
uptime_now=`cat /proc/uptime | cut -d. -f1`
if [ "$uptime_now" -lt 60 ]; then
service neko restart
fi
fi

last_uptime=`cat /tmp/iface/$iface`
echo $uptime > /tmp/iface/$iface
fi

last_uptime=`cat /tmp/iface/$iface`
echo $uptime > /tmp/iface/$iface
echo "- $iface Uptime $uptime s, last Uptime $last_uptime s"

if (( $uptime < $last_uptime )) || [ -z $last_uptime ]; then
echo "reloading firewall"
$firewall restart
echo "[ `date +%T` ] - Detected interfaces $iface changed, Reloading Firewall " >> $log
sleep 1
$tun_bin -ks
else
echo "nothing"
echo "- $iface Uptime $uptime s, last Uptime $last_uptime s"

if (( $uptime < $last_uptime )) || [ -z $last_uptime ]; then
echo "reloading firewall"
$firewall restart
echo "[ `date +%T` ] - Detected interfaces $iface changed, Reloading Firewall " >> $log
sleep 1
$tun_bin -ks
else
echo "nothing"
fi
fi
fi
done
}

if [ "$neko_status" == 1 ] && [ "$neko_new_interface" == 1 ]; then
echo "[ `date +%T` ] - Auto Restart Firewall : ON " >> $log
sleep 20 && neko_checknewver "log"
cnt=0;
while true
do
((cnt++))
sleep "$neko_delay"
neko_reload
if [ $cnt == 30 ]; then
neko_checknewver "log"
fi
done
else
echo "[ `date +%T` ] - Auto Restart Firewall : OFF " >> $log
Expand Down

0 comments on commit 2afeab5

Please sign in to comment.