hotdrop 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/cli.js +111 -0
- package/local_install.sh +37 -0
- package/package.json +46 -0
- package/public/icon-192.svg +14 -0
- package/public/icon-512.svg +10 -0
- package/public/index.html +1204 -0
- package/public/manifest.json +25 -0
- package/public/sw.js +25 -0
- package/signaling/package.json +16 -0
- package/signaling/server.js +142 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Armed Juror
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# HotDrop
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/hotdrop)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://nodejs.org)
|
|
6
|
+
|
|
7
|
+
> Serverless P2P file sharing — no cloud, no installs, just a URL.
|
|
8
|
+
|
|
9
|
+
Files transfer **directly between browsers** via WebRTC. The server only brokers the initial handshake — it never sees your files. Supports multiple peers per room, works across any network, and runs offline on a local LAN with zero internet usage.
|
|
10
|
+
|
|
11
|
+
**[Try it live](https://hotdrop.armedjuror.in)** · [npm](https://www.npmjs.com/package/hotdrop) · [Buy me a coffee](https://buymeacoffee.com/armedjuror)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Table of Contents
|
|
16
|
+
|
|
17
|
+
- [How it works](#how-it-works)
|
|
18
|
+
- [Installation](#installation)
|
|
19
|
+
- [Global CLI (local network)](#global-cli-local-network)
|
|
20
|
+
- [Self-hosted server](#self-hosted-server)
|
|
21
|
+
- [CLI reference](#cli-reference)
|
|
22
|
+
- [Architecture](#architecture)
|
|
23
|
+
- [Features](#features)
|
|
24
|
+
- [Limitations](#limitations)
|
|
25
|
+
- [Contributing](#contributing)
|
|
26
|
+
- [License](#license)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## How it works
|
|
31
|
+
|
|
32
|
+
1. Open the app → tap **Create Room** → share the 6-character code or QR
|
|
33
|
+
2. Other devices scan the QR or enter the code
|
|
34
|
+
3. A direct WebRTC connection is established between all peers
|
|
35
|
+
4. Any peer can send files — recipients get an instant in-browser download prompt
|
|
36
|
+
|
|
37
|
+
Files exist only in browser memory. Nothing is written to disk or stored on the server.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
### Global CLI (local network)
|
|
44
|
+
|
|
45
|
+
Install globally via npm to run HotDrop as a background service on your machine. All traffic stays on your LAN — zero internet data consumed.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g hotdrop
|
|
49
|
+
hotdrop start
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or install from source:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git clone https://github.com/armedjuror/hotdrop
|
|
56
|
+
cd hotdrop
|
|
57
|
+
bash local_install.sh
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Once running, open `http://<YOUR_LOCAL_IP>:5821` on any device on the same network. The QR code on the create screen automatically encodes the server's LAN IP so other devices can scan and join immediately.
|
|
61
|
+
|
|
62
|
+
The UI shows a **HotDrop.local** label when connected to a local server.
|
|
63
|
+
|
|
64
|
+
### Self-hosted server
|
|
65
|
+
|
|
66
|
+
To run HotDrop on a VPS or cloud server (accessible over the internet):
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
git clone https://github.com/armedjuror/hotdrop
|
|
70
|
+
cd hotdrop
|
|
71
|
+
npm install
|
|
72
|
+
npm start
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Set the `PORT` environment variable if needed (defaults to `5821`). For production, place it behind a reverse proxy (nginx, Caddy) with TLS — the client requires `wss://` on HTTPS origins.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## CLI reference
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
hotdrop start Start the server in the background (survives terminal close)
|
|
83
|
+
hotdrop stop Stop the server
|
|
84
|
+
hotdrop status Check whether the server is running
|
|
85
|
+
hotdrop logs View server logs
|
|
86
|
+
hotdrop uninstall Stop the server and remove temp files
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Architecture
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
Browser A ──── WebRTC DataChannel (direct P2P) ──── Browser B
|
|
95
|
+
│ │
|
|
96
|
+
│ Browser C
|
|
97
|
+
│ │
|
|
98
|
+
└────────── WebSocket (signaling only) ───────────────┘
|
|
99
|
+
Signaling server
|
|
100
|
+
(never sees your files)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The signaling server exchanges only WebRTC handshake messages (offer/answer/ICE candidates). Once peers are connected, the server plays no further role.
|
|
104
|
+
|
|
105
|
+
Each pair of peers maintains its own direct P2P connection (mesh topology). Sending a file broadcasts it to all connected peers simultaneously — each peer receives a full independent copy.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Features
|
|
110
|
+
|
|
111
|
+
- No client installs — works in any modern browser
|
|
112
|
+
- Pure P2P — files never touch the server
|
|
113
|
+
- Multi-peer rooms — send to multiple devices at once
|
|
114
|
+
- Room grace period — rooms stay alive for 5 minutes after the last peer disconnects, allowing rejoin without recreating
|
|
115
|
+
- LAN mode — run locally for zero-internet intra-network transfers
|
|
116
|
+
- QR code auto-encodes the server's LAN IP when running locally
|
|
117
|
+
- Installable as a PWA on iOS, Android, and desktop
|
|
118
|
+
- Single-file frontend — no build step, no bundler
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Limitations
|
|
123
|
+
|
|
124
|
+
- All peers must have the page open simultaneously (no store-and-forward)
|
|
125
|
+
- Multi-peer upload cost: a 1 GB file sent to 3 peers uses 2 GB of upload
|
|
126
|
+
- Large files (>1 GB) may be constrained by device RAM
|
|
127
|
+
- No TURN relay — if NAT traversal fails, there is no fallback
|
|
128
|
+
- WebRTC on iOS requires Safari 16+ or any browser on iOS 16+
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Contributing
|
|
133
|
+
|
|
134
|
+
Contributions are welcome. Please open an issue first for significant changes so the approach can be discussed before a PR is submitted.
|
|
135
|
+
|
|
136
|
+
**Guidelines:**
|
|
137
|
+
|
|
138
|
+
- Keep the server minimal — `express` and `ws` are the only dependencies by design
|
|
139
|
+
- The frontend is a single `index.html` with no build step — keep it that way
|
|
140
|
+
- Test on at least two real devices (not just two browser tabs) before submitting
|
|
141
|
+
- Follow existing code style — no linters are enforced, but consistency matters
|
|
142
|
+
|
|
143
|
+
**Development setup:**
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
git clone https://github.com/armedjuror/hotdrop
|
|
147
|
+
cd hotdrop
|
|
148
|
+
npm install
|
|
149
|
+
npm start
|
|
150
|
+
# Open http://localhost:5821 in two tabs or on two devices on the same network
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
1. Fork the repository
|
|
154
|
+
2. Create a feature branch: `git checkout -b feature/your-feature`
|
|
155
|
+
3. Commit your changes
|
|
156
|
+
4. Open a pull request against `main`
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
[MIT](LICENSE)
|
package/cli.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const PID_FILE = path.join(os.tmpdir(), 'hotdrop.pid');
|
|
9
|
+
const LOG_FILE = path.join(os.tmpdir(), 'hotdrop.log');
|
|
10
|
+
const SERVER = path.join(__dirname, 'signaling', 'server.js');
|
|
11
|
+
|
|
12
|
+
const cmd = process.argv[2];
|
|
13
|
+
|
|
14
|
+
if (cmd === 'start') {
|
|
15
|
+
if (fs.existsSync(PID_FILE)) {
|
|
16
|
+
const pid = fs.readFileSync(PID_FILE, 'utf8').trim();
|
|
17
|
+
try {
|
|
18
|
+
process.kill(Number(pid), 0);
|
|
19
|
+
console.log(`\n HotDrop is already running (PID ${pid})`);
|
|
20
|
+
console.log(` Run "hotdrop stop" to stop it.\n`);
|
|
21
|
+
process.exit(0);
|
|
22
|
+
} catch (_) {
|
|
23
|
+
fs.unlinkSync(PID_FILE); // stale PID
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Truncate log on fresh start so old output doesn't confuse
|
|
28
|
+
fs.writeFileSync(LOG_FILE, '');
|
|
29
|
+
const out = fs.openSync(LOG_FILE, 'a');
|
|
30
|
+
|
|
31
|
+
const child = spawn(process.execPath, [SERVER], {
|
|
32
|
+
detached: true,
|
|
33
|
+
stdio: ['ignore', out, out],
|
|
34
|
+
env: { ...process.env }
|
|
35
|
+
});
|
|
36
|
+
fs.writeFileSync(PID_FILE, String(child.pid));
|
|
37
|
+
child.unref();
|
|
38
|
+
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
try {
|
|
41
|
+
const log = fs.readFileSync(LOG_FILE, 'utf8').trim();
|
|
42
|
+
if (log) console.log('\n' + log);
|
|
43
|
+
} catch (_) {}
|
|
44
|
+
console.log(`\n Logs: hotdrop logs\n Stop: hotdrop stop\n`);
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}, 800);
|
|
47
|
+
|
|
48
|
+
} else if (cmd === 'stop') {
|
|
49
|
+
if (!fs.existsSync(PID_FILE)) {
|
|
50
|
+
console.log('\n HotDrop is not running.\n');
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
const pid = fs.readFileSync(PID_FILE, 'utf8').trim();
|
|
54
|
+
try {
|
|
55
|
+
process.kill(Number(pid), 'SIGTERM');
|
|
56
|
+
fs.unlinkSync(PID_FILE);
|
|
57
|
+
console.log(`\n HotDrop stopped (PID ${pid}).\n`);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
console.log(`\n Could not stop process (${e.message}). Cleaning up PID file.\n`);
|
|
60
|
+
try { fs.unlinkSync(PID_FILE); } catch (_) {}
|
|
61
|
+
}
|
|
62
|
+
process.exit(0);
|
|
63
|
+
|
|
64
|
+
} else if (cmd === 'status') {
|
|
65
|
+
if (!fs.existsSync(PID_FILE)) {
|
|
66
|
+
console.log('\n HotDrop is not running.\n');
|
|
67
|
+
} else {
|
|
68
|
+
const pid = fs.readFileSync(PID_FILE, 'utf8').trim();
|
|
69
|
+
try {
|
|
70
|
+
process.kill(Number(pid), 0);
|
|
71
|
+
console.log(`\n HotDrop is running (PID ${pid}).\n`);
|
|
72
|
+
} catch (_) {
|
|
73
|
+
console.log('\n HotDrop is not running (stale PID).\n');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
process.exit(0);
|
|
77
|
+
|
|
78
|
+
} else if (cmd === 'logs') {
|
|
79
|
+
if (fs.existsSync(LOG_FILE)) {
|
|
80
|
+
const log = fs.readFileSync(LOG_FILE, 'utf8').trim();
|
|
81
|
+
console.log(log || '\n Log is empty.\n');
|
|
82
|
+
} else {
|
|
83
|
+
console.log('\n No log file found. Has HotDrop been started yet?\n');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
} else if (cmd === 'uninstall') {
|
|
87
|
+
// Stop if running
|
|
88
|
+
if (fs.existsSync(PID_FILE)) {
|
|
89
|
+
const pid = fs.readFileSync(PID_FILE, 'utf8').trim();
|
|
90
|
+
try { process.kill(Number(pid), 'SIGTERM'); } catch (_) {}
|
|
91
|
+
try { fs.unlinkSync(PID_FILE); } catch (_) {}
|
|
92
|
+
}
|
|
93
|
+
// Clean up log
|
|
94
|
+
try { fs.unlinkSync(LOG_FILE); } catch (_) {}
|
|
95
|
+
console.log('\n HotDrop stopped and temp files removed.');
|
|
96
|
+
console.log(' To fully uninstall, remove the symlink:\n');
|
|
97
|
+
console.log(' sudo rm /usr/local/bin/hotdrop\n');
|
|
98
|
+
process.exit(0);
|
|
99
|
+
|
|
100
|
+
} else {
|
|
101
|
+
console.log(`
|
|
102
|
+
HotDrop — peer-to-peer LAN file sharing
|
|
103
|
+
|
|
104
|
+
Usage:
|
|
105
|
+
hotdrop start Start the server (survives terminal close)
|
|
106
|
+
hotdrop stop Stop the server
|
|
107
|
+
hotdrop status Check if running
|
|
108
|
+
hotdrop logs View server logs
|
|
109
|
+
hotdrop uninstall Stop server and clean up temp files
|
|
110
|
+
`);
|
|
111
|
+
}
|
package/local_install.sh
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
BIN_PATH="/usr/local/bin/hotdrop"
|
|
6
|
+
|
|
7
|
+
echo ""
|
|
8
|
+
echo " Installing HotDrop..."
|
|
9
|
+
|
|
10
|
+
# Install dependencies if needed
|
|
11
|
+
if [ ! -d "$SCRIPT_DIR/node_modules" ]; then
|
|
12
|
+
echo " Installing dependencies..."
|
|
13
|
+
cd "$SCRIPT_DIR" && npm install
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
# Make cli.js executable
|
|
17
|
+
chmod +x "$SCRIPT_DIR/cli.js"
|
|
18
|
+
|
|
19
|
+
# Create symlink in /usr/local/bin
|
|
20
|
+
if [ -w "/usr/local/bin" ]; then
|
|
21
|
+
ln -sf "$SCRIPT_DIR/cli.js" "$BIN_PATH"
|
|
22
|
+
else
|
|
23
|
+
echo " (sudo required to install to /usr/local/bin)"
|
|
24
|
+
sudo ln -sf "$SCRIPT_DIR/cli.js" "$BIN_PATH"
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
echo ""
|
|
28
|
+
echo " ✓ Installed! Commands:"
|
|
29
|
+
echo ""
|
|
30
|
+
echo " hotdrop start — Start the server"
|
|
31
|
+
echo " hotdrop stop — Stop the server"
|
|
32
|
+
echo " hotdrop status — Check if running"
|
|
33
|
+
echo " hotdrop logs — View logs"
|
|
34
|
+
echo " hotdrop uninstall — Stop and clean up"
|
|
35
|
+
echo ""
|
|
36
|
+
echo " Then open http://$(hostname -I 2>/dev/null | awk '{print $1}' || echo 'YOUR_LOCAL_IP'):5821 on any device."
|
|
37
|
+
echo ""
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hotdrop",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "P2P LAN & internet file sharing via WebRTC — no cloud, no installs, just a URL",
|
|
5
|
+
"main": "signaling/server.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"hotdrop": "./cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"cli.js",
|
|
11
|
+
"local_install.sh",
|
|
12
|
+
"signaling/server.js",
|
|
13
|
+
"signaling/package.json",
|
|
14
|
+
"public/"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"start": "node signaling/server.js"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=16"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"webrtc",
|
|
24
|
+
"p2p",
|
|
25
|
+
"file-transfer",
|
|
26
|
+
"lan",
|
|
27
|
+
"local",
|
|
28
|
+
"hotdrop",
|
|
29
|
+
"file-sharing",
|
|
30
|
+
"peer-to-peer"
|
|
31
|
+
],
|
|
32
|
+
"author": "armedjuror",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/armedjuror/hotdrop.git"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/armedjuror/hotdrop#readme",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/armedjuror/hotdrop/issues"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"express": "^5.2.1",
|
|
44
|
+
"ws": "^8.18.2"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 192" width="192" height="192">
|
|
2
|
+
<rect width="192" height="192" fill="#0a0a0a" rx="32"/>
|
|
3
|
+
<rect x="16" y="16" width="160" height="160" fill="none" stroke="#222" stroke-width="1"/>
|
|
4
|
+
<!-- Arrow up -->
|
|
5
|
+
<path d="M96 52 L72 80 L84 80 L84 100 L108 100 L108 80 L120 80 Z" fill="#e8ff47"/>
|
|
6
|
+
<!-- Horizontal line -->
|
|
7
|
+
<rect x="56" y="112" width="80" height="4" fill="#e8ff47" rx="2"/>
|
|
8
|
+
<!-- Dots -->
|
|
9
|
+
<circle cx="60" cy="130" r="4" fill="#47c8ff"/>
|
|
10
|
+
<circle cx="96" cy="130" r="4" fill="#47c8ff"/>
|
|
11
|
+
<circle cx="132" cy="130" r="4" fill="#47c8ff"/>
|
|
12
|
+
<!-- Text -->
|
|
13
|
+
<text x="96" y="158" text-anchor="middle" font-family="monospace" font-size="13" fill="#555" letter-spacing="2">LOCAL</text>
|
|
14
|
+
</svg>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
|
2
|
+
<rect width="512" height="512" fill="#0a0a0a" rx="80"/>
|
|
3
|
+
<rect x="40" y="40" width="432" height="432" fill="none" stroke="#222" stroke-width="2"/>
|
|
4
|
+
<path d="M256 130 L190 210 L222 210 L222 270 L290 270 L290 210 L322 210 Z" fill="#e8ff47"/>
|
|
5
|
+
<rect x="140" y="300" width="232" height="10" fill="#e8ff47" rx="5"/>
|
|
6
|
+
<circle cx="160" cy="348" r="12" fill="#47c8ff"/>
|
|
7
|
+
<circle cx="256" cy="348" r="12" fill="#47c8ff"/>
|
|
8
|
+
<circle cx="352" cy="348" r="12" fill="#47c8ff"/>
|
|
9
|
+
<text x="256" y="418" text-anchor="middle" font-family="monospace" font-size="36" fill="#333" letter-spacing="6">LOCAL</text>
|
|
10
|
+
</svg>
|