HeadlinesBriefing favicon HeadlinesBriefing.com

Developer Builds Open-Source Tunneling Tool in TypeScript

DEV Community •
×

A software engineer embarked on a challenging journey to build Tunnelmole, a TypeScript-based localhost tunneling tool. This open-source project was inspired by the desire to understand the inner workings of proprietary tools like ngrok. The engineer aimed to create a tool that was equally simple and effective, exposing local development servers to the public internet.

One of the surprising discoveries was the tool's attraction to phishing scammers. Tunnelmole quickly became a target for malicious actors hosting phishing sites and hiding their true IP addresses. To combat this, the engineer implemented solutions like adding the X-Forwarded-For header and embedding the client's IP in the URL, effectively deanonymizing the origin of the tunnel.

Another significant hurdle was the limitations of high-level APIs like fetch. The engineer found that these tools, while convenient, were not suitable for perfect, byte-for-byte proxying. This led to the adoption of Node.js's built-in http module, which provided the necessary low-level control.

The engineer also emphasized the importance of structured, typed messaging for WebSockets, ensuring that the tunnel could handle various message types effectively. This approach turned a chaotic data stream into a robust, extensible system. The experience underscored the need for diligent state management in Node.js to prevent memory leaks and ensure efficient resource use.