up luci-app-eqosplus v1.2.5

This commit is contained in:
Pdboy Sir 2024-03-15 16:52:13 +08:00 committed by GitHub
parent 20558e750f
commit 47d82dd275
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 237 additions and 32 deletions

View File

@ -7,13 +7,18 @@
include $(TOPDIR)/rules.mk
THEME_NAME:=eqosplus
PKG_NAME:=luci-app-$(THEME_NAME)
PKG_LICENSE:=Apache-2.0
LUCI_TITLE:=LuCI support for eqosplus.
LUCI_DESCRIPTION:=LuCI support for Easy eqosplus(Support speed limit based on IP address).
LUCI_DEPENDS:=+bash +tc +kmod-sched-core +kmod-ifb +kmod-sched +iptables-mod-filter +iptables-mod-nat-extra
LUCI_PKGARCH:=all
PKG_VERSION:=1.2.2
PKG_RELEASE:=20230719
PKG_VERSION:=1.2.5
PKG_RELEASE:=20231205
PKG_MAINTAINER:=sirpdboy <herboy2008@gmail.com>
define Package/$(PKG_NAME)/conffiles

View File

@ -3,14 +3,17 @@ module("luci.controller.eqosplus", package.seeall)
function index()
if not nixio.fs.access("/etc/config/eqosplus") then return end
entry({"admin", "control"}, firstchild(), "Control", 44).dependent = false
entry({"admin", "control", "eqosplus"}, cbi("eqosplus"), _("Eqosplus"), 10).dependent =true
local e = entry({"admin", "control", "eqosplus"}, cbi("eqosplus"), _("Eqosplus"), 10)
e.dependent=false
e.acl_depends = { "luci-app-eqosplus" }
entry({"admin", "control", "eqosplus", "status"}, call("act_status")).leaf = true
end
function act_status()
local sys = require "luci.sys"
local e = {}
e.status = sys.call(" tc qdisc show | grep 'default' >/dev/null ") == 0
e.status = sys.call(" busybox ps -w | grep eqosplus | grep -v grep >/dev/null ") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -34,6 +34,9 @@ t.template = "cbi/tblsection"
t.anonymous = true
t.addremove = true
comment = t:option(Value, "comment", translate("Comment"))
comment.size = 8
e = t:option(Flag, "enable", translate("Enabled"))
e.rmempty = false
e.size = 4
@ -99,7 +102,5 @@ week:value('1,2,3,4,5',translate("Workday"))
week:value('6,7',translate("Rest Day"))
week.default='0'
week.size = 6
comment = t:option(Value, "comment", translate("Comment"))
comment.size = 8
return a

View File

@ -0,0 +1,61 @@
msgid "Eqosplus"
msgstr "定时限速"
msgid "Network speed limit"
msgstr "定时网速限制"
msgid "Running state"
msgstr "运行状态"
msgid "Not running"
msgstr "未运行"
msgid "Running"
msgstr "已运行"
msgid "Users can limit the network speed for uploading/downloading through MAC, IP.The speed unit is MB/second."
msgstr "可以通过MACIP限制用户上传/下载的网速。速度单位为<font color=\"red\"><b> MB/秒 </b></font>。"
msgid "MAC/IP"
msgstr "MAC/IP"
msgid "Downloads"
msgstr "下载速度"
msgid "Uploads"
msgstr "上传速度"
msgid "Comment"
msgstr "备注"
msgid "Upload bandwidth(Mbit/s)"
msgstr "上传总带宽(Mbit/s)"
msgid "Download bandwidth(Mbit/s)"
msgstr "下载总带宽(Mbit/s)"
msgid "Start control time"
msgstr "起控时间"
msgid "Stop control time"
msgstr "停控时间"
msgid "Week Day(1~7)"
msgstr "星期(1~7)"
msgid "Suggested feedback:"
msgstr "建议反馈:"
msgid "Set the interface used for restriction, use pppoe-wan for dialing, use WAN hardware interface for DHCP mode (such as eth1), and use br-lan for bypass mode"
msgstr "设定用来限制网络速度的接口,拨号使用pppoe-wan,DHCP模式使用WAN口的硬件接口(如:eth1),通用使用br-lan接口"
msgid "Rest Day"
msgstr "休息日"
msgid "Workday"
msgstr "工作日"
msgid "Automatic settings"
msgstr "自动设置"

View File

