FlareSync is a lightweight Rust application that automatically updates your Cloudflare DNS records with your current public IP address. It's designed to run as a background service, periodically checking for IP changes and updating the specified DNS records accordingly.
- Multiple Domain Support: You can now specify multiple domain names to be updated. In your
.envfile, list them as a comma-separated string for theDOMAIN_NAMEvariable (e.g.,DOMAIN_NAME=example.com,sub.example.com). - Major Refactoring: The codebase has been significantly refactored for better readability, maintainability, and performance.
- Docker-Compatible Logs: Logging is now directed to stdout, making it easy to monitor using
docker logs. - Modern Toolchain: The project now uses Rust 1.92 and has all dependencies updated to their latest versions for improved performance and security.
This application was developed using AI. Please note that while AI tools help accelerate development, it is important to review and test the code thoroughly for your specific use cases.
- Periodically checks your current public IP address (using multiple public IP sources for reliability).
- Updates your Cloudflare DNS records only when necessary.
- Asynchronous operation powered by
tokiofor efficiency. - Detailed and structured logging with
log4rs. - Dockerised for easy deployment.
- For improved security, the official Docker image is distroless and runs rootless (non-root).
- Backup of DNS records before updates.
- Retry mechanism with exponential backoff for improved reliability.
- Rust (if building from source)
- Docker (for containerized deployment)
- A Cloudflare account with an API token.
The recommended way to run FlareSync is using Docker or Docker Compose.
-
Clone the repository:
git clone https://github.com/BattermanZ/FlareSync.git cd FlareSync -
Set up your environment: Create a
.envfile by copying the example file:cp .env.example .env
Edit the
.envfile and fill in your details. See the Configuration section for more details on the environment variables.
docker run -d \
--name flaresync \
--env-file .env \
-v $(pwd)/logs:/app/logs \
-v $(pwd)/backups:/app/backups \
--restart unless-stopped \
battermanz/flaresync:latestThis is the recommended method for deployment.
docker-compose up -dThe docker-compose.yml file is already included in the repository. For reference, it contains:
services:
flaresync:
image: battermanz/flaresync:latest
container_name: flaresync
env_file:
- .env
volumes:
- ./backups:/app/backups
restart: unless-stoppedIf you prefer to build from source:
- Make sure you have Rust installed (min. version 1.70).
- Set up your
.envfile as described above. The application will load it automatically. - Build and run the application:
cargo run --release
This project uses environment variables for configuration. Create a .env file in the project root by copying the .env.example file.
| Variable | Description | Default |
|---|---|---|
CLOUDFLARE_API_TOKEN |
Your Cloudflare API token. | (required) |
CLOUDFLARE_ZONE_ID |
The Zone ID of your domain. | (required) |
DOMAIN_NAME |
A single domain or multiple domains separated by commas (e.g., domain1.com,domain2.com). |
(required) |
UPDATE_INTERVAL |
The update interval in minutes. | 5 |
TZ |
The timezone for the container. | Etc/UTC |
PUID |
The user ID for file permissions. | 1000 |
PGID |
The group ID for file permissions. | 1000 |
Make sure your .env file is in the same directory as the docker-compose.yml file.
DNS record backups are stored in the backups directory. A new backup is created each time a DNS record is updated.
Keep your .env file secure and avoid sharing it publicly. It contains sensitive information like your Cloudflare API token.
The following diagram shows the overall system architecture of FlareSync:
+-------------------+ +------------------+ +-------------------+
| Public IP API | <---> | FlareSync | <---> | Cloudflare API |
+-------------------+ +------------------+ +-------------------+
| | |
| | |
[Check IP] [Update DNS Record] [Update Confirmed]
This diagram helps illustrate how FlareSync interacts with public IP services and Cloudflare to maintain updated DNS records.
This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request.
- Built with Rust 🦀
- Powered by
tokio,reqwest, andlog4rs. - Thanks to Cloudflare for their powerful API.
For any questions or issues, feel free to open an issue on this repository.