Software /
code /
prosody
Comparison
core/s2smanager.lua @ 1793:1fc6c2822e6b
s2smanager: Compatibility with domains which use CNAMEs
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 19 Sep 2009 17:47:26 +0100 |
parent | 1791:42d0b68a1efd |
child | 1794:218f720af304 |
child | 1796:5f7b2f940816 |
comparison
equal
deleted
inserted
replaced
1791:42d0b68a1efd | 1793:1fc6c2822e6b |
---|---|
35 | 35 |
36 local sha256_hash = require "util.hashes".sha256; | 36 local sha256_hash = require "util.hashes".sha256; |
37 | 37 |
38 local dialback_secret = uuid_gen(); | 38 local dialback_secret = uuid_gen(); |
39 | 39 |
40 local adns = require "net.adns"; | 40 local adns, dns = require "net.adns", require "net.dns"; |
41 | 41 |
42 local dns_timeout = config.get("*", "core", "dns_timeout") or 60; | 42 local dns_timeout = config.get("*", "core", "dns_timeout") or 60; |
43 | 43 |
44 incoming_s2s = {}; | 44 incoming_s2s = {}; |
45 local incoming_s2s = incoming_s2s; | 45 local incoming_s2s = incoming_s2s; |
238 host_session.connecting = true; | 238 host_session.connecting = true; |
239 local handle; | 239 local handle; |
240 handle = adns.lookup(function (reply) | 240 handle = adns.lookup(function (reply) |
241 handle = nil; | 241 handle = nil; |
242 host_session.connecting = nil; | 242 host_session.connecting = nil; |
243 | |
244 -- COMPAT: This is a compromise for all you CNAME-(ab)users :) | |
245 if not (reply and reply[1] and reply[1].a) then | |
246 reply = dns.peek(connect_host, "CNAME", "IN"); | |
247 while reply and reply[1] and not reply[1].a and reply[1].cname do | |
248 reply = dns.peek(reply[1].cname, "A", "IN") or dns.peek(reply[1].cname, "CNAME", "IN"); | |
249 end | |
250 end | |
251 -- end of CNAME resolving | |
252 | |
243 if reply and reply[1] and reply[1].a then | 253 if reply and reply[1] and reply[1].a then |
244 log("debug", "DNS reply for %s gives us %s", connect_host, reply[1].a); | 254 log("debug", "DNS reply for %s gives us %s", connect_host, reply[1].a); |
245 return make_connect(host_session, reply[1].a, connect_port); | 255 return make_connect(host_session, reply[1].a, connect_port); |
246 else | 256 else |
247 log("debug", "DNS lookup failed to get a response for %s", connect_host); | 257 log("debug", "DNS lookup failed to get a response for %s", connect_host); |