TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: SafeHaven – A Minimal VPN Implementation in Go

99 点作者 kwakubiney2 个月前
Hi HN,<p>For the past few months, I&#x27;ve been exploring tools that integrate with the Linux networking stack. This led me to build SafeHaven, a lightweight and configurable VPN implementation written in Go. The goal was to better understand how virtual private networks work at a fundamental level.<p>Would love feedback from the community! Repo link: <a href="https:&#x2F;&#x2F;github.com&#x2F;kwakubiney&#x2F;safehaven">https:&#x2F;&#x2F;github.com&#x2F;kwakubiney&#x2F;safehaven</a>

5 条评论

max-privatevoid2 个月前
Nice. This does some things very similarly to Hyprspace[1]. The core idea is the same: Receive some bytes from a TUN device, shove them into a network socket, and vice versa. Hyprspace uses libp2p to manage the outer connections between VPN nodes instead of plain UDP, which takes care of addressing, hole punching and encryption.<p>BTW: You can also use the netlink library to configure the routing table without external processes[2]. The &#x2F;1 trick isn&#x27;t necessary either, you can just create a route for 0.0.0.0&#x2F;0 and set its metric lower than the existing default route. That won&#x27;t replace the old route in the table, the new one will just take precedence as long as it exists.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;hyprspace&#x2F;hyprspace">https:&#x2F;&#x2F;github.com&#x2F;hyprspace&#x2F;hyprspace</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;hyprspace&#x2F;hyprspace&#x2F;blob&#x2F;a5957e485ff0c2e9133e7da5408ec1273681688e&#x2F;tun&#x2F;tun_linux.go#L73-L77">https:&#x2F;&#x2F;github.com&#x2F;hyprspace&#x2F;hyprspace&#x2F;blob&#x2F;a5957e485ff0c2e9...</a>
评论 #43234638 未加载
评论 #43235920 未加载
entropyneur2 个月前
Since people are apparently interested in minimal VPNs, here&#x27;s one I built in Rust recently: <a href="https:&#x2F;&#x2F;github.com&#x2F;atereshkin&#x2F;nanovpn">https:&#x2F;&#x2F;github.com&#x2F;atereshkin&#x2F;nanovpn</a><p>My goal there was to have as little code as possible so that one could look at it and immediately grasp what goes into establishing a VPN.
sepositus2 个月前
Awesome, thanks for sharing. Did you use anything particular to help direct the implementation? I&#x27;ve been on a streak of building things in Go for the same reason (learning), and a VPN is one of the items on my list.
评论 #43232491 未加载
jimmyl022 个月前
pretty cool and thanks for the details about TUN devices!<p>I believe wireguard runs over UDP and while you still need a TUN device, it has kernel implementations to handle encrypting the traffic.
评论 #43232569 未加载
gsliepen2 个月前
From the article:<p>&gt; Currently, packets are not being encrypted within the UDP tunnel so packet sniffing over the internet is possible. It is encouraged to use this over a protocol like SSH<p>No encryption takes the P out of VPN. Also, if you are going to need SSH to make it secure, then you can just use OpenSSH&#x27;s built-in support for the tun device using the -w option.
评论 #43236437 未加载