Pyile Protocol Documentation:
Introduction:
This document describes the network protocol used by the Pyile application over TCP/IP on port 4702. The protocol is used for communication and authentication between peers.
Protocol Overview
The Pyile protocol is used for peer-to-peer communication and authentication. This protocol allows for a single central authenticator that established the network and is the source of all authentication within the given network. With this in mind, the authenticating peer has a unique role. It is still considered a peer which means that they still have full communication functionalities. The Pyile protocol supports another type of peer which is a non-authenticating peer or just peer. This type of peer only can be authenticated and send messages.
Sockets:
- Port 4702: Used as the main connection between peer and authenticating peer.
- Dynamic and private port: Randomly generated port that is within the private use range. Used for communication between all peers.
- Temporary Socket: Used to send messages and broadcast but is then closed immediately after.
Protocol Flow
- Authenticating peer is established listening on port 4702 for potential peers
- Authenticating peer, then generates a random port and begins to listen to already established peers. (Should only be themselves)
- A Joining peer then requests to be authenticated by the initial peer.
- The initial peer then checks if the peer is already banned and then checks the password.
- If the password is correct, then the peer is added and then given the list of peers that can be communicated with.
- A heartbeat is then established between both peers.
- The joining peer can now communicate in the network through broadcasting or individual messaging.
Special Flows
Heartbeat
- When a peer is authenticated, A heartbeat is established between the authenticating peer and peer.
- The peer is in a constant state of listening, waiting to send a response to the authenticating peer.
- If a timeout is reached on either sides, the peer will be removed from the list of established peers and must reauthenticate.
Exit
- Any time an exit is called by a peer, the instance variable disconnected will be set to True. All sockets will be closed and any loose threads will be joined.
Figure 1
Message Types
- Banned status - First message sent to peer from authenticating peer. if banned, connection with joining peer is dropped
- Authenticated - Second message sent from authenticating peer. If authenticated, a heartbeat is established
- Heartbeat - Sent throughout the life of the connection that ensures both peers are still alive.
- Set Distributions - When the Authenticating peer has made changes to the peer list, it redistributes to all the peers in the network.
- Communication - Simple messaging between peers
Error Handling
The protocol has custom exceptions to further the detail of errors:
- AuthenticationException
- StatusException
- SendException
- RecvException
Security
The protocol implements an authentication process equipped with a password check and banned status. At this time, there is no encryption.
Code Example
Install
pip install pyile_protocol
Authenticating Peer
import threading
from pyile_protocol.lib.peers.AuthPeer import AuthPeer
auth_peer = AuthPeer(address=("192.168.1.66", 4702), password_attempts=1, password="password")
auth_thread = threading.Thread(target=auth_peer.authenticate_peers)
peer_thread = threading.Thread(target=auth_peer.connect)
auth_thread.start()
peer_thread.start()
while not auth_peer.disconnected:
data = input("~: ")
if data == "exit":
auth_peer.leave()
elif data == "peers":
print(auth_peer.peers)
else:
auth_peer.broadcast(data)
Peer
import threading
from pyile_protocol.lib.peers.JoinPeer import JoinPeer
peer = JoinPeer(address=("192.168.1.65", 4702))
peer.get_authenticated(("192.168.1.66", 4702), "password")
connect_thread = threading.Thread(target=peer.connect)
connect_thread.start()
while not peer.disconnected:
data = input("~: ")
if data == "exit":
peer.leave()
elif data == "peers":
print(peer.peers)
else:
peer.broadcast(data)
Metadata
Release files for pyile-protocol 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyile_protocol-0.1.1.tar.gz | 22.5 kB | Without provenance | Details for pyile_protocol-0.1.1.tar.gz |
Release files / pyile_protocol-0.1.1.tar.gz
| Download URL | pyile_protocol-0.1.1.tar.gz |
|---|---|
| Size | 22.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
514f13d86c7a95758f8d6666cade87ad6e7827535cee6b2231c4d4c2c457f0ed
|
|
BLAKE2b-256 checksum How to use checksums |
f12a565c04166e107653617f3af9e8f89a410e4e57220cb5dd56b2a03be566cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for pyile-protocol 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.