更新koolproxy

This commit is contained in:
monlor
2020-09-08 21:37:55 +08:00
parent bef98a5988
commit b254b48697
10 changed files with 123 additions and 131 deletions

View File

@@ -4,10 +4,10 @@ needver="0.0.1"
supports="linux_aarch64,linux_arm,linux_mips,linux_x86_64"
openport="1"
backupfiles="config/kpcontrol.conf,bin/data/private,bin/data/certs"
newinfo="修复bug"
newinfo="更新主程序,更新规则地址"
appinfo="简单快速屏蔽网页或视频广告TGhttps://t.me/joinchat/AAAAAD-tO7GPvfOU131_vg"
kp_rule_koolproxy="https://houzi-.coding.net/p/my_dream/d/my_dream/git/raw/master/koolproxy.txt"
kp_rule_daily="https://houzi-.coding.net/p/my_dream/d/my_dream/git/raw/master/daily.txt"
kp_rule_dat="https://houzi-.coding.net/p/my_dream/d/my_dream/git/raw/master/kp.dat"
kp_rule_user="https://raw.githubusercontent.com/kysdm/ad-rules/master/user-rules-koolproxy.txt"
version="1.5.8"
kp_rule_koolproxy="https://cdn.jsdelivr.net/gh/houzi-/CDN/koolproxy.txt"
kp_rule_daily="https://cdn.jsdelivr.net/gh/houzi-/CDN/daily.txt"
kp_rule_dat="hhttps://cdn.jsdelivr.net/gh/houzi-/CDN/kp.dat"
kp_rule_user=""
version="1.6.0"

View File

@@ -1,96 +0,0 @@
#----------------【KoolProxy】------------------
koolproxy() {
eval `mbdb export koolproxy`
source /etc/mixbox/bin/base
control=${mbroot}/apps/${appname}/config/kpcontrol.conf
[ ! -f "$control" ] && touch $control
echo "********* $service ***********"
echo "[${appinfo}]"
readsh "启动${appname}服务[1/0] " "enable" "1"
if [ "$enable" == '1' ]; then
echo "[1.全局模式 2.黑名单模式 3.视频模式]"
read -p "请选择${appname}模式:" res
if [ "$res" == '1' -o "$res" == '2' -o "$res" == '3' ]; then
mbdb set $appname.main.mode="$res"
fi
read -p "自动更新用户自定义规则?[1/0] " res
checkread $res && mbdb set $appname.main.autorule="$res"
cat $control | while read line
do
name=$(cutsh ${line} 1)
mode=$(cutsh ${line} 3)
case "$mode" in
0) mode="不过滤" ;;
1) mode="http模式" ;;
2) mode="https模式" ;;
*) mode="空" ;;
esac
echo "设备[$name]运行模式为: $mode"
done
mode=$(mbdb get ${appname}.main.ss_acl_default_mode)
case "$mode" in
0) mode="不过滤" ;;
1) mode="http模式" ;;
2) mode="https模式" ;;
*) mode="http模式" ;;
esac
echo "其余设备运行模式为: $mode"
read -p "设置局域网http/https控制[1/0] " res
if [ "$res" == '1' ]; then
read -p "清空之前的配置再添加?[1/0] " res
[ "$res" == '1' ] && echo -n > $control
i=0
cat /tmp/dhcp.leases | while read line
do
name=$(echo ${line} | cut -d' ' -f4)
mac=$(echo ${line} | cut -d' ' -f2)
ip=$(echo ${line} | cut -d' ' -f3)
let i=$i+1
echo "$i. $name [$ip] [$mac]"
done
while(true)
do
read -p "请选择一个设备或输入mac地址" res
if echo "$res" | grep -E "^[0-9]{0,3}$" &> /dev/null; then
line=$(cat /tmp/dhcp.leases | grep -n . | grep -w "^$res")
name=$(echo ${line} | cut -d' ' -f4)
mac=$(echo ${line} | cut -d' ' -f2)
else
line="1"
name="$res"
mac="$res"
fi
if [ ! -z "${line}" ]; then
read -p "请选择(0.不过滤 1.http 2.https)" res
if [ "$res" == '0' -o "$res" == '1' -o "$res" == '2' ]; then
if [ ! -z "$mac" ]; then
sed -i "/^$name,$mac/d" $control
echo "$name,$mac,$res" >> $control
else
echo "mac不能为空, 添加失败!"
fi
else
echo "输入有误, 添加失败"
fi
read -p "继续增加设备?[1/0] " res
[ "$res" == '0' ] && break
else
echo "输入为空,跳过..."
break
fi
done
readsh "请选择其余设备(0.不过滤 1.http 2.https) " "koolproxy_acl_default_mode" "1"
fi
${mbroot}/apps/${appname}/scripts/${appname}.sh restart
else
${mbroot}/apps/${appname}/scripts/${appname}.sh stop
fi
}
#----------------【KoolProxy】------------------

