diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-01-08 17:03:40 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-01-08 17:03:40 +0000 |
commit | bafb292e20a7d7bab5fe637e4a74d6a95a2af2bc (patch) | |
tree | b0a8301f22a877903af0e35c75deaab633842a6b | |
parent | ddb5e9bae0af0a9bc9333ca8da2a748c6308098f (diff) | |
download | acf-ipsec-tools-bafb292e20a7d7bab5fe637e4a74d6a95a2af2bc.tar.bz2 acf-ipsec-tools-bafb292e20a7d7bab5fe637e4a74d6a95a2af2bc.tar.xz |
Clean up changes for phase2details
-rw-r--r-- | ipsectools-model.lua | 29 |
1 files 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], |