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

Skip to content

Mytai20100/tunnel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tunnel

Version Language Stars Views Pulls

High-performance tunnel proxy with real-time monitoring and analytics

Features • Installation • Usage • API • Configuration


Features

  • High performance proxy for mining connections
  • Real-time monitoring and statistics
  • REST API for integration
  • SQLite database for data storage
  • WebSocket support for live logs
  • Multi-pool support
  • TLS encryption support
  • Prometheus metrics endpoint

Requirements

  • Go 1.21 or higher
  • Git
  • gcc (for CGO dependencies)

Installation

Install Go on Linux/Ubuntu

wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc
go version

Install Go on Windows

Download and run the installer from golang.org/dl


Building from Source

1. Clone Repository

git clone https://github.com/Mytai20100/tunnel.git
cd tunnel

2. Install Dependencies

go mod download
go mod tidy

3. Build

# Linux/macOS
go build -o tunnel main.go

# Windows
go build -o tunnel.exe main.go

Configuration

Create config.yml file:

pools:
  pool1:
    host: "pool.example.com"
    port: 4444
    name: "Example Pool"
  
  pool2:
    host: "another-pool.com"
    port: 3333
    name: "Another Pool"

tunnels:
  tunnel1:
    ip: "0.0.0.0"
    port: 3333
    pool: "pool1"
  
  tunnel2:
    ip: "0.0.0.0"
    port: 3334
    pool: "pool2"

api_port: 8080

database:
  host: "localhost"
  port: 3306
  user: "root"
  password: "password"
  dbname: "mining_tunnel"

Usage

Basic Commands

# Run server
./tunnel

# Run without database
./tunnel --nodata

# Run without API
./tunnel --noapi

# Run with minimal output
./tunnel --nodebug

# Run with TLS
./tunnel --tls --tlscert=cert.pem --tlskey=key.pem

# Show help
./tunnel --help

# Show version
./tunnel --version

Command Options

Option Description
--nodata Disable database logging
--noapi Disable API server
--nodebug Minimal output mode
--tls Enable TLS support
--tlscert TLS certificate file (default: cert.pem)
--tlskey TLS key file (default: key.pem)
--help Show help message
--version Show version

TLS Setup (Optional)

Generate self-signed certificate:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes

Run with TLS:

./tunnel --tls --tlscert=cert.pem --tlskey=key.pem

API Endpoints

System Metrics

GET http://localhost:8080/api/metrics

Miner Information

GET http://localhost:8080/api/i/{wallet_address}

Network Statistics

GET http://localhost:8080/api/network/stats?hours=24

Shares Statistics

GET http://localhost:8080/api/shares/stats?wallet={address}&hours=24

Prometheus Metrics

GET http://localhost:8080/metrics

WebSocket Log Stream

WS ws://localhost:8080/api/logs/stream

Example API Response

GET /api/metrics:

{
  "system": {
    "cpu_model": "Intel Core i7",
    "cpu_cores": 8,
    "cpu_usage_percent": "25.50%",
    "ram_total_bytes": 17179869184,
    "ram_used_bytes": 8589934592,
    "uptime_seconds": 3600
  },
  "network": {
    "total_download_gb": 1.25,
    "total_upload_gb": 0.85,
    "packets_sent": 150000,
    "packets_received": 145000
  },
  "miners": {
    "active_count": 5,
    "list": [...]
  }
}

Docker Support

Dockerfile

FROM golang:1.21-alpine AS builder

WORKDIR /app
COPY . .
RUN go mod download
RUN go build -o tunnel main.go

FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/tunnel .
COPY config.yml .

EXPOSE 3333 8080
CMD ["./tunnel"]

Build and Run

docker build -t tunnel:latest .
docker run -d -p 3333:3333 -p 8080:8080 --name tunnel tunnel:latest

Systemd Service (Linux)

Create /etc/systemd/system/tunnel.service:

[Unit]
Description=Tunnel Mining Proxy
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/root/tunnel
ExecStart=/root/tunnel/tunnel
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Enable and start:

sudo systemctl daemon-reload
sudo systemctl enable tunnel
sudo systemctl start tunnel
sudo systemctl status tunnel

Logs and Debugging

View Logs

# Application logs
tail -f /var/log/tunnel.log

# Systemd logs
journalctl -u tunnel -f

License

MIT License


Acknowledgments


Author

Made by Mytai


Repository

GitHub Repository

Frontend Repository

Tunnel Frontend