ferrotunnel-http
HTTP ingress and proxy for FerroTunnel.
Overview
This crate provides HTTP handling for the tunnel:
HttpIngress- Server-side HTTP listener that routes requests through tunnelsTcpIngress- Server-side TCP listener for raw socket tunnelingHttpProxy- Client-side proxy that forwards tunneled requests to local services
Features
- HTTP/2 Support - Automatic protocol detection for HTTP/1.1 and HTTP/2
- Connection Pooling - Efficient connection reuse to local services
- WebSocket Tunneling - Transparent WebSocket upgrade handling
- Configurable Limits - Max connections, timeouts, response size limits
Components
HttpIngress (Server)
Hyper-based HTTP server that:
- Listens for incoming HTTP requests
- Routes requests to connected tunnel clients
- Supports HTTP/1.1, HTTP/2, and WebSocket upgrades
- Automatic protocol detection via
hyper-util::AutoBuilder
TcpIngress (Server)
Socket listener that:
- Accepts raw TCP connections
- Routes traffic through the tunnel protocol
- Protocol-agnostic (supports Database, SSH, etc.)
HttpProxy (Client)
Handles tunneled HTTP requests by:
- Receiving virtual streams from the multiplexer
- Connecting to local services via connection pool
- Proxying data bidirectionally
- Reusing HTTP/1.1 and HTTP/2 connections for performance
Usage
Basic Usage
use ;
// Server-side: Create ingress (supports HTTP/1.1 and HTTP/2 automatically)
let ingress = new;
let tcp_ingress = new;
try_join!?;
// Client-side: Create proxy with default connection pooling
let proxy = new;
proxy.handle_stream;
Advanced: Custom Connection Pool
use ;
use Duration;
// Configure connection pool for optimal performance
let pool_config = PoolConfig ;
let proxy = with_pool_config;
proxy.handle_stream;
Connection Pooling Benefits:
- Eliminates TCP handshake overhead per request
- Reuses HTTP/1.1 connections via LIFO queue
- Shares HTTP/2 connections via multiplexing
- Background eviction prevents resource leaks
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.