diff options
-rw-r--r-- | openvpn-controller.lua | 5 | ||||
-rw-r--r-- | openvpn-logfile-html.lsp | 5 | ||||
-rw-r--r-- | openvpn-model.lua | 18 | ||||
-rw-r--r-- | openvpn-unknown_config-html.lsp | 7 |
4 files changed, 25 insertions, 10 deletions
diff --git a/openvpn-controller.lua b/openvpn-controller.lua index 99a655b..9597473 100644 --- a/openvpn-controller.lua +++ b/openvpn-controller.lua @@ -42,15 +42,16 @@ end status_info = function (self) local configname = self.clientdata.name or "" - -- FIXME: If return 0 rows, goto read return ( {clientlist = self.model:clientlist(configname), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) end unknown_config = function (self) + local configname = self.clientdata.name or "" + return ( {configfilecontent = self.model:get_config(configname), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) end logfile = function (self) local configname = self.clientdata.name or "" -- FIXME: If return 0 rows, goto read - return ( {logfilecontent = self.model:get_logfile(configname), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) + return ( {logfilecontent = self.model:get_logfile(configname), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } ) end diff --git a/openvpn-logfile-html.lsp b/openvpn-logfile-html.lsp index a8d64b7..6eb05d5 100644 --- a/openvpn-logfile-html.lsp +++ b/openvpn-logfile-html.lsp @@ -1,7 +1,8 @@ <? local view = ... ?> <html> <body> -<h1>Logfile 'xxx.log'</h1> -<textarea name="" style="width:100%;height:450px;"><? io.write(logfilecontent) ?></textarea> +<h1>Logfile '<?= view.logfilecontent.name ?>'</h1> +<textarea name="" style="width:100%;height:450px;"><?= view.logfilecontent.value ?></textarea> + </body> </html> diff --git a/openvpn-model.lua b/openvpn-model.lua index bcae88c..15c791c 100644 --- a/openvpn-model.lua +++ b/openvpn-model.lua @@ -208,10 +208,24 @@ end function get_logfile( self, path) local logcontent = {} config = config_content ( path ) - local logfilecontent = fs.read_file_as_array ( config.log ) - return logfilecontent + local logfilecontent = fs.read_file ( config.log ) + if not (logfilecontent) then + logfilecontent = "File is empty or missing!" + end + return ( { name = config.log, value = logfilecontent } ) end +function get_config( self, path) + local logcontent = {} + config = config_content ( path ) + local logfilecontent = fs.read_file ( config.name ) + if not (logfilecontent) then + logfilecontent = "File is empty or missing!" + end + return ( { name = config.name, value = logfilecontent } ) +end + + function get_conflist () local configlist = {} for k,v in pairs(list_conffiles()) do diff --git a/openvpn-unknown_config-html.lsp b/openvpn-unknown_config-html.lsp index 26787c5..2d33d10 100644 --- a/openvpn-unknown_config-html.lsp +++ b/openvpn-unknown_config-html.lsp @@ -1,12 +1,11 @@ <? local view = ... ?> <html> <body> -<h1>Configuration file 'xxx.conf'</h1> +<h1>Configuration file '<?= view.configfilecontent.name ?>'</h1> <h2>Details</h2> - -<input type=text style="width:100%;height:500px"></input> +<textarea name="" style="width:100%;height:450px;"><?= view.configfilecontent.value ?></textarea> </body> -</html> +</html> |