mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-12 18:41:51 +00:00
Add quota support and small others changes
This commit is contained in:
parent
6fe07f493b
commit
b549503be7
23 changed files with 397 additions and 59 deletions
|
@ -27,7 +27,7 @@ validate_section() {
|
|||
'proto:string' \
|
||||
'bind:string' \
|
||||
'bindport:port' \
|
||||
'mtu:uinteger:1500' \
|
||||
'mtu:uinteger:1450' \
|
||||
'mtuauto:bool:0' \
|
||||
'chacha20:bool:0' \
|
||||
'dev:string'
|
||||
|
@ -84,4 +84,5 @@ start_service() {
|
|||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger glorytun network
|
||||
procd_add_raw_trigger "interface.*" 2000 /etc/init.d/$PROG_NAME reload
|
||||
}
|
||||
|
|
16
luci-app-omr-quota/Makefile
Normal file
16
luci-app-omr-quota/Makefile
Normal file
|
@ -0,0 +1,16 @@
|
|||
#
|
||||
# Copyright (C) 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=Quota configuration module
|
||||
LUCI_DEPENDS:=+omr-quota
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
|
||||
include ../luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
15
luci-app-omr-quota/luasrc/controller/quota.lua
Normal file
15
luci-app-omr-quota/luasrc/controller/quota.lua
Normal file
|
@ -0,0 +1,15 @@
|
|||
-- Copyright 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
module("luci.controller.quota", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/omr-quota") then
|
||||
return
|
||||
end
|
||||
|
||||
local page
|
||||
|
||||
page = entry({"admin", "network", "quota"}, cbi("quota/quota"), _("Quota"))
|
||||
page.dependent = true
|
||||
end
|
38
luci-app-omr-quota/luasrc/model/cbi/quota/quota.lua
Normal file
38
luci-app-omr-quota/luasrc/model/cbi/quota/quota.lua
Normal file
|
@ -0,0 +1,38 @@
|
|||
-- Copyright 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local fs = require "nixio.fs"
|
||||
local net = require "luci.model.network".init()
|
||||
local sys = require "luci.sys"
|
||||
local ifaces = sys.net:devices()
|
||||
|
||||
m = Map("omr-quota", translate("Quota"), translate("Set quota, when quota is reached interface state is set to down"))
|
||||
|
||||
s = m:section(TypedSection, "interface", translate("Interfaces"))
|
||||
s.addremove = true
|
||||
s.anonymous = false
|
||||
|
||||
e = s:option(Flag, "enabled", translate("Enable"))
|
||||
e.rmempty = false
|
||||
|
||||
intf = s:option(ListValue, "interface", translate("Interface name"))
|
||||
for _, iface in ipairs(ifaces) do
|
||||
if not (iface == "lo" or iface:match("^ifb.*")) then
|
||||
intf:value(iface)
|
||||
end
|
||||
end
|
||||
intf.rmempty = false
|
||||
|
||||
tx = s:option(Value, "txquota", translate("TX quota (kbit)"))
|
||||
tx.datatype = "uinteger"
|
||||
|
||||
rx = s:option(Value, "rxquota", translate("RX quota (kbit)"))
|
||||
rx.datatype = "uinteger"
|
||||
|
||||
tt = s:option(Value, "ttquota", translate("TX+RX quota (kbit)"))
|
||||
tt.datatype = "uinteger"
|
||||
|
||||
itv = s:option(Value, "interval", translate("Interval between check (s)"))
|
||||
itv.datatype = "uinteger"
|
||||
|
||||
return m
|
|
@ -1,6 +1,6 @@
|
|||
local m, s, o
|
||||
|
||||
m = Map("omr-tracker", translate("OMR-Tracker"), translate("OMR-Tracker detect when a connection is down"))
|
||||
m = Map("omr-tracker", translate("OMR-Tracker"), translate("OMR-Tracker detect when a connection is down and execute needed scripts"))
|
||||
|
||||
s = m:section(TypedSection, "defaults", translate("Defaults Settings"))
|
||||
s.anonymous = true
|
||||
|
|
|
@ -152,6 +152,9 @@ function index()
|
|||
|
||||
page = entry({"admin", "network", "diag_traceroute6"}, post("diag_traceroute6"), nil)
|
||||
page.leaf = true
|
||||
|
||||
page = entry({"admin", "network", "diag_speedtest"}, post("diag_speedtest"), nil)
|
||||
page.leaf = true
|
||||
-- end
|
||||
end
|
||||
|
||||
|
@ -427,3 +430,11 @@ end
|
|||
function diag_traceroute6(addr)
|
||||
diag_command("traceroute6 -q 1 -w 2 -n %q 2>&1", addr)
|
||||
end
|
||||
|
||||
function diag_speedtest(addr)
|
||||
if addr then
|
||||
diag_command("speedtestc --server %q 2>&1", addr)
|
||||
else
|
||||
diag_command("speedtestc 2>&1", "speedtest.net")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -262,8 +262,8 @@ s = m:section(TypedSection, "host", translate("Static Leases"),
|
|||
"DHCP clients. They are also required for non-dynamic interface configurations where " ..
|
||||
"only hosts with a corresponding lease are served.") .. "<br />" ..
|
||||
translate("Use the <em>Add</em> Button to add a new lease entry. The <em>MAC-Address</em> " ..
|
||||
"indentifies the host, the <em>IPv4-Address</em> specifies to the fixed address to " ..
|
||||
"use and the <em>Hostname</em> is assigned as symbolic name to the requesting host. " ..
|
||||
"indentifies the host, the <em>IPv4-Address</em> specifies the fixed address to " ..
|
||||
"use, and the <em>Hostname</em> is assigned as a symbolic name to the requesting host. " ..
|
||||
"The optional <em>Lease time</em> can be used to set non-standard host-specific " ..
|
||||
"lease time, e.g. 12h, 3d or infinite."))
|
||||
|
||||
|
@ -295,6 +295,19 @@ ip.datatype = "or(ip4addr,'ignore')"
|
|||
time = s:option(Value, "leasetime", translate("Lease time"))
|
||||
time.rmempty = true
|
||||
|
||||
duid = s:option(Value, "duid", translate("<abbr title=\"The DHCP Unique Identifier\">DUID</abbr>"))
|
||||
duid.datatype = "and(rangelength(20,36),hexstring)"
|
||||
fp = io.open("/var/hosts/odhcpd")
|
||||
if fp then
|
||||
for line in fp:lines() do
|
||||
local net_val, duid_val = string.match(line, "# (%S+)%s+(%S+)")
|
||||
if duid_val then
|
||||
duid:value(duid_val, duid_val)
|
||||
end
|
||||
end
|
||||
fp:close()
|
||||
end
|
||||
|
||||
hostid = s:option(Value, "hostid", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Suffix (hex)"))
|
||||
|
||||
ipc.neighbors({ family = 4 }, function(n)
|
||||
|
|
|
@ -160,7 +160,6 @@ if has_firewall then
|
|||
s:tab("firewall", translate("Firewall Settings"))
|
||||
end
|
||||
|
||||
|
||||
st = s:taboption("general", DummyValue, "__status", translate("Status"))
|
||||
|
||||
local function set_status()
|
||||
|
@ -225,7 +224,7 @@ auto.default = (net:proto() == "none") and auto.disabled or auto.enabled
|
|||
|
||||
-- Add MPTCP
|
||||
if fs.access("/proc/sys/net/mptcp") then
|
||||
mptcp = s:taboption("advanced", ListValue, "multipath", translate("Multipath TCP"))
|
||||
mptcp = s:taboption("advanced", ListValue, "multipath", translate("Multipath TCP"), translate("One interface must be set as master"))
|
||||
mptcp:value("on", translate("enabled"))
|
||||
mptcp:value("off", translate("disabled"))
|
||||
mptcp:value("master", translate("master"))
|
||||
|
@ -364,7 +363,6 @@ if has_firewall then
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
function p.write() end
|
||||
function p.remove() end
|
||||
function p.validate(self, value, section)
|
||||
|
|
|
@ -228,6 +228,10 @@ if hwtype == "mac80211" then
|
|||
s:taboption("advanced", Value, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes."))
|
||||
end
|
||||
|
||||
legacyrates = s:taboption("advanced", Flag, "legacy_rates", translate("802.11b rates"))
|
||||
legacyrates.rmempty = false
|
||||
legacyrates.default = "1"
|
||||
|
||||
s:taboption("advanced", Value, "distance", translate("Distance Optimization"),
|
||||
translate("Distance to farthest network member in meters."))
|
||||
|
||||
|
@ -405,15 +409,31 @@ s:tab("encryption", translate("Wireless Security"))
|
|||
s:tab("macfilter", translate("MAC-Filter"))
|
||||
s:tab("advanced", translate("Advanced Settings"))
|
||||
|
||||
ssid = s:taboption("general", Value, "ssid", translate("<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
|
||||
ssid.datatype = "maxlength(32)"
|
||||
|
||||
mode = s:taboption("general", ListValue, "mode", translate("Mode"))
|
||||
mode.override_values = true
|
||||
mode:value("ap", translate("Access Point"))
|
||||
mode:value("sta", translate("Client"))
|
||||
mode:value("adhoc", translate("Ad-Hoc"))
|
||||
|
||||
meshid = s:taboption("general", Value, "mesh_id", translate("Mesh Id"))
|
||||
meshid:depends({mode="mesh"})
|
||||
|
||||
meshfwd = s:taboption("advanced", Flag, "mesh_fwding", translate("internal forwarding of Mesh-peers"))
|
||||
meshfwd.rmempty = false
|
||||
meshfwd.default = "1"
|
||||
meshfwd:depends({mode="mesh"})
|
||||
|
||||
ssid = s:taboption("general", Value, "ssid", translate("<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
|
||||
ssid.datatype = "maxlength(32)"
|
||||
ssid:depends({mode="ap"})
|
||||
ssid:depends({mode="sta"})
|
||||
ssid:depends({mode="adhoc"})
|
||||
ssid:depends({mode="ahdemo"})
|
||||
ssid:depends({mode="monitor"})
|
||||
ssid:depends({mode="ap-wds"})
|
||||
ssid:depends({mode="sta-wds"})
|
||||
ssid:depends({mode="wds"})
|
||||
|
||||
bssid = s:taboption("general", Value, "bssid", translate("<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"))
|
||||
|
||||
network = s:taboption("general", Value, "network", translate("Network"),
|
||||
|
@ -937,21 +957,6 @@ if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
|||
mobility_domain.datatype = "and(hexstring,rangelength(4,4))"
|
||||
mobility_domain.rmempty = true
|
||||
|
||||
r0_key_lifetime = s:taboption("encryption", Value, "r0_key_lifetime",
|
||||
translate("R0 Key Lifetime"), translate("minutes"))
|
||||
r0_key_lifetime:depends({ieee80211r="1"})
|
||||
r0_key_lifetime.placeholder = "10000"
|
||||
r0_key_lifetime.datatype = "uinteger"
|
||||
r0_key_lifetime.rmempty = true
|
||||
|
||||
r1_key_holder = s:taboption("encryption", Value, "r1_key_holder",
|
||||
translate("R1 Key Holder"),
|
||||
translate("6-octet identifier as a hex string - no colons"))
|
||||
r1_key_holder:depends({ieee80211r="1"})
|
||||
r1_key_holder.placeholder = "00004f577274"
|
||||
r1_key_holder.datatype = "and(hexstring,rangelength(12,12))"
|
||||
r1_key_holder.rmempty = true
|
||||
|
||||
reassociation_deadline = s:taboption("encryption", Value, "reassociation_deadline",
|
||||
translate("Reassociation Deadline"),
|
||||
translate("time units (TUs / 1.024 ms) [1000-65535]"))
|
||||
|
@ -960,8 +965,34 @@ if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
|||
reassociation_deadline.datatype = "range(1000,65535)"
|
||||
reassociation_deadline.rmempty = true
|
||||
|
||||
ft_protocol = s:taboption("encryption", ListValue, "ft_over_ds", translate("FT protocol"))
|
||||
ft_protocol:depends({ieee80211r="1"})
|
||||
ft_protocol:value("1", translatef("FT over DS"))
|
||||
ft_protocol:value("0", translatef("FT over the Air"))
|
||||
ft_protocol.rmempty = true
|
||||
|
||||
ft_psk_generate_local = s:taboption("encryption", Flag, "ft_psk_generate_local",
|
||||
translate("Generate PMK locally"),
|
||||
translate("When using a PSK, the PMK can be generated locally without inter AP communications"))
|
||||
ft_psk_generate_local:depends({ieee80211r="1"})
|
||||
|
||||
r0_key_lifetime = s:taboption("encryption", Value, "r0_key_lifetime",
|
||||
translate("R0 Key Lifetime"), translate("minutes"))
|
||||
r0_key_lifetime:depends({ieee80211r="1", ft_psk_generate_local=""})
|
||||
r0_key_lifetime.placeholder = "10000"
|
||||
r0_key_lifetime.datatype = "uinteger"
|
||||
r0_key_lifetime.rmempty = true
|
||||
|
||||
r1_key_holder = s:taboption("encryption", Value, "r1_key_holder",
|
||||
translate("R1 Key Holder"),
|
||||
translate("6-octet identifier as a hex string - no colons"))
|
||||
r1_key_holder:depends({ieee80211r="1", ft_psk_generate_local=""})
|
||||
r1_key_holder.placeholder = "00004f577274"
|
||||
r1_key_holder.datatype = "and(hexstring,rangelength(12,12))"
|
||||
r1_key_holder.rmempty = true
|
||||
|
||||
pmk_r1_push = s:taboption("encryption", Flag, "pmk_r1_push", translate("PMK R1 Push"))
|
||||
pmk_r1_push:depends({ieee80211r="1"})
|
||||
pmk_r1_push:depends({ieee80211r="1", ft_psk_generate_local=""})
|
||||
pmk_r1_push.placeholder = "0"
|
||||
pmk_r1_push.rmempty = true
|
||||
|
||||
|
@ -971,8 +1002,7 @@ if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
|||
"<br />This list is used to map R0KH-ID (NAS Identifier) to a destination " ..
|
||||
"MAC address when requesting PMK-R1 key from the R0KH that the STA " ..
|
||||
"used during the Initial Mobility Domain Association."))
|
||||
|
||||
r0kh:depends({ieee80211r="1"})
|
||||
r0kh:depends({ieee80211r="1", ft_psk_generate_local=""})
|
||||
r0kh.rmempty = true
|
||||
|
||||
r1kh = s:taboption("encryption", DynamicList, "r1kh", translate("External R1 Key Holder List"),
|
||||
|
@ -981,7 +1011,7 @@ if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
|||
"<br />This list is used to map R1KH-ID to a destination MAC address " ..
|
||||
"when sending PMK-R1 key from the R0KH. This is also the " ..
|
||||
"list of authorized R1KHs in the MD that can request PMK-R1 keys."))
|
||||
r1kh:depends({ieee80211r="1"})
|
||||
r1kh:depends({ieee80211r="1", ft_psk_generate_local=""})
|
||||
r1kh.rmempty = true
|
||||
-- End of 802.11r options
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
local fs = require "nixio.fs"
|
||||
local has_ping6 = fs.access("/bin/ping6") or fs.access("/usr/bin/ping6")
|
||||
local has_traceroute6 = fs.access("/usr/bin/traceroute6")
|
||||
local has_speedtest = fs.access("/usr/sbin/speedtestc")
|
||||
|
||||
local dns_host = luci.config.diag and luci.config.diag.dns or "dev.openwrt.org"
|
||||
local ping_host = luci.config.diag and luci.config.diag.ping or "dev.openwrt.org"
|
||||
|
@ -66,7 +67,7 @@ local route_host = luci.config.diag and luci.config.diag.route or "dev.openwrt.o
|
|||
|
||||
<br />
|
||||
|
||||
<div style="width:30%; float:left">
|
||||
<div style="width:26%; float:left">
|
||||
<input style="margin: 5px 0" type="text" value="<%=ping_host%>" name="ping" /><br />
|
||||
<% if has_ping6 then %>
|
||||
<select name="ping_proto" style="width:auto">
|
||||
|
@ -79,7 +80,7 @@ local route_host = luci.config.diag and luci.config.diag.route or "dev.openwrt.o
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<div style="width:33%; float:left">
|
||||
<div style="width:26%; float:left">
|
||||
<input style="margin: 5px 0" type="text" value="<%=route_host%>" name="traceroute" /><br />
|
||||
<% if has_traceroute6 then %>
|
||||
<select name="traceroute_proto" style="width:auto">
|
||||
|
@ -96,11 +97,18 @@ local route_host = luci.config.diag and luci.config.diag.route or "dev.openwrt.o
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<div style="width:33%; float:left;">
|
||||
<div style="width:26%; float:left;">
|
||||
<input style="margin: 5px 0" type="text" value="<%=dns_host%>" name="nslookup" /><br />
|
||||
<input type="button" value="<%:Nslookup%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.nslookup)" />
|
||||
</div>
|
||||
|
||||
<% if has_speedtest then %>
|
||||
<div style="width:10%; float:left;">
|
||||
<input style="margin: 5px 0" type="text" value="" name="speedtest" placeholder="alternate server" /><br />
|
||||
<input type="button" value="<%:Speedtest%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.speedtest)" />
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<br style="clear:both" /><br />
|
||||
|
||||
</fieldset>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
return duid.substr(16).replace(/(..)(?=..)/g, '$1:').toUpperCase();
|
||||
|
||||
// DUID-LL / Ethernet
|
||||
if (duid.length === 24 && duid.substr(0, 8) === '00030001')
|
||||
if (duid.length === 20 && duid.substr(0, 8) === '00030001')
|
||||
return duid.substr(8).replace(/(..)(?=..)/g, '$1:').toUpperCase();
|
||||
|
||||
return null;
|
||||
|
|
|
@ -151,7 +151,7 @@
|
|||
return duid.substr(16).replace(/(..)(?=..)/g, '$1:').toUpperCase();
|
||||
|
||||
// DUID-LL / Ethernet
|
||||
if (duid.length === 24 && duid.substr(0, 8) === '00030001')
|
||||
if (duid.length === 20 && duid.substr(0, 8) === '00030001')
|
||||
return duid.substr(8).replace(/(..)(?=..)/g, '$1:').toUpperCase();
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$(uci -q get luci.diag)" != "internal" ]; then
|
||||
host=""
|
||||
|
||||
if [ -s /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
host="${HOME_URL:-${BUG_URL:-$LEDE_DEVICE_MANUFACTURER_URL}}"
|
||||
host="${host#*://}"
|
||||
host="${host%%/*}"
|
||||
fi
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set luci.diag=internal
|
||||
set luci.diag.dns='${host:-openwrt.org}'
|
||||
set luci.diag.ping='${host:-openwrt.org}'
|
||||
set luci.diag.route='${host:-openwrt.org}'
|
||||
commit luci
|
||||
EOF
|
||||
fi
|
||||
|
||||
exit 0
|
39
omr-quota/Makefile
Normal file
39
omr-quota/Makefile
Normal file
|
@ -0,0 +1,39 @@
|
|||
#
|
||||
# Copyright (C) 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=omr-quota
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=OpenMPTCProuter quota
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+vnstat
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
A module to enforce quota limit
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/$(PKG_NAME)
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
24
omr-quota/files/bin/omr-quota
Executable file
24
omr-quota/files/bin/omr-quota
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
[ -n "$1" ] || exit
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
# retrieve args
|
||||
OMR_QUOTA_INTERFACE="$1"
|
||||
shift
|
||||
|
||||
# main loop
|
||||
while true; do
|
||||
rx=`vnstat -i $OMR_QUOTA_INTERFACE --json | jsonfilter -e '@.interfaces[0].traffic.months[-1].rx' | tr -d "\n"`
|
||||
tx=`vnstat -i $OMR_QUOTA_INTERFACE --json | jsonfilter -e '@.interfaces[0].traffic.months[-1].tx' | tr -d "\n"`
|
||||
tt=$((rx + tx))
|
||||
[ -n "$OMR_QUOTA_RX" ] && [ "$OMR_QUOTA_RX" -gt 0 ] && [ -n "$rx" ] && [ "$OMR_QUOTA_RX" -ge "$rx" ] && ifdown $OMR_QUOTA_INTERFACE \
|
||||
|| \
|
||||
[ -n "$OMR_QUOTA_TX" ] && [ "$OMR_QUOTA_TX" -gt 0 ] && [ -n "$tx" ] && [ "$OMR_QUOTA_TX" -ge "$tx" ] && ifdown $OMR_QUOTA_INTERFACE \
|
||||
|| \
|
||||
[ -n "$OMR_QUOTA_TT" ] && [ "$OMR_QUOTA_TT" -gt 0 ] && [ -n "$tt" ] && [ "$OMR_QUOTA_TT" -ge "$tt" ] && ifdown $OMR_QUOTA_INTERFACE \
|
||||
|| \
|
||||
ifup $OMR_QUOTA_INTERFACE
|
||||
sleep "$OMR_QUOTA_INTERVAL"
|
||||
done
|
15
omr-quota/files/etc/config/omr-quota
Normal file
15
omr-quota/files/etc/config/omr-quota
Normal file
|
@ -0,0 +1,15 @@
|
|||
config interface 'wan1'
|
||||
option enabled '0'
|
||||
option txquota '100000'
|
||||
option rxquota '400000'
|
||||
option ttquota '500000'
|
||||
option interval '10'
|
||||
option interface 'wan1'
|
||||
|
||||
config interface 'wan2'
|
||||
option enabled '0'
|
||||
option txquota '100000'
|
||||
option rxquota '400000'
|
||||
option ttquota '500000'
|
||||
option interval '10'
|
||||
option interface 'wan2'
|
54
omr-quota/files/etc/init.d/omr-quota
Executable file
54
omr-quota/files/etc/init.d/omr-quota
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
{
|
||||
START=90
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
}
|
||||
|
||||
_validate_section() {
|
||||
uci_validate_section omr-quota "$1" "$2" \
|
||||
'txquota:uinteger' \
|
||||
'rxquota:uinteger' \
|
||||
'ttquota:uinteger' \
|
||||
'interval:uinteger' \
|
||||
'interface:string' \
|
||||
'enabled:bool:0'
|
||||
}
|
||||
|
||||
_launch_quota() {
|
||||
local txquota rxquota ttquota interval enabled interface
|
||||
_validate_section "interface" "$1"
|
||||
|
||||
[ -z "$txquota" ] && [ -z "$rxquota" ] && [ -z "$ttquota" ] && return
|
||||
[ $enabled = 0 ] && return
|
||||
|
||||
[ "$(uci get vnstat.@vnstat[-1].interface | grep $interface)" = "" ] && {
|
||||
uci -q batch <<-EOF
|
||||
add_list vnstat.@vnstat[-1].interface=$interface
|
||||
EOF
|
||||
}
|
||||
procd_open_instance
|
||||
procd_set_param command /bin/omr-quota "$interface"
|
||||
procd_append_param env "OMR_QUOTA_TX=$txquota"
|
||||
procd_append_param env "OMR_QUOTA_RX=$rxquota"
|
||||
procd_append_param env "OMR_QUOTA_TT=$ttquota"
|
||||
procd_append_param env "OMR_QUOTA_INTERVAL=$interval"
|
||||
procd_set_param respawn 0 10 0
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load omr-quota
|
||||
config_foreach _launch_quota interface
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger omr-quota network
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
8
omr-quota/files/etc/uci-defaults/omr-quota
Executable file
8
omr-quota/files/etc/uci-defaults/omr-quota
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
uci -q batch <<-EOF
|
||||
delete ucitrack.@omr-quota[-1]
|
||||
add ucitrack omr-quota
|
||||
set ucitrack.@omr-quota[-1].init="omr-quota"
|
||||
add_list ucitrack.@network[-1].affects="omr-quota"
|
||||
commit ucitrack
|
||||
EOF
|
|
@ -8,7 +8,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=openmptcprouter-full
|
||||
PKG_VERSION:=0.3
|
||||
PKG_VERSION:=0.10
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
@ -29,16 +29,40 @@ MY_DEPENDS := \
|
|||
conntrack conntrackd \
|
||||
ebtables ebtables-utils \
|
||||
ip-full \
|
||||
iputils-traceroute6 \
|
||||
iptables-mod-iface iptables-mod-ipmark iptables-mod-hashlimit iptables-mod-condition iptables-mod-trace iptables-mod-conntrack-extra \
|
||||
wireless-tools \
|
||||
libiwinfo-lua \
|
||||
luci-i18n-base-en \
|
||||
luci-i18n-base-fr \
|
||||
luci-i18n-base-de \
|
||||
luci-i18n-base-es \
|
||||
luci-i18n-base-ca \
|
||||
luci-i18n-base-cs \
|
||||
luci-i18n-base-el \
|
||||
luci-i18n-base-he \
|
||||
luci-i18n-base-hu \
|
||||
luci-i18n-base-it \
|
||||
luci-i18n-base-ja \
|
||||
luci-i18n-base-ko \
|
||||
luci-i18n-base-ms \
|
||||
luci-i18n-base-no \
|
||||
luci-i18n-base-pl \
|
||||
luci-i18n-base-pt \
|
||||
luci-i18n-base-ro \
|
||||
luci-i18n-base-ru \
|
||||
luci-i18n-base-sk \
|
||||
luci-i18n-base-sv \
|
||||
luci-i18n-base-tr \
|
||||
luci-i18n-base-vi \
|
||||
luci-i18n-base-zh-cn \
|
||||
luci-i18n-base-zh-tw \
|
||||
luci-i18n-firewall-en \
|
||||
luci-i18n-firewall-fr \
|
||||
ca-bundle ca-certificates \
|
||||
luci-mod-admin-full luci-app-firewall luci-app-glorytun luci-app-shadowsocks-libev luci-app-unbound luci-theme-openmptcprouter luci-base luci-app-haproxy-tcp luci-app-omr-tracker
|
||||
|
||||
luci-mod-admin-full luci-app-firewall luci-app-glorytun luci-app-shadowsocks-libev luci-app-unbound luci-theme-openmptcprouter luci-base luci-app-haproxy-tcp luci-app-omr-tracker luci-app-qos \
|
||||
luci-app-vnstat omr-quota luci-app-omr-quota \
|
||||
speedtestc
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=OMR
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set luci.diag=external
|
||||
set luci.diag.ping="openmptcprouter.com"
|
||||
set luci.diag.dns="openmptcprouter.com"
|
||||
set luci.diag.route="openmptcprouter.com"
|
||||
|
|
19
openmptcprouter/files/etc/uci-defaults/1960-omr-qos
Executable file
19
openmptcprouter/files/etc/uci-defaults/1960-omr-qos
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete qos.wan
|
||||
set qos.wan1=interface
|
||||
set qos.wan1.classgroup="Default"
|
||||
set qos.wan1.enabled="0"
|
||||
set qos.wan1.upload="128"
|
||||
set qos.wan1.download="1024"
|
||||
set qos.wan2=interface
|
||||
set qos.wan2.classgroup="Default"
|
||||
set qos.wan2.enabled="0"
|
||||
set qos.wan2.upload="128"
|
||||
set qos.wan2.download="1024"
|
||||
commit qos
|
||||
EOF
|
||||
rm -f /tmp/luci-indexcache
|
||||
|
||||
exit 0
|
12
openmptcprouter/files/etc/uci-defaults/1970-omr-vnstat
Executable file
12
openmptcprouter/files/etc/uci-defaults/1970-omr-vnstat
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete vnstat.@vnstat[-1]
|
||||
add vnstat vnstat
|
||||
set vnstat.@vnstat[-1].interface="wan1"
|
||||
add_list vnstat.@vnstat[-1].interface="wan2"
|
||||
commit vnstat
|
||||
EOF
|
||||
rm -f /tmp/luci-indexcache
|
||||
|
||||
exit 0
|
34
speedtestc/Makefile
Normal file
34
speedtestc/Makefile
Normal file
|
@ -0,0 +1,34 @@
|
|||
#
|
||||
# Copyright (C) 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=speedtestc
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL:=https://github.com/mobrembski/SpeedTestC.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=56482555e34f7f4002b116efd63cfa68634d389f
|
||||
PKG_MAINTAINER:=Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/speedtestc
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
MAINTAINER:=Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
TITLE:=Client for SpeedTest.net infrastructure written in pure C99 standard using only POSIX libraries.
|
||||
endef
|
||||
|
||||
define Package/speedtestc/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/SpeedTestC $(1)/usr/sbin/speedtestc
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
Loading…
Reference in a new issue