Mercurial > prosody-hg
comparison core/s2smanager.lua @ 4443:7456ddcc0b14
s2smanager: Store port specified by SRV records
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Wed, 07 Dec 2011 23:37:56 +0100 |
| parents | bbede0141f7e |
| children | 447234173e9e |
comparison
equal
deleted
inserted
replaced
| 4442:bc0a68cae236 | 4443:7456ddcc0b14 |
|---|---|
| 293 end | 293 end |
| 294 | 294 |
| 295 return try_connect(host_session, connect_host, connect_port); | 295 return try_connect(host_session, connect_host, connect_port); |
| 296 end | 296 end |
| 297 | 297 |
| 298 function try_next_ip(host_session, connect_port) | 298 function try_next_ip(host_session) |
| 299 host_session.connecting = nil; | 299 host_session.connecting = nil; |
| 300 host_session.ip_choice = host_session.ip_choice + 1; | 300 host_session.ip_choice = host_session.ip_choice + 1; |
| 301 local ip = host_session.ip_hosts[host_session.ip_choice]; | 301 local ip = host_session.ip_hosts[host_session.ip_choice]; |
| 302 local ok, err= make_connect(host_session, ip, connect_port); | 302 local ok, err= make_connect(host_session, ip.ip, ip.port); |
| 303 if not ok then | 303 if not ok then |
| 304 if not attempt_connection(host_session, err or "closed") then | 304 if not attempt_connection(host_session, err or "closed") then |
| 305 err = err and (": "..err) or ""; | 305 err = err and (": "..err) or ""; |
| 306 destroy_session(host_session, "Connection failed"..err); | 306 destroy_session(host_session, "Connection failed"..err); |
| 307 end | 307 end |
| 352 end | 352 end |
| 353 | 353 |
| 354 if has_other then | 354 if has_other then |
| 355 if #IPs > 0 then | 355 if #IPs > 0 then |
| 356 rfc3484_dest(host_session.ip_hosts, sources); | 356 rfc3484_dest(host_session.ip_hosts, sources); |
| 357 for i = 1, #IPs do | |
| 358 IPs[i] = {ip = IPs[i], port = connect_port}; | |
| 359 end | |
| 357 host_session.ip_choice = 0; | 360 host_session.ip_choice = 0; |
| 358 try_next_ip(host_session, connect_port); | 361 try_next_ip(host_session); |
| 359 else | 362 else |
| 360 log("debug", "DNS lookup failed to get a response for %s", connect_host); | 363 log("debug", "DNS lookup failed to get a response for %s", connect_host); |
| 361 host_session.ip_hosts = nil; | 364 host_session.ip_hosts = nil; |
| 362 if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can | 365 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); | 366 log("debug", "No other records to try for %s - destroying", host_session.to_host); |
| 381 end | 384 end |
| 382 | 385 |
| 383 if has_other then | 386 if has_other then |
| 384 if #IPs > 0 then | 387 if #IPs > 0 then |
| 385 rfc3484_dest(host_session.ip_hosts, sources); | 388 rfc3484_dest(host_session.ip_hosts, sources); |
| 389 for i = 1, #IPs do | |
| 390 IPs[i] = {ip = IPs[i], port = connect_port}; | |
| 391 end | |
| 386 host_session.ip_choice = 0; | 392 host_session.ip_choice = 0; |
| 387 try_next_ip(host_session, connect_port); | 393 try_next_ip(host_session); |
| 388 else | 394 else |
| 389 log("debug", "DNS lookup failed to get a response for %s", connect_host); | 395 log("debug", "DNS lookup failed to get a response for %s", connect_host); |
| 390 host_session.ip_hosts = nil; | 396 host_session.ip_hosts = nil; |
| 391 if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can | 397 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); | 398 log("debug", "No other records to try for %s - destroying", host_session.to_host); |
| 399 end | 405 end |
| 400 end, connect_host, "AAAA", "IN"); | 406 end, connect_host, "AAAA", "IN"); |
| 401 | 407 |
| 402 return true; | 408 return true; |
| 403 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 | 409 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 |
| 404 try_next_ip(host_session, connect_port); | 410 try_next_ip(host_session); |
| 405 else | 411 else |
| 406 host_session.ip_hosts = nil; | 412 host_session.ip_hosts = nil; |
| 407 if not attempt_connection(host_session, "out of IP addresses") then -- Retry if we can | 413 if not attempt_connection(host_session, "out of IP addresses") then -- Retry if we can |
| 408 log("debug", "No other records to try for %s - destroying", host_session.to_host); | 414 log("debug", "No other records to try for %s - destroying", host_session.to_host); |
| 409 err = err and (": "..err) or ""; | 415 err = err and (": "..err) or ""; |
