aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/s2smanager.lua14
-rw-r--r--net/dns.lua9
-rw-r--r--plugins/mod_console.lua4
-rw-r--r--plugins/mod_welcome.lua2
4 files changed, 16 insertions, 13 deletions
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index ce8da1e6..e11b305a 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -254,20 +254,20 @@ function try_connect(host_session, connect_host, connect_port)
host_session.connecting = nil;
-- COMPAT: This is a compromise for all you CNAME-(ab)users :)
- if not (reply and reply[1] and reply[1].a) then
+ if not (reply and reply[#reply] and reply[#reply].a) then
local count = max_dns_depth;
reply = dns.peek(connect_host, "CNAME", "IN");
- while count > 0 and reply and reply[1] and not reply[1].a and reply[1].cname do
- log("debug", "Looking up %s (DNS depth is %d)", tostring(reply[1].cname), count);
- reply = dns.peek(reply[1].cname, "A", "IN") or dns.peek(reply[1].cname, "CNAME", "IN");
+ while count > 0 and reply and reply[#reply] and not reply[#reply].a and reply[#reply].cname do
+ log("debug", "Looking up %s (DNS depth is %d)", tostring(reply[#reply].cname), count);
+ reply = dns.peek(reply[#reply].cname, "A", "IN") or dns.peek(reply[#reply].cname, "CNAME", "IN");
count = count - 1;
end
end
-- end of CNAME resolving
- if reply and reply[1] and reply[1].a then
- log("debug", "DNS reply for %s gives us %s", connect_host, reply[1].a);
- return make_connect(host_session, reply[1].a, connect_port);
+ if reply and reply[#reply] and reply[#reply].a then
+ log("debug", "DNS reply for %s gives us %s", connect_host, reply[#reply].a);
+ return make_connect(host_session, reply[#reply].a, connect_port);
else
log("debug", "DNS lookup failed to get a response for %s", connect_host);
if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can
diff --git a/net/dns.lua b/net/dns.lua
index ff07d26e..e793c397 100644
--- a/net/dns.lua
+++ b/net/dns.lua
@@ -95,7 +95,10 @@ local function prune (rrs, time, soft) -- - - - - - - - - - - - - - - prune
if rr.tod then
-- rr.tod = rr.tod - 50 -- accelerated decripitude
rr.ttl = math.floor (rr.tod - time)
- if rr.ttl <= 0 then rrs[i] = nil end
+ if rr.ttl <= 0 then
+ table.remove(rrs, i);
+ return prune(rrs, time, soft); -- Re-iterate
+ end
elseif soft == 'soft' then -- What is this? I forget!
assert (rr.ttl == 0)
@@ -507,8 +510,8 @@ function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers
local resolv_conf = io.open("/etc/resolv.conf");
if resolv_conf then
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
+ local address = line:gsub("#.*$", ""):match('^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$')
+ if address then self:addnameserver (address) end
end
elseif os.getenv("WINDIR") then
self:addnameserver ("208.67.222.222")
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua
index b3963d6c..716c2525 100644
--- a/plugins/mod_console.lua
+++ b/plugins/mod_console.lua
@@ -496,7 +496,7 @@ function def_env.s2s:close(from, to)
if not session then
print("No outgoing connection from "..from.." to "..to)
else
- s2smanager.destroy_session(session);
+ (session.close or s2smanager.destroy_session)(session);
count = count + 1;
print("Closed outgoing session from "..from.." to "..to);
end
@@ -504,7 +504,7 @@ function def_env.s2s:close(from, to)
-- Is an incoming connection
for session in pairs(incoming_s2s) do
if session.to_host == to and session.from_host == from then
- s2smanager.destroy_session(session);
+ (session.close or s2smanager.destroy_session)(session);
count = count + 1;
end
end
diff --git a/plugins/mod_welcome.lua b/plugins/mod_welcome.lua
index 5c0da8b8..e9444363 100644
--- a/plugins/mod_welcome.lua
+++ b/plugins/mod_welcome.lua
@@ -9,7 +9,7 @@
local config = require "core.configmanager";
local host = module:get_host();
-local welcome_text = config.get("*", "core", "welcome_message") or "Hello $user, welcome to the $host IM server!";
+local welcome_text = config.get("*", "core", "welcome_message") or "Hello $username, welcome to the $host IM server!";
local st = require "util.stanza";