Disclaimer: This project is a Rust application developed for educational purposes, specifically to explore and learn about GUI development with the Iced framework, database management with SQLite, and cross-platform compatibility. The code is intended as a learning resource and may not be suitable for production environments.
Host Profiles Manager is a cross-platform desktop application that provides a modern and intuitive interface for managing your system's hosts file. It allows you to create, switch between, and manage multiple host profiles, making it easy to handle different network configurations (e.g., development, staging, production).
The application is built entirely in Rust using the Iced GUI framework and a SQLite database for persistent profile storage.
- Profile Management: Create, select, update, and delete multiple host profiles.
- Persistent Storage: All profiles and their host entries are saved to a SQLite database, ensuring your data is retained between sessions.
- DNS Lookup: Easily add new host entries by performing a DNS lookup for a given hostname.
- Manual Entry: Manually add or edit host entries with specific IP addresses and hostnames.
- Seamless Editing: Modify existing entries directly within the UI, with changes saved automatically to your profile and the
hostsfile. - Import/Export Profiles: Share your host configurations by exporting profiles to a
.jsonfile and importing them on another machine. - Cross-Platform Compatibility: The application is designed to work on Windows, macOS, and Linux. It correctly identifies the OS to manage the
hostsfile and application data paths. - System Permissions Handling: On macOS the app installs a minimal sudoers rule so it can update the
hostsfile without running as root. - Search: Filter host entries by hostname or alias.
- DNS Cache Flush: The system DNS cache is flushed after every change (
mDNSResponderon macOS,ipconfig /flushdnson Windows,resolvectlon Linux), and on demand from the sidebar.
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git cd YOUR_REPO_NAME -
Build the application in release mode:
cargo build --release
The executable will be located in
target/release/.
./scripts/build-dmg.shThis builds the .app bundle with cargo-bundle (installed automatically if missing), signs it ad-hoc and creates target/dmg/HostsManager-<version>.dmg.
The app is not notarized: on first launch right-click the app and choose Open, or run xattr -d com.apple.quarantine /Applications/HostsManager.app.
The application runs as a normal user (do not start it with sudo).
-
macOS: if
/etc/hostsis not writable, click Set up permissions at the bottom of the sidebar. After you enter the administrator password once, the app installs/etc/sudoers.d/hosts-manager, which lets only your user run only this command without a password:<user> ALL=(root) NOPASSWD: /usr/bin/tee /etc/hosts, /usr/bin/killall -HUP mDNSResponderThe second command flushes the DNS cache after every change. If you installed the rule with an older version, the app asks you to update it.
The rule is checked with
visudo -cbefore it is installed, and you can remove it with Remove next to the permission status. -
Linux: add the same rule by hand with
sudo visudo -f /etc/sudoers.d/hosts-manager. -
Windows: right-click
hosts-manager.exeand select "Run as administrator".
The DNS server suggested for lookups can be set with the HOSTS_MANAGER_DNS environment variable. Leave the field empty to use the system DNS.
This project is licensed under the MIT License. See the LICENSE file for details.