Peer enhancements: notes, traffic quotas with auto-disable, batch create, usage tracking; relay subnets for bridging into other tunnels

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
lofyer
2026-07-04 07:34:57 +08:00
co-authored by factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
parent d97ae64c85
commit c4dc22074e
10 changed files with 209 additions and 13 deletions
+12
View File
@@ -12,4 +12,16 @@ iptables -C FORWARD -i "$WG_INTERFACE" -j ACCEPT 2>/dev/null \
iptables -C FORWARD -o "$WG_INTERFACE" -j ACCEPT 2>/dev/null \
|| iptables -A FORWARD -o "$WG_INTERFACE" -j ACCEPT
# Relay wg clients into extra networks (e.g. another wg tunnel on the host).
OLD_IFS="$IFS"; IFS=','
for subnet in ${WG_RELAY_SUBNETS:-}; do
subnet="$(echo "$subnet" | tr -d ' ')"
[ -n "$subnet" ] || continue
relay_iface="$(ip route get "${subnet%/*}" 2>/dev/null | awk '/dev/ {for (i=1;i<NF;i++) if ($i=="dev") print $(i+1); exit}')"
[ -n "$relay_iface" ] || { echo "WARN: no route to relay subnet $subnet, skipping"; continue; }
iptables -t nat -C POSTROUTING -s "$WG_SUBNET" -d "$subnet" -o "$relay_iface" -j MASQUERADE 2>/dev/null \
|| iptables -t nat -A POSTROUTING -s "$WG_SUBNET" -d "$subnet" -o "$relay_iface" -j MASQUERADE
done
IFS="$OLD_IFS"
exec uvicorn app.main:app --host 0.0.0.0 --port 8000