Mercurial > prosody-hg
comparison core/s2smanager.lua @ 4422:c25dee24623f
s2smanager, net.dns: Fix handling for NXNAME and SRV target of "."
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Wed, 26 Oct 2011 02:03:33 +0200 |
| parents | 971a66627f7a |
| children | bbede0141f7e |
comparison
equal
deleted
inserted
replaced
| 4421:971a66627f7a | 4422:c25dee24623f |
|---|---|
| 244 local srv_hosts = {}; | 244 local srv_hosts = {}; |
| 245 host_session.srv_hosts = srv_hosts; | 245 host_session.srv_hosts = srv_hosts; |
| 246 for _, record in ipairs(answer) do | 246 for _, record in ipairs(answer) do |
| 247 t_insert(srv_hosts, record.srv); | 247 t_insert(srv_hosts, record.srv); |
| 248 end | 248 end |
| 249 if #srv_hosts == 1 and srv_hosts[1].target == "." then | |
| 250 log("debug", to_host.." does not provide a XMPP service"); | |
| 251 destroy_session(host_session, err); -- Nothing to see here | |
| 252 return; | |
| 253 end | |
| 249 t_sort(srv_hosts, compare_srv_priorities); | 254 t_sort(srv_hosts, compare_srv_priorities); |
| 250 | 255 |
| 251 local srv_choice = srv_hosts[1]; | 256 local srv_choice = srv_hosts[1]; |
| 252 host_session.srv_choice = 1; | 257 host_session.srv_choice = 1; |
| 253 if srv_choice then | 258 if srv_choice then |
| 345 IPs[#IPs+1] = new_ip(ip.a, "IPv4"); | 350 IPs[#IPs+1] = new_ip(ip.a, "IPv4"); |
| 346 end | 351 end |
| 347 end | 352 end |
| 348 | 353 |
| 349 if has_other then | 354 if has_other then |
| 350 rfc3484_dest(host_session.ip_hosts, sources); | 355 if #IPs > 0 then |
| 351 host_session.ip_choice = 0; | 356 rfc3484_dest(host_session.ip_hosts, sources); |
| 352 try_next_ip(host_session, connect_port); | 357 host_session.ip_choice = 0; |
| 358 try_next_ip(host_session, connect_port); | |
| 359 else | |
| 360 log("debug", "DNS lookup failed to get a response for %s", connect_host); | |
| 361 host_session.ip_hosts = nil; | |
| 362 if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can | |
| 363 log("debug", "No other records to try for %s - destroying", host_session.to_host); | |
| 364 err = err and (": "..err) or ""; | |
| 365 destroy_session(host_session, "DNS resolution failed"..err); -- End of the line, we can't | |
| 366 end | |
| 367 end | |
| 353 else | 368 else |
| 354 has_other = true; | 369 has_other = true; |
| 355 end | 370 end |
| 356 end, connect_host, "A", "IN"); | 371 end, connect_host, "A", "IN"); |
| 357 | 372 |
| 364 IPs[#IPs+1] = new_ip(ip.aaaa, "IPv6"); | 379 IPs[#IPs+1] = new_ip(ip.aaaa, "IPv6"); |
| 365 end | 380 end |
| 366 end | 381 end |
| 367 | 382 |
| 368 if has_other then | 383 if has_other then |
| 369 rfc3484_dest(host_session.ip_hosts, sources); | 384 if #IPs > 0 then |
| 370 host_session.ip_choice = 0; | 385 rfc3484_dest(host_session.ip_hosts, sources); |
| 371 try_next_ip(host_session, connect_port); | 386 host_session.ip_choice = 0; |
| 387 try_next_ip(host_session, connect_port); | |
| 388 else | |
| 389 log("debug", "DNS lookup failed to get a response for %s", connect_host); | |
| 390 host_session.ip_hosts = nil; | |
| 391 if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can | |
| 392 log("debug", "No other records to try for %s - destroying", host_session.to_host); | |
| 393 err = err and (": "..err) or ""; | |
| 394 destroy_session(host_session, "DNS resolution failed"..err); -- End of the line, we can't | |
| 395 end | |
| 396 end | |
| 372 else | 397 else |
| 373 has_other = true; | 398 has_other = true; |
| 374 end | 399 end |
| 375 end, connect_host, "AAAA", "IN"); | 400 end, connect_host, "AAAA", "IN"); |
| 376 | 401 |
