A watchdog that works alongside DCF ID to help secure your mesh instance
505
A lightweight daemon that synchronizes user authentication state with kernel-level firewall rules. Enables real-time IP whitelisting for authenticated game clients.
status.json for dashboard consumptiondocker pull alh477/dcf-watchdog:latest
docker run -d \
--cap-add NET_ADMIN \
--cap-add NET_RAW \
--network host \
-e DB_PATH=/data/identity.db \
-e WEB_ROOT=/data/public \
-e DCF_PORT=7777 \
-v dcf-data:/data \
alh477/dcf-watchdog:latest
services:
dcf-watchdog:
image: alh477/dcf-watchdog:latest
cap_add:
- NET_ADMIN
- NET_RAW
network_mode: host
environment:
- DB_PATH=/data/identity.db
- WEB_ROOT=/data/public
- DCF_PORT=7777
- SYNC_INTERVAL=10
volumes:
- dcf-data:/data
depends_on:
- dcf-id
volumes:
dcf-data:
| Environment Variable | Default | Description |
|---|---|---|
DB_PATH | /var/lib/demod/identity.db | Path to DCF-ID SQLite database |
WEB_ROOT | /var/lib/demod/public | Output directory for status.json |
DCF_PORT | 7777 | UDP port to protect with firewall rules |
SYNC_INTERVAL | 10 | Seconds between firewall sync cycles |
LOG_LEVEL | info | Logging verbosity (debug/info/warn/error) |
┌─────────────────┐
│ Internet │
└────────┬────────┘
│
┌────────▼────────┐
│ nftables │
│ dcf_firewall │
│ │
│ ┌───────────┐ │
│ │ whitelist │◄─┼── dcf-watchdog syncs IPs
│ └───────────┘ │
│ ┌───────────┐ │
│ │ vip_perm │◄─┼── Permanent VIP IPs
│ └───────────┘ │
└────────┬────────┘
│
┌────────▼────────┐
│ DCF-SDK │
│ UDP :7777 │
└─────────────────┘
Every SYNC_INTERVAL seconds:
status.json with system metrics# Table structure created on startup
nft add table ip dcf_firewall
nft add set ip dcf_firewall whitelist { type ipv4_addr; flags interval; timeout 1h; }
nft add set ip dcf_firewall vip_permanent { type ipv4_addr; flags interval; }
# Rules
nft add rule ip dcf_firewall input udp dport 7777 ip saddr @vip_permanent accept
nft add rule ip dcf_firewall input udp dport 7777 ip saddr @whitelist accept
nft add rule ip dcf_firewall input udp dport 7777 drop
Generates /data/public/status.json:
{
"meta": {
"updated_at": "2025-01-02T12:00:00Z",
"node_role": "GATEWAY-01",
"version": "2.4.0"
},
"system": {
"load_avg": 0.42,
"memory_pct": 35,
"rx_bytes": 1234567890,
"tx_bytes": 987654321,
"uptime_secs": 86400
},
"network": {
"active_tunnels": 12
},
"peers": [
{
"username": "player1",
"is_vip": false,
"tier": "paid",
"status": "online"
}
]
}
NET_ADMIN and NET_RAW capabilitiesDCF-Watchdog reads from the same SQLite database as DCF-ID:
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ DCF-ID │────▶│ SQLite │◀────│ DCF-Watchdog│
│ (writes) │ │ identity.db │ │ (reads) │
└─────────────┘ └──────────────┘ └─────────────┘
User flow:
last_ip column# Run directly (requires root for nftables)
sudo DB_PATH=/path/to/identity.db \
WEB_ROOT=/var/www/html \
DCF_PORT=7777 \
./dcf-watchdog.sh
nft list table ip dcf_firewall
nft list set ip dcf_firewall whitelist
docker logs dcf-watchdog -f
nft add element ip dcf_firewall whitelist { 192.168.1.100 }
nft flush set ip dcf_firewall whitelist
BSD 3-Clause License
Copyright (c) 2024-2025, DeMoD LLC
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Content type
Image
Digest
sha256:ccff1cbb2…
Size
24.4 MB
Last updated
9 months ago
docker pull alh477/dcf-watchdog