Skip to content

CurlTransport

CurlTransport is a transport for bare-mux that implements end-to-end encryption using libcurl.js and Wisp. It allows developers to route traffic through SOCKS5, SOCKS4, and HTTP proxies, providing powerful proxy chaining capabilities.

  • End-to-End Encryption: Full TLS encryption using libcurl.js
  • Wisp Protocol: Efficient WebSocket multiplexing
  • Proxy Support: Route through SOCKS5, SOCKS4a, and HTTP proxies
  • Wsproxy Alternative: Optional wsproxy transport mode
  • Connection Management: Configurable connection pooling and limits
npm install @mercuryworkshop/libcurl-transport
import { BareMuxConnection } from "@mercuryworkshop/bare-mux";

const connection = new BareMuxConnection("/baremux/worker.js");

// Set CurlTransport with Wisp server
await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/"
}]);

CurlTransport allows you to route your traffic through intermediate proxies, enabling proxy chaining and advanced network configurations. This is powered by libcurl.js’s native proxy support.

CurlTransport supports three major proxy protocols:

  • Full Name: Socket Secure version 5 with remote DNS
  • Protocol: Established connection-based proxy protocol
  • DNS Resolution: Remote (DNS queries are resolved by the proxy server)
  • Use Cases: Tor integration, anonymity networks, bypassing DNS-based restrictions
  • Port: Typically 1080 or 9050 (Tor)
  • Full Name: Socket Secure version 4A with remote DNS
  • Protocol: Earlier version with remote DNS support
  • DNS Resolution: Remote (DNS queries are resolved by the proxy server)
  • Use Cases: Legacy proxy systems, older SOCKS implementations
  • Port: Typically 1080
  • Note: Less feature-rich than SOCKS5 but widely supported
  • Full Name: HTTP/HTTPS Proxy
  • Protocol: HTTP CONNECT method for tunneling
  • DNS Resolution: Can be local or remote depending on proxy configuration
  • Use Cases: Corporate proxies, web filtering systems, CDN routing
  • Port: Typically 8080, 3128, or 8888
  • Note: Works with both HTTP and HTTPS traffic

Add the proxy parameter with the proxy URL in the format protocol://host:port:

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  proxy: "socks5h://proxy.example.com:1080"
}]);

SOCKS5 Proxy (Recommended for most use cases):

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  proxy: "socks5h://127.0.0.1:9050"  // Tor example
}]);

HTTP Proxy (Common in corporate environments):

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  proxy: "http://proxy.example.com:8080"
}]);

SOCKS4A Proxy (Legacy systems):

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  proxy: "socks4a://proxy.example.com:1080"
}]);

If your proxy requires authentication, include credentials in the URL:

HTTP Proxy with Authentication:

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  proxy: "http://username:[email protected]:8080"
}]);

SOCKS5 Proxy with Authentication:

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  proxy: "socks5h://username:[email protected]:1080"
}]);

If you prefer to use wsproxy instead of Wisp, set transport: "wsproxy". Wsproxy is similar to Wisp, but each TCP connection exists as a separate WebSocket instead of being multiplexed.

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wsproxy/",
  transport: "wsproxy"
}]);

With Proxy:

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wsproxy/",
  transport: "wsproxy",
  proxy: "socks5h://127.0.0.1:9050"
}]);

Configure the maximum number of open connections for libcurl.js. The connections option is passed through to HTTPSession.set_connections in libcurl.js.

Format: [hard_limit, cache_limit, max_per_host]

  • hard_limit (default 60): Maximum active connections
  • cache_limit (default 50): Connection cache size
  • max_per_host (default 6): Max connections per host
await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  connections: [30, 20, 1]  // Conservative settings
}]);

High Performance:

connections: [100, 80, 10]

Conservative (Good for Tor/SOCKS):

connections: [30, 20, 1]

Default:

connections: [60, 50, 6]

Route traffic through Tor for anonymity:

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  proxy: "socks5h://127.0.0.1:9050",  // Tor SOCKS proxy
  connections: [30, 20, 1]  // Tor-friendly settings
}]);

Why SOCKS5 with Tor?

  • Remote DNS resolution prevents DNS leaks
  • Full protocol support for all connection types
  • Better performance than HTTP proxies
  • Native Tor compatibility

Route through a corporate HTTP proxy:

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  proxy: "http://corporate-proxy.company.com:8080"
}]);

Common Corporate Scenarios:

  • Authenticated proxies with credentials
  • Multiple proxy servers for load balancing
  • Proxy auto-configuration (PAC) support via manual URL

Combine CurlTransport’s proxy support with your Wisp server’s routing capabilities for multi-hop proxy chains.

Example Multi-Hop Setup:

  1. Browser → CurlTransport
  2. CurlTransport → SOCKS5 Proxy
  3. SOCKS5 Proxy → Wisp Server
  4. Wisp Server → Destination
await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://wisp-server.com/wisp/",  // Wisp server as second hop
  proxy: "socks5h://first-proxy.com:1080"    // SOCKS5 as first hop
}]);

Route traffic through VPN endpoints that expose SOCKS proxies:

await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  proxy: "socks5h://vpn-exit-node.com:1080"
}]);

Use region-specific proxies for geo-restricted content:

// Route through EU proxy
await connection.setTransport("/path/to/libcurl/index.mjs", [{
  websocket: "wss://example.com/wisp/",
  proxy: "socks5h://eu-proxy.example.com:1080"
}]);
npm install
npm run build

Created and maintained by Mercury Workshop.