Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support resolving from default hosts file #75

Merged
merged 10 commits into from
Aug 18, 2017

Conversation

clue
Copy link
Member

@clue clue commented Aug 16, 2017

TL;DR: Once this is in, you can now create connections to localhost as expected across all platforms (reactphp/socket#88).

This PR adds support for resolving hosts from the system default hosts file. This file is often used for static mappings of certain common hostnames, such as localhost.

The hosts file will be loaded once the Factory creates the Resolver instance. The hosts file is loaded on Unix and Windows based systems alike and if this fails, this will simply be ignored and thus preserves the existing behavior. Windows does not store "localhost" in the hosts file by default, but resolves this internally. This PR also adds static mapping for this, so that the DNS resolver now behaves more like the system resolver.

The hosts file will be preferred for type A (IPv4), AAAA (IPv6) and PTR (reverse DNS) requests. For any other type or if no match is found, it will fall back to the default executor so that this does not affect the existing behavior.

I know this is a pretty big PR, but I've tried to keep the individual commits so reviewing individual changesets may be easier.

Closes #10
Refs reactphp/socket#88

@clue clue added this to the v0.4.11 milestone Aug 16, 2017
@cboden
Copy link
Member

cboden commented Aug 17, 2017

👍

Copy link
Member

@WyriHaximus WyriHaximus left a comment

Choose a reason for hiding this comment

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

Awesome! Tested it on Linux and Windows without any issues 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Added support for /etc/hosts
5 participants