Brifing

Blc: Scheduled Website Blocking for macOS Using Native System Tools

A lightweight macOS utility leveraging launchd and /etc/resolver for domain-level website blocking.

Hacker News: Show HN2 min

1Native macOS Integration Strategy

Blc utilizes built-in macOS components to manage website access without third-party software overhead. By leveraging /etc/resolver, launchd, and Python 3 from Xcode Command Line Tools, the tool creates a lightweight daemon. This approach ensures that blocking mechanisms remain deeply integrated with the operating system's native DNS resolution process for efficiency.

2DNS Resolution Manipulation Mechanism

The tool functions by directing domain lookups to a local loopback address. When a domain is blocked, the daemon updates /etc/resolver to point requests to 127.0.0.1 on port 54. Consequently, Safari receives a 'no such domain' response, effectively preventing access to specified websites and their subdomains through the system's own resolver.

3Configuration and Scheduling Logic

Users manage restrictions via a command-line interface that updates a local JSON configuration file. The root LaunchDaemon monitors this file, re-reading it every two seconds to apply changes. This architecture allows for complex scheduling, such as blocking specific domains during work hours or wrapping time windows past midnight for flexible usage.

4Operational Requirements and Constraints

Successful deployment requires disabling iCloud Private Relay, as this feature bypasses local DNS resolution by routing traffic through Apple servers. Furthermore, browsers like Chrome or Firefox that utilize independent DNS-over-HTTPS settings can circumvent the block. The tool operates on an honor system, as the configuration file remains accessible to the user.

5Pause and Accountability Features

Blc includes a pause functionality allowing temporary access for up to two hours, provided the user supplies a justification comment of at least fifty characters. These comments, along with all block and unblock actions, are recorded in a local log file, creating a historical record of the user's productivity-related behavioral patterns.

6Installation and Removal Workflow

Installation is handled via a shell script that sets up the necessary daemon and dependencies. The uninstallation process is equally straightforward, lifting all active blocks and removing the background daemon while preserving the user's configuration and log files in the home directory for potential future reference or manual data analysis.

7Technical Limitations and Bypasses

The tool is not a foolproof security solution, as it relies on standard DNS resolution paths. Tools like dig or nslookup will ignore /etc/resolver configurations entirely. Additionally, VPN services or applications with custom DNS settings will bypass the restrictions, highlighting the tool's primary role as a productivity aid rather than a firewall.

8Development and Testing Context

The project includes a suite of unit tests accessible via Python to verify the integrity of the blocking logic. By relying on system-native tools rather than kernel extensions, the project maintains high compatibility with macOS updates. It serves as a practical example of using standard system daemons for personal workflow management.

Original article: Hacker News: Show HN — Blc: Scheduled Website Blocking for macOS Using Native System Tools