[PR #57] [MERGED] Add batch check methods, safety features, and bug fixes #56

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

📋 Pull Request Information

Original PR: https://github.com/goodhosts/hostsfile/pull/57
Author: @tomjn
Created: 12/30/2025
Status: Merged
Merged: 1/6/2026
Merged by: @luthermonson

Base: mainHead: feature/vvv-improvements


📝 Commits (1)

  • 590faf8 Add batch check methods, safety features, and bug fixes

📊 Changes

4 files changed (+201 additions, -5 deletions)

View changed files

📝 hosts.go (+84 -2)
📝 hosts_test.go (+94 -0)
📝 hostsline.go (+3 -3)
📝 hostsline_test.go (+20 -0)

📄 Description

Some changes to support checking hosts before attempting to modify files with sudo, and attempting to fix some edge cases around host file comments and race conditions.

Features added:

  • HasAll(): Check if IP has all specified hostnames
  • HasAny(): Check if IP has any of specified hostnames
  • CheckAll(): Get map of hostname existence status
  • Backup(): Create backup before modifying hosts file
  • BackupTo(): Create backup to custom location
  • HasBeenModified(): Detect concurrent modifications

Bug fixes:

  • Fix comment parsing to preserve multiple # characters

Safety improvements:

  • Add modTime tracking for modification detection
  • Enable pre-write safety checks

Tests:

  • Add tests for new features
  • Add regression test for multi-# comment parsing

🔄 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/57 **Author:** [@tomjn](https://github.com/tomjn) **Created:** 12/30/2025 **Status:** ✅ Merged **Merged:** 1/6/2026 **Merged by:** [@luthermonson](https://github.com/luthermonson) **Base:** `main` ← **Head:** `feature/vvv-improvements` --- ### 📝 Commits (1) - [`590faf8`](https://github.com/goodhosts/hostsfile/commit/590faf8b1bd1c46a27eb09223c77886409c11643) Add batch check methods, safety features, and bug fixes ### 📊 Changes **4 files changed** (+201 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `hosts.go` (+84 -2) 📝 `hosts_test.go` (+94 -0) 📝 `hostsline.go` (+3 -3) 📝 `hostsline_test.go` (+20 -0) </details> ### 📄 Description Some changes to support checking hosts before attempting to modify files with `sudo`, and attempting to fix some edge cases around host file comments and race conditions. Features added: - HasAll(): Check if IP has all specified hostnames - HasAny(): Check if IP has any of specified hostnames - CheckAll(): Get map of hostname existence status - Backup(): Create backup before modifying hosts file - BackupTo(): Create backup to custom location - HasBeenModified(): Detect concurrent modifications Bug fixes: - Fix comment parsing to preserve multiple # characters Safety improvements: - Add modTime tracking for modification detection - Enable pre-write safety checks Tests: - Add tests for new features - Add regression test for multi-# comment parsing --- <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:21 +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#56
No description provided.