mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-29 20:25:13 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
echo "$(date "+%F %T"): 正在下载adblockplus规则..."
|
||||
wget-ssl --quiet --no-check-certificate https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt -O /tmp/adlist.txt
|
||||
if [ "$?" == "0" ]; then
|
||||
grep ^\|\|[^\*]*\^$ /tmp/adlist.txt | sed -e 's:||:address\=\/:' -e 's:\^:/0\.0\.0\.0:' > /tmp/dnsmasq.adblock
|
||||
rm -f /tmp/adlist.txt
|
||||
diff /tmp/dnsmasq.adblock /usr/share/koolproxy/dnsmasq.adblock >/dev/null
|
||||
[ $? = 0 ] && echo "$(date "+%F %T"): adblockplus本地规则和服务器规则相同,无需更新!" && rm -f /tmp/dnsmasq.adblock && return 1
|
||||
echo "$(date "+%F %T"): 检测到adblockplus规则有更新,开始转换规则!"
|
||||
sed -i '/youku/d' /tmp/dnsmasq.adblock >/dev/null 2>&1
|
||||
sed -i '/[1-9]\{1,3\}\.[1-9]\{1,3\}\.[1-9]\{1,3\}\.[1-9]\{1,3\}/d' /tmp/dnsmasq.adblock >/dev/null 2>&1
|
||||
mv /tmp/dnsmasq.adblock /usr/share/koolproxy/dnsmasq.adblock
|
||||
echo "$(date "+%F %T"): adblockplus规则转换完成,应用新规则。"
|
||||
echo ""
|
||||
echo "$(date "+%F %T"): 重启dnsmasq进程"
|
||||
/etc/init.d/dnsmasq restart > /dev/null 2>&1
|
||||
|
||||
return 0
|
||||
else
|
||||
echo "$(date "+%F %T"): 获取在线版本时出现错误! "
|
||||
[ -f /tmp/adlist.txt ] && rm -f /tmp/adlist.txt
|
||||
return 1
|
||||
fi
|
||||
Whitespace-only changes.
@@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
kpfolder="/usr/share/koolproxy/data"
|
||||
kplogfile="/var/log/koolproxy.log"
|
||||
readyfolder="/tmp/upload/koolproxy"
|
||||
|
||||
backup() {
|
||||
if [ ! -f $kpfolder/private/ca.key.pem ]; then
|
||||
echo "未找到ca.key.pem,请先运行Koolproxy一次!" > $kplogfile
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f $kpfolder/private/base.key.pem ]; then
|
||||
echo "未找到base.key.pem,请先运行Koolproxy一次!" > $kplogfile
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f $kpfolder/certs/ca.crt ]; then
|
||||
echo "未找到ca.crt,请先运行Koolproxy一次!" > $kplogfile
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p /tmp/upload
|
||||
cd $kpfolder
|
||||
tar czf /tmp/upload/koolproxyca.tar.gz private/ca.key.pem private/base.key.pem certs/ca.crt
|
||||
[ -f /tmp/upload/koolproxyca.tar.gz ] && echo "证书备份已成功生成。" > $kplogfile
|
||||
}
|
||||
|
||||
restore() {
|
||||
if [ ! -f /tmp/upload/koolproxyCA.tar.gz ]; then
|
||||
echo "未找到备份文件,文件名必须为koolproxyCA.tar.gz或已损坏,请检查备份文件!" >> $kplogfile
|
||||
else
|
||||
mkdir -p $readyfolder
|
||||
cd $readyfolder
|
||||
tar xzf /tmp/upload/koolproxyCA.tar.gz
|
||||
fi
|
||||
if [ ! -f $readyfolder/private/ca.key.pem ]; then
|
||||
echo "未找到ca.key.pem,备份文件不正确或已损坏,请检查备份文件!" > $kplogfile
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f $readyfolder/private/base.key.pem ]; then
|
||||
echo "未找到base.key.pem,备份文件不正确或已损坏,请检查备份文件!" > $kplogfile
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f $readyfolder/certs/ca.crt ]; then
|
||||
echo "未找到ca.crt,备份文件不正确或已损坏,请检查备份文件!" > $kplogfile
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv -f $readyfolder/private/ca.key.pem $kpfolder/private/ca.key.pem
|
||||
mv -f $readyfolder/private/base.key.pem $kpfolder/private/base.key.pem
|
||||
mv -f $readyfolder/certs/ca.crt $kpfolder/certs/ca.crt
|
||||
rm -rf $readyfolder
|
||||
rm -f /tmp/upload/koolproxyCA.tar.gz
|
||||
echo "证书成功还原,重启Koolproxy。" > $kplogfile
|
||||
/etc/init.d/koolproxy restart
|
||||
}
|
||||
|
||||
case "$*" in
|
||||
"backup")
|
||||
backup
|
||||
;;
|
||||
"restore")
|
||||
restore
|
||||
;;
|
||||
"help")
|
||||
echo "use backup or restore"
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
alias echo_date='echo $(date +%Y年%m月%d日\ %X):'
|
||||
|
||||
if [ ! -f openssl.cnf ]; then
|
||||
echo_date "Cannot found openssl.cnf"
|
||||
exit 1
|
||||
fi
|
||||
if [ -f /usr/share/koolproxy/data/private/ca.key.pem ]; then
|
||||
echo_date "已经有证书了!"
|
||||
else
|
||||
echo_date "生成证书中..."
|
||||
|
||||
#step 1, root ca
|
||||
mkdir -p certs private
|
||||
rm -f serial private/ca.key.pem
|
||||
chmod 700 private
|
||||
echo 1000 > serial
|
||||
openssl genrsa -traditional -aes256 -passout pass:koolshare -out private/ca.key.pem 2048
|
||||
chmod 400 private/ca.key.pem
|
||||
openssl req -config openssl.cnf -passin pass:koolshare \
|
||||
-subj "/C=CN/ST=Beijing/L=KP/O=KoolProxy inc/CN=koolproxy.com" \
|
||||
-key private/ca.key.pem \
|
||||
-new -x509 -days 7300 -sha256 -extensions v3_ca \
|
||||
-out certs/ca.crt
|
||||
|
||||
#step 2, domain rsa key
|
||||
openssl genrsa -traditional -aes256 -passout pass:koolshare -out private/base.key.pem 2048
|
||||
echo_date "证书生成完毕..."
|
||||
fi
|
||||
@@ -0,0 +1,132 @@
|
||||
# OpenSSL root CA configuration file.
|
||||
# Copy to `/root/ca/openssl.cnf`.
|
||||
|
||||
[ ca ]
|
||||
# `man ca`
|
||||
default_ca = CA_default
|
||||
|
||||
[ CA_default ]
|
||||
# Directory and file locations.
|
||||
dir = ./ca
|
||||
certs = $dir/certs
|
||||
crl_dir = $dir/crl
|
||||
new_certs_dir = $dir/newcerts
|
||||
database = $dir/index.txt
|
||||
serial = $dir/serial
|
||||
RANDFILE = $dir/private/.rand
|
||||
|
||||
# The root key and root certificate.
|
||||
private_key = $dir/private/ca.key.pem
|
||||
certificate = $dir/certs/ca.cert.pem
|
||||
|
||||
# For certificate revocation lists.
|
||||
crlnumber = $dir/crlnumber
|
||||
crl = $dir/crl/ca.crl.pem
|
||||
crl_extensions = crl_ext
|
||||
default_crl_days = 30
|
||||
|
||||
# SHA-1 is deprecated, so use SHA-2 instead.
|
||||
default_md = sha256
|
||||
|
||||
name_opt = ca_default
|
||||
cert_opt = ca_default
|
||||
default_days = 375
|
||||
preserve = no
|
||||
policy = policy_strict
|
||||
|
||||
[ policy_strict ]
|
||||
# The root CA should only sign intermediate certificates that match.
|
||||
# See the POLICY FORMAT section of `man ca`.
|
||||
countryName = match
|
||||
stateOrProvinceName = match
|
||||
organizationName = match
|
||||
organizationalUnitName = optional
|
||||
commonName = supplied
|
||||
emailAddress = optional
|
||||
|
||||
[ policy_loose ]
|
||||
# Allow the intermediate CA to sign a more diverse range of certificates.
|
||||
# See the POLICY FORMAT section of the `ca` man page.
|
||||
countryName = optional
|
||||
stateOrProvinceName = optional
|
||||
localityName = optional
|
||||
organizationName = optional
|
||||
organizationalUnitName = optional
|
||||
commonName = supplied
|
||||
emailAddress = optional
|
||||
|
||||
[ req ]
|
||||
# Options for the `req` tool (`man req`).
|
||||
default_bits = 2048
|
||||
distinguished_name = req_distinguished_name
|
||||
string_mask = utf8only
|
||||
|
||||
# SHA-1 is deprecated, so use SHA-2 instead.
|
||||
default_md = sha256
|
||||
|
||||
# Extension to add when the -x509 option is used.
|
||||
x509_extensions = v3_ca
|
||||
|
||||
[ req_distinguished_name ]
|
||||
# See <https://en.wikipedia.org/wiki/Certificate_signing_request>.
|
||||
countryName = Country Name (2 letter code)
|
||||
stateOrProvinceName = State or Province Name
|
||||
localityName = Locality Name
|
||||
0.organizationName = Organization Name
|
||||
organizationalUnitName = Organizational Unit Name
|
||||
commonName = Common Name
|
||||
emailAddress = Email Address
|
||||
|
||||
# Optionally, specify some defaults.
|
||||
countryName_default = GB
|
||||
stateOrProvinceName_default = England
|
||||
localityName_default =
|
||||
0.organizationName_default = Alice Ltd
|
||||
organizationalUnitName_default =
|
||||
emailAddress_default =
|
||||
|
||||
[ v3_ca ]
|
||||
# Extensions for a typical CA (`man x509v3_config`).
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid:always,issuer
|
||||
basicConstraints = critical, CA:true
|
||||
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
|
||||
|
||||
[ v3_intermediate_ca ]
|
||||
# Extensions for a typical intermediate CA (`man x509v3_config`).
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid:always,issuer
|
||||
basicConstraints = critical, CA:true, pathlen:0
|
||||
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
|
||||
|
||||
[ usr_cert ]
|
||||
# Extensions for client certificates (`man x509v3_config`).
|
||||
basicConstraints = CA:FALSE
|
||||
nsCertType = client, email
|
||||
nsComment = "OpenSSL Generated Client Certificate"
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid,issuer
|
||||
keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
|
||||
extendedKeyUsage = clientAuth, emailProtection
|
||||
|
||||
[ server_cert ]
|
||||
# Extensions for server certificates (`man x509v3_config`).
|
||||
basicConstraints = CA:FALSE
|
||||
nsCertType = server
|
||||
nsComment = "OpenSSL Generated Server Certificate"
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid,issuer:always
|
||||
keyUsage = critical, digitalSignature, keyEncipherment
|
||||
extendedKeyUsage = serverAuth
|
||||
|
||||
[ crl_ext ]
|
||||
# Extension for CRLs (`man x509v3_config`).
|
||||
authorityKeyIdentifier=keyid:always
|
||||
|
||||
[ ocsp ]
|
||||
# Extension for OCSP signing certificates (`man ocsp`).
|
||||
basicConstraints = CA:FALSE
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid,issuer
|
||||
keyUsage = critical, digitalSignature
|
||||
extendedKeyUsage = critical, OCSPSigning
|
||||
@@ -0,0 +1,49 @@
|
||||
! ******************************* KoolProxyR 自定义过滤语法简表 *******************************
|
||||
! ------------------------ 规则基于adblock规则,并进行了语法部分的扩展 ------------------------
|
||||
! ABP规则请参考https://adblockplus.org/zh_CN/filters,下面为大致摘要
|
||||
! "!" 为行注释符,注释行以该符号起始作为一行注释语义,用于规则描述
|
||||
! "@@" 为白名单符,白名单具有最高优先级,放行过滤的网站,例如:@@||taobao.com
|
||||
! "@@@@" 超级白名单,比白名单符拥有更高的优先级,主要用于放行https网站,例如:@@@@||https://taobao.com
|
||||
! ------------------------------------------------------------------------------------------
|
||||
! "*" 为字符通配符,能够匹配0长度或任意长度的字符串,该通配符不能与正则语法混用。
|
||||
! "^" 为分隔符,可以是除了字母、数字或者 _ - . % 之外的任何字符。
|
||||
! "~" 为排除标识符,通配符能过滤大多数广告,但同时存在误杀, 可以通过排除标识符修正误杀链接。
|
||||
! 注:通配符仅在 url 规则中支持,html 规则中不支持
|
||||
! ------------------------------------------------------------------------------------------
|
||||
! "|" 为管线符号,来表示地址的最前端或最末端
|
||||
! "||" 为子域通配符,方便匹配主域名下的所有子域
|
||||
! 用法及例子如下:(以下等号表示等价于)
|
||||
! ||xx.com/ad = http://xx.com/ad* || http://*.xx.com/ad*
|
||||
! ||http://xx.com/ad = http://xx.com/ad* || http://*.xx.com/ad*
|
||||
! ||https://xx.com/ad = https://xx.com/ad* || https://*.xx.com/ad*
|
||||
! |xx.com/ad = http://xx.com/ad*
|
||||
! |http://xx.com/ad = http://xx.com/ad*
|
||||
! |https://xx.com/ad = https://xx.com/ad*
|
||||
! ad = http://*ad*
|
||||
! http://ad = http://*ad*
|
||||
! https://ad = 不支持,需要指定域名,如下例
|
||||
! https://xx.com/ad = |https://xx.com/ad = https://xx.com/ad*
|
||||
! [同时可以表示两个以及两个以上的域名]如下例子
|
||||
! https://xx.ad.com 和 https://xxx.xx.ad.com = ||https://ad.com (注意! 由于https的原因使用要非常谨慎,不可以大范围使用)
|
||||
! ------------------------------------------------------------------------------------------
|
||||
! 兼容adblock规则的html规则语法,例如:
|
||||
! fulldls.com,torrentzap.com##.tp_reccomend_banner
|
||||
! 但是推荐写成以下标准写法:
|
||||
! ||fulldls.com##.tp_reccomend_banner
|
||||
! ||torrentzap.com##.tp_reccomend_banner
|
||||
! 如果一个网站html规则有多条,可以合并为这样:
|
||||
! ||torrentzap.com##.tp_reccomend_banner,.ad_top,[class="ad_right"]......
|
||||
! ------------------------------------------------------------------------------------------
|
||||
! 文本替换语法:$s@匹配内容@替换内容@
|
||||
! 非标准端口过滤语法:||abc.com:8081/ad.html或者|http://adb.com:8081/
|
||||
! 文本替换例子:|http://cdn.pcbeta.js.inimc.com/data/cache/common.js?$s@old@new@
|
||||
! 重定向语法:$r@匹配内容@替换内容@
|
||||
! 重定向例子:|http://koolshare.cn$r@http://koolshare.cn/*@http://www.qq.com@
|
||||
! 注:文本替换语法及重定向语法中的匹配内容不仅支持通配符功能,而且额外支持以下功能
|
||||
! 支持通配符 * 和 ? 表示单个字符
|
||||
! 支持全正则匹配,/正则内容/ 表示应用正则匹配
|
||||
! 正则替换:替换内容支持 $1 $2 这样的符号
|
||||
! 普通替换:替换内容支持 * 这样的符号,表示把命中的内容复制到替换的内容。(类似 $1 $2,但是 * 号会自动计算数字)
|
||||
! ------------------------------------------------------------------------------------------
|
||||
! 未来将逐步添加相关语法,兼容adblock puls的更多语法,敬请期待。
|
||||
! ******************************************************************************************
|
||||
@@ -0,0 +1,9 @@
|
||||
1|koolproxy.txt||静态规则
|
||||
1|daily.txt||每日规则
|
||||
1|kp.dat||视频规则
|
||||
1|user.txt||自定义规则
|
||||
1|yhosts.txt||Yhosts规则
|
||||
1|adg.txt||AdGuard规则
|
||||
1|steven.txt||Steven规则
|
||||
1|antiad.txt||AntiAD规则
|
||||
1|adgk.txt||坂本规则
|
||||
@@ -0,0 +1,49 @@
|
||||
! ******************************* KoolProxy 自定义过滤语法简表 *******************************
|
||||
! ------------------------ 规则基于adblock规则,并进行了语法部分的扩展 ------------------------
|
||||
! ABP规则请参考https://adblockplus.org/zh_CN/filters,下面为大致摘要
|
||||
! "!" 为行注释符,注释行以该符号起始作为一行注释语义,用于规则描述
|
||||
! "@@" 为白名单符,白名单具有最高优先级,放行过滤的网站,例如:@@||taobao.com
|
||||
! "@@@@" 超级白名单,比白名单符拥有更高的优先级,主要用于放行https网站,例如:@@@@||https://taobao.com
|
||||
! ------------------------------------------------------------------------------------------
|
||||
! "*" 为字符通配符,能够匹配0长度或任意长度的字符串,该通配符不能与正则语法混用。
|
||||
! "^" 为分隔符,可以是除了字母、数字或者 _ - . % 之外的任何字符。
|
||||
! "~" 为排除标识符,通配符能过滤大多数广告,但同时存在误杀, 可以通过排除标识符修正误杀链接。
|
||||
! 注:通配符仅在 url 规则中支持,html 规则中不支持
|
||||
! ------------------------------------------------------------------------------------------
|
||||
! "|" 为管线符号,来表示地址的最前端或最末端
|
||||
! "||" 为子域通配符,方便匹配主域名下的所有子域
|
||||
! 用法及例子如下:(以下等号表示等价于)
|
||||
! ||xx.com/ad = http://xx.com/ad* || http://*.xx.com/ad*
|
||||
! ||http://xx.com/ad = http://xx.com/ad* || http://*.xx.com/ad*
|
||||
! ||https://xx.com/ad = https://xx.com/ad* || https://*.xx.com/ad*
|
||||
! |xx.com/ad = http://xx.com/ad*
|
||||
! |http://xx.com/ad = http://xx.com/ad*
|
||||
! |https://xx.com/ad = https://xx.com/ad*
|
||||
! ad = http://*ad*
|
||||
! http://ad = http://*ad*
|
||||
! https://ad = 不支持,需要指定域名,如下例
|
||||
! https://xx.com/ad = |https://xx.com/ad = https://xx.com/ad*
|
||||
! [同时可以表示两个以及两个以上的域名]如下例子
|
||||
! https://xx.ad.com 和 https://xxx.xx.ad.com = ||https://ad.com (注意! 由于https的原因使用要非常谨慎,不可以大范围使用)
|
||||
! ------------------------------------------------------------------------------------------
|
||||
! 兼容adblock规则的html规则语法,例如:
|
||||
! fulldls.com,torrentzap.com##.tp_reccomend_banner
|
||||
! 但是推荐写成以下标准写法:
|
||||
! ||fulldls.com##.tp_reccomend_banner
|
||||
! ||torrentzap.com##.tp_reccomend_banner
|
||||
! 如果一个网站html规则有多条,可以合并为这样:
|
||||
! ||torrentzap.com##.tp_reccomend_banner,.ad_top,[class="ad_right"]......
|
||||
! ------------------------------------------------------------------------------------------
|
||||
! 文本替换语法:$s@匹配内容@替换内容@
|
||||
! 非标准端口过滤语法:||abc.com:8081/ad.html或者|http://adb.com:8081/
|
||||
! 文本替换例子:|http://cdn.pcbeta.js.inimc.com/data/cache/common.js?$s@old@new@
|
||||
! 重定向语法:$r@匹配内容@替换内容@
|
||||
! 重定向例子:|http://koolshare.cn$r@http://koolshare.cn/*@http://www.qq.com@
|
||||
! 注:文本替换语法及重定向语法中的匹配内容不仅支持通配符功能,而且额外支持以下功能
|
||||
! 支持通配符 * 和 ? 表示单个字符
|
||||
! 支持全正则匹配,/正则内容/ 表示应用正则匹配
|
||||
! 正则替换:替换内容支持 $1 $2 这样的符号
|
||||
! 普通替换:替换内容支持 * 这样的符号,表示把命中的内容复制到替换的内容。(类似 $1 $2,但是 * 号会自动计算数字)
|
||||
! ------------------------------------------------------------------------------------------
|
||||
! 未来将逐步添加相关语法,兼容adblock puls的更多语法,敬请期待。
|
||||
! ******************************************************************************************
|
||||
Whitespace-only changes.
Whitespace-only changes.
+171
@@ -0,0 +1,171 @@
|
||||
#!/bin/sh
|
||||
# set -x
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
CONFIG=koolproxy
|
||||
KP_DIR=/usr/share/koolproxy
|
||||
TMP_DIR=/tmp/koolproxy
|
||||
LOGFILE="/var/log/koolproxy.log"
|
||||
|
||||
config_t_get() {
|
||||
local index=0
|
||||
[ -n "$4" ] && index=$4
|
||||
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
limit_log() {
|
||||
local log=$1
|
||||
[ ! -f "$log" ] && return
|
||||
local sc=100
|
||||
[ -n "$2" ] && sc=$2
|
||||
local count=$(grep -c "" $log)
|
||||
if [ $count -gt $sc ];then
|
||||
let count=count-$sc
|
||||
sed -i "1,$count d" $log
|
||||
fi
|
||||
}
|
||||
|
||||
init_env() {
|
||||
rm -rf "$TMP_DIR"
|
||||
mkdir -p "$TMP_DIR"
|
||||
}
|
||||
|
||||
restart_koolproxy() {
|
||||
/etc/init.d/koolproxy restart
|
||||
}
|
||||
|
||||
__compare_file() {
|
||||
local descript=$1
|
||||
local localPath=$2
|
||||
local remoteUrl=$3
|
||||
|
||||
echo $(date "+%F %T"): ------------------- $descript更新 ------------------- >>$LOGFILE
|
||||
local filename=`basename $localPath`
|
||||
local remotePath="$TMP_DIR/$filename"
|
||||
wget "$remoteUrl" -q -O "$remotePath"
|
||||
if [ "$?" == "0" ]; then
|
||||
if [ -f "$localPath" ]; then
|
||||
localMD5=`md5sum "$localPath" | awk '{print $1}'`
|
||||
localNum=`cat "$localPath" | grep -v '^!' | wc -l`
|
||||
else
|
||||
localMD5="文件不存在"
|
||||
localNum="0"
|
||||
fi
|
||||
remoteMD5=`md5sum "$remotePath" | awk '{print $1}'`
|
||||
remoteNum=`cat "$remotePath" | grep -v '^!' | wc -l`
|
||||
|
||||
echo $(date "+%F %T"): 本地版本MD5:$localMD5 >>$LOGFILE
|
||||
echo $(date "+%F %T"): 本地版本条数:$localNum >>$LOGFILE
|
||||
echo >>$LOGFILE
|
||||
echo $(date "+%F %T"): 在线版本MD5:$remoteMD5 >>$LOGFILE
|
||||
echo $(date "+%F %T"): 在线版本条数:$remoteNum >>$LOGFILE
|
||||
echo >>$LOGFILE
|
||||
|
||||
if [ "$localMD5" != "$remoteMD5" ];then
|
||||
echo $(date "+%F %T"): 检测到更新,开始更新规则! >>$LOGFILE
|
||||
mv -f "$remotePath" "$localPath"
|
||||
echo $(date "+%F %T"): 更新成功! >>$LOGFILE
|
||||
echo >>$LOGFILE
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
echo "$(date "+%F %T"): 获取在线版本时出现错误! " >>$LOGFILE
|
||||
echo >>$LOGFILE
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
__update_rule() {
|
||||
local name
|
||||
local file
|
||||
local exrule
|
||||
local enable
|
||||
config_get name $1 name
|
||||
config_get file $1 file
|
||||
config_get exrule $1 url
|
||||
config_get enable $1 load
|
||||
if [ -n "$file" ] && [ -n "$exrule" ]; then
|
||||
if [ $enable -ne 1 ]; then
|
||||
return
|
||||
fi
|
||||
__compare_file "$name" "$KP_DIR/data/rules/$file" "$exrule"
|
||||
if [ "$?" == "0" ]; then
|
||||
uci set koolproxy.$1.time="`date +%Y-%m-%d" "%H:%M`"
|
||||
uci commit koolproxy
|
||||
RESTART_KOOLPROXY=true
|
||||
fi
|
||||
cat $KP_DIR/data/rules/$file >>$KP_DIR/data/rules/user.txt
|
||||
echo >>$LOGFILE
|
||||
fi
|
||||
}
|
||||
|
||||
update_rss_rules() {
|
||||
cp $KP_DIR/data/user.txt $KP_DIR/data/rules/user.txt
|
||||
config_load $CONFIG
|
||||
config_foreach __update_rule rss_rule
|
||||
}
|
||||
|
||||
|
||||
|
||||
update_rules() {
|
||||
echo $(date "+%F %T"): ------------------- 内置规则更新 ------------------- >>$LOGFILE
|
||||
wget 'https://cdn.jsdelivr.net/gh/ilxp/koolproxy@main/rules/kp.dat' -q -O $KP_DIR/data/rules/kp.dat
|
||||
wget 'https://cdn.jsdelivr.net/gh/ilxp/koolproxy@main/rules/daily.txt' -q -O $KP_DIR/data/rules/daily.txt
|
||||
wget 'https://cdn.jsdelivr.net/gh/ilxp/koolproxy@main/rules/koolproxy.txt' -q -O $KP_DIR/data/rules/koolproxy.txt
|
||||
wget 'https://cdn.jsdelivr.net/gh/ilxp/koolproxy@main/rules/yhosts.txt' -q -O $KP_DIR/data/rules/yhosts.txt
|
||||
wget 'https://cdn.jsdelivr.net/gh/ilxp/koolproxy@main/rules/steven.txt' -q -O $KP_DIR/data/rules/steven.txt
|
||||
wget 'https://cdn.jsdelivr.net/gh/ilxp/koolproxy@main/rules/adg.txt' -q -O $KP_DIR/data/rules/adg.txt
|
||||
wget 'https://cdn.jsdelivr.net/gh/ilxp/koolproxy@main/rules/antiad.txt' -q -O $KP_DIR/data/rules/antiad.txt
|
||||
wget 'https://cdn.jsdelivr.net/gh/ilxp/koolproxy@main/rules/adgk.txt' -q -O $KP_DIR/data/rules/adgk.txt
|
||||
wget 'https://cdn.jsdelivr.net/gh/ilxp/koolproxy@main/rules/koolproxy_ipset.conf' -q -O $KP_DIR/koolproxy_ipset.conf
|
||||
wget 'https://cdn.jsdelivr.net/gh/ilxp/koolproxy@main/rules/dnsmasq.adblock' -q -O $KP_DIR/dnsmasq.adblock
|
||||
adg_rules_local=`cat /usr/share/koolproxy/data/rules/adg.txt | sed -n '4p'|awk '{print $4}'`
|
||||
steven_rules_local=`cat /usr/share/koolproxy/data/rules/steven.txt | sed -n '2p'|awk '{print $3,$4,$5,$6}'`
|
||||
yhosts_rules_local=`cat /usr/share/koolproxy/data/rules/yhosts.txt | sed -n '1p' | cut -d ":" -f2`
|
||||
antiad_rules_local=`cat /usr/share/koolproxy/data/rules/antiad.txt | sed -n '2p' | cut -d "=" -f2`
|
||||
koolproxy_rules_local=`cat /usr/share/koolproxy/data/rules/koolproxy.txt | sed -n '3p'|awk '{print $3,$4}'`
|
||||
adgk_rules_local=`cat /usr/share/koolproxy/data/rules/adgk.txt | sed -n '2p'|awk '{print $3}'`
|
||||
echo $(date "+%F %T"): -------------------AdGuard规则 Version $adg_rules_local >>$LOGFILE
|
||||
echo $(date "+%F %T"): -------------------Steven规则 Version $steven_rules_local >>$LOGFILE
|
||||
echo $(date "+%F %T"): -------------------Yhosts规则 Version $yhosts_rules_local >>$LOGFILE
|
||||
echo $(date "+%F %T"): -------------------AntiAD规则 Version $antiad_rules_local >>$LOGFILE
|
||||
echo $(date "+%F %T"): -------------------坂本规则 Version $adgk_rules_local >>$LOGFILE
|
||||
echo $(date "+%F %T"): -------------------静态规则 Version $koolproxy_rules_local >>$LOGFILE
|
||||
echo $(date "+%F %T"): ------------------- 内置规则更新成功! ------------------- >>$LOGFILE
|
||||
RESTART_KOOLPROXY=true
|
||||
|
||||
}
|
||||
|
||||
update_adb_host() {
|
||||
/usr/sbin/adblockplus >>$LOGFILE 2>&1 &
|
||||
if [ "$?" == "0" ]; then
|
||||
RESTART_DNSMASQ=true
|
||||
fi
|
||||
}
|
||||
|
||||
# main process
|
||||
init_env
|
||||
limit_log $LOGFILE
|
||||
|
||||
# update rules
|
||||
update_rules
|
||||
|
||||
# update user rules
|
||||
update_rss_rules
|
||||
|
||||
koolproxy_mode=$(config_t_get global koolproxy_mode 1)
|
||||
koolproxy_host=$(config_t_get global koolproxy_host 0)
|
||||
|
||||
# update ADB Plus Host
|
||||
if [ "$koolproxy_mode" == "2" ] && [ "$koolproxy_host" == "1" ];then
|
||||
update_adb_host
|
||||
fi
|
||||
|
||||
if [ $RESTART_KOOLPROXY ]; then
|
||||
restart_koolproxy
|
||||
echo $(date "+%F %T"): 重启koolproxy进程 >>$LOGFILE
|
||||
fi
|
||||
|
||||
init_env
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-ikoolproxy": {
|
||||
"description": "Grant UCI access for luci-app-ikoolproxy",
|
||||
"read": {
|
||||
"uci": [ "koolproxy" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "koolproxy" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"config": "koolproxy",
|
||||
"init": "koolproxy"
|
||||
}
|
||||
Reference in new issue
Block a user