From: Jo-Philipp Wich Date: Fri, 18 Jan 2013 14:08:37 +0000 (+0000) Subject: luci-0.11: merge r9571 - r9622 X-Git-Tag: 0.11.0~2 X-Git-Url: http://git.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=03ed541b7613206010ddfbfc5a8fb6af5cbbf106 luci-0.11: merge r9571 - r9622 --- diff --git a/applications/luci-freifunk-diagnostics/Makefile b/applications/luci-freifunk-diagnostics/Makefile new file mode 100644 index 0000000000..f7fac7740e --- /dev/null +++ b/applications/luci-freifunk-diagnostics/Makefile @@ -0,0 +1,2 @@ +include ../../build/config.mk +include ../../build/module.mk diff --git a/applications/luci-freifunk-diagnostics/ipkg/postinst b/applications/luci-freifunk-diagnostics/ipkg/postinst new file mode 100644 index 0000000000..cc814c365c --- /dev/null +++ b/applications/luci-freifunk-diagnostics/ipkg/postinst @@ -0,0 +1,4 @@ +#!/bin/sh +[ -n "${IPKG_INSTROOT}" ] || { + ( . /etc/uci-defaults/luci-freifunk-diagnostics ) && rm -f /etc/uci-defaults/luci-freifunk-diagnostics +} diff --git a/applications/luci-freifunk-diagnostics/luasrc/controller/freifunk/diag.lua b/applications/luci-freifunk-diagnostics/luasrc/controller/freifunk/diag.lua new file mode 100644 index 0000000000..2a5db6751a --- /dev/null +++ b/applications/luci-freifunk-diagnostics/luasrc/controller/freifunk/diag.lua @@ -0,0 +1,82 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth +Copyright 2011 Jo-Philipp Wich +Copyright 2013 Manuel Munz + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +]]-- + +module("luci.controller.freifunk.diag", package.seeall) + +function index() + local uci = require("luci.model.uci").cursor() + local page + page = node("freifunk", "status", "diagnostics") + page.target = template("freifunk/diagnostics") + page.title = _("Diagnostics") + page.order = 60 + + page = entry({"freifunk", "status", "diag_ping"}, call("diag_ping"), nil) + page.leaf = true + + page = entry({"freifunk", "status", "diag_nslookup"}, call("diag_nslookup"), nil) + page.leaf = true + + page = entry({"freifunk", "status", "diag_traceroute"}, call("diag_traceroute"), nil) + page.leaf = true + + page = entry({"freifunk", "status", "diag_ping6"}, call("diag_ping6"), nil) + page.leaf = true + + page = entry({"freifunk", "status", "diag_traceroute6"}, call("diag_traceroute6"), nil) + page.leaf = true +end + +function diag_command(cmd, addr) + if addr and addr:match("^[a-zA-Z0-9%-%.:_]+$") then + luci.http.prepare_content("text/plain") + + local util = io.popen(cmd % addr) + if util then + while true do + local ln = util:read("*l") + if not ln then break end + luci.http.write(ln) + luci.http.write("\n") + end + + util:close() + end + + return + end + + luci.http.status(500, "Bad address") +end + +function diag_ping(addr) + diag_command("ping -c 5 -W 1 %q 2>&1", addr) +end + +function diag_traceroute(addr) + diag_command("traceroute -q 1 -w 1 -n %q 2>&1", addr) +end + +function diag_nslookup(addr) + diag_command("nslookup %q 2>&1", addr) +end + +function diag_ping6(addr) + diag_command("ping6 -c 5 %q 2>&1", addr) +end + +function diag_traceroute6(addr) + diag_command("traceroute6 -q 1 -w 2 -n %q 2>&1", addr) +end diff --git a/applications/luci-freifunk-diagnostics/luasrc/view/freifunk/diagnostics.htm b/applications/luci-freifunk-diagnostics/luasrc/view/freifunk/diagnostics.htm new file mode 100644 index 0000000000..f35811f648 --- /dev/null +++ b/applications/luci-freifunk-diagnostics/luasrc/view/freifunk/diagnostics.htm @@ -0,0 +1,120 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2010 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ + +-%> + +<%+header%> + +<% +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") +%> + + + + +
"> +
+

