mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-30 13:45:13 +08:00
update 2026-09-26 11:07:27
This commit is contained in:
1 parent
7b88b273d0
commit
97ae9f68da
4898 files changed
-1712274
No files matched your search
@@ -1,50 +0,0 @@
|
||||
# Copyright 2019 Shun Li <riverscn@gmail.com>
|
||||
# Licensed to the public under the GNU General Public License v3.
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=iptvhelper
|
||||
PKG_VERSION:=0.1.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER:=Shun Li <riverscn@gmail.com>
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/iptvhelper
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
DEPENDS:= \
|
||||
+ipset \
|
||||
+iptables
|
||||
TITLE:=Scripts for configure IPTV easily
|
||||
MAINTAINER:=Shun Li <riverscn@gmail.com>
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/iptvhelper/description
|
||||
Scripts for configure IPTV easily
|
||||
endef
|
||||
|
||||
define Package/iptvhelper/conffiles
|
||||
/etc/config/iptvhelper
|
||||
/etc/firewall.iptvhelper
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/iptvhelper/postinst
|
||||
#!/bin/sh
|
||||
endef
|
||||
|
||||
define Package/iptvhelper/postrm
|
||||
#!/bin/sh
|
||||
endef
|
||||
|
||||
define Package/iptvhelper/install
|
||||
$(CP) ./files/* $(1)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,iptvhelper))
|
||||
@@ -1,8 +0,0 @@
|
||||
config tvbox 'default'
|
||||
option disabled '1'
|
||||
option respawn '1'
|
||||
option mac '00:00:00:00:00:00'
|
||||
option ipset '1'
|
||||
option dns_redir '1'
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
test -s "/etc/init.d/iptvhelper" && /etc/init.d/iptvhelper reload
|
||||
@@ -1,127 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright 2019 Shun Li <riverscn@gmail.com>
|
||||
# Licensed to the public under the GNU General Public License v3.
|
||||
|
||||
START=95
|
||||
USE_PROCD=1
|
||||
|
||||
_ipt() {
|
||||
cmd="$(echo "$@" | sed 's|-A|-D|g;s|-I|-D|g')"
|
||||
while iptables $cmd &>/dev/null; do
|
||||
:
|
||||
done
|
||||
iptables $@
|
||||
}
|
||||
|
||||
destroy_iptv_ipset() {
|
||||
for ip_set in $(ipset list | awk '/iptvhelper/ {print $2}'); do ipset destroy $ip_set; done
|
||||
}
|
||||
|
||||
clear_iptv_rules() {
|
||||
iptables-save --counters | grep -v "iptvhelper-rule" | iptables-restore --counters
|
||||
}
|
||||
|
||||
append_arg() {
|
||||
local cfg="$1"
|
||||
local var="$2"
|
||||
local opt="$3"
|
||||
local def="$4"
|
||||
local val
|
||||
|
||||
config_get val "$cfg" "$var"
|
||||
[ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}"
|
||||
}
|
||||
|
||||
append_bool() {
|
||||
local cfg="$1"
|
||||
local var="$2"
|
||||
local opt="$3"
|
||||
local def="$4"
|
||||
local val
|
||||
|
||||
config_get_bool val "$cfg" "$var" "$def"
|
||||
[ "$val" = 1 ] && procd_append_param command "$opt"
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local cfg="$1"
|
||||
local aux
|
||||
|
||||
config_get_bool aux "$cfg" 'disabled' '0'
|
||||
[ "$aux" = 1 ] && return 1
|
||||
|
||||
logger "iptvhelper.$cfg: instance starting"
|
||||
|
||||
local IPTV_MAC
|
||||
local IPTV_DNS_REDIR
|
||||
local IPTV_IPSET
|
||||
|
||||
config_get IPTV_MAC $cfg mac
|
||||
config_get IPTV_DNS_REDIR $cfg dns_redir
|
||||
config_get IPTV_IPSET $cfg ipset
|
||||
logger "iptvhelper.$cfg: topbox mac=$IPTV_MAC"
|
||||
|
||||
if [[ $IPTV_DNS_REDIR == '1' ]]; then
|
||||
logger "iptvhelper.$cfg: topbox DNS redierct enabled"
|
||||
_ipt -t nat -A PREROUTING -m mac --mac-source $IPTV_MAC -m comment --comment "iptvhelper-rule" -p udp --dport 53 -j REDIRECT --to-ports 53
|
||||
fi
|
||||
|
||||
if [[ $IPTV_IPSET='1' ]]; then
|
||||
logger "iptvhelper.$cfg: topbox ipset enabled"
|
||||
if ! ipset -q list iptvhelper_$cfg >/dev/null; then
|
||||
ipset create iptvhelper_$cfg nethash
|
||||
fi
|
||||
_ipt -t nat -I PREROUTING -m mac --mac-source $IPTV_MAC -m comment --comment "iptvhelper-rule" -m set ! --match-set iptvhelper_$cfg dst -m conntrack --ctstate NEW -j LOG --log-prefix "iptvhelper.$cfg:"
|
||||
procd_open_instance
|
||||
procd_set_param command /usr/sbin/iptvhelper.sh $cfg
|
||||
config_get_bool aux "$cfg" 'respawn' '0'
|
||||
[ "$aux" = 1 ] && procd_set_param respawn
|
||||
procd_set_param pidfile /var/run/iptvhelper_$cfg.pid
|
||||
procd_close_instance
|
||||
fi
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "iptvhelper"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
logger "iptvhelper: starting"
|
||||
echo "iptvhelper: starting"
|
||||
config_load iptvhelper
|
||||
config_foreach start_instance tvbox
|
||||
if uci -q show firewall >/dev/null; then
|
||||
if ! uci -q get firewall.iptvhelper >/dev/null; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set firewall.iptvhelper=include
|
||||
set firewall.iptvhelper.type='script'
|
||||
set firewall.iptvhelper.path='/etc/firewall.iptvhelper'
|
||||
set firewall.iptvhelper.family='any'
|
||||
set firewall.iptvhelper.reload='1'
|
||||
commit firewall
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
if uci -q show firewall >/dev/null; then
|
||||
if uci -q get firewall.iptvhelper >/dev/null; then
|
||||
uci delete firewall.iptvhelper
|
||||
uci commit firewall
|
||||
fi
|
||||
fi
|
||||
for pid in $(ps | grep -v awk | awk '/iptvhelper.sh/ {print $1}'); do kill -9 $pid; done
|
||||
for pid in $(ps | grep -v awk | awk '/logread -e iptvhelper/ {print $1}'); do kill -9 $pid; done
|
||||
clear_iptv_rules
|
||||
destroy_iptv_ipset
|
||||
logger "iptvhelper: stopped"
|
||||
echo "iptvhelper: stopped"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
logger "iptvhelper: reloading"
|
||||
echo "iptvhelper: reloading"
|
||||
stop
|
||||
start
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright 2019 Shun Li <riverscn@gmail.com>
|
||||
# Licensed to the public under the GNU General Public License v3.
|
||||
|
||||
add_to_set() {
|
||||
local ip=$1
|
||||
local cfg=$2
|
||||
local subnet=$ip/24
|
||||
ping -W1 -c1 $ip &>/dev/null && return
|
||||
if ! ipset -q test iptvhelper_$cfg $subnet; then
|
||||
ipset add iptvhelper_$cfg $subnet
|
||||
echo added $subnet to set iptvhelper_$cfg
|
||||
fi
|
||||
}
|
||||
|
||||
echo $1
|
||||
|
||||
logread -e "iptvhelper\.$1" -f |
|
||||
while read line; do
|
||||
ip=$(echo "$line" | sed -r 's|.*DST=([0-9.]+).*|\1|')
|
||||
echo requested $ip
|
||||
add_to_set $ip $1 &
|
||||
done
|
||||
Reference in new issue
Block a user