Thanks to visit codestin.com
Credit goes to github.com

Skip to content

NamiraNet/namira-core

Namira Core

Go Version Docker License

A high-performance, self-hosted quality assurance toolkit for VPN proxy configurations. Namira Core validates, benchmarks, and ranks VMess, VLESS, Trojan, and Shadowsocks connections with real TCP handshakes and latency measurements.

πŸš€ Features

  • Multi-Protocol Support: Validates VMess, VLESS, Shadowsocks, and Trojan VPN configurations
  • Real Connection Testing: Uses real TCP handshakes, not just pings
  • High Concurrency: Dynamically adjusts concurrent connection limits based on system resources
  • API Server: RESTful API for checking VPN configurations
  • Notification System: Integrated Telegram notifications for valid configurations
  • Worker Pool: Efficient job processing with configurable worker pools
  • Redis Integration: Persistent storage and caching of results
  • GitHub Integration: Automated updates to GitHub repositories with valid configurations

πŸ“‹ Table of Contents

⚑ Quick Start

Using Docker Compose

# Clone the repository
git clone https://github.com/NamiraNet/namira-core.git
cd namira-core

# Create .env file with your configuration
cp .env.example .env
# Edit .env with your settings

# Start the services
docker-compose up -d

Access the API at http://localhost:8080

Using CLI

# Build the application
make build-local

# Check VPN configurations from file
./bin/namira-core check --file proxies.txt

# Check individual configurations
./bin/namira-core check --config "vmess://..." --config "vless://..."

πŸ”„ How It Works

Namira Core processes VPN configurations through a pipeline of operations to validate their connectivity and measure performance:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             β”‚    β”‚             β”‚    β”‚             β”‚    β”‚             β”‚    β”‚             β”‚
β”‚    Input    │───►│   Parser    │───►│  Checker    │───►│  Analyzer   │───►│   Output    β”‚
β”‚  VPN Links  β”‚    β”‚             β”‚    β”‚             β”‚    β”‚             β”‚    β”‚   Results   β”‚
β”‚             β”‚    β”‚             β”‚    β”‚             β”‚    β”‚             β”‚    β”‚             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚                  β”‚                  β”‚
                         β–Ό                  β–Ό                  β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚             β”‚    β”‚             β”‚    β”‚             β”‚
                   β”‚  Protocol   β”‚    β”‚    TCP      β”‚    β”‚  Latency    β”‚
                   β”‚ Extraction  β”‚    β”‚ Handshake   β”‚    β”‚ Measurement β”‚
                   β”‚             β”‚    β”‚             β”‚    β”‚             β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Workflow

  1. Input Processing:

    • VPN configuration links are submitted via API or CLI
    • Links are queued for processing in the worker pool
  2. Parsing:

    • Each link is parsed to extract protocol-specific parameters
    • Supported protocols: VMess, VLESS, Shadowsocks, Trojan
  3. Checking:

    • Real TCP handshakes are performed to verify connectivity
    • Connection timeouts and errors are handled gracefully
    • Latency is measured with multiple samples for accuracy
  4. Analysis:

    • Results are analyzed to determine availability status
    • Configurations are ranked by performance
    • Metadata is enriched (location, provider, etc.)
  5. Output:

    • Results are returned via API or saved to files
    • Valid configurations can be automatically:
      • Sent to Telegram channels
      • Committed to GitHub repositories
      • Stored in Redis for caching

The worker pool manages concurrency, ensuring optimal resource utilization while preventing system overload.

πŸ— Architecture

The application is structured with clean separation of concerns:

  • Core: Central components for parsing and checking VPN configurations
  • API: RESTful endpoints for submitting configuration check requests
  • Worker: Background job processing for handling configuration checks
  • Notify: Notification system for sending results via Telegram
  • Config: Configuration management from environment variables
  • Logger: Structured logging using zap

πŸ“‹ Requirements

  • Go 1.24+
  • Redis 8.0+
  • GitHub SSH key (for GitHub integration)
  • Docker and Docker Compose (for containerized deployment)

βš™οΈ Configuration

The application is configured via environment variables:

Server Configuration

Variable Default Description
SERVER_PORT 8080 Port for the HTTP server
SERVER_HOST localhost Host for the HTTP server
SERVER_READ_TIMEOUT 30s Server read timeout
SERVER_WRITE_TIMEOUT 30s Server write timeout
SERVER_IDLE_TIMEOUT 60s Server idle timeout

Worker Configuration

