mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-10 11:09:57 +08:00
baidupcs-web/iptvhelper: move to packages
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
parent
c741baa9e8
commit
159dcd1c96
@ -1,62 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2019 OpenWrt.org
|
||||
#
|
||||
# KFERMercer <KFER.Mercer@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=baidupcs-web
|
||||
PKG_VERSION:=3.7.3
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/Erope/BaiduPCS-Go.git
|
||||
PKG_SOURCE_VERSION:=b2f5436699d1acd6dc3d90f2066bf1e36c373cd5
|
||||
PKG_MIRROR_HASH:=815410a7c348c82eea638f6d34fd4dfab59286e16b172c434ff0008de24676dc
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_DEPENDS:=golang/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
GO_PKG:=github.com/Erope/BaiduPCS-Go
|
||||
GO_PKG_LDFLAGS:=-s -w
|
||||
GO_PKG_LDFLAGS_X:=main.Version=v$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=BaiduPCS-Web is a web controller for BaiduPCS-Go
|
||||
URL:=https://github.com/Erope/BaiduPCS-Go
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS)
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
BaiduPCS-Web is a web controller for BaiduPCS-Go
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
( \
|
||||
GOOS=$$$$(go env GOOS) GOARCH=$$$$(go env GOARCH) go get -v github.com/GeertJohan/go.rice/rice/... ; \
|
||||
cd $(PKG_BUILD_DIR)/internal/pcsweb ; \
|
||||
"$$$$(go env GOPATH)/bin/rice" embed-go ; \
|
||||
$(call GoPackage/Build/Compile) ; \
|
||||
)
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/BaiduPCS-Go $(1)/usr/bin/$(PKG_NAME)
|
||||
endef
|
||||
|
||||
$(eval $(call GoBinPackage,$(PKG_NAME)))
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
@ -1,21 +0,0 @@
|
||||
--- a/go.sum
|
||||
+++ b/go.sum
|
||||
@@ -45,6 +45,7 @@ github.com/daaku/go.zipexe v1.0.1 h1:wV4zMsDOI2SZ2m7Tdz1Ps96Zrx+TzaK15VbUaGozw0M
|
||||
github.com/daaku/go.zipexe v1.0.1/go.mod h1:5xWogtqlYnfBXkSB1o9xysukNP9GTvaNkqzUZbt3Bw8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
+github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
|
||||
--- a/pcsutil/jwted25519/jwted25519.go
|
||||
+++ b/pcsutil/jwted25519/jwted25519.go
|
||||
@@ -2,7 +2,7 @@ package jwted25519
|
||||
|
||||
import (
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
- "golang.org/x/crypto/ed25519"
|
||||
+ "crypto/ed25519"
|
||||
"unsafe"
|
||||
)
|
||||
|
@ -1,42 +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/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
|
Loading…
x
Reference in New Issue
Block a user