HLT is a lightweight, scalable, and ultra-fast HTTP and WebSocket tunneling system powered by Bun. It exposes local development servers, APIs, Webhooks, and complex frontend applications (such as Next.js, React Fast Refresh, Vite HMR, and large file streams) to the public internet through a secure TCP multiplexed tunnel.
- Blazing Fast Performance: Built on Bun with native streaming and optimized socket buffers.
- WebSocket & HMR Reliability: Full duplex streaming with unshifted initial head flushing, case-insensitive upgrade negotiation, and clean socket teardown for Next.js Fast Refresh and Vite/React HMR.
-
Zero-Leak Stream Multiplexing:
$O(1)$ stream dispatch viaTunnelSocketManager. Single listener per event eliminates Node'sMaxListenersExceededWarningand prevents memory bloat under heavy concurrent loads. - Threshold Backpressure Flow Control: Engine.io buffer monitoring with drain safety timeouts prevents sender deadlocks and socket starvation during large file transfers.
-
Multi-Worker Cluster: Built-in host-sticky TCP router (
cluster.js) distributes incoming HTTP/WS traffic across CPU cores while keeping each client tunnel pinned to its worker. -
Unified Security & JWT: Single consolidated
/api/tokenroute for acquiring tokens with strict JWT validation across CLI and SDK. -
Admin Management API: RESTful management endpoints under
/admin/apiprotected with JWT middleware. - Privacy-First Telemetry: Aggregated counters (connections, requests, active sockets) stored in Redis or memory. Strictly no credentials, sensitive headers, or user payloads are ever tracked or stored.
- Dual Client Support: Use as a standalone CLI tool or embed into your JavaScript/TypeScript runtime (Node.js & Bun) via the SDK.
- Bun v1.1+ (recommended: latest Bun)
- Node.js 18+ (optional, for client runtime compatibility)
cd server
bun install
# Start single server instance
bun run server
# OR start in clustered mode (auto-scales to CPU cores)
bun run startThe server listens on http://localhost:3000. Health check endpoint: http://localhost:3000/_/health.
cd client
bun install
bun run build
# Initialize configuration and acquire JWT token
bun run start init --server http://localhost:3000
# Tunnel local port 8080 to the public/server endpoint
bun run start 8080npm install -g @cubetiq/hlt
# OR
bun add -g @cubetiq/hlt# 1. Initialize client config and acquire JWT token
hlt init --server https://tunnel.example.com
# 2. Forward local port 3000
hlt start 3000
# 3. Forward with custom subdomain / suffix
hlt start 3000 -s dev
# 4. Forward to remote IP / internal network address
hlt start 192.168.1.50:8080
# 5. Start webhook receiver
hlt webhook --port 8080
# 6. Manage profiles
hlt profile listInstall in your project:
npm install @cubetiq/hlt
# OR
bun add @cubetiq/hltimport { HltClient, getToken } from "@cubetiq/hlt";
async function main() {
// 1. Initialize client
const hlt = new HltClient({
server: "https://tunnel.example.com",
// apiKey: "optional_server_api_key_if_registration_is_restricted",
});
// 2. Start tunnel forwarding to local port 3000
const tunnel = await hlt.connect({
port: 3000,
host: "localhost",
suffix: "myapp",
});
console.log("Public Tunnel URL:", tunnel.endpoint);
// 3. Graceful shutdown on SIGINT / application stop
process.on("SIGINT", () => {
tunnel.stop();
process.exit(0);
});
}
main().catch(console.error);HLT includes a modern, high-performance Web Admin Console embedded directly with the server, built using React 19, Tailwind CSS v4, shadcn UI, TanStack Query (for background state polling & cache invalidation), and TanStack Table (for interactive data tables).
- Live Cluster Overview: Real-time KPI summary (active tunnels, routed requests, total sessions, uptime) and V8 memory heap/CPU gauges.
- Active Tunnels Management: Searchable and sortable table of all connected client sockets with per-host request counts and one-click disconnect actions.
- Client Token Generator: Admin workspace to issue cryptographically signed JWT credentials with customizable expiration periods and one-click copyable CLI / SDK commands.
- Privacy-Preserving Telemetry: Aggregate monotonic counters and traffic distribution tracking with zero retention of user payloads, headers, or tokens.
- Production URL:
http://localhost:3000/admin(or your configured server domain) - Local Development: Run
cd web && bun install && bun run devto launch the Vite dev server with instant HMR and API proxy onhttp://localhost:5173. - Default Credentials: Configured via
ADMIN_USERNAME(defaultadmin) andADMIN_PASSWORD(defaultadmin123).
HLT provides a production-ready docker-compose.yml leveraging lightweight oven/bun:alpine images and healthchecks.
# Clone the repository
git clone https://github.com/cubetiq/hlt.git
cd hlt
# Copy and configure environment variables
cp .env.example .env
nano .env
# Launch server with Docker Compose
docker compose up -d --build- Multi-Stage Build: Installs production dependencies in a builder stage and copies them to an unprivileged Alpine runner (
USER bun). - Minimal Image Size: ~120MB total container footprint.
- Built-in Healthcheck: Probes
/_/healthvia Bun's HTTP client every 30s.
HLT includes a high-performance cluster router (server/cluster.js) with host-sticky TCP proxying:
[ Public HTTP / WebSocket Traffic ]
│
▼
┌───────────────────────┐
│ Cluster Master (:3000)│
│ Host-Sticky TCP Proxy│
└───────────┬───────────┘
│ IPC Socket Handover
┌─────────────────────┼─────────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ Worker 1 (Bun)│ │ Worker 2 (Bun)│ │ Worker N (Bun)│
└───────────────┘ └───────────────┘ └───────────────┘
To enable clustering:
CLUSTER_ENABLED=true
WORKERS=auto # 'auto' uses os.cpus().length, or specify a number (e.g. 4)Worker processes register active tunnel client hosts with the master over IPC. Inbound requests for a given tunnel domain are handed off directly to the worker holding that client's socket connection, avoiding inter-worker proxying overhead.
HLT enforces JWT token authentication on every WebSocket connection:
- Public or private token acquisition via
POST /api/token. - When
PUBLIC_TOKEN_REGISTRATION=false, clients must supply a matchingSERVER_API_KEYto acquire tokens. - Sockets attempting to connect without a valid token signed by
SECRET_KEYare rejected immediately with401 Unauthorized.
The server exposes management routes under /admin/api:
| Method | Path | Description | Protected |
|---|---|---|---|
POST |
/admin/api/auth/login |
Login with username/password to acquire Admin JWT | No |
GET |
/admin/api/status |
Instance uptime, CPU/memory usage, active sockets | Yes (Bearer JWT) |
GET |
/admin/api/sockets |
List connected tunnel sockets and stats | Yes (Bearer JWT) |
DELETE |
/admin/api/sockets/:host |
Forcefully disconnect a client tunnel by host | Yes (Bearer JWT) |
GET |
/admin/api/stats |
Global accumulated privacy-first metrics | Yes (Bearer JWT) |
POST |
/admin/api/tokens/generate |
Generate long-lived tunnel tokens with custom claims | Yes (Bearer JWT) |
# 1. Login to get Admin JWT
TOKEN=$(curl -s -X POST http://localhost:3000/admin/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"your_admin_password"}' | jq -r .token)
# 2. Query server status
curl -s http://localhost:3000/admin/api/status \
-H "Authorization: Bearer $TOKEN" | jqTelemetry records only non-identifying operational counters:
total_connections&total_disconnectionsactive_socketstotal_http_requests&total_ws_requests- Per-host request count and connection timestamps
Privacy Guarantees:
- No request headers (cookies, auth headers) are ever inspected or stored.
- No client payload data is ever logged or retained.
- When
REDIS_ENABLED=true, aggregated counters use Redis hashes (HINCRBY) with zero retention of sensitive metadata.
| Variable | Default | Description |
|---|---|---|
PORT |
3000 |
HTTP & WebSocket server port |
TRUSTED_HOST |
localhost:3000 |
Host header reserved for server APIs (bypasses tunnel routing) |
TRUSTED_SECRET |
(empty) | Optional header token for trusted administration |
CLUSTER_ENABLED |
true |
Enable multi-process clustering |
WORKERS |
auto |
Number of worker processes (auto or numeric count) |
SECRET_KEY |
(required) | Secret key used to sign and verify client tunnel JWTs |
VERIFY_TOKEN |
(optional) | Secondary token claim check |
PUBLIC_TOKEN_REGISTRATION |
true |
When false, requires SERVER_API_KEY to generate tokens |
SERVER_API_KEY |
(empty) | API key required if public registration is disabled |
ADMIN_USERNAME |
admin |
Admin dashboard/API username |
ADMIN_PASSWORD |
admin123 |
Admin dashboard/API password |
ADMIN_JWT_SECRET |
(secret) | Secret used to sign Admin management JWT tokens |
ADMIN_JWT_EXPIRES_IN |
24h |
Expiration duration for Admin tokens |
REDIS_ENABLED |
false |
Enable Redis adapter for telemetry and multi-node sync |
REDIS_URL |
redis://localhost:6379 |
Redis connection URL |
MAX_HTTP_BUFFER_SIZE |
500000000 |
Maximum socket buffer size in bytes (default: 500MB) |
CONCURRENCY_LIMIT |
1000 |
Concurrency limit for active streams per socket |
When deploying behind Nginx with wildcard domain support (e.g., *.tunnel.example.com):
server {
listen 80;
server_name tunnel.example.com *.tunnel.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
# WebSocket support
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Disable buffering for line-speed chunked responses
proxy_buffering off;
proxy_request_buffering off;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
client_max_body_size 0;
}
}ISC License. Copyright (c) 2026 Cubis.