summaryrefslogtreecommitdiffstats
path: root/interfaces-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'interfaces-model.lua')
-rw-r--r--interfaces-model.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/interfaces-model.lua b/interfaces-model.lua
index bfa9bb8..0d27ec0 100644
--- a/interfaces-model.lua
+++ b/interfaces-model.lua
@@ -406,6 +406,15 @@ iface.iproute = function ()
return cfe({ type="longtext", value=cmdresult, label="ip route" })
end
+iface.ifconfig = function ()
+ local cmd = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin ifconfig"
+ local f = io.popen(cmd)
+ local cmdresult = f:read("*a")
+ f:close()
+
+ return cfe({ type="longtext", value=cmdresult, label="ifconfig" })
+end
+
-------------------------------------------------------------------------------
-- Public Methods
-------------------------------------------------------------------------------
@@ -465,3 +474,18 @@ write_file = function (newfile)
return get_file()
end
+
+get_addresses = function()
+ local ipaddr = iface.ipaddr()
+ -- now parse the result to find the interfaces and IP addresses
+ local retval = {}
+ local interface
+ for line in string.gmatch(ipaddr.value, "[^\n]*\n?") do
+ if string.find(line, "^%x+:%s+%w+:") then
+ interface=string.match(line, "^%x+:%s+(%w+):")
+ elseif string.find(line, "^%s*inet%s") then
+ table.insert(retval, {interface=interface, ipaddr=string.match(line, "^%s*inet%s+([%d%.]+)")})
+ end
+ end
+ return cfe({ type="structure", value=retval, label="Interface IP Addresses" })
+end