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

added support for CRLF on windows to avoid max aliases per line issue #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dwkerwin
Copy link

I've been using this for a while, and even though on Windows when you view the hosts file everything appears to be on one line, it has been working. I recently noticed that if you have a lot of host aliases on the same machine the ones at the end aren't honored, and then discovered that there is a limit on Windows of 9 aliases per line. So this small fix uses the environment specific newline terminator, so "\r\n" for Windows and "\n" for all other environments.

@dwkerwin
Copy link
Author

The first commit didn't completely solve the problem. Line terminations were right but it was still flattening the hosts to a single line. In the use case where you have multiple (> 10) hostnames which you want to all point to a single IP (typically 127.0.0.1), this exceeds the Windows limit of 9 per line. This change prevents this flattening for Windows while continuing to be idempotent, preventing duplicate entries by hostname rather than IP address.

@dwkerwin
Copy link
Author

It looks like the Travis CI errors are unrelated to my changes. Please let me know if this is not the case or how I could help.

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

Successfully merging this pull request may close these issues.

1 participant