1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add quota support and small others changes

This commit is contained in:
Ycarus 2018-03-06 15:09:20 +01:00
parent 6fe07f493b
commit b549503be7
23 changed files with 397 additions and 59 deletions

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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>

View file

@ -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;

View file

@ -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;

View file

@ -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