[PR #25] [CLOSED] hostsperline fixing, moves slice funcs to slice.go, add testing #35

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/25
Author: @luthermonson
Created: 11/30/2021
Status: Closed

Base: masterHead: windows-hostsperline


📝 Commits (3)

  • 5d51567 update ci workflow + bump go to 1.17
  • 19c3246 hostsperline fixing, moves slice funcs to slice.go, add testing
  • 799ff47 vendor

📊 Changes

72 files changed (+23065 additions, -97 deletions)

View changed files

📝 .github/workflows/ci.yml (+6 -12)
const.go (+0 -9)
const_windows.go (+0 -7)
📝 go.mod (+12 -2)
📝 go.sum (+15 -2)
📝 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 52 more files

📄 Description

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/25 **Author:** [@luthermonson](https://github.com/luthermonson) **Created:** 11/30/2021 **Status:** ❌ Closed **Base:** `master` ← **Head:** `windows-hostsperline` --- ### 📝 Commits (3) - [`5d51567`](https://github.com/goodhosts/hostsfile/commit/5d51567c4bd121e10ffb0336c6b4ee695e56dbc0) update ci workflow + bump go to 1.17 - [`19c3246`](https://github.com/goodhosts/hostsfile/commit/19c324644eefc0ac2567e42685cc3adc6911f8de) hostsperline fixing, moves slice funcs to slice.go, add testing - [`799ff47`](https://github.com/goodhosts/hostsfile/commit/799ff47db70f7ab1ce1c175658a9d22ff2f91ecc) vendor ### 📊 Changes **72 files changed** (+23065 additions, -97 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+6 -12) ➖ `const.go` (+0 -9) ➖ `const_windows.go` (+0 -7) 📝 `go.mod` (+12 -2) 📝 `go.sum` (+15 -2) 📝 `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 52 more files_ </details> ### 📄 Description 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#35
No description provided.