From bafb292e20a7d7bab5fe637e4a74d6a95a2af2bc Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 8 Jan 2013 17:03:40 +0000 Subject: Clean up changes for phase2details --- ipsectools-model.lua | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/ipsectools-model.lua b/ipsectools-model.lua index 4c1360f..9bd5f04 100644 --- a/ipsectools-model.lua +++ b/ipsectools-model.lua @@ -33,23 +33,9 @@ local descr = { -- ################################################################################ -- LOCAL FUNCTIONS -local function phase2details(dst) - local output = {} - dst = string.match(dst,"^(.*)%.") -- Removes the portnumber - local value = modelfunctions.run_executable({"ip", "xfrm", "state", "list", "src", dst}) - -- Get rid of all lines that don't start with "src" - table.insert(output, {label="Outgoing", value=string.gsub(value, "\n[^s][^\n]*", "")}) - - value = modelfunctions.run_executable({"ip", "xfrm", "state", "list", "dst", dst}) - -- Get rid of all lines that don't start with "src" - table.insert(output, {label="Incoming", value=string.gsub(value, "\n[^s][^\n]*", "")}) - - return output -end - local function racoonctl_table() local output = {} - local value = modelfunctions.run_executable({"ip", "xfrm", "state", "list", "src", dst}) + local value = modelfunctions.run_executable({"ip", "xfrm", "state"}) -- Get rid of all lines that don't start with "src" local phase2details = string.gsub(value, "\n[^s][^\n]*", "") @@ -95,16 +81,15 @@ local function racoonctl_table() }) local dst = string.match(variable[2],"^(.*)%.") -- Removes the portnumber - local input = {} - local output = {} - for l in string.gmatch(phase2details, "src [^n]* "..dst.."\n") do - input[#input+1] = l + local incoming = {} + local outgoing = {} + for l in string.gmatch(phase2details, "src [^\n]* "..dst.."\n") do + outgoing[#outgoing+1] = l end for l in string.gmatch(phase2details, "src "..dst.." [^\n]*\n") do - output[#output+1] = l + incoming[#incoming+1] = l end - local phase2s = {{label="Outgoing", value=table.concat(output)}, {label="Incoming", value=table.concat(input)}} - --local phase2s = phase2details(variable[2]) + local phase2s = {{label="Outgoing", value=table.concat(outgoing)}, {label="Incoming", value=table.concat(incoming)}} entry['Phase2']=cfe({ label="Phase2", value=variable[10], -- cgit v1.2.3