summaryrefslogtreecommitdiffstats
path: root/zebra-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-09-18 20:55:58 +0000
committerTed Trask <ttrask01@yahoo.com>2008-09-18 20:55:58 +0000
commit8e208afe45bd9d4f9a76c1e818142dc69a371afd (patch)
tree40b33a5c64d1d2f284ea0324330ad365440ae00c /zebra-model.lua
parentbaba8af25fe9edc4e266495783128a8af4e42a1a (diff)
downloadacf-quagga-8e208afe45bd9d4f9a76c1e818142dc69a371afd.tar.bz2
acf-quagga-8e208afe45bd9d4f9a76c1e818142dc69a371afd.tar.xz
Modified quagga to account for failures in details.v0.3.1
git-svn-id: svn://svn.alpinelinux.org/acf/quagga/trunk@1478 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'zebra-model.lua')
-rw-r--r--zebra-model.lua32
1 files changed, 16 insertions, 16 deletions
diff --git a/zebra-model.lua b/zebra-model.lua
index 89bfc26..1b9b8b9 100644
--- a/zebra-model.lua
+++ b/zebra-model.lua
@@ -34,26 +34,26 @@ end
local function telnetshowip()
local output = {}
- local configfile = parseconfigfile()
- local cmd_output_result, cmd_output_error
+ local configfile = parseconfigfile() or {}
local cmd = path .. "echo -e '" .. (configfile.password or "") .. "\nshow ip route\nquit\n' | nc localhost zebra 2>/dev/null"
local f = io.popen( cmd )
- local line = f:read("*l")
+ local result = f:read("*a") or ""
local validoutput
- while line do
- if (string.find(line, "^Codes")) then
- validoutput = true
- end
- if (string.find(line, "> quit")) then
- validoutput = false
- end
- if (validoutput) then
- table.insert(output,line)
+ if result == "" then
+ result = "Failed to find routes"
+ end
+ local startout, stopout
+ for line in string.gmatch(result, "([^\n]*)\n?") do
+ table.insert(output,line)
+ if (string.find(line, "^Password:")) then
+ startout = #output+1
+ elseif (string.find(line, "^Codes:")) then
+ startout = #output
+ elseif (string.find(line, "> quit")) then
+ stopout = #output-1
end
- line = f:read("*l")
end
- return table.concat(output,"\n"),cmd_output_error
--- return configfile.password
+ return table.concat(output,"\n",startout,stopout)
end
-- ################################################################################
@@ -79,7 +79,7 @@ end
function getdetails()
local status = {}
status.showip = cfe({ label="Zebra routes" })
- status.showip.value,status.showip.errtxt = telnetshowip()
+ status.showip.value = telnetshowip()
return cfe({ type="group", value=status, label="Zebra Details" })
end