summaryrefslogtreecommitdiffstats
path: root/dnscache-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-09-29 18:01:28 +0000
committerTed Trask <ttrask01@yahoo.com>2008-09-29 18:01:28 +0000
commita185bea39ff2c99c138665640b31dfbe68269350 (patch)
tree020298eac6569a0607cdbd3896f977a28cb26d3f /dnscache-model.lua
parent3aa16eef7ecf45ece462e8185044fa846a1488fb (diff)
downloadacf-dnscache-a185bea39ff2c99c138665640b31dfbe68269350.tar.bz2
acf-dnscache-a185bea39ff2c99c138665640b31dfbe68269350.tar.xz
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/dnscache/trunk@1535 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'dnscache-model.lua')
-rw-r--r--dnscache-model.lua15
1 files changed, 7 insertions, 8 deletions
diff --git a/dnscache-model.lua b/dnscache-model.lua
index 88b6335..d3db087 100644
--- a/dnscache-model.lua
+++ b/dnscache-model.lua
@@ -3,7 +3,6 @@ module(..., package.seeall)
-- Load libraries
require("modelfunctions")
require("fs")
-require("getopts")
require("format")
require("posix")
require("validator")
@@ -69,7 +68,7 @@ function getstatus()
end
function getconfig()
- local conf = getopts.getoptsfromfile(configfile, "") or {}
+ local conf = format.parse_configfile2(fs.read_file(configfile), "") or {}
local output = {}
output.IPSEND = cfe({ value = conf.IPSEND or "", label="IP address for requests",
descr="Use 0.0.0.0 for default address" })
@@ -85,13 +84,13 @@ function setconfig(config)
if success then
local file = fs.read_file(configfile)
- getopts.setoptsinfile(file,"","IPSEND",config.value.IPSEND.value)
- getopts.setoptsinfile(file,"","CACHESIZE",config.value.CACHESIZE.value)
- getopts.setoptsinfile(file,"","IP",config.value.IP.value)
- if config.value.IPSEND.value then
- getopts.setoptsinfile(file,"","FORWARDONLY",config.value.IPSEND.value)
+ file = format.update_configfile2(file,"","IPSEND",config.value.IPSEND.value)
+ file = format.update_configfile2(file,"","CACHESIZE",config.value.CACHESIZE.value)
+ file = format.update_configfile2(file,"","IP",config.value.IP.value)
+ if config.value.FORWARDONLY.value then
+ file = format.update_configfile2(file,"","FORWARDONLY","true")
else
- getopts.setoptsinfile(file,"","FORWARDONLY","")
+ file = format.update_configfile2(file,"","FORWARDONLY","")
end
fs.write_file(configfile, file)
else