Mercurial > prosody-hg
comparison core/s2smanager.lua @ 1805:7e41ad68fe3c
core.s2smanager: Don't recurse CNAMEs infinitely :)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 21 Sep 2009 14:40:14 +0100 |
| parents | 5f7b2f940816 |
| children | c55e06eb53b2 48cb27e2716e |
comparison
equal
deleted
inserted
replaced
| 1804:f0f5ff6f82d6 | 1805:7e41ad68fe3c |
|---|---|
| 39 | 39 |
| 40 local adns, dns = require "net.adns", require "net.dns"; | 40 local adns, dns = require "net.adns", require "net.dns"; |
| 41 | 41 |
| 42 local connect_timeout = config.get("*", "core", "s2s_timeout") or 60; | 42 local connect_timeout = config.get("*", "core", "s2s_timeout") or 60; |
| 43 local dns_timeout = config.get("*", "core", "dns_timeout") or 60; | 43 local dns_timeout = config.get("*", "core", "dns_timeout") or 60; |
| 44 local max_dns_depth = config.get("*", "core", "dns_max_depth") or 3; | |
| 44 | 45 |
| 45 incoming_s2s = {}; | 46 incoming_s2s = {}; |
| 46 local incoming_s2s = incoming_s2s; | 47 local incoming_s2s = incoming_s2s; |
| 47 | 48 |
| 48 module "s2smanager" | 49 module "s2smanager" |
| 252 handle = nil; | 253 handle = nil; |
| 253 host_session.connecting = nil; | 254 host_session.connecting = nil; |
| 254 | 255 |
| 255 -- COMPAT: This is a compromise for all you CNAME-(ab)users :) | 256 -- COMPAT: This is a compromise for all you CNAME-(ab)users :) |
| 256 if not (reply and reply[1] and reply[1].a) then | 257 if not (reply and reply[1] and reply[1].a) then |
| 258 local count = max_dns_depth; | |
| 257 reply = dns.peek(connect_host, "CNAME", "IN"); | 259 reply = dns.peek(connect_host, "CNAME", "IN"); |
| 258 while reply and reply[1] and not reply[1].a and reply[1].cname do | 260 while count > 0 and reply and reply[1] and not reply[1].a and reply[1].cname do |
| 261 log("debug", "Looking up %s (DNS depth is %d)", tostring(reply[1].cname), count); | |
| 259 reply = dns.peek(reply[1].cname, "A", "IN") or dns.peek(reply[1].cname, "CNAME", "IN"); | 262 reply = dns.peek(reply[1].cname, "A", "IN") or dns.peek(reply[1].cname, "CNAME", "IN"); |
| 263 count = count - 1; | |
| 260 end | 264 end |
| 261 end | 265 end |
| 262 -- end of CNAME resolving | 266 -- end of CNAME resolving |
| 263 | 267 |
| 264 if reply and reply[1] and reply[1].a then | 268 if reply and reply[1] and reply[1].a then |
