[PR #623] [MERGED] Support Windows hosts file when system configuration is used #1562

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

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/623
Author: @sticnarf
Created: 11/21/2018
Status: Merged
Merged: 11/21/2018
Merged by: @bluejekyll

Base: masterHead: windows-hosts


📝 Commits (2)

  • 6438bf2 Read hosts file on Windows
  • 3a077d5 Simplify code and avoid unnecessary copies

📊 Changes

1 file changed (+33 additions, -20 deletions)

View changed files

📝 crates/resolver/src/hosts.rs (+33 -20)

📄 Description

Resolves #252

I get the Windows system directory path from the environment variable SystemRoot instead of using WINAPI GetSystemDirectory which @briansmith mentioned. I choose this solution because it is simpler and it works on NT systems which are the only Windows systems that Rust supports.

Windows hosts file has the same format as unix hosts file expect that it uses CRLF instead of LF. The previous implementation can obviously deal with it well. So, a separate test is unnecessary in my opinion.

This PR also contains a tiny improvement on reading the hosts file. Some unnecessary copies are avoided.


🔄 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/hickory-dns/hickory-dns/pull/623 **Author:** [@sticnarf](https://github.com/sticnarf) **Created:** 11/21/2018 **Status:** ✅ Merged **Merged:** 11/21/2018 **Merged by:** [@bluejekyll](https://github.com/bluejekyll) **Base:** `master` ← **Head:** `windows-hosts` --- ### 📝 Commits (2) - [`6438bf2`](https://github.com/hickory-dns/hickory-dns/commit/6438bf2c581e21ec5b001efb8a518d00330e3a37) Read hosts file on Windows - [`3a077d5`](https://github.com/hickory-dns/hickory-dns/commit/3a077d5774e9e126cca1ae71e15a9c8e5f9fd8e7) Simplify code and avoid unnecessary copies ### 📊 Changes **1 file changed** (+33 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `crates/resolver/src/hosts.rs` (+33 -20) </details> ### 📄 Description Resolves #252 I get the Windows system directory path from the environment variable `SystemRoot` instead of using WINAPI `GetSystemDirectory` which @briansmith mentioned. I choose this solution because it is simpler and it works on NT systems which are the only Windows systems that Rust supports. Windows hosts file has the same format as unix hosts file expect that it uses CRLF instead of LF. The previous implementation can obviously deal with it well. So, a separate test is unnecessary in my opinion. This PR also contains a tiny improvement on reading the hosts file. Some unnecessary copies are avoided. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 02:13:16 +03:00
Sign in to join this conversation.
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/hickory-dns#1562
No description provided.