mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-17 08:55:48 +00:00
Fix handling of hostname with multiple candidate IP addresses when using alternate ports
This commit is contained in:
parent
a290ec032b
commit
5b2cf1b8f7
@ -326,12 +326,33 @@ int LiStartConnection(PSERVER_INFORMATION serverInfo, PSTREAM_CONFIGURATION stre
|
||||
|
||||
Limelog("Resolving host name...");
|
||||
ListenerCallbacks.stageStarting(STAGE_NAME_RESOLUTION);
|
||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, 47984, &RemoteAddr, &RemoteAddrLen);
|
||||
if (err != 0) {
|
||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, 47989, &RemoteAddr, &RemoteAddrLen);
|
||||
LC_ASSERT(RtspPortNumber != 0);
|
||||
if (RtspPortNumber != 48010) {
|
||||
// If we have an alternate RTSP port, use that as our test port. The host probably
|
||||
// isn't listening on 47989 or 47984 anyway, since they're using alternate ports.
|
||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, RtspPortNumber, &RemoteAddr, &RemoteAddrLen);
|
||||
if (err != 0) {
|
||||
// Sleep for a second and try again. It's possible that we've attempt to connect
|
||||
// before the host has gotten around to listening on the RTSP port. Give it some
|
||||
// time before retrying.
|
||||
PltSleepMs(1000);
|
||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, RtspPortNumber, &RemoteAddr, &RemoteAddrLen);
|
||||
}
|
||||
}
|
||||
if (err != 0) {
|
||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, 48010, &RemoteAddr, &RemoteAddrLen);
|
||||
else {
|
||||
// We use TCP 47984 and 47989 first here because we know those should always be listening
|
||||
// on hosts using the standard ports.
|
||||
//
|
||||
// TCP 48010 is a last resort because:
|
||||
// a) it's not always listening and there's a race between listen() on the host and our connect()
|
||||
// b) it's not used at all by certain host versions which perform RTSP over ENet
|
||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, 47984, &RemoteAddr, &RemoteAddrLen);
|
||||
if (err != 0) {
|
||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, 47989, &RemoteAddr, &RemoteAddrLen);
|
||||
}
|
||||
if (err != 0) {
|
||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, 48010, &RemoteAddr, &RemoteAddrLen);
|
||||
}
|
||||
}
|
||||
if (err != 0) {
|
||||
Limelog("failed: %d\n", err);
|
||||
|
Loading…
x
Reference in New Issue
Block a user