aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/connlisteners.lua4
-rw-r--r--net/dns.lua18
-rw-r--r--net/server.lua2
3 files changed, 13 insertions, 11 deletions
diff --git a/net/connlisteners.lua b/net/connlisteners.lua
index 431d8717..2b95331c 100644
--- a/net/connlisteners.lua
+++ b/net/connlisteners.lua
@@ -38,8 +38,8 @@ function start(name, udata)
error("No such connection module: "..name, 0);
end
return server_add(h,
- udata.port or h.default_port or error("Can't start listener "..name.." because no port was specified, and it has no default port", 0),
- udata.interface or "*", udata.mode or h.default_mode or 1, udata.ssl );
+ (udata and udata.port) or h.default_port or error("Can't start listener "..name.." because no port was specified, and it has no default port", 0),
+ (udata and udata.interface) or "*", (udata and udata.mode) or h.default_mode or 1, (udata and udata.ssl) or nil );
end
return _M; \ No newline at end of file
diff --git a/net/dns.lua b/net/dns.lua
index a75c1bf5..1d165de1 100644
--- a/net/dns.lua
+++ b/net/dns.lua
@@ -19,8 +19,8 @@ local ztact = require 'util.ztact'
local coroutine, io, math, socket, string, table =
coroutine, io, math, socket, string, table
-local ipairs, next, pairs, print, setmetatable, tostring =
- ipairs, next, pairs, print, setmetatable, tostring
+local ipairs, next, pairs, print, setmetatable, tostring, assert, error =
+ ipairs, next, pairs, print, setmetatable, tostring, assert, error
local get, set = ztact.get, ztact.set
@@ -130,7 +130,7 @@ function rr_metatable.__tostring (rr)
local rrs_metatable = {} -- - - - - - - - - - - - - - - - - - rrs_metatable
function rrs_metatable.__tostring (rrs)
- t = {}
+ local t = {}
for i,rr in pairs (rrs) do append (t, tostring (rr)..'\n') end
return table.concat (t)
end
@@ -501,8 +501,10 @@ function resolver:setnameserver (address) -- - - - - - - - - - setnameserver
function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers
- for line in io.lines ('/etc/resolv.conf') do
- address = string.match (line, 'nameserver%s+(%d+%.%d+%.%d+%.%d+)')
+ local resolv_conf = io.open("/etc/resolv.conf");
+ if not resolv_conf then return nil; end
+ for line in resolv_conf:lines() do
+ local address = string.match (line, 'nameserver%s+(%d+%.%d+%.%d+%.%d+)')
if address then self:addnameserver (address) end
end end
@@ -580,7 +582,7 @@ function resolver:purge (soft) -- - - - - - - - - - - - - - - - - - - purge
for class,types in pairs (self.cache or {}) do
for type,names in pairs (types) do
for name,rrs in pairs (names) do
- prune (rrs, time, 'soft')
+ prune (rrs, self.time, 'soft')
end end end
else self.cache = {} end
end
@@ -592,7 +594,7 @@ function resolver:query (qname, qtype, qclass) -- - - - - - - - - - -- query
if not self.server then self:adddefaultnameservers () end
- local question = question or encodeQuestion (qname, qtype, qclass)
+ local question = encodeQuestion (qname, qtype, qclass)
local peek = self:peek (qname, qtype, qclass)
if peek then return peek end
@@ -765,7 +767,7 @@ function dns.resolver () -- - - - - - - - - - - - - - - - - - - - - resolver
-- this function seems to be redundant with resolver.new ()
- r = { active = {}, cache = {}, unsorted = {}, wanted = {}, yielded = {} }
+ local r = { active = {}, cache = {}, unsorted = {}, wanted = {}, yielded = {} }
setmetatable (r, resolver)
setmetatable (r.cache, cache_metatable)
setmetatable (r.unsorted, { __mode = 'kv' })
diff --git a/net/server.lua b/net/server.lua
index 3ff777d5..40f37345 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -619,7 +619,7 @@ wraptcpclient = function( listener, socket, ip, serverport, clientport, mode )
return shutdown( socket, pattern )
end
handler.close = function( closed )
- if eol and not fatal_send_error then handler._dispatchdata(); end
+ if eol and not fatal_send_error then handler.dispatchdata(); end
_ = not closed and shutdown( socket )
_ = not closed and close( socket )
writelen = ( eol and removesocket( writelist, socket, writelen ) ) or writelen