From 131d8583638dd5b44d37c292d99740bde3dcf2b6 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 29 Sep 2008 18:01:28 +0000 Subject: Removed getopts library and added functionality to format library as opts_to_table, table_to_opts, parse_configfile2, update_configfile2, get_section, and set_section. New functions work on strings, not files. Modified all code using getopts to use format instead. Fixed nil string bugs in TCPProxy. Fixed forward only bug in DNSCache. git-svn-id: svn://svn.alpinelinux.org/acf/tcpproxy/trunk@1535 ab2d0c66-481e-0410-8bed-d214d4d58bed --- tcpproxy-model.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tcpproxy-model.lua') diff --git a/tcpproxy-model.lua b/tcpproxy-model.lua index d812bb3..e0e820b 100644 --- a/tcpproxy-model.lua +++ b/tcpproxy-model.lua @@ -5,7 +5,7 @@ require("modelfunctions") require("validator") require("fs") require("posix") -require("getopts") +require("format") -- Set variables local configfile = "/etc/tcpproxy.conf" @@ -68,7 +68,7 @@ end local function setsmtpcmd(ipaddr, cmd) if cmd then cmd = "exec "..cmd end - local file = fs.read_file(configfile) + local file = fs.read_file(configfile) or "" local inport25 = false local ininterface = false local done = false @@ -115,7 +115,7 @@ end local function parsesmtpcmd(exec) -- parse the command line into a table exec = exec or "" - local options = getopts.opts_to_table(exec) or {} + local options = format.opts_to_table(exec) or {} local server = string.match(exec, "rxmtp.*%s(%S+)%s*$") if server and not string.match(server, "^%-") then local test = string.match(exec, "rxmtp.*%s(%S+)%s+%S+%s*$") @@ -269,9 +269,9 @@ function readsmtpentry(ipaddr) server.value = options[""] or server.value addressonly.value = (options["-b"] ~= nil) if options["-o"] then - domain.value = string.match(options["-o"], "^[^=]*") - optionalserver.value = string.match(options["-o"], "=([^=]*)") - optionalrewritelist.value = string.match(options["-o"], "=.*=(.*)") + domain.value = string.match(options["-o"], "^[^=]*") or "" + optionalserver.value = string.match(options["-o"], "=([^=]*)") or "" + optionalrewritelist.value = string.match(options["-o"], "=.*=(.*)") or "" end senderlistfile.value = options["-x"] or senderlistfile.value rcptlistfile.value = options["-X"] or rcptlistfile.value -- cgit v1.2.3