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

fix hostsperline to 9 #17

Closed
wants to merge 2 commits into from
Closed

fix hostsperline to 9 #17

wants to merge 2 commits into from

Conversation

tomjn
Copy link
Contributor

@tomjn tomjn commented Mar 22, 2021

Windows does not support more than 9 hosts per line

Windows does not support more than 9 hosts per line
@tomjn tomjn changed the title fix hostsper line to 9 fix hostsperline to 9 Mar 22, 2021
@luthermonson
Copy link
Contributor

this already happens with this https://github.com/goodhosts/hostsfile/blob/master/const_windows.go#L5

@tomjn
Copy link
Contributor Author

tomjn commented Mar 25, 2021

@luthermonson where is that applied though? We were dealing with a user that had 16 entries on a single line

@luthermonson
Copy link
Contributor

it's compiled into the windows executable via build flags. it should be the default. did you try your fix and did it fix it? because it should be the exact same value/logic and if its doing 16 before it will do 16 after your change. basically the logic is these build tags here https://github.com/goodhosts/hostsfile/blob/master/const.go#L1 says this is for anything not windows so windows has it's own consts... this works cause we know the hosts file location changes and it finds the system32/drivers/etc/hosts file

@@ -120,6 +120,7 @@ func (h *Hosts) Add(ip string, hosts ...string) error {
}
h.Lines[position].Hosts = hostsCopy
h.Lines[position].Raw = h.Lines[position].ToRaw() // reset raw
h.HostsPerLine(9) // make sure this does not break on Windows
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@luthermonson is the actual fix that this line should be added but that it shouldn't be hardcoded to 9?

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.

None yet

2 participants