@ -0,0 +1,61 @@
msgid "Eqosplus"
msgstr "定时限速"
msgid "Network speed limit"
msgstr "定时网速限制"
msgid "Running state"
msgstr "运行状态"
msgid "Not running"
msgstr "未运行"
msgid "Running"
msgstr "已运行"
msgid "Users can limit the network speed for uploading/downloading through MAC, IP.The speed unit is MB/second."
msgstr "可以通过MACIP限制用户上传/下载的网速。速度单位为<font color=\"red\"><b> MB/秒 </b></font>。"
msgid "MAC/IP"
msgstr "MAC/IP"
msgid "Downloads"
msgstr "下载速度"
msgid "Uploads"
msgstr "上传速度"
msgid "Comment"
msgstr "备注"
msgid "Upload bandwidth(Mbit/s)"
msgstr "上传总带宽(Mbit/s)"
msgid "Download bandwidth(Mbit/s)"
msgstr "下载总带宽(Mbit/s)"
msgid "Start control time"
msgstr "起控时间"
msgid "Stop control time"
msgstr "停控时间"
msgid "Week Day(1~7)"
msgstr "星期(1~7)"
msgid "Suggested feedback:"
msgstr "建议反馈:"
msgid "Set the interface used for restriction, use pppoe-wan for dialing, use WAN hardware interface for DHCP mode (such as eth1), and use br-lan for bypass mode"
msgstr "设定用来限制网络速度的接口,拨号使用pppoe-wan,DHCP模式使用WAN口的硬件接口(如:eth1),通用使用br-lan接口"
msgid "Rest Day"
msgstr "休息日"
msgid "Workday"
msgstr "工作日"
msgid "Automatic settings"
msgstr "自动设置"

View File

@ -7,7 +7,6 @@ config eqosplus
config device
option timestart '00:00'
option week '0'
option download '1'
option timeend '23:55'
@ -19,7 +18,6 @@ config device
option mac '192.168.10.10/24'
option timestart '00:00'
option timeend '00:00'
option week '0'
option download '0.1'
option upload '0.1'

View File

