1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# Examples
Small programs that talk to MeshBay the way the application does, without the
application. The values to change are variables at the top of each script.
| File | What it does |
|---|---|
| `meshbay_session.py` | The shared part: signs in to the hub, connects to a node serving the group over WebRTC, and completes the handshake. Used by the scripts below |
| `list_groups.py` | Lists your groups, `up` when a node serving the group is connected to the hub, `down` otherwise |
| `create_group.py` | Creates a group on the hub and hosts it on the node running on this machine, through the node's control API on 127.0.0.1 |
| `download.py` | Downloads one file from a group and saves it decrypted |
| `upload.py` | Uploads one file into a folder of a group |
```bash
# From the root of the repository
python3 -m venv .venv
.venv/bin/pip install -e packages/meshbay-common aiortc httpx argon2-cffi
# Edit the variables at the top of the script, then
cd examples
../.venv/bin/python download.py
```
The hub is `https://meshbay.org` by default. Paths in a group start with the
root's name, then the folders, as in the group's file browser: `FILE_PATH =
"shared/2024/beach.jpg"`, `DEST_DIR = "shared/2024"`. An upload needs a root the
operator made writable, and never replaces a file: on a name clash the node
picks a free name and says which.
Why not curl: files never pass through the hub. They travel over a WebRTC
DataChannel, straight between you and the node, encrypted under the group key.
Signing in, the handshake with the node and the encryption all happen in the
scripts.
They need the node to keep a copy of your identity keys, sealed so that only
your passphrase and your hub account can open it. That is the case when
*Browser access* is on in the application's settings, or once you have opened
the group in a browser.
|