diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-09-21 14:40:14 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-09-21 14:40:14 +0100 |
commit | 46e4ac25f4f8e0ba69a3b852573dd5892406fd00 (patch) | |
tree | 33d7f4755cf45868d95733266b7f132ad3b2ea1b /core/s2smanager.lua | |
parent | df867fb148541c8b10e1b1decc0387eb63d35464 (diff) | |
download | prosody-46e4ac25f4f8e0ba69a3b852573dd5892406fd00.tar.gz prosody-46e4ac25f4f8e0ba69a3b852573dd5892406fd00.zip |
core.s2smanager: Don't recurse CNAMEs infinitely :)
Diffstat (limited to 'core/s2smanager.lua')
-rw-r--r-- | core/s2smanager.lua | 6 |
1 files changed, 5 insertions, 1 deletions
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 |