<%:Diagnostics%>

+ +
+ <%:Network Utilities%> + +
+ +
+
+ <% if has_ping6 then %> + + + <% else %> + + <% end %> +
+ +
+
+ <% if has_traceroute6 then %> + + + <% else %> + + <% end %> + <% if not has_traceroute6 then %> +

 

+

<%:Install iputils-traceroute6 for IPv6 traceroute%>

+ <% end %> +
+ +
+
+ +
+ +

+ +
+
+ + +
+ +<%+footer%> diff --git a/applications/luci-freifunk-diagnostics/root/etc/uci-defaults/luci-freifunk-diagnostics b/applications/luci-freifunk-diagnostics/root/etc/uci-defaults/luci-freifunk-diagnostics new file mode 100644 index 0000000000..963d8a4efc --- /dev/null +++ b/applications/luci-freifunk-diagnostics/root/etc/uci-defaults/luci-freifunk-diagnostics @@ -0,0 +1,2 @@ +#!/bin/sh +rm -f /tmp/luci-indexcache diff --git a/applications/luci-freifunk-widgets/root/etc/config/freifunk-widgets b/applications/luci-freifunk-widgets/root/etc/config/freifunk-widgets index e5a20e7e5f..5a9f3254fa 100644 --- a/applications/luci-freifunk-widgets/root/etc/config/freifunk-widgets +++ b/applications/luci-freifunk-widgets/root/etc/config/freifunk-widgets @@ -19,7 +19,7 @@ config widget 'example_search' option enabled '0' option title 'Search' list engine 'Google|http://www.google.de/search?q=' - list engine 'Freifunk Wiki|http://wiki.freifunk.net/index.php?search=' + list engine 'Freifunk Wiki|http://wiki.freifunk.net/index.php?search=' option width '50%' option paddingright '8%' diff --git a/applications/luci-meshwizard/luasrc/model/cbi/freifunk/meshwizard.lua b/applications/luci-meshwizard/luasrc/model/cbi/freifunk/meshwizard.lua index f4478f61cc..3a52419e9a 100644 --- a/applications/luci-meshwizard/luasrc/model/cbi/freifunk/meshwizard.lua +++ b/applications/luci-meshwizard/luasrc/model/cbi/freifunk/meshwizard.lua @@ -142,7 +142,11 @@ uci:foreach("wireless", "wifi-device", function(section) end -- Enable VAP - if hwtype == "atheros" then + local supports_vap = 0 + if sys.call("/usr/bin/meshwizard/helpers/supports_vap.sh " .. device .. " " .. hwtype) == 0 then + supports_vap = 1 + end + if supports_vap == 1 then local vap = n:taboption(device, Flag, device .. "_vap", translate("Virtual Access Point (VAP)"), translate("This will setup a new virtual wireless interface in Access Point mode.")) vap:depends(device .. "_dhcp", "1") diff --git a/applications/luci-olsr/luasrc/view/status-olsr/overview.htm b/applications/luci-olsr/luasrc/view/status-olsr/overview.htm index d57da7cfe3..294af7b3a6 100644 --- a/applications/luci-olsr/luasrc/view/status-olsr/overview.htm +++ b/applications/luci-olsr/luasrc/view/status-olsr/overview.htm @@ -168,7 +168,7 @@ XHR.poll(30, '<%=REQUEST_URI%>', { status: 1 },
- "> + <%=nr_topo%> diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/olsrd.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/olsrd.lua index 1bb1f836bc..e3eb7b2c4b 100644 --- a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/olsrd.lua +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/olsrd.lua @@ -21,7 +21,7 @@ enable.default = 0 host = s:option(Value, "Host", translate("Host"), translate("IP or hostname where to get the txtinfo output from")) host.placeholder = "127.0.0.1" -host.datatype = "hostname" +host.datatype = "host" host.rmempty = true port = s:option(Value, "Port", translate("Port")) diff --git a/applications/luci-upnp/luasrc/controller/upnp.lua b/applications/luci-upnp/luasrc/controller/upnp.lua index 7acd029a5f..83fa94154b 100644 --- a/applications/luci-upnp/luasrc/controller/upnp.lua +++ b/applications/luci-upnp/luasrc/controller/upnp.lua @@ -10,7 +10,6 @@ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -$Id$ ]]-- module("luci.controller.upnp", package.seeall) @@ -25,9 +24,6 @@ function index() page = entry({"admin", "services", "upnp"}, cbi("upnp/upnp"), _("UPNP")) page.dependent = true - page = entry({"mini", "network", "upnp"}, cbi("upnp/upnpmini", {autoapply=true}), _("UPNP")) - page.dependent = true - entry({"admin", "services", "upnp", "status"}, call("act_status")).leaf = true entry({"admin", "services", "upnp", "delete"}, call("act_delete")).leaf = true end @@ -67,11 +63,20 @@ function act_status() end end -function act_delete(idx) - idx = tonumber(idx) +function act_delete(num) + local idx = tonumber(num) + local uci = luci.model.uci.cursor() + if idx and idx > 0 then luci.sys.call("iptables -t filter -D MINIUPNPD %d 2>/dev/null" % idx) luci.sys.call("iptables -t nat -D MINIUPNPD %d 2>/dev/null" % idx) + + local lease_file = uci:get("upnpd", "config", "upnp_lease_file") + if lease_file and nixio.fs.access(lease_file) then + luci.sys.call("sed -i -e '%dd' %q" %{ idx, lease_file }) + end + + luci.http.status(200, "OK") return end diff --git a/applications/luci-upnp/luasrc/model/cbi/upnp/upnpmini.lua b/applications/luci-upnp/luasrc/model/cbi/upnp/upnpmini.lua deleted file mode 100644 index 3f1ba3035a..0000000000 --- a/applications/luci-upnp/luasrc/model/cbi/upnp/upnpmini.lua +++ /dev/null @@ -1,26 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth -Copyright 2008 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- -m = Map("upnpd", translate("Universal Plug & Play"), translate("UPNP allows clients in the local network to automatically configure the router.")) - -s = m:section(NamedSection, "config", "upnpd", "") -s.addremove = false - -e = s:option(Flag, "enabled", translate("enable")) -e.rmempty = false - -s:option(Value, "download", translate("Downlink"), "kByte/s").rmempty = true -s:option(Value, "upload", translate("Uplink"), "kByte/s").rmempty = true - -return m diff --git a/contrib/package/community-profiles/files/etc/config/profile_augsburg b/contrib/package/community-profiles/files/etc/config/profile_augsburg index 46cf1006a4..fdb73ccaa8 100644 --- a/contrib/package/community-profiles/files/etc/config/profile_augsburg +++ b/contrib/package/community-profiles/files/etc/config/profile_augsburg @@ -53,8 +53,8 @@ config widget 'search' option enabled '1' option width '50%' list engine 'Google|http://www.google.de/search?q=' - list engine 'Freifunk Augsburg|http://www.google.de/search?q=site:augsburg.freifunk.net&' - list engine 'Freifunk Wiki|http://wiki.freifunk.net/index.php?search=' + list engine 'Freifunk Augsburg|http://www.google.de/search?q=site:augsburg.freifunk.net+' + list engine 'Freifunk Wiki|http://wiki.freifunk.net/index.php?search=' config widget 'clear1' option template 'clear' diff --git a/contrib/package/luci/Makefile b/contrib/package/luci/Makefile index 33267b6c9c..9fbc587497 100644 --- a/contrib/package/luci/Makefile +++ b/contrib/package/luci/Makefile @@ -344,6 +344,8 @@ $(eval $(call application,olsr,OLSR configuration and status module,\ $(eval $(call application,olsr-viz,OLSR Visualisation,\ luci-app-olsr +olsrd-mod-txtinfo)) +$(eval $(call application,freifunk-diagnostics,Tools for network diagnosis like traceroute and ping)) + $(eval $(call application,olsr-services,Show services announced with the nameservice plugin,\ luci-app-olsr +olsrd-mod-nameservice)) diff --git a/contrib/package/meshwizard/Makefile b/contrib/package/meshwizard/Makefile index a9a1a0b6e8..3aaddec256 100644 --- a/contrib/package/meshwizard/Makefile +++ b/contrib/package/meshwizard/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=meshwizard -PKG_RELEASE:=0.0.8-1 +PKG_RELEASE:=0.0.8-3 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/gen_bssid.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/gen_bssid.sh index 8c9155e5e9..efe101fad0 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/gen_bssid.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/gen_bssid.sh @@ -24,10 +24,10 @@ if [ -z "$bssid" ]; then bssid="$(printf "%X\n" $channel)2:CA:FF:EE:BA:BE" ;; [3-9][0-9]) - bssid="00:$channel:CA:FF:EE:EE" + bssid="02:$channel:CA:FF:EE:EE" ;; 1[0-9][0-9]) - bssid="${channel/1/01:}:CA:FF:EE:EE" + bssid="${channel/1/12:}:CA:FF:EE:EE" ;; *) bssid="02:CA:FF:EE:BA:BE" ;; diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh index 7f40f87147..fc664430fe 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh @@ -45,7 +45,11 @@ network=$(echo $network) # Removes leading and trailing whitespaces [ -n "$netrenamed" ] && [ -z "$(echo $network | grep $netrenamed)" ] && network="$network $netrenamed" -if [ "$type" == "atheros" -a "$vap" == 1 ]; then +# check if this hardware supports VAPs +supports_vap="0" +$dir/helpers/supports_vap.sh $net $type && supports_vap=1 + +if [ "$supports_vap" == "1" -a "$vap" == 1 ]; then [ -n "$netrenamed" ] && [ "$network" == "${network/${netrenamed}dhcp/}" ] && network="$network ${netrenamed}dhcp" fi diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh index 84c5438ebc..34bd0cbb03 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh @@ -79,7 +79,16 @@ uci_commitverbose "Setup wifi interface for $netrenamed" wireless ## VAP ip4addr="$(uci get meshwizard.netconfig.$net\_ip4addr)" -if [ "$type" == "atheros" -a "$vap" == 1 ]; then + +# check if this hardware supports VAPs +# the interface needs to be up before the check can happen + +/sbin/wifi + +supports_vap="0" +$dir/helpers/supports_vap.sh $net $type && supports_vap=1 + +if [ "$supports_vap" == "1" -a "$vap" == 1 ]; then uci batch <<- EOF set wireless.$net\_iface_dhcp="wifi-iface" set wireless.$net\_iface_dhcp.device="$net" diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh new file mode 100755 index 0000000000..045ea976e0 --- /dev/null +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/supports_vap.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# checks if a given device can be used for a VAP interface (1 adhoc + 1 ap) +dev="$1" +type="$2" + + +if [ -z "$dev" -o -z "$type" ]; then + exit 1 +fi + +if [ "$type" = "atheros" ]; then + exit 0 +elif [ "$type" = "mac80211" ]; then + # not hostapd[-mini], no VAP + if [ ! -x /usr/sbin/hostapd ]; then + echo "WARNING: hostapd[-mini] is required to be able to use VAP with mac80211." + exit 1 + fi + # get driver in use + netindex="$(echo $dev |sed 's/[a-zA-z]*//')" + if [ -d /sys/class/net/wlan${netindex}/device/driver/module ]; then + driver="$(basename $(ls -l /sys/class/net/wlan${netindex}/device/driver/module | sed -ne 's/.* -> //p'))" + if [ "$driver" = "ath9k" -o "$driver" = "ath5k" ]; then + exit 0 + else + exit 1 + fi + else + exit 1 + fi +else + exit 1 +fi + + diff --git a/libs/core/luasrc/model/network.lua b/libs/core/luasrc/model/network.lua index 56f1751f81..09a58d7424 100644 --- a/libs/core/luasrc/model/network.lua +++ b/libs/core/luasrc/model/network.lua @@ -1164,31 +1164,24 @@ function interface.is_bridgeport(self) return self.dev and self.dev.bridge and true or false end -local function uint(x) - if x then - return (x < 0) and ((2^32) + x) or x - end - return 0 -end - function interface.tx_bytes(self) local stat = self:_ubus("statistics") - return stat and uint(stat.tx_bytes) or 0 + return stat and stat.tx_bytes or 0 end function interface.rx_bytes(self) local stat = self:_ubus("statistics") - return stat and uint(stat.rx_bytes) or 0 + return stat and stat.rx_bytes or 0 end function interface.tx_packets(self) local stat = self:_ubus("statistics") - return stat and uint(stat.tx_packets) or 0 + return stat and stat.tx_packets or 0 end function interface.rx_packets(self) local stat = self:_ubus("statistics") - return stat and uint(stat.rx_packets) or 0 + return stat and stat.rx_packets or 0 end function interface.get_network(self) diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua index 825092fff8..18622da77c 100644 --- a/libs/sys/luasrc/sys.lua +++ b/libs/sys/luasrc/sys.lua @@ -695,38 +695,29 @@ end function process.list() local data = {} local k - local ps = luci.util.execi("top -bn1") + local ps = luci.util.execi("/bin/busybox top -bn1") if not ps then return end - while true do - local line = ps() - if not line then - return - end - - k = luci.util.split(luci.util.trim(line), "%s+", nil, true) - if k[6] == "%VSZ" then - k[6] = "%MEM" - end - if k[1] == "PID" then - break - end - end - for line in ps do - local row = {} - - line = luci.util.trim(line) - for i, value in ipairs(luci.util.split(line, "%s+", #k-1, true)) do - row[k[i]] = value - end + local pid, ppid, user, stat, vsz, mem, cpu, cmd = line:match( + "^ *(%d+) +(%d+) +(%S.-%S) +([RSDZTW][W ][ #include #include +#include #if (defined(__GNUC__) && defined(__i386__)) #define sfh_get16(d) (*((const uint16_t *) (d))) diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua index bf8418f812..98f9d8ecf9 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua @@ -236,6 +236,7 @@ name.rmempty = true mac = s:option(Value, "mac", translate("MAC-Address")) mac.datatype = "list(macaddr)" +mac.rmempty = true ip = s:option(Value, "ip", translate("IPv4-Address")) ip.datatype = "ip4addr" @@ -248,5 +249,14 @@ sys.net.arptable(function(entry) ) end) +function ip.validate(self, value, section) + local m = mac:formvalue(section) or "" + local n = name:formvalue(section) or "" + if value and #n == 0 and #m == 0 then + return nil, translate("One of hostname or mac address must be specified!") + end + return Value.validate(self, value, section) +end + return m diff --git a/modules/admin-full/luasrc/view/admin_network/diagnostics.htm b/modules/admin-full/luasrc/view/admin_network/diagnostics.htm index 64666880da..d1bef2a8b7 100644 --- a/modules/admin-full/luasrc/view/admin_network/diagnostics.htm +++ b/modules/admin-full/luasrc/view/admin_network/diagnostics.htm @@ -24,23 +24,15 @@ local has_traceroute6 = fs.access("/usr/bin/traceroute6")