Variable Default Description
WORKER_COUNT 5 Number of workers
WORKER_QUEUE_SIZE 100 Size of worker queue

Redis Configuration

Variable Default Description
REDIS_ADDR localhost:6379 Redis server address
REDIS_PASSWORD - Redis password
REDIS_DB 0 Redis database number
REDIS_RESULT_TTL 24h Redis result TTL

GitHub Configuration

Variable Default Description
GITHUB_OWNER - GitHub repository owner
GITHUB_REPO - GitHub repository name
SSH_KEY_PATH ./keys/github_deploy_key Path to GitHub SSH key for pushing result in github repo

App Configuration

Variable Default Description
LOG_LEVEL info Logging level (debug, info, warn, error)
APP_TIMEOUT 10s Connection timeout per proxy test
REFRESH_INTERVAL 1h Background refresh interval
MAX_CONCURRENT 50 Maximum concurrent connections
ENCRYPTION_KEY - Key for encrypting sensitive data

Telegram Configuration

Variable Default Description
TELEGRAM_BOT_TOKEN - Telegram bot token
TELEGRAM_CHANNEL - Telegram channel username or ID for forwarding
TELEGRAM_TEMPLATE - Template for Telegram messages
TELEGRAM_QR_CONFIG - QR configuration for Telegram
TELEGRAM_PROXY_URL - Proxy URL for Telegram
TELEGRAM_SENDING_INTERVAL 10s Interval between sending messages

πŸ“¦ Installation

Using Docker Compose (Recommended)

  1. Clone the repository:

    git clone https://github.com/NamiraNet/namira-core.git
    cd namira-core
  2. Create a .env file with your configuration:

    cp .env.example .env
    # Edit .env with your preferred text editor
  3. Start the services:

    make prod    # For production environment
    # OR
    make dev     # For development environment with logs
  4. Check if the service is healthy:

    make health

Manual Installation

  1. Clone the repository:

    git clone https://github.com/NamiraNet/namira-core.git
    cd namira-core
  2. Install dependencies:

    make install
  3. Build the application:

    make build-local
  4. Run the application:

    make run-local
    # OR run directly
    ./bin/namira-core api

Available Make Commands

Run make help to see all available commands:

Namira Core Makefile
Usage: make [target]

Targets:
build                Build Docker containers without starting them
build-local          Build the Go binary locally
build-release        Build optimized release binary
clean                Clean up Docker resources and build artifacts
dev                  Start development environment with Docker Compose
docker-build         Build Docker image
docker-push          Build and push Docker image
down                 Stop Docker Compose services
health               Check service health
help                 Show this help message
install              Install project dependencies
lint                 Run linters
logs                 View Docker Compose logs
prod                 Start production environment with Docker Compose
run-local            Run the application locally
test                 Run all tests / Coming Soon 
test-coverage        Run tests with coverage / Coming Soon 
up                   Start Docker Compose services
version              Show version information

πŸ’» CLI Usage

The CLI provides a powerful interface for batch checking VPN configurations without requiring a full server setup.

Basic Usage

# Show version
./bin/namira-core --version

# Display help
./bin/namira-core check --help

# Check configurations from a file
./bin/namira-core check --file proxies.txt

# Check individual configurations
./bin/namira-core check --config "vmess://..." --config "vless://..."

# Mix file and individual configs
./bin/namira-core check --file proxies.txt --config "trojan://..."

CLI Flags

Flag Short Default Description
--file -i - File containing VPN configurations (one per line)
--config -c - VPN configuration strings (can be used multiple times)
--format -f table Output format: table, json, csv
--output -o stdout Output file path
--progress - true Show progress during checking
--concurrent -j 10 Maximum concurrent checks
--timeout -t 10s Timeout for each check

CLI Examples

Basic File Checking

# Check all configurations in a file
./bin/namira-core check --file proxies.txt

# Check with custom concurrency and timeout
./bin/namira-core check --file proxies.txt --concurrent 20 --timeout 15s

Individual Configuration Checking

# Check single configuration
./bin/namira-core check --config "vmess://eyJ2IjoiMiIsInBzIjoi..."

# Check multiple configurations
./bin/namira-core check \
  --config "vmess://eyJ2IjoiMiIsInBzIjoi..." \
  --config "vless://..." \
  --config "trojan://..."

Advanced Usage

# Silent mode with JSON output
./bin/namira-core check \
  --file proxies.txt \
  --format json \
  --output results.json \
  --progress false

