2024-03-24 14:44:44 +01:00
# @serve.zone/remoteingress
2024-04-14 03:40:55 +02:00
2026-03-26 16:39:53 +00:00
Edge ingress tunnel for DcRouter — tunnels **TCP and UDP ** traffic from the network edge to a private DcRouter/SmartProxy cluster over encrypted TLS or QUIC connections, preserving the original client IP via PROXY protocol. Includes **hub-controlled nftables firewall ** for IP blocking, rate limiting, and custom firewall rules applied directly at the edge.
2024-03-24 14:44:44 +01:00
2026-02-18 06:01:33 +00:00
## Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/ ](https://community.foss.global/ ). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/ ](https://code.foss.global/ ) account to submit Pull Requests directly.
2026-02-16 13:15:12 +00:00
## Install
2024-04-14 03:38:00 +02:00
```sh
2026-02-16 13:15:12 +00:00
pnpm install @serve .zone/remoteingress
2024-04-14 03:38:00 +02:00
```
2026-03-26 07:49:44 +00:00
## Architecture
2024-03-24 14:44:44 +01:00
2026-02-17 10:04:54 +00:00
`@serve.zone/remoteingress` uses a **Hub/Edge ** topology with a high-performance Rust core and a TypeScript API surface:
2024-04-14 03:38:00 +02:00
2026-02-16 13:15:12 +00:00
```
2026-03-26 17:06:28 +00:00
TLS or QUIC Tunnel
2026-03-26 07:49:44 +00:00
┌─────────────────────┐ ◄══════════════════════════► ┌─────────────────────┐
│ Network Edge │ TCP+TLS: frame mux │ Private Cluster │
2026-03-26 17:05:38 +00:00
│ │ QUIC: native streams │ │
│ RemoteIngressEdge │ UDP: QUIC datagrams │ RemoteIngressHub │
│ │ │ │
│ • TCP/UDP listeners│ ◄─── FRAME_CONFIG pushes ─── │ • Port assignments │
│ • nftables firewall│ ports + firewall rules │ • Firewall config │
│ • Rate limiting │ at any time │ • Rate limit rules │
└─────────────────────┘ └─────────────────────┘
▲ │
│ TCP + UDP from end users ▼
Internet DcRouter / SmartProxy
2026-02-16 13:15:12 +00:00
```
2024-04-14 03:40:55 +02:00
2026-02-16 13:15:12 +00:00
| Component | Role |
|-----------|------|
2026-03-26 17:05:38 +00:00
| **RemoteIngressEdge ** | Deployed at the network edge (VPS, cloud instance). Runs as root. Listens on hub-assigned TCP/UDP ports, tunnels traffic to the hub, and applies hub-pushed nftables rules (IP blocking, rate limiting). All config is hot-reloadable at runtime. |
| **RemoteIngressHub ** | Deployed alongside DcRouter/SmartProxy in a private cluster. Accepts edge connections, demuxes streams/datagrams, and forwards each to SmartProxy with PROXY protocol headers so the real client IP is preserved. Pushes all edge config (ports, firewall) via a single API. |
2026-02-16 13:15:12 +00:00
| **Rust Binary ** (`remoteingress-bin` ) | The performance-critical networking core. Managed via `@push.rocks/smartrust` RustBridge IPC — you never interact with it directly. Cross-compiled for `linux/amd64` and `linux/arm64` . |
2024-04-14 03:38:00 +02:00
2026-03-26 16:39:53 +00:00
### ⚡ Key Features
2026-03-26 07:49:44 +00:00
- **Dual transport** — choose between TCP+TLS (frame-multiplexed) or QUIC (native stream multiplexing, zero head-of-line blocking)
- **TCP + UDP tunneling** — tunnel any TCP connection or UDP datagram through the same edge/hub pair
- **PROXY protocol v1 & v2** — SmartProxy sees the real client IP for both TCP (v1 text) and UDP (v2 binary)
2026-03-26 17:05:38 +00:00
- **Hub-controlled firewall** — push nftables rules (IP blocking, rate limiting, custom firewall rules) to edges as part of the same config update that assigns ports — powered by `@push.rocks/smartnftables`
2026-03-26 07:49:44 +00:00
- **Multiplexed streams** — thousands of concurrent TCP connections over a single tunnel
- **QUIC datagrams** — UDP traffic forwarded via QUIC unreliable datagrams for lowest possible latency
- **Shared-secret authentication** — edges must present valid credentials to connect
- **Connection tokens** — encode all connection details into a single opaque base64url string
- **STUN-based public IP discovery** — edges automatically discover their public IP via Cloudflare STUN
- **Auto-reconnect** with exponential backoff if the tunnel drops
2026-03-26 17:05:38 +00:00
- **Dynamic runtime configuration** — the hub pushes ports, firewall rules, and rate limits to edges at any time via a single `updateAllowedEdges()` call
2026-03-26 07:49:44 +00:00
- **Event-driven** — both Hub and Edge extend `EventEmitter` for real-time monitoring
- **3-tier QoS** — control frames, normal data, and sustained (elephant flow) traffic each get their own priority queue
- **Adaptive flow control** — per-stream windows scale with active stream count to prevent memory overuse
- **UDP session management** — automatic session tracking with 60s idle timeout and cleanup
- **Crash recovery** — automatic restart with exponential backoff if the Rust binary crashes unexpectedly
## Usage
2024-04-14 03:38:00 +02:00
2026-03-19 14:43:42 +00:00
Both classes are imported from the package and communicate with the Rust binary under the hood.
2024-04-14 03:40:55 +02:00
2026-02-18 06:01:33 +00:00
### Setting Up the Hub (Private Cluster Side)
2024-04-14 03:38:00 +02:00
```typescript
2026-02-16 13:15:12 +00:00
import { RemoteIngressHub } from '@serve .zone/remoteingress';
const hub = new RemoteIngressHub();
// Listen for events
2026-03-19 14:43:42 +00:00
hub.on('edgeConnected', ({ edgeId }) => console.log(`Edge ${edgeId} connected` ));
hub.on('edgeDisconnected', ({ edgeId }) => console.log(`Edge ${edgeId} disconnected` ));
hub.on('streamOpened', ({ edgeId, streamId }) => console.log(`Stream ${streamId} from ${edgeId}` ));
hub.on('streamClosed', ({ edgeId, streamId }) => console.log(`Stream ${streamId} closed` ));
2026-02-16 13:15:12 +00:00
2026-03-19 14:43:42 +00:00
// Start the hub — listens for edge connections on both TCP and QUIC (same port)
2026-02-16 13:15:12 +00:00
await hub.start({
2026-02-17 10:04:54 +00:00
tunnelPort: 8443, // port edges connect to (default: 8443)
2026-03-19 14:43:42 +00:00
targetHost: '127.0.0.1', // SmartProxy host to forward traffic to
2024-04-14 03:40:55 +02:00
});
2024-04-14 03:38:00 +02:00
2026-03-26 16:39:53 +00:00
// Register allowed edges with TCP and UDP listen ports + firewall config
2026-02-16 13:15:12 +00:00
await hub.updateAllowedEdges([
2026-02-18 18:41:25 +00:00
{
id: 'edge-nyc-01',
secret: 'supersecrettoken1',
2026-03-19 14:43:42 +00:00
listenPorts: [80, 443], // TCP ports the edge should listen on
listenPortsUdp: [53, 51820], // UDP ports (e.g., DNS, WireGuard)
stunIntervalSecs: 300,
2026-03-26 16:39:53 +00:00
firewallConfig: {
blockedIps: ['192.168.1.100', '10.0.0.0/8'],
rateLimits: [
{ id: 'http-rate', port: 80, protocol: 'tcp', rate: '100/second', perSourceIP: true },
],
rules: [
{ id: 'allow-ssh', direction: 'input', action: 'accept', sourceIP: '10.0.0.0/24', destPort: 22, protocol: 'tcp' },
],
},
2026-02-18 18:41:25 +00:00
},
{
id: 'edge-fra-02',
secret: 'supersecrettoken2',
listenPorts: [443, 8080],
},
]);
2026-03-26 16:39:53 +00:00
// Dynamically update ports and firewall — changes are pushed instantly to connected edges
2026-02-18 18:41:25 +00:00
await hub.updateAllowedEdges([
{
id: 'edge-nyc-01',
secret: 'supersecrettoken1',
2026-03-19 14:43:42 +00:00
listenPorts: [80, 443, 8443], // added TCP port 8443
listenPortsUdp: [53], // removed WireGuard UDP port
2026-03-26 16:39:53 +00:00
firewallConfig: {
blockedIps: ['192.168.1.100', '10.0.0.0/8', '203.0.113.50'], // added new blocked IP
rateLimits: [
{ id: 'http-rate', port: 80, protocol: 'tcp', rate: '200/second', perSourceIP: true },
],
},
2026-02-18 18:41:25 +00:00
},
2026-02-16 13:15:12 +00:00
]);
2026-03-19 14:43:42 +00:00
// Check status
2026-02-16 13:15:12 +00:00
const status = await hub.getStatus();
2026-03-19 14:43:42 +00:00
// { running: true, tunnelPort: 8443, connectedEdges: [...] }
2026-02-16 13:15:12 +00:00
await hub.stop();
```
2024-04-14 03:38:00 +02:00
2026-02-18 06:01:33 +00:00
### Setting Up the Edge (Network Edge Side)
2026-03-26 16:39:53 +00:00
The edge can connect via **TCP+TLS ** (default) or **QUIC ** transport. Edges run as **root ** so they can bind to privileged ports and apply nftables firewall rules.
2026-02-18 06:01:33 +00:00
#### Option A: Connection Token (Recommended)
2024-04-14 03:38:00 +02:00
```typescript
2026-02-16 13:15:12 +00:00
import { RemoteIngressEdge } from '@serve .zone/remoteingress';
const edge = new RemoteIngressEdge();
2026-02-18 06:01:33 +00:00
edge.on('tunnelConnected', () => console.log('Tunnel established'));
edge.on('tunnelDisconnected', () => console.log('Tunnel lost — will auto-reconnect'));
edge.on('publicIpDiscovered', ({ ip }) => console.log(`Public IP: ${ip}` ));
2026-03-19 14:43:42 +00:00
edge.on('portsAssigned', ({ listenPorts }) => console.log(`TCP ports: ${listenPorts}` ));
2026-03-26 16:39:53 +00:00
edge.on('firewallConfigUpdated', () => console.log('Firewall rules applied'));
2026-02-18 06:01:33 +00:00
await edge.start({
2026-03-19 14:43:42 +00:00
token: 'eyJoIjoiaHViLmV4YW1wbGUuY29tIiwi...',
2024-04-14 03:40:55 +02:00
});
2026-02-18 06:01:33 +00:00
```
2026-03-19 14:43:42 +00:00
#### Option B: Explicit Config with QUIC Transport
2026-02-18 06:01:33 +00:00
```typescript
import { RemoteIngressEdge } from '@serve .zone/remoteingress';
const edge = new RemoteIngressEdge();
2026-02-16 13:15:12 +00:00
await edge.start({
2026-03-19 14:43:42 +00:00
hubHost: 'hub.example.com',
hubPort: 8443,
edgeId: 'edge-nyc-01',
secret: 'supersecrettoken1',
transportMode: 'quic', // 'tcpTls' (default) | 'quic' | 'quicWithFallback'
2026-02-16 13:15:12 +00:00
});
2026-02-17 10:04:54 +00:00
const edgeStatus = await edge.getStatus();
2026-03-19 14:43:42 +00:00
// { running: true, connected: true, publicIp: '203.0.113.42', activeStreams: 5, listenPorts: [80, 443] }
2026-02-16 13:15:12 +00:00
await edge.stop();
2024-04-14 03:38:00 +02:00
```
2026-03-19 14:43:42 +00:00
#### Transport Modes
| Mode | Description |
|------|-------------|
| `'tcpTls'` | **Default. ** Single TLS connection with frame-based multiplexing. Universal compatibility. |
| `'quic'` | QUIC with native stream multiplexing. Eliminates head-of-line blocking. Uses QUIC datagrams for UDP traffic. |
| `'quicWithFallback'` | Tries QUIC first (5s timeout), falls back to TCP+TLS if UDP is blocked by the network. |
2026-03-26 07:49:44 +00:00
### Connection Tokens
2026-02-18 06:01:33 +00:00
2026-03-19 14:43:42 +00:00
Encode all connection details into a single opaque string for easy distribution:
2026-02-18 06:01:33 +00:00
```typescript
import { encodeConnectionToken, decodeConnectionToken } from '@serve .zone/remoteingress';
2026-03-19 14:43:42 +00:00
// Hub operator generates a token
2026-02-18 06:01:33 +00:00
const token = encodeConnectionToken({
hubHost: 'hub.example.com',
hubPort: 8443,
edgeId: 'edge-nyc-01',
secret: 'supersecrettoken1',
});
// => 'eyJoIjoiaHViLmV4YW1wbGUuY29tIiwi...'
2026-03-19 14:43:42 +00:00
// Edge operator decodes (optional — start() does this automatically)
2026-02-18 06:01:33 +00:00
const data = decodeConnectionToken(token);
2026-03-19 14:43:42 +00:00
// { hubHost: 'hub.example.com', hubPort: 8443, edgeId: 'edge-nyc-01', secret: '...' }
2026-02-18 06:01:33 +00:00
```
2026-03-19 14:43:42 +00:00
Tokens are base64url-encoded — safe for environment variables, CLI arguments, and config files.
2026-02-18 06:01:33 +00:00
2026-03-26 17:05:38 +00:00
## 🔥 Firewall Config
2026-03-26 16:39:53 +00:00
2026-03-26 17:05:38 +00:00
The `firewallConfig` field in `updateAllowedEdges()` works exactly like `listenPorts` — it travels in the same `FRAME_CONFIG` frame, is delivered on initial handshake and on every subsequent update, and is applied atomically at the edge using `@push.rocks/smartnftables` . Each update fully replaces the previous ruleset.
2026-03-26 16:39:53 +00:00
2026-03-26 17:05:38 +00:00
Since edges run as root, the rules are applied directly to the Linux kernel via nftables. If the edge isn't root or nftables is unavailable, it logs a warning and continues — the tunnel works fine, just without kernel-level firewall rules.
2026-03-26 16:39:53 +00:00
2026-03-26 17:05:38 +00:00
### Config Structure
2026-03-26 16:39:53 +00:00
```typescript
interface IFirewallConfig {
blockedIps?: string[]; // IPs or CIDRs to block (e.g., '1.2.3.4', '10.0.0.0/8')
rateLimits?: IFirewallRateLimit[];
rules?: IFirewallRule[];
}
interface IFirewallRateLimit {
id: string; // unique identifier for this rate limit
port: number; // port to rate-limit
protocol?: 'tcp' | 'udp'; // default: both
rate: string; // e.g., '100/second', '1000/minute'
burst?: number; // burst allowance
perSourceIP?: boolean; // per-client rate limiting (recommended)
}
interface IFirewallRule {
id: string; // unique identifier for this rule
direction: 'input' | 'output' | 'forward';
action: 'accept' | 'drop' | 'reject';
sourceIP?: string; // source IP or CIDR
destPort?: number; // destination port
protocol?: 'tcp' | 'udp';
comment?: string;
}
```
### Example: Rate Limiting + IP Blocking
```typescript
await hub.updateAllowedEdges([
{
id: 'edge-nyc-01',
secret: 'secret',
listenPorts: [80, 443],
firewallConfig: {
// Block known bad actors
blockedIps: ['198.51.100.0/24', '203.0.113.50'],
// Rate limit HTTP traffic per source IP
rateLimits: [
{ id: 'http', port: 80, protocol: 'tcp', rate: '100/second', burst: 50, perSourceIP: true },
{ id: 'https', port: 443, protocol: 'tcp', rate: '200/second', burst: 100, perSourceIP: true },
],
// Allow monitoring from trusted subnet
rules: [
{ id: 'monitoring', direction: 'input', action: 'accept', sourceIP: '10.0.0.0/24', destPort: 9090, protocol: 'tcp', comment: 'Prometheus scraping' },
],
},
},
]);
```
2026-03-26 07:49:44 +00:00
## API Reference
2024-04-14 03:40:55 +02:00
2026-02-18 06:01:33 +00:00
### `RemoteIngressHub`
2024-04-14 03:40:55 +02:00
2026-02-16 13:15:12 +00:00
| Method / Property | Description |
|-------------------|-------------|
2026-03-26 07:10:15 +00:00
| `start(config?)` | Start the hub. Config: `{ tunnelPort?, targetHost?, tls?: { certPem?, keyPem? } }` . Listens on both TCP and UDP (QUIC) on the tunnel port. |
2026-03-19 14:43:42 +00:00
| `stop()` | Graceful shutdown. |
2026-03-26 16:39:53 +00:00
| `updateAllowedEdges(edges)` | Set authorized edges. Each: `{ id, secret, listenPorts?, listenPortsUdp?, stunIntervalSecs?, firewallConfig? }` . Port and firewall changes are pushed to connected edges in real time. |
2026-03-19 14:43:42 +00:00
| `getStatus()` | Returns `{ running, tunnelPort, connectedEdges: [...] }` . |
2026-02-16 13:15:12 +00:00
| `running` | `boolean` — whether the Rust binary is alive. |
2024-04-14 03:40:55 +02:00
2026-03-26 07:49:44 +00:00
**Events:** `edgeConnected` , `edgeDisconnected` , `streamOpened` , `streamClosed` , `crashRecovered` , `crashRecoveryFailed`
2024-04-14 03:40:55 +02:00
2026-02-18 06:01:33 +00:00
### `RemoteIngressEdge`
2024-04-14 03:40:55 +02:00
2026-02-16 13:15:12 +00:00
| Method / Property | Description |
|-------------------|-------------|
2026-03-26 07:49:44 +00:00
| `start(config)` | Connect to hub. Accepts `{ token }` or `{ hubHost, hubPort, edgeId, secret, bindAddress?, transportMode? }` . |
2026-03-26 16:39:53 +00:00
| `stop()` | Graceful shutdown. Cleans up all nftables rules. |
2026-03-19 14:43:42 +00:00
| `getStatus()` | Returns `{ running, connected, publicIp, activeStreams, listenPorts }` . |
2026-02-16 13:15:12 +00:00
| `running` | `boolean` — whether the Rust binary is alive. |
2024-04-14 03:38:00 +02:00
2026-03-26 16:39:53 +00:00
**Events:** `tunnelConnected` , `tunnelDisconnected` , `publicIpDiscovered` , `portsAssigned` , `portsUpdated` , `firewallConfigUpdated` , `crashRecovered` , `crashRecoveryFailed`
2024-04-14 03:38:00 +02:00
2026-02-18 06:01:33 +00:00
### Token Utilities
| Function | Description |
|----------|-------------|
2026-03-19 14:43:42 +00:00
| `encodeConnectionToken(data)` | Encodes connection info into a base64url token. |
| `decodeConnectionToken(token)` | Decodes a token. Throws on malformed input. |
2026-02-18 06:01:33 +00:00
### Interfaces
```typescript
interface IHubConfig {
tunnelPort?: number; // default: 8443
targetHost?: string; // default: '127.0.0.1'
2026-03-26 07:10:15 +00:00
tls?: {
certPem?: string; // PEM-encoded TLS certificate
keyPem?: string; // PEM-encoded TLS private key
};
2026-02-18 06:01:33 +00:00
}
interface IEdgeConfig {
hubHost: string;
hubPort?: number; // default: 8443
edgeId: string;
secret: string;
2026-03-19 14:43:42 +00:00
bindAddress?: string;
transportMode?: 'tcpTls' | 'quic' | 'quicWithFallback';
2026-02-18 06:01:33 +00:00
}
interface IConnectionTokenData {
hubHost: string;
hubPort: number;
edgeId: string;
secret: string;
}
```
2026-03-26 07:49:44 +00:00
## Wire Protocol
2024-04-14 03:38:00 +02:00
2026-03-19 14:43:42 +00:00
### TCP+TLS Transport (Frame Protocol)
The tunnel uses a custom binary frame protocol over a single TLS connection:
2024-04-14 03:38:00 +02:00
2026-02-16 13:15:12 +00:00
```
2026-02-18 18:41:25 +00:00
[stream_id: 4 bytes BE][type: 1 byte][length: 4 bytes BE][payload: N bytes]
2026-02-16 13:15:12 +00:00
```
2024-04-14 03:38:00 +02:00
2026-02-16 13:15:12 +00:00
| Frame Type | Value | Direction | Purpose |
|------------|-------|-----------|---------|
2026-03-26 16:39:53 +00:00
| `OPEN` | `0x01` | Edge → Hub | Open TCP stream; payload is PROXY v1 header |
| `DATA` | `0x02` | Edge → Hub | Client data (upload) |
| `CLOSE` | `0x03` | Edge → Hub | Client closed connection |
| `DATA_BACK` | `0x04` | Hub → Edge | Response data (download) |
| `CLOSE_BACK` | `0x05` | Hub → Edge | Upstream closed connection |
| `CONFIG` | `0x06` | Hub → Edge | Runtime config update (JSON: ports + firewall config) |
| `PING` | `0x07` | Hub → Edge | Heartbeat probe (every 15s) |
| `PONG` | `0x08` | Edge → Hub | Heartbeat response |
| `WINDOW_UPDATE` | `0x09` | Edge → Hub | Flow control: edge consumed N bytes |
| `WINDOW_UPDATE_BACK` | `0x0A` | Hub → Edge | Flow control: hub consumed N bytes |
| `UDP_OPEN` | `0x0B` | Edge → Hub | Open UDP session; payload is PROXY v2 header |
| `UDP_DATA` | `0x0C` | Edge → Hub | UDP datagram (upload) |
| `UDP_DATA_BACK` | `0x0D` | Hub → Edge | UDP datagram (download) |
2026-03-19 14:43:42 +00:00
| `UDP_CLOSE` | `0x0E` | Either | Close UDP session |
### QUIC Transport
2026-02-18 18:41:25 +00:00
2026-03-19 14:43:42 +00:00
When using QUIC, the frame protocol is replaced by native QUIC primitives:
- **TCP connections:** Each tunneled TCP connection gets its own QUIC bidirectional stream. No framing overhead.
- **UDP datagrams:** Forwarded via QUIC unreliable datagrams (RFC 9221). Format: `[session_id: 4 bytes][payload]` . Session open uses magic byte `0xFF` : `[session_id: 4][0xFF][PROXY v2 header]` .
- **Control channel:** First QUIC bidirectional stream carries auth handshake + config updates using `[type: 1][length: 4][payload]` format.
2024-04-14 03:38:00 +02:00
2026-02-18 18:41:25 +00:00
### Handshake Sequence
2026-03-19 14:43:42 +00:00
1. Edge opens a TLS or QUIC connection to the hub
2026-02-18 18:41:25 +00:00
2. Edge sends: `EDGE <edgeId> <secret>\n`
2026-03-19 14:43:42 +00:00
3. Hub verifies credentials (constant-time comparison) and responds with JSON:
2026-03-26 16:39:53 +00:00
`{"listenPorts":[...],"listenPortsUdp":[...],"stunIntervalSecs":300,"firewallConfig":{...}}\n`
2026-03-19 14:43:42 +00:00
4. Edge starts TCP and UDP listeners on the assigned ports
2026-03-26 16:39:53 +00:00
5. Edge applies firewall config via nftables (if present and running as root)
6. Data flows — TCP frames/QUIC streams for TCP traffic, UDP frames/QUIC datagrams for UDP traffic
2026-02-16 13:15:12 +00:00
2026-03-26 07:49:44 +00:00
## QoS & Flow Control
2026-03-18 00:30:03 +00:00
2026-03-19 14:43:42 +00:00
### Priority Tiers (TCP+TLS Transport)
2026-03-18 00:30:03 +00:00
2026-03-19 14:43:42 +00:00
| Tier | Frames | Behavior |
|------|--------|----------|
2026-03-26 07:49:44 +00:00
| **Control ** | PING, PONG, WINDOW_UPDATE, OPEN, CLOSE, CONFIG | Always drained first. Never delayed. |
| **Data ** | DATA/DATA_BACK from normal streams, UDP frames | Drained when control queue is empty. |
| **Sustained ** | DATA/DATA_BACK from elephant flows | Lowest priority with guaranteed **1 MB/s ** drain rate. |
2026-03-18 00:30:03 +00:00
### Sustained Stream Classification
2026-03-19 14:43:42 +00:00
A TCP stream is classified as **sustained ** (elephant flow) when:
- Active for * * >10 seconds**, AND
- Average throughput exceeds **20 Mbit/s ** (2.5 MB/s)
2026-03-18 00:30:03 +00:00
2026-03-19 14:43:42 +00:00
Once classified, its flow control window locks to 1 MB and data frames move to the lowest-priority queue.
2026-03-18 00:30:03 +00:00
### Adaptive Per-Stream Windows
2026-03-19 14:43:42 +00:00
Each TCP stream has a send window from a shared **200 MB budget ** :
2026-03-18 00:30:03 +00:00
| Active Streams | Window per Stream |
|---|---|
2026-03-26 16:39:53 +00:00
| 1– 50 | 4 MB (maximum) |
| 51– 200 | Scales down (4 MB → 1 MB) |
2026-03-18 00:30:03 +00:00
| 200+ | 1 MB (floor) |
2026-03-19 14:43:42 +00:00
UDP traffic uses no flow control — datagrams are fire-and-forget, matching UDP semantics.
2026-03-18 00:30:03 +00:00
2026-03-26 07:49:44 +00:00
## Example Scenarios
2026-02-18 06:01:33 +00:00
2026-03-26 16:39:53 +00:00
### 1. 🌐 Expose a Private Cluster to the Internet
2024-04-14 03:38:00 +02:00
2026-03-19 14:43:42 +00:00
Deploy an Edge on a public VPS, point DNS to its IP. The Edge tunnels all TCP and UDP traffic to the Hub running inside your private cluster. No public ports needed on the cluster.
2026-02-16 13:15:12 +00:00
2026-03-26 16:39:53 +00:00
### 2. 🗺️ Multi-Region Edge Ingress
2026-02-16 13:15:12 +00:00
2026-03-19 14:43:42 +00:00
Run Edges in NYC, Frankfurt, and Tokyo — all connecting to a single Hub. Use GeoDNS to route users to their nearest Edge. PROXY protocol ensures the Hub sees real client IPs regardless of which Edge they entered through.
2026-03-26 16:39:53 +00:00
### 3. 📡 UDP Forwarding (DNS, Gaming, VoIP)
2026-03-19 14:43:42 +00:00
Configure UDP listen ports alongside TCP ports. DNS queries, game server traffic, or VoIP packets are tunneled through the same edge/hub connection and forwarded to SmartProxy with a PROXY v2 binary header preserving the client's real IP.
2026-02-18 06:01:33 +00:00
2026-03-19 14:43:42 +00:00
```typescript
await hub.updateAllowedEdges([
{
id: 'edge-nyc-01',
secret: 'secret',
listenPorts: [80, 443], // TCP
listenPortsUdp: [53, 27015], // DNS + game server
},
]);
```
2026-02-18 06:01:33 +00:00
2026-03-26 16:39:53 +00:00
### 4. 🚀 QUIC Transport for Low-Latency
2026-02-18 06:01:33 +00:00
2026-03-19 14:43:42 +00:00
Use QUIC transport to eliminate head-of-line blocking — a lost packet on one stream doesn't stall others. QUIC also enables 0-RTT reconnection and connection migration.
2026-02-18 06:01:33 +00:00
2026-03-19 14:43:42 +00:00
```typescript
await edge.start({
hubHost: 'hub.example.com',
hubPort: 8443,
edgeId: 'edge-01',
secret: 'secret',
transportMode: 'quicWithFallback', // try QUIC, fall back to TLS if UDP blocked
});
```
2026-03-26 16:39:53 +00:00
### 5. 🔑 Token-Based Edge Provisioning
2026-03-19 14:43:42 +00:00
Generate connection tokens on the hub side and distribute them to edge operators:
2026-02-18 06:01:33 +00:00
```typescript
2026-03-26 07:49:44 +00:00
import { encodeConnectionToken, RemoteIngressEdge } from '@serve .zone/remoteingress';
2026-02-18 06:01:33 +00:00
const token = encodeConnectionToken({
hubHost: 'hub.prod.example.com',
hubPort: 8443,
edgeId: 'edge-tokyo-01',
secret: 'generated-secret-abc123',
});
2026-03-19 14:43:42 +00:00
// Send `token` to the edge operator — a single string is all they need
2026-02-18 06:01:33 +00:00
const edge = new RemoteIngressEdge();
await edge.start({ token });
```
2024-04-14 03:38:00 +02:00
2026-03-26 16:39:53 +00:00
### 6. 🛡️ Centralized Firewall Management
Push firewall rules from the hub to all your edge nodes. Block bad actors, rate-limit abusive traffic, and whitelist trusted subnets — all from a single control plane:
```typescript
await hub.updateAllowedEdges([
{
id: 'edge-nyc-01',
secret: 'secret',
listenPorts: [80, 443],
firewallConfig: {
blockedIps: ['198.51.100.0/24'],
rateLimits: [
{ id: 'https', port: 443, protocol: 'tcp', rate: '500/second', perSourceIP: true, burst: 100 },
],
rules: [
{ id: 'allow-monitoring', direction: 'input', action: 'accept', sourceIP: '10.0.0.0/8', destPort: 9090, protocol: 'tcp' },
],
},
},
]);
// Firewall rules are applied at the edge via nftables within seconds
```
2024-04-14 03:38:00 +02:00
## License and Legal Information
2026-03-26 16:39:53 +00:00
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE ](./LICENSE ) file.
2024-04-14 03:38:00 +02:00
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
2026-03-26 16:39:53 +00:00
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
2024-04-14 03:38:00 +02:00
### Company Information
2026-02-16 13:15:12 +00:00
Task Venture Capital GmbH
2026-03-26 16:39:53 +00:00
Registered at District Court Bremen HRB 35230 HB, Germany
2024-04-14 03:38:00 +02:00
2026-03-26 16:39:53 +00:00
For any legal inquiries or further information, please contact us via email at hello@task .vc.
2024-03-24 14:44:44 +01:00
2024-04-14 03:38:00 +02:00
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.