Skip to content

catalogfi/cloudflare-dns-watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare DNS Monitoring Tool

A Rust-based DNS monitoring tool that watches for changes in Cloudflare DNS records and sends notifications through Discord webhooks.

Features

  • 🔍 Monitors DNS records across multiple Cloudflare zones
  • 🔄 Real-time detection of DNS record changes
  • 📊 Tracks additions, modifications, and deletions of DNS records
  • 💾 SQLite-based persistent storage for tracking changes
  • 🚨 Discord notifications with detailed alerts
  • 🔐 Secure API authentication using Cloudflare tokens

Prerequisites

  • Rust and Cargo installed
  • Cloudflare API token with DNS permissions
  • Discord webhook URL
  • SQLite

Installation

  1. Clone the repository
  2. Build the project:
cargo build --release

Configuration

Create a config.toml file in the project root with the following structure:

api_endpoint = "https://api.
cloudflare.com/client/v4"
api_token = 
"your-cloudflare-api-token"
discord_webhook_url = 
"your-discord-webhook-url"

Usage

Run the application:

cargo run --release

The application will:

  1. Load all existing DNS records from your Cloudflare zones
  2. Start monitoring for changes
  3. Send Discord notifications when:
    • New DNS records are added
    • Existing records are modified
    • Records are deleted

Discord Notifications

The tool sends detailed Discord notifications with:

  • Record type (A/CNAME)
  • Domain name
  • Content changes
  • Severity level
  • Timestamp of change

Project Structure

  • src/main.rs : Application entry point and monitoring logic
  • src/dns.rs : Cloudflare DNS API interaction
  • src/db.rs : SQLite database operations
  • src/discord.rs : Discord webhook notifications
  • src/get_domains.rs : Cloudflare zone management

Dependencies

  • tokio : Async runtime
  • reqwest : HTTP client
  • rusqlite : SQLite database
  • serde : Serialization/deserialization
  • config : Configuration management
  • chrono : Time handling

Security Notes

  • Store your config.toml securely
  • Use restricted Cloudflare API tokens
  • Monitor Discord webhook access

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published