Better HN
topnewbestaskshowjobs
Log inSign up

heroncoder

3 karma · joined Jul 20, 2026 (4mo ago) · 4 submissions

Independent developer. I make a native Mac app for debugging traffic from phones and WebViews. https://getheron.app
Submissions

comment 3mo ago · link · parent

Author here. One implementation detail that may be interesting: the drift check is enforced inside the privileged write transaction, not just by the UI watcher.

The daemon receives the fully rendered hosts content, its target hash, the expected hash of the live /etc/hosts file, and a merge ID. Under a transaction lock, it hashes the live file and rejects the request if the expected hash no longer matches. It writes and fsyncs a temporary file, then rereads /etc/hosts immediately before rename; if the bytes changed between those two reads, it aborts instead of overwriting them. Only then does it atomically rename the temporary file and flush DNS.

The daemon exposes only that merge operation over XPC, and the app and daemon verify each other's signing identity. I'm happy to discuss the TOCTOU/drift tradeoffs, SMAppService, or the packaging and notarization side.

2.

Show HN: Hostflip – a macOS /etc/hosts switcher that detects external edits(github.com ↗)

3 points · by heroncoder · 3mo ago · 1 comment

comment 4mo ago · link · parent

Good,this is very helpful for handling the layout in the print template.