View File

@@ -0,0 +1,89 @@
#!/bin/sh
#copyright by monlor
eval `mbdb export koolproxy`
source "$(mbdb get mixbox.main.path)"/bin/base
control=${mbroot}/apps/${appname}/config/kpcontrol.conf
[ ! -f "$control" ] && touch $control
echo "********* $service ***********"
echo "[${appinfo}]"
readsh "启动${appname}服务[1/0] " "enable" "1"
if [ "$enable" == '1' ]; then
echo "[1.全局模式 2.黑名单模式 3.视频模式]"
read -p "请选择${appname}模式:" res
if [ "$res" == '1' -o "$res" == '2' -o "$res" == '3' ]; then
mbdb set $appname.main.mode="$res"
fi
# read -p "自动更新用户自定义规则?[1/0] " res
# checkread $res && mbdb set $appname.main.autorule="$res"
cat $control | while read line
do
name=$(cutsh ${line} 1)
mode=$(cutsh ${line} 3)
case "$mode" in
0) mode="不过滤" ;;
1) mode="http模式" ;;
2) mode="https模式" ;;
*) mode="空" ;;
esac
echo "设备[$name]运行模式为: $mode"
done
mode=$(mbdb get ${appname}.main.ss_acl_default_mode)
case "$mode" in
0) mode="不过滤" ;;
1) mode="http模式" ;;
2) mode="https模式" ;;
*) mode="http模式" ;;
esac
echo "其余设备运行模式为: $mode"
read -p "设置局域网http/https控制[1/0] " res
if [ "$res" == '1' ]; then
read -p "清空之前的配置再添加?[1/0] " res
[ "$res" == '1' ] && echo -n > $control
i=0
cat /tmp/dhcp.leases | while read line
do
name=$(echo ${line} | cut -d' ' -f4)
mac=$(echo ${line} | cut -d' ' -f2)
ip=$(echo ${line} | cut -d' ' -f3)
let i=$i+1
echo "$i. $name [$ip] [$mac]"
done
while(true)
do
read -p "请选择一个设备或输入mac地址" res
if echo "$res" | grep -E "^[0-9]{0,3}$" &> /dev/null; then
line=$(cat /tmp/dhcp.leases | grep -n . | grep -w "^$res")
name=$(echo ${line} | cut -d' ' -f4)
mac=$(echo ${line} | cut -d' ' -f2)
else
line="1"
name="$res"
mac="$res"
fi
if [ ! -z "${line}" ]; then
read -p "请选择(0.不过滤 1.http 2.https)" res
if [ "$res" == '0' -o "$res" == '1' -o "$res" == '2' ]; then
if [ ! -z "$mac" ]; then
sed -i "/^$name,$mac/d" $control
echo "$name,$mac,$res" >> $control
else
echo "mac不能为空, 添加失败!"
fi
else
echo "输入有误, 添加失败"
fi
read -p "继续增加设备?[1/0] " res
[ "$res" == '0' ] && break
else
echo "输入为空,跳过..."
break
fi
done
readsh "请选择其余设备(0.不过滤 1.http 2.https) " "koolproxy_acl_default_mode" "1"
fi
readsh "重启${appname}服务[1/0] " "res" "1"
[ "$res" != '0' ] && exit 0
fi
exit 1

View File

@@ -219,14 +219,14 @@ detect_cert () {
fi
}
update_userrule () {
result=$(mbdb get ${appname}.main.autorule)
if [ "$result" == '1' ]; then
cru a "${appname}"_rule "20 5 * * * ${mbroot}/apps/${appname}/scripts/updaterules.sh"
else
cru d "${appname}"_rule
fi
}
# update_userrule () {
# result=$(mbdb get ${appname}.main.autorule)
# if [ "$result" == '1' ]; then
# cru a "${appname}"_rule "20 5 * * * ${mbroot}/apps/${appname}/scripts/updaterules.sh"
# else
# cru d "${appname}"_rule
# fi
# }
start () {
@@ -238,7 +238,7 @@ start () {
cru a "${appname}" "0 6 * * * ${mbroot}/apps/${appname}/scripts/${appname}.sh restart"
[ -z $mode ] && logsh "$service" "${appname}未配置" && exit
detect_cert
update_userrule
# update_userrule
update_rules
start_koolproxy
add_ipset_conf && restart_dnsmasq