Attempt to use AF_UNIX sockets instead of AF_INET on Windows 10+ #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is based on the improvements we made in OpenConnect in https://gitlab.com/openconnect/openconnect/-/merge_requests/320.
Unfortunately, and maddeningly, it's possible for the local IPv4 routes (127.0.0.0/8) to be deleted on Windows; this will prevent dumb_socketpair() from working in its current form. Using AF_UNIX sockets
In order to deal with the above weaknesses, the approach taken here is to first try creating an AF_UNIX socketpair, and then to fallback to AF_INET if it fails. Furthermore, because the AF_UNIX socketpair requires a real, writable filesystem path, it tries binding to each of the following before giving up on AF_UNIX:
Based on testing so far, this implementation appears to be robust and to avoid the problems with deleted IPv4 localhost routes.
Also adds a stub for the <afunix.h>, which defines
UNIX_PATH_MAX
andstruct sockaddr_un
. MinGW lacks this header, but other FLOSS projects show how to embed the needed definitions: