尚未检测到更新。GitHub 发布版本后会显示在这里。
PeerDrop is a lightweight self-hosted app for sharing text and files instantly, with normal server-based sharing in Drop mode and direct peer-to-peer transfer in Beam mode.
翻译准备中
正在加载完整 README。
查看完整 README ↗Lightweight, self-hosted text & file sharing with optional P2P transfer. No sign-up required.
| Layer | Tech |
|---|---|
| Backend | Node.js + Fastify |
| Realtime | WebSocket (@fastify/websocket) |
| P2P | WebRTC (STUN/TURN via coturn) |
| Storage | Redis (metadata + TTL) + Disk (files) |
| Frontend | Vanilla HTML + CSS + JS |
git clone <your-repo-url> peerdrop
cd peerdrop
npm install
Copy and edit the environment file:
cp .env.example .env
| Variable | Default | Description |
|---|---|---|
PORT | 6000 | Server port |
REDIS_URL | redis://localhost:6379 | Redis connection string |
UPLOAD_DIR | ./uploads | File storage directory |
MAX_FILE_SIZE | 31457280 | Max upload size in bytes (30MB) |
ALLOWED_EXPIRY_DAYS | 2,4,7 | Comma-separated allowed TTLs |
DEFAULT_EXPIRY_DAYS | 2 | Fallback expiry |
STUN_SERVERS | Google STUN pair | Comma-separated STUN URLs |
TURN_URLS | auto-derived | Optional explicit TURN URLs |
TURN_PORT | 3478 | TURN port for auto-derived URL |
TURN_USERNAME | empty | TURN username |
TURN_PASSWORD | empty | TURN password |
TURN_REALM | optional | Override coturn realm |
# Start Redis (if not running)
docker run -d --name redis -p 6379:6379 redis:alpine
# Start the server
npm start
docker compose up -d --build
This starts the app, Redis, and a coturn server. The app is available on port 6000.
For Beam mode on a VPS, the simplest .env is:
TURN_PORT=3478
TURN_USERNAME=peerdrop
TURN_PASSWORD=replace-with-a-strong-secret
With that setup, PeerDrop auto-derives the TURN host from the same hostname the browser is already using to reach /peerdrop/. You only need TURN_URLS if you want to override it manually.
Then start everything:
docker compose up -d --build
Open these ports on the VPS/firewall:
3478/tcp3478/udp49160-49200/udpThis bundled setup uses plain TURN on port 3478. If you later want turns: on 5349, you’ll need to add TLS certificates to coturn separately.
If you reverse-proxy PeerDrop under /peerdrop, see deploy/nginx/peerdrop.conf.example.
To rebuild after changes:
docker compose up -d --build
POST /paste
Content-Type: application/json
{
"content": "Hello, world!",
"password": "optional-secret",
"expiry_days": 2
}
Response 201:
{
"id": "abc123",
"url": "/paste/abc123",
"expires_in_days": 2,
"has_password": false
}
GET /paste/:id?password=optional-secret
POST /upload
Content-Type: multipart/form-data
Fields: file, password (optional), expiry_days
Response 201:
{
"id": "xyz789",
"url": "/file/xyz789",
"original_name": "doc.pdf",
"size": 102400,
"expires_in_days": 2,
"has_password": false
}
GET /file/:id?password=optional-secret
GET /file/:id/info
WS /ws
Messages: join, offer, answer, ice-candidate, leave
GET /health → { "status": "ok", "uptime": 123.45 }
GET /config → { "allowed_expiry_days": [2,4,7], ... }
GET /config also returns the browser ICE server list used by Beam mode.
Orphaned files (whose Redis keys have expired) are cleaned up automatically:
node-cron runs every hour inside the server# Manual
npm run cleanup
# System cron (every hour)
0 * * * * cd /path/to/peerdrop && node scripts/cleanup.js
peerdrop/
├── app/
│ ├── server.js # Entry point
│ ├── routes/
│ │ ├── paste.js # Paste API
│ │ ├── file.js # File upload/download API
│ │ └── ws.js # WebSocket signaling
│ ├── services/
│ │ ├── redis.js # Redis client & helpers
│ │ └── storage.js # File system operations
│ ├── utils/
│ │ ├── expiry.js # Expiry validation
│ │ ├── password.js # bcrypt helpers
│ │ └── ids.js # nanoid generation
│ └── public/
│ ├── index.html # SPA shell
│ ├── style.css # Design system
│ └── app.js # Frontend logic
├── scripts/
│ └── cleanup.js # Standalone cleanup
├── uploads/ # File storage (gitignored)
├── docker-compose.yml
├── Dockerfile
├── .env
└── package.json
ISC