[PR #26] [MERGED] fix windows hosts per line problem #36

Closed
opened 2026-03-02 05:08:16 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/goodhosts/hostsfile/pull/26
Author: @luthermonson
Created: 11/30/2021
Status: Merged
Merged: 12/1/2021
Merged by: @luthermonson

Base: masterHead: win-hosts


📝 Commits (2)

  • d63e5fa hostsperline fixing, moves slice funcs to slice.go, add testing
  • bbaa605 vendor

📊 Changes

69 files changed (+23038 additions, -82 deletions)

View changed files

📝 .github/workflows/ci.yml (+1 -8)
const.go (+0 -9)
const_windows.go (+0 -7)
📝 go.mod (+11 -1)
📝 go.sum (+13 -0)
📝 hosts.go (+25 -8)
📝 hosts_test.go (+25 -0)
📝 hostsline.go (+1 -1)
slice.go (+29 -0)
📝 slice_test.go (+0 -0)
📝 utils.go (+7 -48)
utils_windows.go (+12 -0)
vendor/github.com/asaskevich/govalidator/.gitignore (+15 -0)
vendor/github.com/asaskevich/govalidator/.travis.yml (+12 -0)
vendor/github.com/asaskevich/govalidator/CODE_OF_CONDUCT.md (+43 -0)
vendor/github.com/asaskevich/govalidator/CONTRIBUTING.md (+63 -0)
vendor/github.com/asaskevich/govalidator/LICENSE (+21 -0)
vendor/github.com/asaskevich/govalidator/README.md (+622 -0)
vendor/github.com/asaskevich/govalidator/arrays.go (+87 -0)
vendor/github.com/asaskevich/govalidator/converter.go (+81 -0)

...and 49 more files

📄 Description

closes #18

problem: windows has some limits to how many hosts it can have per line and we've seen more issues with 255 char dns limits
fix: rework flush to include a preFlushClean which targets windows/linux. linux is a noop but on windows we will force a 9 hosts per line limit. To accommodate this we have to add a RemoveDuplicateIps at the top of each HostsPerLine call to reset the internal hosts.Lines slice so that the 9/line limit is upheld. A developer who wants to override this can change the const HostsPerLine but use at your own risk on windows with values > 9

important: added a dns name validator which restricts > 255chars and has a regex to make sure weird special chars etc.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/goodhosts/hostsfile/pull/26 **Author:** [@luthermonson](https://github.com/luthermonson) **Created:** 11/30/2021 **Status:** ✅ Merged **Merged:** 12/1/2021 **Merged by:** [@luthermonson](https://github.com/luthermonson) **Base:** `master` ← **Head:** `win-hosts` --- ### 📝 Commits (2) - [`d63e5fa`](https://github.com/goodhosts/hostsfile/commit/d63e5fa5a36a2cfb13e879637f650c8a7be9f8c5) hostsperline fixing, moves slice funcs to slice.go, add testing - [`bbaa605`](https://github.com/goodhosts/hostsfile/commit/bbaa60591a0a92db9f76ee8eadbc90585b50dd36) vendor ### 📊 Changes **69 files changed** (+23038 additions, -82 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+1 -8) ➖ `const.go` (+0 -9) ➖ `const_windows.go` (+0 -7) 📝 `go.mod` (+11 -1) 📝 `go.sum` (+13 -0) 📝 `hosts.go` (+25 -8) 📝 `hosts_test.go` (+25 -0) 📝 `hostsline.go` (+1 -1) ➕ `slice.go` (+29 -0) 📝 `slice_test.go` (+0 -0) 📝 `utils.go` (+7 -48) ➕ `utils_windows.go` (+12 -0) ➕ `vendor/github.com/asaskevich/govalidator/.gitignore` (+15 -0) ➕ `vendor/github.com/asaskevich/govalidator/.travis.yml` (+12 -0) ➕ `vendor/github.com/asaskevich/govalidator/CODE_OF_CONDUCT.md` (+43 -0) ➕ `vendor/github.com/asaskevich/govalidator/CONTRIBUTING.md` (+63 -0) ➕ `vendor/github.com/asaskevich/govalidator/LICENSE` (+21 -0) ➕ `vendor/github.com/asaskevich/govalidator/README.md` (+622 -0) ➕ `vendor/github.com/asaskevich/govalidator/arrays.go` (+87 -0) ➕ `vendor/github.com/asaskevich/govalidator/converter.go` (+81 -0) _...and 49 more files_ </details> ### 📄 Description closes #18 problem: windows has some limits to how many hosts it can have per line and we've seen more issues with 255 char dns limits fix: rework flush to include a preFlushClean which targets windows/linux. linux is a noop but on windows we will force a 9 hosts per line limit. To accommodate this we have to add a `RemoveDuplicateIps` at the top of each HostsPerLine call to reset the internal hosts.Lines slice so that the 9/line limit is upheld. A developer who wants to override this can change the const HostsPerLine but use at your own risk on windows with values > 9 important: added a dns name validator which restricts > 255chars and has a regex to make sure weird special chars etc. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 05:08:16 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hostsfile#36
No description provided.