johnmehr / gitup

A minimalist, dependency-free FreeBSD program to clone/pull Git repositories.
BSD 2-Clause "Simplified" License
51 stars 9 forks source link

change connect behavior: try each address returned by getaddrinfo to connect, not just the first (preferred) one #66

Closed fiebrandt closed 3 years ago

fiebrandt commented 3 years ago

the current code iterates only thru the returned list of getaddrinfo if socket operation is successful. That might not the case for AF_INET6 if IPV6 is disabled in the kernel (as per issue report). The proposal push is a fix using for loop similar to the example approach of man 3 getaddrinfo and move the error handling outside of the loop to make sure we try to connect with all possible addresses returned first. I would leave it to you how to final integrate. This will fix some change behavior that seem to come with 13.0-FREEBSD not returning "in order" the preferred protocol version, but also adds support to "try all connections" which can help in situation where both protocols are configured but only one can reach the destination.