xiaorouji / openwrt-passwall

7.01k stars 2.62k forks source link

建议passwall-smartdns版本在延时启动前先创建 /tmp/etc/smartdns/passwall.conf 空文件 #3203

Closed lwb1978 closed 3 months ago

lwb1978 commented 4 months ago

描述你想要的新功能

smartdns在启动时先检查自定义文件是否存在,如果不存在则停止启动。而passwall-smartdns版本的 /tmp/etc/smartdns/passwall.conf 文件因为储存在内存中,在每次路由重启时都会丢失,因此如果passwall设置了延时启动,在路由重启后smartdns时由于passwall正在延时启动,没有创建出/tmp/etc/smartdns/passwall.conf 文件,此时smartdns将无法启动,并在系统日志中报无法找到文件的错误,此过程一直延续到passwall正常启动并创建了配置文件后才正常工作。 这个情况就造成路由在等待passwall延时启动中由于smartdns未能工作,从而导致客户端无法解析dns,局域网无法上网的情况。因此建议passwall在延时启动工作时首先创建出/tmp/etc/smartdns/passwall.conf空文件,让smartdns先正常工作。

描述你想要的解决方案

本来想要提交个PR,但由于是passwall-smartdns版本,老大需要从普通版本加入补丁演变为smartdns版,所以就直接在这里提了这个需求和建议。我个人修改自用的相关代码如下: 涉及文件:luci-app-passwall/root/etc/init.d/passwall boot函数下加入

local smartdns=$(uci -q get ${CONFIG}.@global[0].dns_shunt || echo "")
if [ "$smartdns" == "smartdns" ]; then
   touch  /tmp/etc/smartdns/passwall.conf
fi

最终为:

boot() {
    local smartdns=$(uci -q get ${CONFIG}.@global[0].dns_shunt || echo "")
    if [ "$smartdns" == "smartdns" ]; then
        touch  /tmp/etc/smartdns/passwall.conf
    fi
    local delay=$(uci -q get ${CONFIG}.@global_delay[0].start_delay || echo 1)
    if [ "$delay" -gt 0 ]; then
        $APP_FILE echolog "执行启动延时 $delay 秒后再启动!"
        sleep $delay
    fi
    restart
    touch ${LOCK_FILE_DIR}/${CONFIG}_ready.lock
}

描述你考虑过的替代方案

No response

其他信息

No response

nftbty commented 3 months ago

回复下,免得被自动关了