# High concurrency for large files
./bin/namira-core check \
  --file large_proxy_list.txt \
  --concurrent 50 \
  --timeout 5s \
  --format csv \
  --output report.csv

Input File Format

Your input file should contain one VPN configuration per line:

vmess://eyJ2IjoiMiIsInBzIjoidGVzdCIsImFkZCI6IjEuMS4xLjEiLCJwb3J0IjoiNDQzIiwiaWQiOiJ0ZXN0LWlkIiwiYWlkIjoiMCIsInNjeSI6ImF1dG8iLCJuZXQiOiJ3cyIsInR5cGUiOiJub25lIiwiaG9zdCI6IiIsInBhdGgiOiIvIiwidGxzIjoidGxzIiwic25pIjoiIn0=
vless://[email protected]:443?encryption=none&security=tls&type=ws&path=/&host=#test
trojan://[email protected]:443?security=tls&type=tcp&headerType=none#test
ss://[email protected]:8388#test

πŸ“š API Documentation

Health Check

GET /health

Returns service health status.

πŸš€ Start Asynchronous Job

This endpoint accepts proxy configurations to initiate a background scanning job.

You can submit configurations in two formats:


🟒 JSON Format

POST /scan
Content-Type: application/json

{
  "configs": [
    "vmess://xxxxxxxxxxxxxxxxxxxx",
    "vless://yyyyyyyyyyyyyyyyyyyy"
  ]
}

🟒 Seperated File Format

POST /scan
Content-Type: text/plain

vmess://xxxxxxxxxxxxxxxxxxxx
vless://yyyyyyyyyyyyyyyyyyyy
trojan://zzzzzzzzzzzzzzzzzz
Curl Example:
curl -X POST http://localhost:8080/scan \
  -H "Content-Type: text/plain" \
  --data-binary @proxies.txt
proxies.txt
vmess://xxxxxxxxxxxxxxxxxxxx
vless://yyyyyyyyyyyyyyyyyyyy
trojan://zzzzzzzzzzzzzzzzzz

Get Job Status

GET /jobs/{job_id}

πŸ” Example Usage

CLI Mode

Quick Check

# Check a few configurations quickly
./bin/namira-core check \
  --config "vmess://..." \
  --config "vless://..." \
  --format table

Batch Processing

# Process large list with optimal settings
./bin/namira-core check \
  --file large_list.txt \
  --concurrent 30 \
  --timeout 8s \
  --format json \
  --output results.json \
  --progress

API Mode

Start Asynchronous Scanning

curl -X POST http://localhost:8080/scan \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: apikey" \
  -d '{"configs": ["vmess://...", "vless://..."]}'

Check Job Status

curl -X GET -H "X-API-KEY: apikey" http://localhost:8080/jobs/{job_id}

🧾 Swagger Documentation

Namira Core provides OpenAPI-compliant documentation to help you explore and interact with the API.

πŸ“ Swagger Files Location

  • docs/swagger.yaml – OpenAPI specification in YAML format
  • docs/swagger.json – OpenAPI specification in JSON format
  • docs/docs.go – Go-based embedded Swagger handler for serving docs via the API

πŸ› οΈ Troubleshooting

Common Issues

Issue Cause Solution
All connections timeout Firewall blocking outbound connections Open required ports or test from different network
Redis connection failed Redis not running or wrong connection string Verify Redis is running and configuration is correct
SSH connectivity test failed Invalid SSH key or permissions Check SSH key path and permissions

Debug Mode

Enable debug logging:

export LOG_LEVEL=debug
./bin/namira-core api
# OR
./bin/namira-core check --file proxies.txt

CLI Specific Issues

Issue Solution
"Permission denied" when running binary Run chmod +x ./bin/namira-core
CLI hangs on large files Reduce --concurrent value or increase --timeout
Invalid output format Use one of: table, json, csv

🀝 Contributing

Contributions are welcome! Please read our Contributing Guidelines before submitting a pull request.

Development Setup

# Clone the repository
git clone https://github.com/NamiraNet/namira-core.git
cd namira-core

# Install dependencies
make install

# Run tests
make test

# Start development server
make dev

πŸ“„ License

Distributed under the AGPL-3 License. See LICENSE for full text.

πŸ™ Acknowledgments

  • Go community for excellent libraries and tools
  • V2Ray project for providing the foundation for VPN protocol implementation

Support & Contact

Stargazers over time

Stargazers over time


🀝 Contributors

Contributors
Made with ❀️ by the community using contrib.rocks

πŸ™ Thank you to all the contributors who make this project possible.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •