summaryrefslogtreecommitdiffstats
path: root/interfaces-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'interfaces-model.lua')
-rw-r--r--interfaces-model.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/interfaces-model.lua b/interfaces-model.lua
index ea18e56..66132b3 100644
--- a/interfaces-model.lua
+++ b/interfaces-model.lua
@@ -407,6 +407,22 @@ write_file = function (newfile)
return modelfunctions.setfiledetails(newfile, {filename})
end
+get_interfaces = function()
+ local cmd = path.."ip addr"
+ local f = io.popen(format.escapespecialcharacters(cmd))
+ local ipaddr = f:read("*a")
+ f:close()
+ -- now parse the result to find the interfaces
+ local retval = {}
+ for line in string.gmatch(ipaddr, "[^\n]*\n?") do
+ if string.find(line, "^%d+:%s+") then
+ local interface=string.match(line, "^%d+:%s+([^:@]+)")
+ retval[#retval+1] = interface
+ end
+ end
+ return cfe({ type="list", value=retval, label="IP Interfaces" })
+end
+
get_addresses = function()
local cmd = path.."ip addr"
local f = io.popen(format.escapespecialcharacters(cmd))