diff options
-rw-r--r-- | ipsec-tools-model.lua | 57 | ||||
-rw-r--r-- | ipsec-tools-status-html.lsp | 43 |
2 files changed, 94 insertions, 6 deletions
diff --git a/ipsec-tools-model.lua b/ipsec-tools-model.lua index 3994007..ece5886 100644 --- a/ipsec-tools-model.lua +++ b/ipsec-tools-model.lua @@ -26,6 +26,35 @@ local function get_version() return cmd_output_result,cmd_output_error end +local function autostarts() + local cmd_output_result, cmd_output_error + local cmd = "/sbin/rc_status | egrep '^S' | egrep '" .. processname .."' 2>/dev/null" + local f = io.popen( cmd ) + local cmdresult = f:read("*a") + if (cmdresult) and (#cmdresult > 0) then + cmd_output_result = "Process will autostart at next boot (at sequence '" .. string.match(cmdresult,"^%a+(%d%d)") .. "')" + else + cmd_output_error = "Not programmed to autostart" + end + f:close() + return cmd_output_result,cmd_output_error + +end + +local function racoonctl(proto) + local cmd_output_result, cmd_output_error + local cmd = "/usr/sbin/racoonctl show-sa ".. proto .. " 2>/dev/null" + local f = io.popen( cmd ) + local cmdresult = f:read("*a") + if (cmdresult) and (#cmdresult > 0) then + cmd_output_result = cmdresult + else + cmd_output_error = "Not programmed to autostart" + end + f:close() + return cmd_output_result,cmd_output_error + +end function process_status_text(procname) local t = procps.pidof(procname) @@ -50,6 +79,34 @@ function getstatus() label="Program status", value=process_status_text(processname), }) + local autostart_sequense, autostart_errtxt = autostarts() + status.autostart = cfe({ name="autostart", + label="Autostart sequence", + value=autostart_sequense, + errtxt=autostart_errtxt, + }) + + local racoon_sequense, racoon_errtxt = racoonctl("isakmp") + status.show_isakmp = cfe({ name="show_isakmp", + label="racoon show-sa isakmp", + value=racoon_sequense, + errtxt=racoon_errtxt, + }) + + local racoon_sequense, racoon_errtxt = racoonctl("esp") + status.show_esp = cfe({ name="show_esp", + label="racoon show-sa esp", + value=racoon_sequense, + errtxt=racoon_errtxt, + }) + + local racoon_sequense, racoon_errtxt = racoonctl("ah") + status.show_ah = cfe({ name="show_ah", + label="racoon show-sa ah", + value=racoon_sequense, + errtxt=racoon_errtxt, + }) + return status end diff --git a/ipsec-tools-status-html.lsp b/ipsec-tools-status-html.lsp index f3acbb4..34b1248 100644 --- a/ipsec-tools-status-html.lsp +++ b/ipsec-tools-status-html.lsp @@ -29,20 +29,51 @@ end <DL> <? local myform = form.status -local tags = { "status", "version", } +local tags = { "status", "version", "autostart", } informationform(myform,tags) ?> </DL> -<? ---[[ ?> <H2>PROGRAM SPECIFIC OPTIONS/INFORMATION</H2> <DL> <? ---local myform = form.status ---local tags = { "stats", } ---informationform(myform,tags) +local myform = form.status.show_isakmp +io.write("\t<DT") +if (#myform.errtxt > 0) then io.write(" class='error'") end +io.write(">" .. myform.label .. "</DT>\n") + +io.write("\t\t<DD><PRE>" .. myform.value .. "</PRE>\n") +if (myform.descr) and (#myform.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(myform.descr, "\n", "<BR>") .. "</P>\n") end +if (#myform.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(myform.errtxt, "\n", "<BR>") .. "</P>\n") end +io.write("\t\t</DD>\n") + +?> +<? +local myform = form.status.show_esp +io.write("\t<DT") +if (#myform.errtxt > 0) then io.write(" class='error'") end +io.write(">" .. myform.label .. "</DT>\n") + +io.write("\t\t<DD><PRE>" .. myform.value .. "</PRE>\n") +if (myform.descr) and (#myform.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(myform.descr, "\n", "<BR>") .. "</P>\n") end +if (#myform.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(myform.errtxt, "\n", "<BR>") .. "</P>\n") end +io.write("\t\t</DD>\n") + ?> -<? --]] ?> +<? +local myform = form.status.show_ah +io.write("\t<DT") +if (#myform.errtxt > 0) then io.write(" class='error'") end +io.write(">" .. myform.label .. "</DT>\n") + +io.write("\t\t<DD><PRE>" .. myform.value .. "</PRE>\n") +if (myform.descr) and (#myform.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(myform.descr, "\n", "<BR>") .. "</P>\n") end +if (#myform.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(myform.errtxt, "\n", "<BR>") .. "</P>\n") end +io.write("\t\t</DD>\n") + +?> + +</DL> <? |