Skip to content

feat(awg): per-peer connection flood warnings (P2P/torrent detection) - #100

Open
leonidorlov-hash wants to merge 4 commits into
PRVTPRO:mainfrom
leonidorlov-hash:feat/conn-flood-warnings
Open

feat(awg): per-peer connection flood warnings (P2P/torrent detection)#100
leonidorlov-hash wants to merge 4 commits into
PRVTPRO:mainfrom
leonidorlov-hash:feat/conn-flood-warnings

Conversation

@leonidorlov-hash

@leonidorlov-hash leonidorlov-hash commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Что добавляет

Индикация пиров с аномально большим числом одновременных соединений — типичный признак торрентов/P2P, которые забивают conntrack и полосу сервера.

Под карточкой пира появляются предупреждения вида:

⚠️ 21.08.2026 at 23:56 was opened 7777 connections!

(текст локализован, язык берётся из настроек панели)

Как работает

  • При опросе пиров панель считает записи каждого пира в таблице conntrack внутри контейнера инстанса (/proc/net/nf_conntrack — на хосте виден только IP контейнера, поэтому читаем изнутри). Дополнительных пакетов на хосте не требуется.
  • Порог: 600 одновременных соединений. Обычный веб/мессенджеры/почта столько не открывают.
  • Антиспам: не чаще одного предупреждения в час на пира, хранятся последние 5 событий (новые сверху), персистентно в conn_warnings.json в data-каталоге контейнера (volume-backed, переживает рестарты).

Что НЕ входит

Никаких автоматических блокировок — только индикация, админ сам решает что делать с нарушителем. (Авто-бан в планах.)

Замечания

  • Фича покрывает AWG-инстансы (awg/awg2/awg3); для xray не применимо.
  • IP-бейдж рядом с именем пира вынесен в отдельный PR (feat(ui): show peer internal IP next to the client name #99), чтобы PR не пересекались.

- Count conntrack entries per peer IP from /proc/net/nf_conntrack (no extra
  packages on the host), matching against the instance subnet
- Record a warning when a peer exceeds 600 simultaneous connections,
  at most one per hour per peer, keeping the last 5 events; persisted in
  conn_warnings.json inside the container data dir (volume-backed)
- Render warnings under the client meta row (.conn-warnings/.conn-warning,
  no inline styles), localized via new conn_warning_text key (en/ru/fr/fa/zh)
- Show peer internal IP next to the client name (.client-ip)
NAT for the VPN subnet happens in the container's network namespace, so the
host /proc/net/nf_conntrack only sees the container's own IP and per-peer
counts were always zero.
The torrent-detection warning block under a peer now has a 🗑 button that
wipes the recorded warning history for that peer (conn_warnings.json is
keyed by peer IP; backend resolves the IP from clientsTable).
Adds POST /api/servers/{id}/connections/clear_warnings and
clear_warnings / warnings_cleared translation keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant