Sign inSign up

sedyh/remna-traffic-drifter-bot

By sedyh

Updated about 1 month ago

Remnawave traffic reset monitor with Telegram alerts

Image
0

684

sedyh/remna-traffic-drifter-bot repository overview

Remna Traffic Drifter Bot

drifter-preview

DockerHub

Requires Remnawave Panel 3.x (users addressed by numeric id, not uuid).

Background monitor for Remnawave: polls the panel API and sends Telegram alerts when paid users have the wrong traffic reset strategy or have not had a calendar reset for too long.

Expected strategy and stale-reset threshold are configured per tariff tag in TAG_RULES.

What it checks

Polls GET /api/users (paginated).

TypeCondition
wrong_strategytrafficLimitStrategy does not match the strategy from TAG_RULES for the user tag
stale_resetexpected strategy is MONTH, traffic was used, but lastTrafficResetAt is empty or older than the stale threshold

Filters:

  • only tags listed in TAG_RULES are checked
  • WATCH_UNTAGGED_LIMITED=true - also checks limited users without a tag (UNTAGGED_LIMITED_RULE)
  • unlimited users (trafficLimitBytes=0) are skipped
  • EXPIRED users are skipped
  • tags not listed in TAG_RULES (for example TRIAL) are skipped
  • stale_reset with empty lastTrafficResetAt is not alerted if the account is younger than the stale threshold

Alerts link the subscription name to the user page in the panel. You must be logged into the panel (session cookie after sign-in).

Docker (minimal setup)

Edit environment in drifter.compose.yaml and run:

docker compose -f drifter.compose.yaml up -d

Image on Docker Hub: sedyh/remna-traffic-drifter-bot.

Persistent data is stored in the /data volume (STATE_PATH, TELEGRAM_OFFSET_PATH by default).

Required variables
VariableDescription
PANEL_URLRemnawave panel base URL
PANEL_TOKENAPI bearer token
TELEGRAM_BOT_TOKENTelegram bot token
TELEGRAM_CHAT_IDSComma-separated chat IDs; use chat_id:topic_id for forum topics
TAG_RULESPer-tag rules: TAG:STRATEGY or TAG:STRATEGY:STALE (comma-separated)

TAG_RULES examples:

  • TAG_TARIFF_MIN:MONTH:35d - expect MONTH, stale reset after 35d
  • TAG_TARRIF_PRO:MONTH - expect MONTH, stale threshold from STALE_RESET_AFTER
  • MAX:NO_RESET - expect NO_RESET, no stale-reset checks

Strategies: MONTH, NO_RESET. Stale accepts Go durations (35d, 720h).

Optional variables
VariableDefaultDescription
TELEGRAM_SEND_INTERVAL3sDelay between outbound messages
TELEGRAM_PROXY_URL-HTTP(S) proxy for Telegram API
POLL_INTERVAL15mPanel poll interval
STALE_RESET_AFTER35dDefault stale threshold when not set per tag
UNTAGGED_LIMITED_RULEMONTHRule for limited users without a tag (STRATEGY or STRATEGY:STALE)
WATCH_UNTAGGED_LIMITEDtrueWatch limited users without a tag
PAGE_SIZE500/api/users page size
STATE_PATH/data/state.jsonAlert deduplication state file
TELEGRAM_OFFSET_PATH/data/telegram_offsetLong polling offset file
docker run (Docker Hub)
docker run -d --name traffic-drifter --restart unless-stopped \
  -e PANEL_URL=https://panel.example.com \
  -e PANEL_TOKEN=secret \
  -e TELEGRAM_BOT_TOKEN=secret \
  -e TELEGRAM_CHAT_IDS=-1001234567890:289 \
  -e TAG_RULES=TAG_TARIFF_MIN:MONTH:35d,TAG_TARRIF_PRO:MONTH:35d \
  -v traffic-drifter-data:/data \
  sedyh/remna-traffic-drifter-bot:latest

Local run

cp .env.example .env
go run ./cmd/traffic_drifter

Development

task test
task build
task image

Docker Hub publish: push a v* git tag (secrets.DOCKERHUB_USERNAME, secrets.DOCKERHUB_TOKEN).

Tag summary

Content type

Image

Digest

sha256:2be4dbad5

Size

3.2 MB

Last updated

about 1 month ago

docker pull sedyh/remna-traffic-drifter-bot