zapret/init.d/openwrt/zapret

100 lines
2.1 KiB
Plaintext
Raw Normal View History

2016-02-15 13:34:45 +00:00
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
# CHOOSE ISP HERE. UNCOMMENT ONLY ONE LINE.
2017-04-23 07:14:00 +00:00
ISP=mns
2016-02-17 17:22:21 +00:00
#ISP=rt
2017-04-23 07:14:00 +00:00
#ISP=beeline
2016-03-05 08:04:40 +00:00
#ISP=domru
#ISP=tiera
2017-04-23 07:14:00 +00:00
#ISP=athome
2016-12-09 13:33:29 +00:00
# If ISP is unlisted then uncomment "custom"
# Find out what works for your ISP and modify "# PLACEHOLDER" parts of this script
#ISP=custom
2016-02-15 13:34:45 +00:00
USE_PROCD=1
# start betfore firewall - we need ipset populated
START=18
2016-02-26 08:09:31 +00:00
# !!!!! in openwrt you need to add firewall rules manually to /etc/firewall.user
2016-02-15 13:34:45 +00:00
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
2016-02-26 08:09:31 +00:00
# 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
}
2016-02-15 13:34:45 +00:00
get_daemon() {
case "${ISP}" in
2016-02-17 17:22:21 +00:00
mns)
2017-02-19 11:06:58 +00:00
DAEMON_OPTS="--qnum=$QNUM --wsize=3"
2016-02-15 13:34:45 +00:00
DAEMON=$NFQWS
;;
2016-02-17 17:22:21 +00:00
rt)
DAEMON_OPTS="--qnum=$QNUM --wsize=20"
DAEMON=$NFQWS
;;
2016-02-15 13:34:45 +00:00
beeline)
DAEMON_OPTS="--qnum=$QNUM --hostspell=HOST"
2016-02-15 13:34:45 +00:00
DAEMON=$NFQWS
;;
domru)
DAEMON_OPTS="--port=$TPPORT --hostcase --split-http-req=host --bind-addr=127.0.0.1 --user=$TPWS_USER"
DAEMON=$TPWS
;;
2016-03-05 08:04:40 +00:00
tiera)
DAEMON_OPTS="--port=$TPPORT --split-http-req=host --bind-addr=127.0.0.1 --user=$TPWS_USER"
DAEMON=$TPWS
;;
2017-04-23 07:14:00 +00:00
athome)
DAEMON_OPTS="--port=$TPPORT --split-http-req=method --bind-addr=127.0.0.1 --user=$TPWS_USER"
DAEMON=$TPWS
;;
2016-12-09 13:33:29 +00:00
custom)
# PLACEHOLDER
echo !!! NEED ATTENTION !!!
echo Select which daemon and what options work for you
DAEMON_OPTS=20
DAEMON=/bin/sleep
;;
2016-02-15 13:34:45 +00:00
esac
}
start_service() {
2016-02-26 08:09:31 +00:00
set_firewall_user_reload
2016-02-15 13:34:45 +00:00
echo "Creating ipset"
($IPSET_CR)
get_daemon
2016-03-05 08:04:40 +00:00
[ -n "$DAEMON" ] && {
echo "Starting $DAEMON"
procd_open_instance
procd_set_param command $DAEMON $DAEMON_OPTS
procd_close_instance
2016-03-05 08:04:40 +00:00
}
2016-02-15 13:34:45 +00:00
}