mirror of
https://github.com/bol-van/zapret.git
synced 2024-12-02 22:50:53 +03:00
90 lines
1.7 KiB
Bash
Executable File
90 lines
1.7 KiB
Bash
Executable File
#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2006-2011 OpenWrt.org
|
|
|
|
# CHOOSE ISP HERE. UNCOMMENT ONLY ONE LINE.
|
|
#ISP=mns
|
|
#ISP=rt
|
|
#ISP=beeline
|
|
#ISP=domru
|
|
ISP=tiera
|
|
#ISP=none
|
|
|
|
# !!!!! in openwrt you need to add firewall rules manually to /etc/firewall.user
|
|
|
|
QNUM=200
|
|
TPPORT=1188
|
|
ROUTE_TABLE_NUM=100
|
|
NFQWS=/opt/zapret/nfq/nfqws
|
|
TPWS=/opt/zapret/tpws/tpws
|
|
IPSET_CR=/opt/zapret/ipset/create_ipset.sh
|
|
TPWS_USER=daemon
|
|
|
|
# start betfore firewall - we need ipset populated
|
|
START=18
|
|
|
|
|
|
# must execute /etc/firewall.user on every firewall reload
|
|
set_firewall_user_reload() {
|
|
i=0
|
|
while true
|
|
do
|
|
path=$(uci -q get firewall.@include[$i].path)
|
|
[ -n "$path" ] || break
|
|
[ "$path" == "/etc/firewall.user" ] && {
|
|
reload=$(uci -q get firewall.@include[$i].reload)
|
|
[ "$reload" = "1" ] || {
|
|
echo Setting 'reload' call option to /etc/firewall.user
|
|
uci set firewall.@include[$i].reload=1
|
|
uci commit firewall
|
|
}
|
|
}
|
|
i=$((i+1))
|
|
done
|
|
}
|
|
|
|
get_daemon() {
|
|
case "${ISP}" in
|
|
mns)
|
|
DAEMON_OPTS="--qnum=$QNUM --wsize=4"
|
|
DAEMON=$NFQWS
|
|
;;
|
|
rt)
|
|
DAEMON_OPTS="--qnum=$QNUM --wsize=20"
|
|
DAEMON=$NFQWS
|
|
;;
|
|
beeline)
|
|
DAEMON_OPTS="--qnum=$QNUM --hostcase"
|
|
DAEMON=$NFQWS
|
|
;;
|
|
domru)
|
|
DAEMON_OPTS="--port=$TPPORT --hostcase --split-http-req=host --bind-addr=127.0.0.1 --user=$TPWS_USER"
|
|
DAEMON=$TPWS
|
|
;;
|
|
tiera)
|
|
DAEMON_OPTS="--port=$TPPORT --split-http-req=host --bind-addr=127.0.0.1 --user=$TPWS_USER"
|
|
DAEMON=$TPWS
|
|
;;
|
|
esac
|
|
}
|
|
|
|
|
|
start() {
|
|
set_firewall_user_reload
|
|
echo "Creating ipset"
|
|
($IPSET_CR)
|
|
|
|
get_daemon
|
|
[ -n "$DAEMON" ] && {
|
|
echo "Starting $DAEMON"
|
|
service_start $DAEMON --daemon $DAEMON_OPTS
|
|
}
|
|
}
|
|
|
|
stop() {
|
|
get_daemon
|
|
[ -n "$DAEMON" ] && {
|
|
service_stop $DAEMON
|
|
}
|
|
}
|
|
|