Comparison

core/s2smanager.lua @ 1794:218f720af304

Merge with 0.5
author Matthew Wild <mwild1@gmail.com>
date Sat, 19 Sep 2009 17:48:15 +0100
parent 1792:407f282f559e
parent 1793:1fc6c2822e6b
child 1797:a3b0f21c4e37
comparison
equal deleted inserted replaced
1792:407f282f559e 1794:218f720af304
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;
239 host_session.connecting = true; 239 host_session.connecting = true;
240 local handle; 240 local handle;
241 handle = adns.lookup(function (reply) 241 handle = adns.lookup(function (reply)
242 handle = nil; 242 handle = nil;
243 host_session.connecting = nil; 243 host_session.connecting = nil;
244
245 -- COMPAT: This is a compromise for all you CNAME-(ab)users :)
246 if not (reply and reply[1] and reply[1].a) then
247 reply = dns.peek(connect_host, "CNAME", "IN");
248 while reply and reply[1] and not reply[1].a and reply[1].cname do
249 reply = dns.peek(reply[1].cname, "A", "IN") or dns.peek(reply[1].cname, "CNAME", "IN");
250 end
251 end
252 -- end of CNAME resolving
253
244 if reply and reply[1] and reply[1].a then 254 if reply and reply[1] and reply[1].a then
245 log("debug", "DNS reply for %s gives us %s", connect_host, reply[1].a); 255 log("debug", "DNS reply for %s gives us %s", connect_host, reply[1].a);
246 return make_connect(host_session, reply[1].a, connect_port); 256 return make_connect(host_session, reply[1].a, connect_port);
247 else 257 else
248 log("debug", "DNS lookup failed to get a response for %s", connect_host); 258 log("debug", "DNS lookup failed to get a response for %s", connect_host);