P2P - kl3mta3/Maplecord GitHub Wiki
P2P
P2P means peer-to-peer: your app connects straight to the other person's app, with nothing in between.
Everything else in Maplecord works without it. Ordinary chat goes to the Maplecord server, and ordinary voice and video go through a relay, so nobody you talk to learns your IP address. P2P is extra, kept apart from the rest, and off until you turn it on.
What it costs
To connect straight to someone, each side has to be told the other's IP address. Maplecord never shows it, but anyone you connect to that way can find it with ordinary tools. An IP address shows roughly where you are and can be used to knock your connection offline.
To learn its own address in the first place, your app asks the relay of the Maplecord server you are on. No outside service is asked.
So P2P is for people you trust. That is why it has to be chosen three times over:
- Someone makes a channel a P2P channel on purpose, which takes its own permission.
- You allow P2P on your own account, and sign in again to prove it is you.
- Your app warns you the first time you join each P2P channel, and again if the channel is changed.
What it gives you
- The server keeps nothing. What is said in a P2P text channel goes between people's apps and is kept only on their own devices.
- Files of any size between friends, straight from one computer to the other.
- Higher stream quality. A server can allow more in P2P channels and calls, 1080p at 60 frames a second for example, because the traffic is not on a relay.
- Test your connection. In the share dialog, Test connection shows how far away each relay is, your download and upload speed, and about how many viewers that upload carries in a P2P channel. One speed test every 3 minutes.
- Streams with several viewers. From the third viewer on, a stream in a P2P channel is sent at the quality its sharer chose and up to two smaller ones, and each viewer gets the best their connection takes. Right-click a stream you are watching to choose the most you want: a stream shared at 60 frames a second can also be had at 30. Works when the sharer uses the desktop app or Chrome.
How it works
- The Maplecord server only makes the introduction. It tells each app who else is in the channel and passes the messages they need to find each other. Those set-up messages are sealed between the apps, so the server carries them without being able to read them.
- Then the apps talk directly. Messages, files, voice and video go from app to app. None of it passes through the Maplecord server or the relay.
- Every message is signed by the app that wrote it. Each app has its own signing key and tells the server the public half. When a message reaches you, your app checks the signature, so nobody passing a message along can change it or make one up.
- History lives on your device, encrypted. There is no copy on the server to fetch.
- Catching up comes from other people. When two apps connect in a channel, each says which messages it holds and hands over what the other is missing. If you were away, you get what you missed from whoever is connected and has it. If nobody who has it is there, you do not get it until someone is.
If your app sees someone connect from an app or browser it has not seen them use before, it tells you. If that is not expected, check with them some other way before trusting what it sends.
Turning it on
Settings, then Voice & audio, then under P2P untick Do not allow P2P connections. You are asked to sign in again, to make sure it is really you deciding. Tick it again whenever you like; that takes effect at once.
Once P2P is allowed, the same page has more choices:
- Join P2P channels through the relay. Nobody in the channel learns your address, and what you send and receive there is held to the ordinary relayed limits. It only works where the server allows it, and a bot in the channel is never reached this way.
- Voice quality in P2P and Video I share in P2P, per viewer. In P2P it is your own connection that carries everything, and each person is sent a copy of their own, so a higher rate uses that much more of your upload for every one of them.
P2P channels
They are shown in italics with a P2P tag. Only private servers can have them. To make one, see Servers and channels.
P2P text channels and galleries
Open one and press Connect. The bar above the message box says how many people you are connected to.
- Replies, reactions, threads, edits, pins and search all work, and polls in text channels.
- Search looks through what your own device has kept.
- Editing changes what everyone's app shows. It cannot take back the copies people already received.
- Deleting is Remove from this device: only your own copy is removed. Everyone else who received it keeps theirs.
- Files and pictures are fetched from whoever is connected and has them, up to 100 MB a file.
- Bot commands do not work, because what is typed there does not go to the server.
- If nobody else is connected, a message you send reaches people when they next connect to someone who has it.
Right-click the channel for two choices:
- Subscribe (stay connected): your app stays connected to that channel whenever it is open, not only while you are reading it, so messages arrive as they are sent. Off unless you turn it on.
- Send others what they missed: your app hands other members the messages they are missing. On unless you turn it off.
P2P channels need an app or browser that can keep and sign messages. If yours cannot, the app says so.
P2P voice channels
Click to join; you are asked first. People in it connect straight to each other. The chat beside the voice channel is P2P too.
A voice channel can be switched between P2P and relayed by someone with the permission. Everyone in the call is taken out of it when that happens.
While you are in one, the voice box says P2P · using your IP or P2P · through the relay.
Bots in P2P channels
An ordinary bot is never in a P2P channel. A P2P bot is a separate kind that is let into P2P channels one at a time, in a full P2P server or a hybrid. Each one belongs to a single server: it cannot be added to a second. The usual one is an archive bot, which keeps the channel's messages so people who were offline can catch up.
Your app asks before it connects to a bot. Connecting lets whoever runs the bot find your IP address; a bot is never reached through the relay. If you say no, your address is kept from it, but what you write can still reach it through the people who are connected to it. How long a bot keeps things is up to whoever runs it.
A P2P bot can also be in a P2P voice channel it was let into, if its owner allows that. (How that differs from a bot in an ordinary voice channel is set out under Voice in Building a bot.) Your app does not connect to it until you press Connect to it: until then you do not hear it and it does not hear you. If you join P2P channels through the relay, your app never connects to a bot. A Maplecord older than 0.3.15 cannot ask first, so it and a bot are never let into the same P2P voice channel.
P2P calls and files with friends
- P2P call: a separate button in a conversation with a friend, shown only if you allow P2P. It asks first, and it only rings if your friend allows P2P too.
- Sending a file straight from your computer: the ⇄ button in a conversation with a friend. The file is not kept on the server, so it can be any size. Your friend can download it while Maplecord is open on your computer.
Three kinds of server
When you make a private server you pick one of these. Standard and Hybrid only decide what the first two channels are; you can add either kind of channel later. Full P2P is for good: every channel made in it is P2P.
| Kind | Text | Voice and video | Bots |
|---|---|---|---|
| Standard | Kept by the server | Through the relay | Ordinary bots |
| Hybrid | Kept by the server | P2P | Both kinds, each in its own kind of channel |
| Full P2P | P2P, kept only on people's devices | P2P | P2P bots |
A standard server that is given a P2P channel is a hybrid from then on, for as long as it has one.
What a server owner should know
- A public server cannot have P2P channels, and a server with P2P channels cannot be made public.
- A text channel or gallery is P2P or ordinary from the moment it is made and stays that way.
- Four permissions govern P2P: Create P2P channels, Join P2P channels, Use the relay in P2P channels and Stream in P2P channels. Everyone starts with the second and third.
- Rolls made in a P2P voice channel are still decided by the server, so they stay fair, but the server does not keep the results. Whether they count towards people's roll totals is a choice in Server settings, Overview.