dnsproxy is a tool designed to simplify the lives of developers who need to switch between different environments (local, development, production) for their websites. Instead of manually editing hosts files to see how a site looks across different stages, dnsproxy allows you to quickly switch DNS configurations with the click of a button.
- Environment Switching: Easily switch between local, development, production, and world environments.
- Automatic DNS Configuration: Automatically sets and resets DNS configurations on startup and exit.
- Cross-Platform Support: Works on macOS, Linux, and Windows.
- Web Interface: Simple web interface for switching environments.
- Administrative privileges (for setting DNS configurations)
-
Download the binary:
Go to the Releases page and download the appropriate binary for your operating system.
-
Extract the binary:
Extract the downloaded archive to a directory of your choice.
-
Create a
hosts.jsonconfiguration file in the same directory as the binary.
-
Run the program with administrative privileges:
- On macOS or Linux:
sudo ./dnsproxy
- On Windows:
.\dnsproxy.exe
- On macOS or Linux:
-
Access the web interface:
Open a web browser and navigate to
http://localhost:5000. -
Switch environments:
Use the provided buttons to switch between
local,dev,prod, andworldenvironments.
The hosts.json file should contain the environments and the sites you want to handle. Example structure:
{
"environment": {
"local": "127.0.0.1",
"dev": "1.2.3.4",
"prod": "5.6.7.8",
"world": ""
},
"sites": [
"test.com",
"example.com"
]
}- environment: Maps environment names to IP addresses.
- sites: List of domain names you want to manage.
- DNS Handling: When a DNS query is received, the tool checks if the queried domain matches any site in the configuration. If it matches, it responds with the IP address of the current environment.
- Environment Switching: A web interface allows switching between environments by updating the current environment variable.
- System DNS Management: On startup, the tool sets the system's DNS to
127.0.0.1and resets it to the original configuration on exit.
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request with a clear description of your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
For issues and feature requests, please visit the GitHub Issues page.
Happy coding! 🚀