mirror of
https://github.com/bol-van/zapret.git
synced 2024-12-02 14:40:52 +03:00
85 lines
1.7 KiB
Bash
Executable File
85 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
|
|
|
|
USE_PROCD=1
|
|
# start betfore firewall - we need ipset populated
|
|
START=18
|
|
|
|
# !!!!! 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
|
|
|
|
|
|
# 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 --hostspell=HOST"
|
|
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_service() {
|
|
set_firewall_user_reload
|
|
echo "Creating ipset"
|
|
($IPSET_CR)
|
|
|
|
get_daemon
|
|
[ -n "$DAEMON" ] && {
|
|
echo "Starting $DAEMON"
|
|
procd_open_instance
|
|
procd_set_param command $DAEMON $DAEMON_OPTS
|
|
procd_close_instance
|
|
}
|
|
}
|