Skip to content

TheForensic/test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Tor Bridge Bot

Telegram bot that fetches Tor bridge lines (obfs4/webtunnel for IPv4/IPv6), de-duplicates them per type, saves history, and posts updates to Telegram.

  • GitHub Actions (cron-driven)
  • Node.js HTTP server with /run, /health, built-in scheduler, and a web control panel (server-only)

Features

  • Automatic bridge fetching on schedule.
  • obfs4/webtunnel, IPv4/IPv6 support.
  • Telegram posting with HTML formatting.
  • De-duplication per bridge type.

How It Works

  1. Fetch: The bot scrapes the official Tor Project bridges website.
  2. Parse: It extracts all the bridge lines from the website's HTML.
  3. Compare: It compares the fetched bridges against a local history of already-sent bridges.
  4. Notify: It sends any new, unique bridges to your Telegram channel.
  5. Save: It saves the new bridges to the history to prevent future duplicates.

Quick Install (One‑liner)

Run this on a vanilla Linux server to install and run the Node HTTP server under systemd:

bash <(curl -Ls https://raw.githubusercontent.com/YrustPd/AutoBridgeBot/main/scripts/install.sh)

The installer will (idempotent):

  • Install/upgrade Node.js LTS, curl, and Git
  • Clone or update the repo in /opt/AutoBridgeBot
  • Prompt for TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID
  • Pick a random free port if you leave PORT blank
  • Generate admin credentials for the control panel and a JWT secret
  • Install or update npm dependencies
  • Create/update and start systemd service autobridgebot
  • Write or preserve .env (schedule + settings)
  • Print real URLs (health, panel, run) using your server’s IP

HTTP endpoints after install:

  • GET /health → returns JSON { ok, running, lastRun, nextRun, version }
  • GET/POST /run → triggers a fetch + post cycle, returns JSON report
  • GET /panel/ → control panel (login required)

Upgrade only (already installed):

sudo bash /opt/AutoBridgeBot/scripts/update.sh

or just re-run the one-liner installer; it will pull latest and restart.

Server Cron

The Node HTTP server can run the bot on a schedule, controlled by .env:

  • CRON_SCHEDULE — a standard cron string (e.g. "0 */12 * * *"). If set, it takes precedence.
  • INTERVAL_HOURS — integer hours interval (default 12). Used only if CRON_SCHEDULE is blank.
  • DISABLE_INTERNAL_CRON — set to true to disable the internal schedule and use manual triggers only.

Defaults: if neither CRON_SCHEDULE nor INTERVAL_HOURS is set, the server runs every 12 hours.

Examples:

  • Every 6 hours: CRON_SCHEDULE="0 */6 * * *"
  • Every 12 hours (default): INTERVAL_HOURS=12
  • Disable schedule: DISABLE_INTERNAL_CRON=true

Trigger a run manually while the scheduler is active:

curl -X POST http://127.0.0.1:3000/run

Control Panel

  • URL: http://<server-ip>:<port>/panel/
  • Login: ADMIN_USER / ADMIN_PASS (generated by installer; stored in /opt/AutoBridgeBot/.env)
  • Features:
    • Dashboard (status, last run, next run, Run Now)
    • Schedule (daily at HH:MM or every N hours; live reload without restart)
    • Secrets (update Telegram token/chat)
    • Settings (bind host, port shown; disable internal cron)
    • Health & Logs (recent in-memory logs + download)
    • About (version/links)

CLI

  • After install, use the CLI menu:
atb-cli
  • Options include: show status, run now, change schedule, edit secrets, update, uninstall, and show control panel URL.

Manual Usage

Prerequisites:

  • Node.js 18+
  • A Bot Token from @BotFather and a target chat ID

Install dependencies:

npm install

Run once (same as GitHub Actions behavior):

TELEGRAM_BOT_TOKEN=... TELEGRAM_CHAT_ID=... npm run once

Run HTTP server:

PORT=3000 TELEGRAM_BOT_TOKEN=... TELEGRAM_CHAT_ID=... npm run server

GitHub Actions (Cron)

  • Workflow file: .github/workflows/main.yml
  • Secrets required:
    • TELEGRAM_BOT_TOKEN
    • TELEGRAM_CHAT_ID
  • By default runs twice a day (0 0,13 * * *).

CI behavior:

  • Actions invokes node bin/cli.js, which runs one cycle and exits.
  • No server or panel is started in CI. Panel is only available in server mode.

Notes on Behavior and Data

  • De-duplication is within each type (exact trimmed match).
  • Local persistence uses JSON files in config/ (same format as before): { bridges: BridgeData[] }.

Maintenance

  • To tidy and re-sort local JSON files deterministically:
node update_bridges.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published