Skip to content

Instantly share code, notes, and snippets.

@IAALAI
Created April 5, 2024 23:36
Show Gist options
  • Save IAALAI/fa92c95d5881660478d3ccc4228f3c24 to your computer and use it in GitHub Desktop.
Save IAALAI/fa92c95d5881660478d3ccc4228f3c24 to your computer and use it in GitHub Desktop.
# 将 qBittorrent-ClientBlocker 的日志中的内容提取为 ipfilter.dat 文件
if [ ! -f $1 ]; then
echo "文件不存在"
exit 1
fi
private_ip_regex='^(10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.|192\.168\.)'
grep -oP '(?<=^|\s)((\d{1,3}\.){3}\d{1,3})' $1 | while read line; do
if [[ $line =~ $private_ip_regex ]]; then
continue
fi
echo "$line - $line , 0 , "
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment