Skip to content

babywbx/TGeoIP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—บ๏ธ TGeoIP

A tool to automatically find and categorize Telegram's IP ranges by geolocation.

English ยท ็ฎ€ไฝ“ไธญๆ–‡

Table of Contents

๐Ÿ“– About The Project

TGeoIP is an automated tool that fetches the latest official IP ranges from Telegram, checks for reachable hosts, and categorizes them by geolocation. The resulting IP lists and CIDR blocks are automatically committed to the geoip branch for easy use.

This project aims to provide an up-to-date, reliable source of categorized Telegram IPs for developers and network administrators.

โœจ Features

  • ๐Ÿค– Fully Automated: Updates hourly via GitHub Actions.
  • โšก๏ธ Fast & Concurrent: High-concurrency checks with memory-efficient net/netip based IP processing, pre-parsed sorting, and streaming file I/O.
  • ๐Ÿชถ Lightweight: Only one external dependency (maxminddb-golang). Core IP logic is pure Go stdlib.
  • ๐Ÿ›ก๏ธ Reliable: Defaults to a TCP port 443 check with HTTP timeouts, more reliable than ICMP ping in cloud environments.
  • ๐ŸŒ Geolocation Lookup: Uses a local MMDB database for fast and offline geo-lookups.
  • ๐Ÿ“ Dual-Format Output: Generates both plain IP lists (US.txt) and aggregated CIDR lists (US-CIDR.txt).
  • ๐Ÿ”„ Retry Mechanism: Implements 3-retry logic with 200ms intervals for better reliability.
  • โฑ๏ธ Optimized Timeouts: Uses 3-second timeouts for checks, 30-second timeout for HTTP requests.
  • ๐Ÿ” Dual Check Modes: Support for ICMP-only, TCP-only, or combined ICMP/TCP checks.
  • โšก Skip Check Option: Bypass connectivity checks for faster processing when needed.

โš™๏ธ How It Works

  1. A GitHub Actions workflow runs on an hourly schedule.
  2. It downloads the latest Telegram CIDR list and the free IPinfo geo database.
  3. The Go application processes all IPs, checking for live hosts.
  4. Results are grouped by country and saved as .txt files.
  5. wbxBot automatically commits the updated files to the geoip branch.

๐Ÿš€ How to Use the Data

The generated data is available on the geoip branch of this repository. This branch contains only the data files for easy integration.

โžก๏ธ Go to the geoip branch to view the data

You can use these files directly in your firewall, routing rules, or other applications.

๐Ÿ› ๏ธ Local Development

Prerequisites

To run this application locally, you need:

  • Go (version 1.26+ recommended)
  • An ipinfo_lite.mmdb file from IPinfo in the project root.

Running the Application

Clone the repository and run:

# Run with default TCP check
go run . -local

# Run with a limit of 1000 IPs for a quick test
go run . -local -limit 1000

# Run using the ICMP ping method
go run . -local -icmp

# Skip connectivity checks for faster processing
go run . -local -skip-check

# Use dual ICMP/TCP check mode (either passes)
go run . -local -full 1

# Use dual ICMP/TCP check mode (both must pass)
go run . -local -full 2

# Combine multiple flags for specific use cases
go run . -local -full 1 -limit 500

Command-line Flags

  • -local: Enables local mode (uses ipinfo_lite.mmdb from the current directory).
  • -icmp: Switches the check method from the default TCP dial to ICMP ping.
  • -limit <number>: Limits the number of IPs to check (e.g., -limit 500). 0 means no limit.
  • -skip-check: Skips connectivity checks and classifies all expanded IPs (useful for faster processing).
  • -full <mode>: Uses both ICMP and TCP checks together:
    • -full 1: Either ICMP or TCP passes (more lenient)
    • -full 2: Both ICMP and TCP must pass (more strict)

๐Ÿ”ง Configuration

For the GitHub Actions workflow to run, you must set one secret in your repository settings (Settings > Secrets and variables > Actions):

  • IPINFO_TOKEN: Your API token from ipinfo.io, which is required to download the MMDB database.

๐Ÿค Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

๐Ÿ“„ License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.

Copyright ยฉ 2025-2026 Babywbx.

About

๐Ÿ—บ๏ธ TGeoIP - An automated workflow that finds, categorizes, and provides up-to-date Telegram IP ranges by geolocation.

Resources

License

Stars

Watchers

Forks

Contributors

Languages