compress pic;add a new bolg
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
---
|
||||
title: "Why I Open-Sourced PrivyDrop: A Story of Privacy, WebRTC, and Community Building"
|
||||
description: "PrivyDrop is now open source! This article tells the story of its evolution from a personal need to a production-grade private file transfer tool, dives deep into its architecture, and invites you to build the future together."
|
||||
date: "2025-07-07"
|
||||
author: "david bai"
|
||||
cover: "/blog-assets/privydrop-open-source.jpg"
|
||||
tags: [Open Source, WebRTC, Privacy, Security, Next.js, Node.js]
|
||||
status: "published"
|
||||
---
|
||||
|
||||

|
||||
|
||||
## Introduction
|
||||
|
||||
Today, I'm incredibly excited to announce that a personal project I've poured my heart and soul into, **PrivyDrop**, is now officially open source!
|
||||
|
||||
[**Try it Live »**](https://www.privydrop.app/) | [**GitHub Repo »**](https://github.com/david-bai00/PrivyDrop)
|
||||
|
||||
This project began with a very simple personal need: "I just want to send things between my phone and computer, securely and easily."
|
||||
|
||||
If you, like me, have ever been frustrated looking for a file-sharing tool that requires no registration, has no speed limits, and truly respects your privacy, then this article is for you. It will not only share the story of "scratching my own itch" but will also take you on a complete "behind-the-scenes" tour to explore PrivyDrop's core architecture and design philosophy. And most importantly, it's a sincere invitation for you to become a co-author of its next chapter.
|
||||
|
||||
## Part 1: The Birth of a Tool: From "I Need It" to "Everyone Can Use It"
|
||||
|
||||
### 1.1 A Developer's Journey of Scratching His Own Itch
|
||||
|
||||
It all started with a small but persistent pain point in my daily workflow.
|
||||
|
||||
I frequently need to quickly send files, screenshots, or text snippets between my phone and my laptop. I tried many tools, but none of them fully met my requirements:
|
||||
|
||||
- Some online P2P tools were powerful but could only send files, failing my need to send lightweight text or links.
|
||||
- Some online clipboards could sync text conveniently, but I was deeply concerned about uploading my clipboard content to an unknown server.
|
||||
- And the mainstream cloud storage or social apps either required logging in or had size and speed limits, making the whole process feel clunky and cumbersome.
|
||||
|
||||
After failing to find a tool that perfectly matched my three core requirements—**fast, private, and no account needed**—I decided to build one for myself.
|
||||
|
||||
### 1.2 From a Personal Utility to a Public Project
|
||||
|
||||
Initially, PrivyDrop was just a small utility to meet my own needs. But as I gradually improved its features, I realized that my pain point was likely a common one.
|
||||
|
||||
In an era where data and privacy are increasingly important, we deserve a better choice—a tool that doesn't force us to make a painful trade-off between "convenience" and "privacy." This idea drove me to polish PrivyDrop from a personal project into a robust and reliable public service.
|
||||
|
||||
Our core vision is simple, as I wrote in the project's README: **We believe everyone should have control over their own data.**
|
||||
|
||||
### 1.3 Why Open Source? The Only Answer for Trust
|
||||
|
||||
For a tool that claims "privacy and security" as its core value, being closed-source is a contradiction in itself. How can users trust your promises?
|
||||
|
||||
Therefore, open-sourcing was the inevitable choice and the only answer.
|
||||
|
||||
- **To Build Trust**: Code is the best proof. We are making all our code public to be scrutinized by the world, thereby building undeniable trust.
|
||||
- **The Power of Community**: I am well aware that an individual's power is limited. I believe the collective wisdom of the community can help find flaws I've missed and suggest features I've never thought of, helping PrivyDrop go further and become more robust.
|
||||
- **To Give Back and Learn**: I have benefited immensely from the open-source community, and now it's my time to give back. Open-sourcing the project is both a way to learn from talented developers and a joy of sharing.
|
||||
|
||||
## Part 2: A Deep Dive into the Architecture: A "Production-Grade" Practice
|
||||
|
||||
PrivyDrop is not just a toy project. In its architectural design, we pursued simplicity, efficiency, and scalability, striving to meet production-grade standards.
|
||||
|
||||
### 2.1 The Big Picture: A Simple and Efficient System
|
||||
|
||||
Our core design principle is: **a lightweight backend, an intelligent frontend**. The backend only acts as a "traffic cop" (for signaling), while the frontend handles all the "heavy lifting" (file processing and transfer).
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
subgraph "User A (Sender)"
|
||||
A[Frontend App]
|
||||
end
|
||||
subgraph "User B (Recipient)"
|
||||
B[Frontend App]
|
||||
end
|
||||
subgraph "Cloud"
|
||||
C(Signaling Server - Node.js)
|
||||
D(State Storage - Redis)
|
||||
end
|
||||
|
||||
A -- "1. Request to create/join room" --> C
|
||||
B -- "2. Request to join same room" --> C
|
||||
C -- "3. Exchange WebRTC signals (SDP/ICE)" --> A
|
||||
C -- "4. Exchange WebRTC signals (SDP/ICE)" --> B
|
||||
A <-.-> B;
|
||||
C <--> D
|
||||
A <-. "5. Establish P2P direct connection" .-> B
|
||||
A -- "6. Transfer files/text directly" --> B
|
||||
|
||||
style A fill:#D5E8D4,stroke:#82B366
|
||||
style B fill:#D5E8D4,stroke:#82B366
|
||||
```
|
||||
|
||||
### 2.2 Frontend Architecture: From Separation of Concerns to Logical Cohesion
|
||||
|
||||
The frontend is built with Next.js 14, and our core design philosophy is **using custom Hooks as the heart of our business logic**.
|
||||
|
||||
You might ask, why not Redux or Zustand? For PrivyDrop, most of the state is tightly coupled with specific, highly cohesive business logic. We encapsulated this logic and state into a series of custom Hooks (like `useWebRTCConnection`, `useRoomManager`, `useFileTransferHandler`), which brought several clear benefits:
|
||||
|
||||
- **Logical Cohesion**: All state and methods related to the WebRTC connection are in `useWebRTCConnection`, making it extremely easy to maintain.
|
||||
- **Pure Components**: React components are freed from complex business logic, returning to their essential role of rendering UI.
|
||||
- **Clear Layering**: This creates a clear data flow and dependency relationship from `app` (routing) -> `components` (UI) -> `hooks` (logic) -> `lib` (low-level capabilities), greatly enhancing the maintainability of the codebase.
|
||||
|
||||
### 2.3 Backend Architecture: The Art of Statelessness and Efficiency
|
||||
|
||||
The backend, based on Node.js and Express, strictly follows the **stateless** principle in its design.
|
||||
|
||||
The server itself holds no state related to rooms or users. All state is delegated to **Redis**. This allows the backend application to be scaled horizontally with ease.
|
||||
|
||||
We also cleverly utilized different Redis data structures to meet business needs:
|
||||
|
||||
- **Hash**: To store room metadata.
|
||||
- **Set**: To store the `socketId` of all members in a room, ensuring uniqueness.
|
||||
- **String**: To reverse-map a `socketId` to its `roomId`, facilitating quick cleanup when a user disconnects.
|
||||
- **Sorted Set**: To implement IP-based rate limiting, effectively preventing malicious attacks.
|
||||
|
||||
All keys are set with a reasonable TTL (Time To Live), ensuring automatic resource cleanup and allowing the system to run stably over the long term.
|
||||
|
||||
### 2.4 "Production-Grade" Considerations: From Deployment to Security
|
||||
|
||||
We provide a complete production deployment plan, including:
|
||||
|
||||
- Using **Nginx** as a reverse proxy and for SSL termination.
|
||||
- Using **PM2** for Node.js process management.
|
||||
- Using **Certbot** for automatic SSL certificate acquisition and renewal.
|
||||
- A comprehensive guide for setting up a **TURN/STUN** server for scenarios requiring traversal of complex NATs.
|
||||
|
||||
These all demonstrate that PrivyDrop is a serious project that can be trusted and deployed to a production environment.
|
||||
|
||||
## Part 3: More Than Code: An Invitation to Build the Future
|
||||
|
||||
Open sourcing is just the beginning. We have an exciting future planned for PrivyDrop, and now, we want to invite you to join us.
|
||||
|
||||
### 3.1 Project Roadmap
|
||||
|
||||
We have a public [**Project Roadmap**](./ROADMAP.md) that outlines our future priorities. We plan to add some highly requested features in the future, such as:
|
||||
|
||||
- **Resumable Transfers**: To handle very large files and unstable network conditions.
|
||||
- **E2E Encrypted Group Chat**: To extend secure P2P communication to multi-user text chats.
|
||||
- Other undetermined features.
|
||||
|
||||
### 3.2 How to Contribute?
|
||||
|
||||
We welcome contributions of all forms! No matter who you are, there's always a way to help make PrivyDrop better. Please read our [**Contributing Guidelines**](./.github/CONTRIBUTING.md) to start your journey.
|
||||
|
||||
- **For Users**: Use the product, report bugs, and suggest features via [GitHub Issues](https://github.com/david-bai00/PrivyDrop/issues).
|
||||
- **For Developers**: Claim a bug, implement a new feature, or refactor a piece of existing code.
|
||||
- **For Documentarians/Translators**: Help us improve the documentation or translate PrivyDrop into more languages.
|
||||
|
||||
### 3.3 A Strong Call to Action
|
||||
|
||||
- **For Users**: Experience the ultimate privacy and convenience with PrivyDrop now!
|
||||
[**➡️ Try it Live**](https://www.privydrop.app/)
|
||||
|
||||
- **For Developers**: If PrivyDrop's philosophy or technology excites you, please give our GitHub repository a Star! It's the greatest recognition and encouragement for us.
|
||||
[**⭐️ Star Us on GitHub**](https://github.com/david-bai00/PrivyDrop)
|
||||
|
||||
- **For Everyone**: Join our community discussions and let us hear your voice!
|
||||
|
||||
## Conclusion
|
||||
|
||||
Thank you again for taking the time to read this story.
|
||||
|
||||
The story of PrivyDrop began with one person's need, and I look forward to its future being written by a community.
|
||||
@@ -0,0 +1,159 @@
|
||||
---
|
||||
title: "我为什么开源了 PrivyDrop:一个关于隐私、WebRTC 和社区共建的故事"
|
||||
description: "PrivyDrop 正式开源!本文讲述了它从一个个人需求演变为一个生产级隐私文件传输工具的故事,深入解析其前后端架构,并邀请您一同共建未来。"
|
||||
date: "2025-07-07"
|
||||
author: "david bai"
|
||||
cover: "/blog-assets/privydrop-open-source.jpg"
|
||||
tags: [开源, WebRTC, 隐私安全, Next.js, Node.js]
|
||||
status: "published"
|
||||
---
|
||||
|
||||

|
||||
|
||||
## 引言
|
||||
|
||||
今天,我怀着无比激动的心情宣布,我投入了大量心血开发的个人项目——**PrivyDrop**,现在正式开源!
|
||||
|
||||
[**在线体验 »**](https://www.privydrop.app/) | [**GitHub 仓库 »**](https://github.com/david-bai00/PrivyDrop)
|
||||
|
||||
这个项目始于一个非常简单的个人需求:“我只是想在手机和电脑间安全、方便地传点东西。”
|
||||
|
||||
如果你也曾像我一样,在寻找一个无需注册、不限速、真正尊重你隐私的文件分享工具时感到困惑,那么这篇文章就是为你而写。它不仅会分享这个“自救”故事,还将带你进行一次彻底的“幕后之旅”,深入探索 PrivyDrop 的核心架构与设计哲学,并真诚地邀请你,成为这个故事新篇章的共同作者。
|
||||
|
||||
## 第一部分:一个工具的诞生:从“我需要”到“大家用”
|
||||
|
||||
### 1.1 一个开发者的“自救”之路
|
||||
|
||||
一切都源于我日常工作中的一个不大不小的痛点。
|
||||
|
||||
我经常需要在手机和笔记本电脑之间快速发送文件、截图或一段文本链接。我试过很多工具,但没有一个能完全满足我的要求:
|
||||
|
||||
- 有的在线 P2P 工具,功能强大,但只能发送文件,无法满足我发送轻便文本或链接的需求。
|
||||
- 有的在线剪贴板工具,可以方便地同步文本,但我又对将剪贴板内容上传到未知服务器感到深深的担忧。
|
||||
- 而那些主流的云存储或社交软件,要么需要登录,要么有大小和速度的限制,整个过程显得笨重而繁琐。
|
||||
|
||||
在找不到一个完美符合我“**快速、私密、无需账户**”这三点核心要求的工具后,我决定,自己动手,为自己打造一个。
|
||||
|
||||
### 1.2 从个人工具到公开项目的演变
|
||||
|
||||
最初,PrivyDrop 只是一个满足我个人需求的小工具。但随着功能的逐步完善,我意识到,我的痛点可能也是许多人的痛点。
|
||||
|
||||
在这个数据和隐私日益重要的时代,我们值得拥有一个更好的选择。一个让我们不必在“便利”和“隐私”之间做痛苦抉择的工具。这个想法驱动着我将 PrivyDrop 从一个个人项目,逐渐打磨成一个健壮、可靠的公开服务。
|
||||
|
||||
我们的核心愿景很简单,正如我在项目文档里写下的:**我们相信,每个人都应掌控自己的数据。**
|
||||
|
||||
### 1.3 为什么是开源?——信任的唯一答案
|
||||
|
||||
对于一个将“隐私安全”作为核心价值的工具,闭源本身就是一种矛盾。用户凭什么相信你的承诺?
|
||||
|
||||
因此,开源是必然的选择,也是唯一的答案。
|
||||
|
||||
- **建立信任**:代码是最好的证明。我们将所有代码公开,接受全世界的审视,以此建立无可辩驳的信任。
|
||||
- **社区力量**:我深知个人的力量是有限的。我相信社区的集体智慧可以发现我忽略的缺陷,提出我未曾想到的功能,帮助 PrivyDrop 走得更远、更健壮。
|
||||
- **回馈与学习**:我从开源社区中受益良多,现在是我回馈的时候了。将项目开源,既是向优秀的开发者们学习,也是一种分享的快乐。
|
||||
|
||||
## 第二部分:深入架构:一次“生产级”实践
|
||||
|
||||
PrivyDrop 不仅仅是一个玩具项目。在架构设计上,我们追求简洁、高效与可扩展性,力求达到生产级标准。
|
||||
|
||||
### 2.1 宏观视角:简洁而高效的系统
|
||||
|
||||
我们的核心设计原则是:**后端轻量化、前端智能化**。后端只做“交通警察”(信令协调),而前端负责所有“重活”(文件处理与传输)。
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
subgraph "用户A (发送方)"
|
||||
A[前端应用]
|
||||
end
|
||||
subgraph "用户B (接收方)"
|
||||
B[前端应用]
|
||||
end
|
||||
subgraph "云端"
|
||||
C(信令服务器 - Node.js)
|
||||
D(状态存储 - Redis)
|
||||
end
|
||||
|
||||
A -- "1. 请求创建/加入房间" --> C
|
||||
B -- "2. 请求加入同一房间" --> C
|
||||
C -- "3. 交换WebRTC信令 (SDP/ICE)" --> A
|
||||
C -- "4. 交换WebRTC信令 (SDP/ICE)" --> B
|
||||
A <-.-> B;
|
||||
C <--> D
|
||||
A <-. "5. 建立P2P直连" .-> B
|
||||
A -- "6. 文件/文本直接传输" --> B
|
||||
|
||||
style A fill:#D5E8D4,stroke:#82B366
|
||||
style B fill:#D5E8D4,stroke:#82B366
|
||||
```
|
||||
|
||||
### 2.2 前端架构:从“关注点分离”到“逻辑内聚”
|
||||
|
||||
前端采用 Next.js 14 构建,我们最核心的设计哲学是**以自定义 Hooks 作为业务逻辑的核心**。
|
||||
|
||||
你可能会问,为什么没有用 Redux 或 Zustand?因为对于 PrivyDrop 而言,大部分状态都与特定的、高内聚的业务逻辑紧密相关。我们通过一系列自定义 Hooks(如 `useWebRTCConnection`, `useRoomManager`, `useFileTransferHandler`)来封装这些逻辑和状态,带来了几个显而易见的好处:
|
||||
|
||||
- **逻辑内聚**:所有与 WebRTC 连接相关的状态和方法都在 `useWebRTCConnection` 中,极易维护。
|
||||
- **组件纯粹**:React 组件从复杂的业务逻辑中解放出来,回归到 UI 渲染的本质职责。
|
||||
- **清晰分层**:形成了 `app` (路由) -> `components` (UI) -> `hooks` (逻辑) -> `lib` (底层能力) 的清晰数据流和依赖关系,代码库的可维护性大大增强。
|
||||
|
||||
### 2.3 后端架构:无状态与高效率的艺术
|
||||
|
||||
后端基于 Node.js 和 Express,设计上严格遵循**无状态 (Stateless)** 原则。
|
||||
|
||||
服务器本身不持有任何与房间或用户相关的状态。所有状态都被委托给 **Redis** 进行管理。这使得后端应用可以非常轻松地进行水平扩展。
|
||||
|
||||
我们还巧妙地利用了 Redis 不同的数据结构来满足业务需求:
|
||||
|
||||
- **Hash**: 存储房间的元数据。
|
||||
- **Set**: 存储一个房间内所有成员的 `socketId`,保证唯一性。
|
||||
- **String**: 将 `socketId` 反向映射到 `roomId`,便于在用户断线时快速清理。
|
||||
- **Sorted Set**: 用于实现基于 IP 的速率限制,有效防止恶意攻击。
|
||||
|
||||
所有 Key 都设置了合理的 TTL (过期时间),确保了资源的自动清理,系统可以长期稳定运行。
|
||||
|
||||
### 2.4 “生产级”的考量:从部署到安全
|
||||
|
||||
我们提供了一套完整的生产环境部署方案,包括:
|
||||
|
||||
- 使用 **Nginx** 作为反向代理和 SSL 终止。
|
||||
- 使用 **PM2** 进行 Node.js 进程管理。
|
||||
- 使用 **Certbot** 实现 SSL 证书的自动申请和续期。
|
||||
- 为需要穿透复杂 NAT 的场景,提供了完整的 **TURN/STUN** 服务器搭建指南。
|
||||
|
||||
这些都证明了 PrivyDrop 是一个可以被信赖并部署到生产环境的严肃项目。
|
||||
|
||||
## 第三部分:不止于代码:邀请你共建未来
|
||||
|
||||
开源只是一个开始。我们为 PrivyDrop 规划了激动人心的未来,而现在,我们想邀请你加入我们。
|
||||
|
||||
### 3.1 项目路线图 (Roadmap)
|
||||
|
||||
我们有一个公开的 [**项目路线图**](./ROADMAP.zh-CN.md),其中概述了未来的工作重点。我们计划在未来加入一些大家呼声很高的功能,例如:
|
||||
|
||||
- **断点续传**:应对超大文件传输和网络不稳定的情况。
|
||||
- **E2E 加密群聊**:将安全的 P2P 通信扩展到多人文本聊天。
|
||||
- 其他待定功能
|
||||
|
||||
### 3.2 如何参与贡献?
|
||||
|
||||
我们欢迎任何形式的贡献!无论你是谁,总有一种方式可以帮助 PrivyDrop 变得更好。请阅读我们的 [**贡献指南**](./.github/CONTRIBUTING.zh-CN.md) 来开始你的旅程。
|
||||
|
||||
- **普通用户**:使用产品,通过 [GitHub Issues](https://github.com/david-bai00/PrivyDrop/issues) 报告 Bug、提出功能建议。
|
||||
- **开发者**:认领一个 Bug、实现一个新功能、或者优化一段既有代码。
|
||||
- **文档/国际化贡献者**:帮助我们改进文档,或将 PrivyDrop 翻译成更多语言。
|
||||
|
||||
### 3.3 响亮的行动号召 (Call to Action)
|
||||
|
||||
- **对于用户**:立即体验 PrivyDrop,感受极致的私密与便捷!
|
||||
[**➡️ 在线体验**](https://www.privydrop.app/)
|
||||
|
||||
- **对于开发者**:如果 PrivyDrop 的理念或技术让你眼前一亮,请给我们的 GitHub 仓库一个 Star 吧!这是对我们最大的认可和鼓励!
|
||||
[**⭐️ Star Us on GitHub**](https://github.com/david-bai00/PrivyDrop)
|
||||
|
||||
- **对于所有人**:加入我们的社区讨论,让我们听到你的声音!
|
||||
|
||||
## 结语
|
||||
|
||||
再次感谢你花时间阅读这个故事。
|
||||
|
||||
PrivyDrop 的故事始于一个人的需求,而它的未来,期待由一群人共同书写。
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
Executable → Regular
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 276 KiB After Width: | Height: | Size: 74 KiB |
Reference in New Issue
Block a user