├── EQoS.png ├── Makefile ├── README.md └── files ├── eqos-cbi.lua ├── eqos-controller.lua ├── eqos.config ├── eqos.hotplug ├── eqos.init ├── eqos.sh ├── po └── zh-cn │ └── eqos.po └── uci-defaults-eqos /EQoS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TorBoxCode/luci-app-eqos/59ab72e443528337d96149a6edfd3936c58b964a/EQoS.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2006-2017 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=eqos 11 | PKG_VERSION:=1.0.0 12 | PKG_RELEASE:=1 13 | LUCI_DIR:=/usr/lib/lua/luci 14 | 15 | PKG_MAINTAINER:=Jianhui Zhao 16 | 17 | include $(INCLUDE_DIR)/package.mk 18 | 19 | define Package/eqos 20 | SECTION:=net 21 | CATEGORY:=Network 22 | DEPENDS:=+tc +kmod-sched-core +kmod-ifb 23 | TITLE:=Easy QoS(Support speed limit based on IP address) 24 | PKGARCH:=all 25 | endef 26 | 27 | 28 | define Package/luci-app-eqos 29 | SECTION:=luci 30 | CATEGORY:=LuCI 31 | TITLE:=EQOS - LuCI interface 32 | PKGARCH:=all 33 | DEPENDS:=+luci-base +eqos 34 | SUBMENU:=3. Applications 35 | endef 36 | 37 | define Package/luci-app-eqos/description 38 | Luci interface for the eqos. 39 | endef 40 | 41 | define Package/luci-i18n-eqos-zh-cn 42 | SECTION:=luci 43 | CATEGORY:=LuCI 44 | TITLE:=luci-app-eqos - zh-cn translation 45 | HIDDEN:=1 46 | DEPENDS:=luci-app-eqos 47 | DEFAULT:=LUCI_LANG_zh-cn 48 | PKGARCH:=all 49 | endef 50 | 51 | define Build/Prepare 52 | endef 53 | 54 | define Build/Configure 55 | endef 56 | 57 | define Build/Compile 58 | endef 59 | 60 | define Package/eqos/install 61 | $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d $(1)/etc/hotplug.d/iface 62 | $(INSTALL_BIN) ./files/eqos.sh $(1)/usr/sbin/eqos 63 | $(INSTALL_BIN) ./files/eqos.init $(1)/etc/init.d/eqos 64 | $(INSTALL_BIN) ./files/eqos.hotplug $(1)/etc/hotplug.d/iface/10-eqos 65 | $(INSTALL_CONF) ./files/eqos.config $(1)/etc/config/eqos 66 | endef 67 | 68 | define Package/luci-app-eqos/install 69 | $(INSTALL_DIR) $(1)$(LUCI_DIR)/controller $(1)$(LUCI_DIR)/model/cbi $(1)$(LUCI_DIR)/i18n $(1)/etc/uci-defaults 70 | $(INSTALL_DATA) ./files/eqos-controller.lua $(1)$(LUCI_DIR)/controller/eqos.lua 71 | $(INSTALL_DATA) ./files/eqos-cbi.lua $(1)$(LUCI_DIR)/model/cbi/eqos.lua 72 | $(INSTALL_BIN) ./files/uci-defaults-eqos $(1)/etc/uci-defaults/luci-eqos 73 | endef 74 | 75 | define Package/luci-app-eqos/postinst 76 | #!/bin/sh 77 | which uci > /dev/null || exit 0 78 | uci -q get ucitrack.@eqos[0] > /dev/null || { 79 | uci add ucitrack eqos > /dev/null 80 | uci set ucitrack.@eqos[0].init=eqos 81 | uci commit 82 | } 83 | endef 84 | 85 | define Package/luci-app-eqos/postrm 86 | #!/bin/sh 87 | which uci > /dev/null || exit 0 88 | uci -q get ucitrack.@eqos[0] > /dev/null && { 89 | uci delete ucitrack.@eqos[0] 90 | uci commit 91 | } 92 | endef 93 | 94 | define Package/luci-i18n-eqos-zh-cn/install 95 | $(INSTALL_DIR) $(1)$(LUCI_DIR)/i18n 96 | po2lmo ./files/po/zh-cn/eqos.po $(1)$(LUCI_DIR)/i18n/eqos.zh-cn.lmo 97 | endef 98 | 99 | $(eval $(call BuildPackage,eqos)) 100 | $(eval $(call BuildPackage,luci-app-eqos)) 101 | $(eval $(call BuildPackage,luci-i18n-eqos-zh-cn)) 102 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # luci-app-eqos 2 | 基于EQoS修改。 3 | 4 | ![](./EQoS.png) 5 | -------------------------------------------------------------------------------- /files/eqos-cbi.lua: -------------------------------------------------------------------------------- 1 | local ipc = require "luci.ip" 2 | 3 | local m = Map("eqos", translate("Network speed control service")) 4 | 5 | local s = m:section(TypedSection, "eqos", "") 6 | s.anonymous = true 7 | 8 | local e = s:option(Flag, "enabled", translate("Enable")) 9 | e.rmempty = false 10 | 11 | local dl = s:option(Value, "download", translate("Download speed (Kbit/s)"), translate("Total bandwidth")) 12 | dl.datatype = "and(uinteger,min(1))" 13 | 14 | local ul = s:option(Value, "upload", translate("Upload speed (Kbit/s)"), translate("Total bandwidth")) 15 | ul.datatype = "and(uinteger,min(1))" 16 | 17 | s = m:section(TypedSection, "device", translate("Speed limit based on IP address")) 18 | s.template = "cbi/tblsection" 19 | s.anonymous = true 20 | s.addremove = true 21 | s.sortable = true 22 | 23 | local ip = s:option(Value, "ip", translate("IP address")) 24 | 25 | ipc.neighbors({family = 4, dev = "br-lan"}, function(n) 26 | if n.mac and n.dest then 27 | ip:value(n.dest:string(), "%s (%s)" %{ n.dest:string(), n.mac }) 28 | end 29 | end) 30 | 31 | dl = s:option(Value, "download", translate("Download speed (Kbit/s)")) 32 | dl.datatype = "and(uinteger,min(1))" 33 | 34 | ul = s:option(Value, "upload", translate("Upload speed (Kbit/s)")) 35 | ul.datatype = "and(uinteger,min(1))" 36 | 37 | comment = s:option(Value, "comment", translate("Comment")) 38 | 39 | return m 40 | -------------------------------------------------------------------------------- /files/eqos-controller.lua: -------------------------------------------------------------------------------- 1 | module("luci.controller.eqos", package.seeall) 2 | 3 | function index() 4 | if not nixio.fs.access("/etc/config/eqos") then 5 | return 6 | end 7 | 8 | local page 9 | 10 | page = entry({"admin", "network", "eqos"}, cbi("eqos"), "EQoS") 11 | page.dependent = true 12 | end 13 | -------------------------------------------------------------------------------- /files/eqos.config: -------------------------------------------------------------------------------- 1 | # The bandwidth unit is Kbit/s 2 | config eqos 3 | option enabled 0 4 | option download 100 5 | option upload 20 6 | 7 | # Limiting the bandwidth of a single Device 8 | #config device 9 | # option ip "192.168.1.100" 10 | # option download 10 11 | # option upload 5 12 | # option comment "test" 13 | -------------------------------------------------------------------------------- /files/eqos.hotplug: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ "$ACTION" = "ifup" ] || exit 0 3 | [ "$INTERFACE" = "lan" ] || exit 0 4 | 5 | /etc/init.d/eqos start 6 | -------------------------------------------------------------------------------- /files/eqos.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006 OpenWrt.org 3 | 4 | START=50 5 | 6 | parse_device() { 7 | local cfg="$1" ip download upload 8 | 9 | config_get ip "$cfg" ip 10 | config_get download "$cfg" download 11 | config_get upload "$cfg" upload 12 | 13 | eqos add $ip $download $upload 14 | } 15 | 16 | eqos_start() { 17 | local cfg="$1" enabled download upload 18 | 19 | config_get_bool enabled "$cfg" enabled 0 20 | [ $enabled -eq 0 ] && return 0 21 | 22 | config_get download "$cfg" download 23 | config_get upload "$cfg" upload 24 | 25 | eqos start $download $upload 26 | 27 | config_foreach parse_device device 28 | } 29 | 30 | start() { 31 | eqos stop 32 | 33 | config_load eqos 34 | config_foreach eqos_start eqos 35 | } 36 | 37 | stop() { 38 | eqos stop 39 | } -------------------------------------------------------------------------------- /files/eqos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | dev=br-lan 4 | 5 | stop_qos() { 6 | tc qdisc del dev $dev root 2>/dev/null 7 | tc qdisc del dev $dev ingress 2>/dev/null 8 | tc qdisc del dev ${dev}-ifb root 2>/dev/null 9 | ip link del dev ${dev}-ifb 2>/dev/null 10 | } 11 | 12 | start_qos() { 13 | local dl=$1 14 | local up=$2 15 | 16 | tc qdisc add dev $dev root handle 1: htb 17 | tc class add dev $dev parent 1: classid 1:1 htb rate ${dl}kbit 18 | 19 | ip link add dev ${dev}-ifb name ${dev}-ifb type ifb 20 | ip link set dev ${dev}-ifb up 21 | 22 | tc qdisc add dev ${dev}-ifb root handle 1: htb 23 | tc class add dev ${dev}-ifb parent 1: classid 1:1 htb rate ${up}kbit 24 | 25 | tc qdisc add dev $dev ingress 26 | tc filter add dev $dev parent ffff: protocol ip u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ${dev}-ifb 27 | } 28 | 29 | case "$1" in 30 | "stop") 31 | stop_qos 32 | ;; 33 | "start") 34 | stop_qos 35 | start_qos $2 $3 36 | ;; 37 | "add") 38 | ip="$2" 39 | dl="$3" 40 | up="$4" 41 | 42 | cnt=$(tc class show dev $dev | wc -l) 43 | 44 | tc class add dev $dev parent 1:1 classid 1:1$cnt htb rate ${dl}kbit ceil ${dl}kbit 45 | tc filter add dev $dev parent 1:0 protocol ip u32 match ip dst $ip flowid 1:1$cnt 46 | 47 | tc class add dev ${dev}-ifb parent 1:1 classid 1:1$cnt htb rate ${up}kbit ceil ${up}kbit 48 | tc filter add dev ${dev}-ifb parent 1:0 protocol ip u32 match ip src $ip flowid 1:1$cnt 49 | ;; 50 | *) 51 | echo "Usage: $0 [options]" 52 | echo "Commands:" 53 | echo " start dl_rate up_rate #Total bandwidth (Kbit/s)" 54 | echo " stop" 55 | echo " add ip dl_rate up_rate #Limiting the bandwidth of a single IP (Kbit/s)" 56 | echo "Example:" 57 | echo " $0 start 30 20 # Total bandwidth: down 30Kbit/s up 20Kbit/s" 58 | echo " $0 add 192.168.22.12 10 2 # down 10Kbit/s up 2Kbit/s" 59 | ;; 60 | esac 61 | -------------------------------------------------------------------------------- /files/po/zh-cn/eqos.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: LuCi Chinese Translation\n" 4 | "Report-Msgid-Bugs-To: \n" 5 | "Language: zh_CN\n" 6 | "MIME-Version: 1.0\n" 7 | "Content-Type: text/plain; charset=UTF-8\n" 8 | "Content-Transfer-Encoding: 8bit\n" 9 | "Plural-Forms: nplurals=1; plural=0;\n" 10 | "X-Generator: Pootle 2.0.6\n" 11 | 12 | 13 | msgid "EQoS" 14 | msgstr "网速控制" 15 | 16 | msgid "eqos" 17 | msgstr "网速控制" 18 | 19 | msgid "Comment" 20 | msgstr "备注" 21 | 22 | msgid "Download speed (Kbit/s)" 23 | msgstr "下载速度 (Kbit/s)" 24 | 25 | msgid "Enable" 26 | msgstr "开启" 27 | 28 | msgid "QoS" 29 | msgstr "QoS" 30 | 31 | msgid "Network speed control service" 32 | msgstr "网速控制" 33 | 34 | msgid "Upload speed (Kbit/s)" 35 | msgstr "上传速度 (Kbit/s)" 36 | 37 | msgid "Speed limit based on IP address" 38 | msgstr "IP限速规则" 39 | 40 | msgid "Total bandwidth" 41 | msgstr "总带宽" 42 | 43 | msgid "Flow control setting" 44 | msgstr "流控设置" 45 | -------------------------------------------------------------------------------- /files/uci-defaults-eqos: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | uci -q get ucitrack.@eqos[0] > /dev/null || { 4 | uci add ucitrack eqos > /dev/null 5 | uci set ucitrack.@eqos[0].init=eqos 6 | uci commit 7 | } 8 | 9 | exit 0 10 | --------------------------------------------------------------------------------