<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dhinesh Krishnan</title>
    <description>The latest articles on DEV Community by Dhinesh Krishnan (@dhinesh_krishnan).</description>
    <link>https://dev.to/dhinesh_krishnan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2499878%2Fef875e67-0240-4ce0-9293-16424b4fd19a.jpg</url>
      <title>DEV Community: Dhinesh Krishnan</title>
      <link>https://dev.to/dhinesh_krishnan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dhinesh_krishnan"/>
    <language>en</language>
    <item>
      <title>Why I Stopped Paying for Tunnels and Built My Own (in 500 Lines of Rust).</title>
      <dc:creator>Dhinesh Krishnan</dc:creator>
      <pubDate>Wed, 10 Jun 2026 05:37:22 +0000</pubDate>
      <link>https://dev.to/dhinesh_krishnan/why-i-stopped-paying-for-tunnels-and-built-my-own-in-500-lines-of-rust-3b3o</link>
      <guid>https://dev.to/dhinesh_krishnan/why-i-stopped-paying-for-tunnels-and-built-my-own-in-500-lines-of-rust-3b3o</guid>
      <description>&lt;h1&gt;
  
  
  Why I Stopped Paying for Tunnels and Built My Own (in 500 Lines of Rust)
&lt;/h1&gt;

&lt;p&gt;We’ve all been there: you’re working on a project, you need to show it to a client or a teammate, and you reach for Ngrok. It works, it’s reliable, but then you hit the paywall. Or maybe, like me, you just wanted to understand &lt;em&gt;how&lt;/em&gt; that "magic" URL actually pipes traffic to your &lt;code&gt;localhost&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I wanted to see if I could build a solution that was lightweight, self-hosted, and blazing fast. So, I spent the last few weeks building &lt;strong&gt;Macha&lt;/strong&gt;—a high-performance reverse tunnel written in Rust.&lt;/p&gt;

&lt;h2&gt;
  
  
  The "Aha!" Moment: How Tunnels Actually Work
&lt;/h2&gt;

&lt;p&gt;Most people think a tunnel is just a complex proxy. In reality, it’s a &lt;strong&gt;multiplexer&lt;/strong&gt;. To make this work, you need two distinct communication planes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The Control Plane (Port 9000):&lt;/strong&gt; A persistent TCP heartbeat that tells your machine, "Hey, a request is waiting for you."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Data Plane (Port 9001):&lt;/strong&gt; An ephemeral, high-speed pipe that opens only when traffic actually arrives.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By separating these, you ensure your tunnel doesn't hang when someone downloads a large file or triggers a heavy request.&lt;/p&gt;

&lt;p&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Rust?
&lt;/h2&gt;

&lt;p&gt;I chose Rust because I needed three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Memory Safety:&lt;/strong&gt; Network programming is rife with buffer overflows and memory leaks. Rust’s borrow checker gives me total peace of mind.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Async Power:&lt;/strong&gt; Using &lt;code&gt;tokio&lt;/code&gt;, I can handle thousands of concurrent connections on a single thread.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static Binaries:&lt;/strong&gt; I wanted a tool that "just works" without needing to install a heavy runtime like Node.js or Python. Rust compiles down to a single binary I can drop on any server.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Architecture Under the Hood
&lt;/h2&gt;

&lt;p&gt;The system is built on three components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Server (EC2 + Nginx):&lt;/strong&gt; My "Switchboard Operator." It maintains a registry of connected agents using an in-memory &lt;code&gt;DashMap&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Agent (CLI):&lt;/strong&gt; A thin Rust binary that handles the tunneling and provides a real-time telemetry dashboard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Dashboard (SSE):&lt;/strong&gt; My favorite part—I built a real-time monitoring dashboard in-process using Server-Sent Events (SSE) that lets me watch incoming requests in real-time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned (The "Internet Background Noise")
&lt;/h2&gt;

&lt;p&gt;The second I put this live on a public domain, I realized how loud the internet is. Within minutes, my Nginx logs were flooded with automated bots scanning for &lt;code&gt;/robots.txt&lt;/code&gt; and &lt;code&gt;.env&lt;/code&gt; files. &lt;/p&gt;

&lt;p&gt;It was a wake-up call: &lt;strong&gt;When you build infrastructure, you don't just build an app—you build a digital perimeter.&lt;/strong&gt; I had to quickly learn how to use &lt;code&gt;fail2ban&lt;/code&gt; and secure my AWS Security Groups to ensure my infrastructure didn't become a playground for scanners.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check it out!
&lt;/h2&gt;

&lt;p&gt;The project is MIT-licensed, open-source, and—most importantly—totally free to self-host. You can install it with a one-liner:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;curl -fsSL [https://macha.live/install.sh](https://macha.live/install.sh) | bash&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/DhineshKrishnan1206/macha" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>networking</category>
      <category>rust</category>
      <category>showdev</category>
      <category>sideprojects</category>
    </item>
  </channel>
</rss>
