diff options
| author | Bitflash-sh <btf01@proton.me> | 2026-07-24 12:13:30 -0300 |
|---|---|---|
| committer | Bitflash-sh <btf01@proton.me> | 2026-07-24 12:13:30 -0300 |
| commit | 3efd9a089cc6b924d9bc917d3d8145f7c01265ad (patch) | |
| tree | 5c4d1bc9a487e54fb0ec5b386dbd4360b6779f42 /relay | |
| parent | 51d617e70f90a972185917ea0096c1ecef2bfa8b (diff) | |
Multi-relay rendezvous with failover + relay rate-limiting
Seed list of 3 geographically-spread relays (Sao Paulo, New Jersey, Almaty);
nodes register at the first reachable one and fail over if it is attacked or
goes down, so no single relay IP is a point of failure. Relay installer now
applies iptables connection rate-limits to soak up single-source floods.
Diffstat (limited to 'relay')
| -rw-r--r-- | relay/install-bitflash-relay.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/relay/install-bitflash-relay.sh b/relay/install-bitflash-relay.sh index 77a46b2..fd901ac 100644 --- a/relay/install-bitflash-relay.sh +++ b/relay/install-bitflash-relay.sh | |||
| @@ -295,6 +295,25 @@ echo ">> building bitflashd" | |||
| 295 | g++ -std=gnu++14 -O2 -pthread bitflashd.cpp btfrv.cpp -o bitflashd | 295 | g++ -std=gnu++14 -O2 -pthread bitflashd.cpp btfrv.cpp -o bitflashd |
| 296 | echo ">> build OK: $DIR/bitflashd" | 296 | echo ">> build OK: $DIR/bitflashd" |
| 297 | 297 | ||
| 298 | # Basic anti-flood firewall rules (idempotent). These soak up single-source | ||
| 299 | # connection floods; volumetric DDoS still needs provider-level protection. | ||
| 300 | # Limits are generous so many users behind one CGNAT public IP aren't blocked. | ||
| 301 | if command -v iptables >/dev/null 2>&1; then | ||
| 302 | echo ">> applying connection rate-limit on port $PORT" | ||
| 303 | # Cap concurrent connections per source IP (stops one IP hogging thousands) | ||
| 304 | iptables -C INPUT -p tcp --dport "$PORT" -m connlimit --connlimit-above 200 --connlimit-mask 32 -j REJECT --reject-with tcp-reset 2>/dev/null || \ | ||
| 305 | iptables -A INPUT -p tcp --dport "$PORT" -m connlimit --connlimit-above 200 --connlimit-mask 32 -j REJECT --reject-with tcp-reset | ||
| 306 | # Cap NEW-connection rate per source IP (stops connection floods) | ||
| 307 | iptables -C INPUT -p tcp --dport "$PORT" -m conntrack --ctstate NEW -m hashlimit \ | ||
| 308 | --hashlimit-name btfrelay --hashlimit-mode srcip --hashlimit-above 60/min --hashlimit-burst 100 -j DROP 2>/dev/null || \ | ||
| 309 | iptables -A INPUT -p tcp --dport "$PORT" -m conntrack --ctstate NEW -m hashlimit \ | ||
| 310 | --hashlimit-name btfrelay --hashlimit-mode srcip --hashlimit-above 60/min --hashlimit-burst 100 -j DROP | ||
| 311 | # Persist across reboots if the tooling is present | ||
| 312 | command -v netfilter-persistent >/dev/null 2>&1 && netfilter-persistent save >/dev/null 2>&1 || true | ||
| 313 | else | ||
| 314 | echo ">> iptables not found; skipping rate-limit (host on a provider with anti-DDoS)" | ||
| 315 | fi | ||
| 316 | |||
| 298 | # systemd service so it survives reboots (skipped if systemd is absent) | 317 | # systemd service so it survives reboots (skipped if systemd is absent) |
| 299 | if command -v systemctl >/dev/null 2>&1 && [ -d /etc/systemd/system ]; then | 318 | if command -v systemctl >/dev/null 2>&1 && [ -d /etc/systemd/system ]; then |
| 300 | cat > /etc/systemd/system/bitflashd.service <<EOF | 319 | cat > /etc/systemd/system/bitflashd.service <<EOF |