SunBK201 / UA3F

Implementation of the next generation of HTTP User-Agent modification methodology.
GNU General Public License v3.0
193 stars 10 forks source link

不定时出现无法上网的问题,查看log得到`too many open files` #27

Open GamerNoTitle opened 4 hours ago

GamerNoTitle commented 4 hours ago

这个问题是不定时出现的,但是出现频率很高,经常用着用着就炸了,log文件我放下面,在大概21984行出现第一次too many open files image ua3f-2024-09-23-10-30-00.log

软路由信息

root@LUMINE-OPENWRT:~/ua3f# uname -a
Linux LUMINE-OPENWRT 5.15.162 #0 SMP PREEMPT Mon Jul 15 22:14:18 2024 aarch64 GNU/Linux

UA3F配置

root@LUMINE-OPENWRT:~/ua3f# uci show | grep ua3f
uci: Entry not found
ua3f.enabled=ua3f
ua3f.enabled.enabled='1'
ua3f.main=ua3f
ua3f.main.port='1080'
ua3f.main.bind='0.0.0.0'
ua3f.main.ua='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0'
ua3f.main.log_level='debug'

OpenClash相关版本信息

image

GamerNoTitle commented 4 hours ago

附我现在正在使用的临时解决办法,使用了crontab任务

#!/bin/sh

# Path to log file
LOG_FILE="/var/log/ua3f.log"
# Keyword to search for in the log
KEYWORD="too many open"

# Check if the log file exists
if [ -f "$LOG_FILE" ]; then
    # Get the last line of the log file
    LAST_LINE=$(tail -n 1 "$LOG_FILE")

    # Check if the last line contains the keyword
    case "$LAST_LINE" in
        *"$KEYWORD"*)
            # Get the current timestamp in the format YYYY-MM-DD-HH-mm-SS
            TIMESTAMP=$(date +"%Y-%m-%d-%H-%M-%S")

            # Path to new log file in /root/ua3f/
            NEW_LOG_FILE="/root/ua3f/ua3f-$TIMESTAMP.log"

            # Move the original log file to the new location and rename it
            mv "$LOG_FILE" "$NEW_LOG_FILE"

            # Delete the original log file
            rm -f "$LOG_FILE"

            # Restart the ua3f service
            service ua3f restart
            ;;
    esac
fi
SunBK201 commented 3 hours ago

如果启动 UA3F 短时间内出现大量日志,说明出现流量回环,你需要检查你的 Clash 配置,让 Clash 不要接管本机网络流量