Skip to main content

A terminal-based P2P messaging application using WebRTC

Project description

pypeer Logo

A Python Terminal-based P2P Messaging Application.

pypeer is a lightweight TUI application that enables direct, encrypted communication between peers. It leverages WebRTC for decentralized data transfer and Firebase RTDB as an ephemeral signaling server.

Python Version License Technology

Start Screen
pypeer home
Host Setup
pypeer host
Join Room
pypeer join
Messaging Screen
pypeer messaging

Installation & Usage

$ pip install pypeer

After installation launch the application by simply typing:

$ pypeer

How to use:

  1. Host a Room: Click "Host", set a password, and share the generated 6-character Room ID.
  2. Join a Room: Click "Join", enter the Room ID and the password.
  3. Chat: Once connected, start messaging.

How it Works

  1. Encrypted Signaling: Before a direct connection is established, peers must exchange handshake metadata (SDP and ICE candidates). pypeer uses Firebase RTDB as an ephemeral signaling server that acts as a temporary bulletin board.

    • Key Derivation: A 32-byte key is derived using SHA-256 from a combination of the Room ID and the User Password.
    • Layered Security: The connection metadata is cryptographically unreadable to anyone even the data provider that do not have the specific Room ID and Password.
      • Compression: Raw SDP strings are compressed using zlib to reduce payload size and obfuscate data structure.
      • Encryption: Compressed data is encrypted via AES-128 (Fernet),ensuring that only the intended peer can decrypt the handshake.
  2. The WebRTC Handshake: Once the encrypted metadata is exchanged, the terminals move from "talking to the cloud" to "talking to each other":

    • Firewall Navigation: The app uses Google's STUN servers to navigate through home routers and firewalls and determine the best route between peers.
    • Encrypted DataChannel: A dedicated tunnel is established between peers. Unlike traditional TCP sockets, SCTP over WebRTC provides native encryption, reliability, and ordered delivery without the need for a central server.
  3. Secure Direct Messaging: Once connected, the chat enters a serverless state:

    • Zero-Trace Handshake: The signaling data on Firebase RTDB is deleted. The peers remain connected directly, ensuring that no trace of the handshake remains on the cloud.
    • P2P Memory-to-Memory: Messages are sent directly between terminal memories. No history is stored on any server, and no middleman can intercept the traffic once the P2P tunnel is established.
    • Volatile Sessions: Your messages exist only as long as your terminal window is open. Once you quit, the session is wiped from your RAM.
  4. Automated Cleanup: To maintain a a clean and secure signaling bridge, pypeer employs a two-tier cleanup strategy:

    • Host-Led Deletion: Under normal conditions, the host cleans up the signaling metadata as soon as the handshake is complete.
    • GitHub Action Janitor: As a failsafe, a scheduled GitHub Action acts as a "Janitor," running every hour to automatically purge any stale or abandoned rooms left behind by interrupted connections.

Tech Stack

Core Components Implementation Purpose
TUI Engine Textual Powers the modern, responsive terminal interface.
P2P Protocol aiortc Handles WebRTC stack, ICE gathering, and DataChannels.
Signaling Firebase RTDB Used as a temporary, real-time bridge for handshakes.
Encryption Fernet (AES) Encrypts signaling payloads so metadata never leaks.
Async Core asyncio Manages concurrent networking and UI updates.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypeer-0.1.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypeer-0.1.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file pypeer-0.1.0.tar.gz.

File metadata

  • Download URL: pypeer-0.1.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pypeer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 426bfdf3377b8f0659e81241c0b29bef62e13e306d6058410c984bb9c33d73e4
MD5 8f0e53ae16b05d43bbb4805cf3736581
BLAKE2b-256 cd9216dee343cfc98f82d53df8576981b87dfe52ba3d8ec17195142e0187fdce

See more details on using hashes here.

File details

Details for the file pypeer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pypeer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pypeer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ea771c6753ae4f488c6f39b535a0c3aea7e4c55dcbdb89f1d19a9aed6cb4eb9
MD5 5605c86f6447b968ab2be1bd621c4f87
BLAKE2b-256 3bd924473ebba1c49970c46ebc24633a3cbe518eec3b19bca2558871ec3798f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page