# HG changeset patch # User Matthew Wild # Date 1253540414 -3600 # Node ID 7e41ad68fe3c16943ce6ccd72b7e904c34668ce2 # Parent f0f5ff6f82d6ceef032f42faf809ae65d0e3865e core.s2smanager: Don't recurse CNAMEs infinitely :) diff -r f0f5ff6f82d6 -r 7e41ad68fe3c core/s2smanager.lua --- a/core/s2smanager.lua Mon Sep 21 13:53:59 2009 +0100 +++ b/core/s2smanager.lua Mon Sep 21 14:40:14 2009 +0100 @@ -41,6 +41,7 @@ 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 @@ -- 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 -r f0f5ff6f82d6 -r 7e41ad68fe3c net/dns.lua --- a/net/dns.lua Mon Sep 21 13:53:59 2009 +0100 +++ b/net/dns.lua Mon Sep 21 14:40:14 2009 +0100 @@ -504,6 +504,7 @@ 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