Software /
code /
prosody
Comparison
plugins/mod_s2s/s2sout.lib.lua @ 4957:1722a6bea115
mod_s2s/s2sout.lib: Don't wait for both v4 and v6 DNS responses if we only send one (e.g. because v6 is disabled)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 22 Jul 2012 16:17:04 +0100 |
parent | 4923:760a1f367f02 |
child | 4959:ab696f5394cf |
comparison
equal
deleted
inserted
replaced
4955:4f1b6a4784f9 | 4957:1722a6bea115 |
---|---|
168 | 168 |
169 if not err then | 169 if not err then |
170 local IPs = {}; | 170 local IPs = {}; |
171 host_session.ip_hosts = IPs; | 171 host_session.ip_hosts = IPs; |
172 local handle4, handle6; | 172 local handle4, handle6; |
173 local has_other = false; | 173 local have_other_result = not(has_ipv4) or not(has_ipv6) or false; |
174 | 174 |
175 if has_ipv4 then | 175 if has_ipv4 then |
176 handle4 = adns.lookup(function (reply, err) | 176 handle4 = adns.lookup(function (reply, err) |
177 handle4 = nil; | 177 handle4 = nil; |
178 | 178 |
193 log("debug", "DNS reply for %s gives us %s", connect_host, ip.a); | 193 log("debug", "DNS reply for %s gives us %s", connect_host, ip.a); |
194 IPs[#IPs+1] = new_ip(ip.a, "IPv4"); | 194 IPs[#IPs+1] = new_ip(ip.a, "IPv4"); |
195 end | 195 end |
196 end | 196 end |
197 | 197 |
198 if has_other then | 198 if have_other_result then |
199 if #IPs > 0 then | 199 if #IPs > 0 then |
200 rfc3484_dest(host_session.ip_hosts, sources); | 200 rfc3484_dest(host_session.ip_hosts, sources); |
201 for i = 1, #IPs do | 201 for i = 1, #IPs do |
202 IPs[i] = {ip = IPs[i], port = connect_port}; | 202 IPs[i] = {ip = IPs[i], port = connect_port}; |
203 end | 203 end |
211 err = err and (": "..err) or ""; | 211 err = err and (": "..err) or ""; |
212 s2s_destroy_session(host_session, "DNS resolution failed"..err); -- End of the line, we can't | 212 s2s_destroy_session(host_session, "DNS resolution failed"..err); -- End of the line, we can't |
213 end | 213 end |
214 end | 214 end |
215 else | 215 else |
216 has_other = true; | 216 have_other_result = true; |
217 end | 217 end |
218 end, connect_host, "A", "IN"); | 218 end, connect_host, "A", "IN"); |
219 else | 219 else |
220 has_other = true; | 220 have_other_result = true; |
221 end | 221 end |
222 | 222 |
223 if has_ipv6 then | 223 if has_ipv6 then |
224 handle6 = adns.lookup(function (reply, err) | 224 handle6 = adns.lookup(function (reply, err) |
225 handle6 = nil; | 225 handle6 = nil; |
229 log("debug", "DNS reply for %s gives us %s", connect_host, ip.aaaa); | 229 log("debug", "DNS reply for %s gives us %s", connect_host, ip.aaaa); |
230 IPs[#IPs+1] = new_ip(ip.aaaa, "IPv6"); | 230 IPs[#IPs+1] = new_ip(ip.aaaa, "IPv6"); |
231 end | 231 end |
232 end | 232 end |
233 | 233 |
234 if has_other then | 234 if have_other_result then |
235 if #IPs > 0 then | 235 if #IPs > 0 then |
236 rfc3484_dest(host_session.ip_hosts, sources); | 236 rfc3484_dest(host_session.ip_hosts, sources); |
237 for i = 1, #IPs do | 237 for i = 1, #IPs do |
238 IPs[i] = {ip = IPs[i], port = connect_port}; | 238 IPs[i] = {ip = IPs[i], port = connect_port}; |
239 end | 239 end |
247 err = err and (": "..err) or ""; | 247 err = err and (": "..err) or ""; |
248 s2s_destroy_session(host_session, "DNS resolution failed"..err); -- End of the line, we can't | 248 s2s_destroy_session(host_session, "DNS resolution failed"..err); -- End of the line, we can't |
249 end | 249 end |
250 end | 250 end |
251 else | 251 else |
252 has_other = true; | 252 have_other_result = true; |
253 end | 253 end |
254 end, connect_host, "AAAA", "IN"); | 254 end, connect_host, "AAAA", "IN"); |
255 else | 255 else |
256 has_other = true; | 256 have_other_result = true; |
257 end | 257 end |
258 | |
259 return true; | 258 return true; |
260 elseif host_session.ip_hosts and #host_session.ip_hosts > host_session.ip_choice then -- Not our first attempt, and we also have IPs left to try | 259 elseif host_session.ip_hosts and #host_session.ip_hosts > host_session.ip_choice then -- Not our first attempt, and we also have IPs left to try |
261 s2sout.try_next_ip(host_session); | 260 s2sout.try_next_ip(host_session); |
262 else | 261 else |
263 host_session.ip_hosts = nil; | 262 host_session.ip_hosts = nil; |