Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/shared/inc/conncheckshared.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ using unique_socket = wil::unique_fd;

enum class ConnCheckStatus
{
InProgress,
Success,
FailureGetAddrInfo,
FailureConfig,
FailureSocketConnect,
InProgress = 0,
Success = 1,
FailureGetAddrInfo = 2,
FailureConfig = 3,
FailureSocketConnect = 4,
NoRecordsForFamily = 5,
};
Comment on lines 47 to 55

struct ConnCheckResult
Expand Down Expand Up @@ -116,6 +117,15 @@ inline unique_socket ConnCheckConnectSocket(int family, const char* hostname, co
auto status = getaddrinfo(hostname, port, &hints, &servinfo);
if (status != 0)
{
if (status == EAI_NODATA || status == EAI_NONAME) // Check for both as EAI_NODATA is deprecated on newer linux versions
{
Comment on lines +120 to +121
// EAI_NODATA means the domain exists but lacks records for the requested
// address family (A for IPv4, AAAA for IPv6). This is expected behavior
// for domains that are IPv4-only or IPv6-only.
// This is not treated as an error; we simply skip this address family and
// continue testing the other protocols.
*connCheckStatus = ConnCheckStatus::NoRecordsForFamily;
}
Comment on lines +120 to +128
throw std::runtime_error(std::format("CheckConnection: getaddrinfo() failed: {}", status));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should only throw in an else branch, right? (if status != EAI_NODATA and status != EAI_NONAME)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also: we should immediately return so we don't continue this function.

}
Comment on lines +120 to 130

Comment on lines 129 to 131
Expand Down
Loading