惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Securelist
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
博客园 - 聂微东
博客园 - 【当耐特】
小众软件
小众软件
V
V2EX
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
N
News and Events Feed by Topic
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 司徒正美
P
Privacy & Cybersecurity Law Blog
The Hacker News
The Hacker News
AI
AI
O
OpenAI News
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threat Research - Cisco Blogs
Jina AI
Jina AI
博客园_首页
罗磊的独立博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
IT之家
IT之家
V
Vulnerabilities – Threatpost
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google Online Security Blog
Google Online Security Blog
G
GRAHAM CLULEY
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hacker News: Ask HN
Hacker News: Ask HN
P
Palo Alto Networks Blog
S
SegmentFault 最新的问题
T
The Exploit Database - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
News and Events Feed by Topic
V
Visual Studio Blog
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
The Story of How I Built a VPN protocol: Part 1
Smile · 2026-05-02 · via DEV Community
<h1> 🚨🚨🚨 Disclaimer 🚨🚨🚨 </h1> <p>This article and the VPN itself are written <strong>for educational purposes only</strong>.</p> <h1> How It All Started </h1> <p>I recently switched to Arch. Everything started off well: I installed all the utilities I needed, and then I decided to install the VPN I used to use. And then a problem appeared — it doesn't work on Arch (even as an AppImage).</p> <p>My provider also supported Shadowsocks, but instead of using it, I decided to write my own VPN. For more practice.</p> <h1> VPN Protocol </h1> <p>My VPN protocol is designed for maximum stealth. In my opinion, one of the most important things here is <strong>encryption from the very first packet</strong>. In my protocol, this is implemented just like in Shadowsocks — with a pre-shared key.</p> <p>Encryption algorithm: <strong>ChaCha20-Poly1305</strong>.</p> <p>It's also worth mentioning that the protocol works over <strong>TCP</strong>. A random amount of junk bytes is added to each packet for length obfuscation.</p> <h2> Packet Structure </h2> <p>Each packet has a 5-byte header that is masked as encrypted data using XOR with the first 5 bytes of the key.</p> <ul> <li> <strong>First 2 bytes</strong> — total packet length. Needed to determine where the packet ends (since TCP can segment packets).</li> <li> <strong>Third byte</strong> — flags byte. Currently only 2 flags are used: <ul> <li>Bit 1 — indicates that this packet is fake and should not be processed (not yet implemented).</li> <li>Bit 2 — flag for performing ECDH (Elliptic Curve Diffie‑Hellman).</li> </ul> </li> <li> <strong>Last 2 bytes</strong> — ciphertext length, used to separate junk bytes from the ciphertext.</li> </ul> <p>Then comes:</p> <ul> <li> <strong>12 bytes</strong> — randomly generated nonce;</li> <li> <strong>ciphertext</strong>;</li> <li> <strong>AEAD</strong> (authentication tag);</li> <li> <strong>junk bytes</strong>.</li> </ul> <h2> Handshake and Key Exchange </h2> <h3> 1. First packet from the client </h3> <p>The client sends its <strong>16-byte username</strong> to the server (encrypted, of course).</p> <h3> 2. Server response </h3> <p>If the server finds a user with that username, it:</p> <ul> <li>sends the client a randomly generated <strong>32-byte salt</strong>;</li> <li>starts computing the keys: <ul> <li> <strong>sending key</strong> (server → client)</li> <li> <strong>receiving key</strong> (server ← client)</li> </ul> </li> </ul> <h3> 3. Key computation on the server </h3> <p>The server stores the user's password in plaintext.</p> <ul> <li> <strong>Receiving key</strong> (for decrypting from the client) = hash(password + <strong>first 16 bytes</strong> of salt).</li> <li> <strong>Sending key</strong> (for encrypting to the client) = hash(password + <strong>last 16 bytes</strong> of salt).</li> </ul> <h3> 4. Client actions </h3> <p>The client receives the salt, decrypts it, and does the same thing, <strong>but the key roles are inverted</strong>:</p> <ul> <li>what is the sending key for the server becomes the receiving key for the client, and vice versa.</li> </ul> <h3> 5. ECDH and connection finalization </h3> <p>After the client has generated the keys, it generates an <strong>ephemeral key pair</strong> based on the <strong>Curve25519</strong> elliptic curve (this pair is needed for ECDH). It then sends a connection confirmation (first byte = <code>0xFF</code>) along with the public ephemeral key, setting the ECDH flag.</p> <p>The server receives the packet, deobfuscates it, and gets the confirmation and the client's ephemeral key. Then it:</p> <ul> <li>assigns an IP address to the client from a local private network;</li> <li>generates its own ephemeral key pair;</li> <li>sends the client its assigned IP address and the server's public key;</li> <li>performs the ECDH round.</li> </ul> <p>After sending, the server updates its keys by hashing the old keys with the secret obtained from ECDH.</p> <h3> 6. Client finalization </h3> <p>After receiving the packet with the IP address and the server's public ephemeral key, the client:</p> <ul> <li>creates a local tunnel;</li> <li>sets its IP address (received from the server);</li> <li>performs the ECDH round;</li> <li>updates its keys.</li> </ul> <h2> Main Work Loop </h2> <p>After the connection is established and keys are generated, the main work loop begins.</p> <h3> Client Side </h3> <p><strong>3 goroutines</strong> run on the client side:</p> <h4> First goroutine (reading from the tunnel and preparing packets) </h4> <ul> <li>Reads packets from the tunnel.</li> <li>Generates an <strong>8-byte salt</strong> to update the sending key (by hashing the old sending key with the salt).</li> <li>Adds this 8-byte salt to the beginning of the plaintext (the salt is followed by the packet read from the tunnel).</li> <li>Encrypts everything.</li> <li>Adds random junk bytes for obfuscation.</li> <li>Stores the prepared packet in a buffer.</li> </ul> <h4> Second goroutine (sending packets) </h4> <ul> <li>Responsible for sending already prepared packets.</li> <li>Packets are sent in <strong>batches of 1 to 5 packets</strong> (the protocol is of course segmented at OSI layers 3 and 4, but I can't influence that).</li> </ul> <h4> Third goroutine (receiving packets from the server) </h4> <ul> <li>Responsible for receiving packets from the server.</li> <li>Performs deobfuscation and decryption.</li> <li>Writes the decrypted data to the tunnel.</li> </ul> <h3> Server Side </h3> <p>The server has <strong>3 main goroutines</strong>, plus additional goroutines for receiving packets from clients.</p> <h4> First goroutine (handshake handling) </h4> <p>Handles incoming handshake requests from clients. If the handshake is successful, a <strong>new goroutine</strong> is created to process packets sent by that client.</p> <h4> Second goroutine (reading from the tunnel) </h4> <p>Reads packets from the tunnel and sends them to clients.</p> <h4> Third goroutine (cleaning inactive connections) </h4> <p>Cleans up inactive connections.</p> <h2> Key Updates </h2> <h3> Salt in every packet </h3> <p>Every packet (whether from client or server) contains a <strong>salt</strong>. It is used to update the keys:</p> <ul> <li> <strong>The server</strong>, when sending a packet, includes a salt. After sending, it updates its <strong>sending key</strong> by hashing the old key with that salt.</li> <li> <strong>The client</strong>, when receiving and decrypting a packet, also updates a key — but not the sending key, the <strong>receiving key</strong>.</li> <li>When the client sends a packet, the same happens, but the roles are reversed.</li> </ul> <h3> Periodic ECDH updates </h3> <p>Every <strong>4 minutes</strong> or after sending <strong>2³² packets</strong> (whichever comes first), keys are updated using ECDH on elliptic curves. The keys are transmitted along with data packets.</p> <p>And that, in fact, is the entire protocol. During implementation, I thought about writing it in <strong>Go</strong> or <strong>Rust</strong>. I chose Go for its simplicity.</p> <h1> Implementation Process </h1> <p>To be honest, the protocol architecture was mostly developed while writing the code. It has quite a few problems — both in terms of protocol design and implementation.</p> <h3> Example problems </h3> <ul> <li><p><strong>Constant username packet length</strong><br><br> The encrypted username packet has a constant length of 44 bytes (12 bytes nonce, 16 bytes ciphertext, and a 16-byte AEAD tag). Knowing this and that the user is using this protocol, you can calculate the 4th and 5th bytes of the key.</p></li> <li><p><strong>Repository duplication</strong><br><br> I foolishly created two separate repositories — one for the client and one for the server. As a result, the branches containing common modules just duplicate each other.</p></li> <li><p><strong>Git flow</strong><br><br> I tried to follow git flow, but failed here too.</p></li> <li><p><strong>Vulnerabilities</strong><br><br> I also have a feeling that there are more vulnerabilities in the code than working logic.</p></li> <li><p><strong>No graceful shutdown</strong><br><br> There is no proper negotiated client-server disconnect — just a connection break.</p></li> </ul> <p>Although considering this is my first project, I think it didn't turn out too badly. If anyone wants to check out this mess, here are the links:</p> <ul> <li> <strong>Client</strong>: <a href="https://github.com/SmileUwUI/smileTun-client" rel="noopener noreferrer">https://github.com/SmileUwUI/smileTun-client</a> </li> <li> <strong>Server</strong>: <a href="https://github.com/SmileUwUI/smileTun-server" rel="noopener noreferrer">https://github.com/SmileUwUI/smileTun-server</a> </li> </ul> <p>Currently, the implementation works. And I'm writing this article through my own VPN protocol.</p> <h1> Future Plans </h1> <ul> <li>Merge both repositories into one.</li> <li>Add fake packet sending.</li> <li>Add TLS mimicry.</li> <li>And much more.</li> </ul> <p>If anyone has any questions or recommendations — leave them in the comments. For now, I bid you farewell. Good luck to everyone!</p>