@ -12,7 +12,7 @@ CR=/etc/crontabs/root
start_instance() {
procd_open_instance
procd_set_param command /usr/sbin/eqosplusctrl
procd_set_param command /usr/bin/eqosplusctrl
procd_set_param respawn
procd_set_param stderr 1
procd_close_instance

View File

@ -1,5 +1,5 @@
#!/bin/sh
chmod +x /etc/init.d/eqosplus /usr/bin/eqosplus
chmod +x /etc/init.d/eqosplus /usr/bin/eqosplus*
uci -q batch <<-EOF >/dev/null
delete ucitrack.@eqosplus[-1]
add ucitrack eqosplus

View File

@ -10,9 +10,13 @@ IDLIST="/var/$NAME.idlist"
LOCK="/var/lock/$NAME.lock"
TMPID="/var/$NAME.tmpid"
if [ x$(uci get $NAME.@$NAME[0].ifname) = 'x1' ] ;then
dev=`ifconfig | grep "Point-to-Point" | cut -d " " -f1`
# [ ! ${dev} ] && dev=` uci -q get network.wan.ifname ` || dev=` uci -q get network.wan.device `
# dev=`ifconfig | grep "Point-to-Point" | cut -d " " -f1`
ifname=$(uci -q get network.lan.ifname )
[ "x$ifname" = "x" ] && ifname="device" || ifname="ifname"
[ ! ${dev} ] && dev=` uci -q get network.wan.$ifname `
[ ! ${dev} ] && dev=br-lan
dev=br-lan
#ALL_DEVICES=$(echo $(ifconfig | grep 'Point-to-Point' | cut -d ' ' -f1) $(uci -q get network.wan.$ifname) $(ports_for_device $(uci -q get network.wan.device)) | tr ' ' '\n' | sort -u)
else
dev=`uci -q get $NAME.@$NAME[0].ifname `
fi
@ -20,32 +24,27 @@ fi
bin_iptables=$(which iptables)
bin_ip6tables=$(which ip6tables)
bin_tc=$(which tc)
bin_ebtables=$(which ebtables)
bin_ip=$(which ip)
# Uncomment this to debug commands
# DEBUG=1
DEBUG=0
## End
# Debug functions - echo + run
dbg_iptables() {
[ "${DEBUG:-0}" -eq 0 ] || echo "D: iptables $@"
$bin_iptables "$@"
[ "${DEBUG:-0}" -eq 0 ] || echo "DEBUG: iptables $*"
$bin_iptables "$*"
}
dbg_ip6tables() {
[ "${DEBUG:-0}" -eq 0 ] || echo "D: ip6tables $@"
$bin_ip6tables "$@"
[ "${DEBUG:-0}" -eq 0 ] || echo "DEBUG: ip6tables $*"
$bin_ip6tables "$*"
}
dbg_tc() {
[ "${DEBUG:-0}" -eq 0 ] || echo "D: tc $@"
$bin_tc "$@"
}
dbg_ebtables() {
[ "${DEBUG:-0}" -eq 0 ] || echo "D: ebtables $@"
$bin_ebtables "$@"
[ "${DEBUG:-0}" -eq 0 ] || echo "DEBUG: tc $*"
$bin_tc $*
}
dbg_ip() {
[ "${DEBUG:-0}" -eq 0 ] || echo "D: ip $@"
$bin_ip "$@"
[ "${DEBUG:-0}" -eq 0 ] || echo "DEBUG: ip $*"
$bin_ip $*
}
is_macaddr() {
ret=1
@ -60,17 +59,17 @@ iptables="dbg_iptables"
ip6tables="dbg_ip6tables"
tc="dbg_tc"
ip="dbg_ip"
ebt="dbg_ebtables"
ipt=$iptables
ipt6=$ip6tables
ipt(){
$iptables $@
$ip6tables $@
$iptables $*
$ip6tables $*
}
iptm(){
$iptables "-t mangle $@"
$ip6tables "-t mangle $@"
$iptables "-t mangle $*"
$ip6tables "-t mangle $*"
}
stop_qos() {
@ -106,6 +105,7 @@ init_qosplus() {
}
del_id() {
id=`expr $1 + 11 `
[ "${DEBUG:-0}" -eq 0 ] || echo "D: del_id $@" "--$id --$mac"
$tc qd del dev ${dev} parent 1:$id 2>/dev/null
$tc qd del dev ${dev}_ifb parent 1:$id 2>/dev/null
@ -136,6 +136,7 @@ add_mac() {
M0=$(echo $mac | cut -d : -f 1)$(echo $mac | cut -d : -f 2)
M1=$(echo $mac | cut -d : -f 3)$(echo $mac | cut -d : -f 4)
M2=$(echo $mac | cut -d : -f 5)$(echo $mac | cut -d : -f 6)
[ "${DEBUG:-0}" -eq 0 ] || echo "D: add_mac $@ --id:$id --mac:$mac M012--$M0-$M1-$M2"
if [ "$UL" -gt 0 ]; then
$tc class add dev ${dev}_ifb parent 1:1 classid 1:$id htb rate "$UL"kbit ceil "$UL"kbit prio $id quantum 1500
$tc qdisc add dev ${dev}_ifb parent 1:"$id" handle "$id": sfq perturb 1
@ -156,6 +157,7 @@ add_mac() {
add_ip() {
id=`expr $1 + 11 `
# id=printf "%x\n" "$1"
[ "${DEBUG:-0}" -eq 0 ] || echo "D: add_ip $@ --$id --$mac"
Z=`echo $mac |awk -F '[/]' '{print $2}' `
[ -n "$Z" ] && mac=`echo $mac |awk -F '[/]' '{print $1}' `|| Z=32
if [ "$UL" -gt 0 ]; then
@ -199,7 +201,7 @@ check_list() {
case "$crrun" in
"stop")
stop_qos
echo '' >$IDLIST
touch $IDLIST
;;
"start")
idlist=`uci show $NAME | grep "enable='1'" | grep "device" | grep -oE '\[.*?\]' | grep -o '[0-9]' | sed -e 's/^/!/g' -e 's/$/!/g' > $IDLIST ;cat $IDLIST | sed -e 's/!//g' `

View File

@ -0,0 +1,63 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
# Copyright 2022-2023 sirpdboy <herboy2008@gmail.com>
NAME=eqosplus
IDLIST="/var/$NAME.idlist"
TMPID="/var/$NAME.tmpid"
idlist=`uci show $NAME | grep "enable='1'" | grep "device" | grep -oE '\[.*?\]' | grep -o '[0-9]' `
check_list() {
i=$1
checki='0'
start_time=$(uci -q get $NAME.@device[$i].timestart 2>/dev/null)
end_time=$(uci -q get $NAME.@device[$i].timeend 2>/dev/null)
wweek=`uci -q get $NAME.@device[$i].week `
current_time=$(date +%H:%M)
current_weekday=$(date +%u)
for ww in `echo $wweek | sed 's/,/ /g' `; do
if [ $current_weekday = $ww ] || [ 'x0' = x$ww ] ;then
[ "$start_time" = "$end_time" ] && checki='1' || {
if [ "$start_time" \< "$end_time" ]; then
if [ "$current_time" \> "$start_time" ] && [ "$current_time" \< "$end_time" ] ; then
checki='1'
fi
else
if [ "$start_time" \> "$end_time" ] ; then
if [ "$current_time" \< "$start_time" ] && [ "$current_time" \> "$end_time" ] ; then
checki='1'
fi
fi
fi
}
fi
done
return
}
idlistusr(){
checki='0'
[ -s $IDLIST ] || touch $IDLIST
for list in $idlist ;do
check_list $list
if [ $checki == '1' ] ; then
[ `cat $IDLIST 2>/dev/null | grep "!${list}!" | wc -l ` -gt 0 ] || {
eqosplus add $list
echo "!${list}!" >> $IDLIST ; cat $IDLIST | sort | uniq > $TMPID ;cat $TMPID >$IDLIST ;rm -rf $TMPID
}
else
[ `cat $IDLIST 2>/dev/null | grep "!${list}!" | wc -l ` -gt 0 ] && {
eqosplus del $list
sed -i "/!$list!/d" $IDLIST >/dev/null 2>&1
}
fi
done
}
while :;do
sleep 30
idlistusr
sleep 30
done

View File

@ -0,0 +1,11 @@
{
"luci-app-eqosplus": {
"description": "Grant UCI access for luci-app-eqosplus",
"read": {
"uci": [ "eqosplus" ]
},
"write": {
"uci": [ "eqosplus" ]
}
}
}