304 end |
304 end |
305 -- end of CNAME resolving |
305 -- end of CNAME resolving |
306 |
306 |
307 if reply and reply[#reply] and reply[#reply].a then |
307 if reply and reply[#reply] and reply[#reply].a then |
308 log("debug", "DNS reply for %s gives us %s", connect_host, reply[#reply].a); |
308 log("debug", "DNS reply for %s gives us %s", connect_host, reply[#reply].a); |
309 return make_connect(host_session, reply[#reply].a, connect_port); |
309 local ok, err = make_connect(host_session, reply[#reply].a, connect_port); |
|
310 if not ok then |
|
311 if not attempt_connection(host_session, err or "closed") then |
|
312 err = err and (": "..err) or ""; |
|
313 destroy_session(host_session, "Connection failed"..err); |
|
314 end |
|
315 end |
310 else |
316 else |
311 log("debug", "DNS lookup failed to get a response for %s", connect_host); |
317 log("debug", "DNS lookup failed to get a response for %s", connect_host); |
312 if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can |
318 if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can |
313 log("debug", "No other records to try for %s - destroying", host_session.to_host); |
319 log("debug", "No other records to try for %s - destroying", host_session.to_host); |
314 err = err and (": "..err) or ""; |
320 err = err and (": "..err) or ""; |