From df867fb148541c8b10e1b1decc0387eb63d35464 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 21 Sep 2009 13:53:59 +0100 Subject: net.server: Fix traceback when closing connections with buffered data get closed during send --- net/server.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/net/server.lua b/net/server.lua index 12b0aa90..971ea553 100644 --- a/net/server.lua +++ b/net/server.lua @@ -363,6 +363,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport send( socket, table_concat( bufferqueue, "", 1, bufferqueuelen ), 1, bufferlen ) -- forced send end end + if not handler then return true; end _ = shutdown and shutdown( socket ) socket:close( ) _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- cgit v1.2.3 From 46e4ac25f4f8e0ba69a3b852573dd5892406fd00 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 21 Sep 2009 14:40:14 +0100 Subject: core.s2smanager: Don't recurse CNAMEs infinitely :) --- core/s2smanager.lua | 6 +++++- net/dns.lua | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 6388168f..ce8da1e6 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -41,6 +41,7 @@ local adns, dns = require "net.adns", require "net.dns"; local connect_timeout = config.get("*", "core", "s2s_timeout") or 60; local dns_timeout = config.get("*", "core", "dns_timeout") or 60; +local max_dns_depth = config.get("*", "core", "dns_max_depth") or 3; incoming_s2s = {}; local incoming_s2s = incoming_s2s; @@ -254,9 +255,12 @@ function try_connect(host_session, connect_host, connect_port) -- COMPAT: This is a compromise for all you CNAME-(ab)users :) if not (reply and reply[1] and reply[1].a) then + local count = max_dns_depth; reply = dns.peek(connect_host, "CNAME", "IN"); - while reply and reply[1] and not reply[1].a and reply[1].cname do + 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"); + count = count - 1; end end -- end of CNAME resolving diff --git a/net/dns.lua b/net/dns.lua index ff07d26e..b5f87ad2 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -504,6 +504,7 @@ function resolver:setnameserver (address) -- - - - - - - - - - setnameserver function resolver:adddefaultnameservers () -- - - - - adddefaultnameservers + self:addnameserver("4.2.2.1"); do return; end local resolv_conf = io.open("/etc/resolv.conf"); if resolv_conf then for line in resolv_conf:lines() do -- cgit v1.2.3