mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-30 05:50:53 +03:00
Add minimal config and init script to tpws for minimal openwrt image(4MB flash devices)
This commit is contained in:
parent
03d51a3ccc
commit
fb9e33eab2
@ -33,7 +33,8 @@ How to compile native programs for use in openwrt
|
||||
|
||||
5) make toolchain/compile
|
||||
|
||||
6) make package/tpws/compile
|
||||
6) #For minimal version building twps package only is enough
|
||||
make package/tpws/compile
|
||||
make package/nfqws/compile
|
||||
make package/ip2net/compile
|
||||
make package/mdig/compile
|
||||
|
@ -3,7 +3,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=tpws
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=1.1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@ -12,7 +12,8 @@ define Package/tpws
|
||||
CATEGORY:=Network
|
||||
TITLE:=tpws
|
||||
SUBMENU:=Zapret
|
||||
DEPENDS:=+zlib +libcap
|
||||
DEPENDS:=+zlib +libcap +zlib +libcap +gzip +iptables +iptables-mod-extra +iptables-mod-nfqueue +iptables-mod-filter +iptables-mod-ipopt +iptables-mod-conntrack-extra
|
||||
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
@ -24,7 +25,17 @@ define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS)
|
||||
endef
|
||||
|
||||
define Package/tpws/conffiles
|
||||
/etc/config/zapret
|
||||
endef
|
||||
|
||||
define Package/tpws/install
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/zapret.conf $(1)/etc/config/zapret
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/zapret.init $(1)/etc/init.d/zapret
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d
|
||||
$(INSTALL_DATA) ./files/zapret.hotplug $(1)/etc/hotplug.d/90-zapret
|
||||
$(INSTALL_DIR) $(1)/opt/zapret/tpws
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tpws $(1)/opt/zapret/tpws
|
||||
endef
|
||||
|
@ -0,0 +1,4 @@
|
||||
config zapret tpws
|
||||
option opts "--split-pos=2"
|
||||
option pidfile "tpws.pid"
|
||||
option port "8088"
|
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
ZAPRET=/etc/init.d/zapret
|
||||
|
||||
check_lan()
|
||||
{
|
||||
IS_LAN=
|
||||
[ -n "$OPENWRT_LAN" ] || OPENWRT_LAN=lan
|
||||
for lan in $OPENWRT_LAN; do
|
||||
[ "$INTERFACE" = "$lan" ] && {
|
||||
IS_LAN=1
|
||||
break
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
[ -n "$INTERFACE" ] && check_lan && [ -n "$IS_LAN" ] && [ "$ACTION" = ifup -o "$ACTION" = ifupdate ] && [ $ZAPRET stop ] && [ $ZAPRET start ]
|
||||
[ -n "$INTERFACE" ] && [ -n "$IS_LAN" ] && [ "$ACTION" = ifdown ] && [ $ZAPRET stop ]
|
90
docs/compile/openwrt/package/zapret/tpws/files/zapret.init
Normal file
90
docs/compile/openwrt/package/zapret/tpws/files/zapret.init
Normal file
@ -0,0 +1,90 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
# after network
|
||||
START=21
|
||||
|
||||
CONFIGURATION=zapret
|
||||
PIDDIR=/var/run
|
||||
|
||||
|
||||
load_fw_rules()
|
||||
{
|
||||
json_add_object ""
|
||||
json_add_string type redirect
|
||||
json_add_string name "Transparent Proxy Redirect HTTP"
|
||||
json_add_string src lan
|
||||
json_add_string proto tcp
|
||||
json_add_string dest_port "$1"
|
||||
json_add_string src_dip "!$2"
|
||||
json_add_string dest_ip "$2"
|
||||
json_add_string src_dport "80"
|
||||
json_add_string dest lan
|
||||
json_close_object
|
||||
|
||||
json_add_object ""
|
||||
json_add_string type redirect
|
||||
json_add_string name "Transparent Proxy Redirect HTTPS"
|
||||
json_add_string src lan
|
||||
json_add_string proto tcp
|
||||
json_add_string dest_port "$1"
|
||||
json_add_string src_dip "!$2"
|
||||
json_add_string dest_ip "$2"
|
||||
json_add_string src_dport "443"
|
||||
json_add_string dest lan
|
||||
json_close_object
|
||||
}
|
||||
|
||||
start_service()
|
||||
{
|
||||
echo "Starting Zapret service"
|
||||
config_load "$CONFIGURATION"
|
||||
|
||||
local opts
|
||||
local pid
|
||||
local lanaddr
|
||||
local lport
|
||||
|
||||
config_get opts tpws opts
|
||||
config_get pid tpws pid
|
||||
config_get lport tpws port
|
||||
config_load "network"
|
||||
config_get lanaddr lan ipaddr
|
||||
|
||||
procd_open_instance
|
||||
|
||||
procd_set_param command "/opt/zapret/tpws/tpws"
|
||||
procd_append_param command "--port=$lport"
|
||||
procd_append_param command "--user=nobody"
|
||||
procd_append_param command "--bind-addr=$lanaddr"
|
||||
procd_append_param command "--bind-wait-ifup=30"
|
||||
procd_append_param command "--bind-wait-ip=10"
|
||||
procd_append_param command "$opts"
|
||||
|
||||
procd_set_param file /etc/config/zapret
|
||||
procd_set_param pidfile "$PIDDIR/$pid"
|
||||
procd_set_param netdev "br-lan"
|
||||
|
||||
procd_open_data
|
||||
|
||||
json_add_array firewall
|
||||
load_fw_rules "$lport" "$lanaddr"
|
||||
json_close_array
|
||||
|
||||
procd_close_data
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service()
|
||||
{
|
||||
# this procedure is called from stop()
|
||||
# stop() already stop daemons
|
||||
procd_set_config_changed firewall
|
||||
echo "STOP Zapret service"
|
||||
}
|
||||
|
||||
service_started()
|
||||
{
|
||||
procd_set_config_changed firewall
|
||||
}
|
Loading…
Reference in New Issue
Block a user