Peertable
Welcome to Peertable! This project is an infrastructural peer-to-peer networking library for Python 3. You can also use it in standalone mode, although that is for little use other than connecting existing peers and networks (so they can find each other - but once they do, you don't need that anymore!).
Creating a Bridge Peer
The default (mostly demonstrative) Peertable application will, by default, only log messages given to it, but, like any peer, will, yes, serve to an actual purpose: acting as a bridge between peers, or possibly even networks!
To use the default application, use:
python3 -i -m peertable
Then, insert your listen port, public IP address (preferentially either outside a NAT or port forwarded), and external port (if behind a tunnel of sorts, e.g. ngrok), in order. The external port is optional.
Then, insert a space-separated list of initial peers to connect to (or nothing, if none).
Et voilá! You are now connected, and in the interactive prompt. It might seem like it's idle, but it is connecting to the target peers! And it's sending identificatoin requests (and identifying your server as well, by extension). You can now use the Send Commands:
>>> [c.id for c in s.clients]
['fc4h0MwGznaAqObYDWMXUiAAZ']
>>> for c in s.clients:
... s.send_id(c.id, peertable.Message(True, "TESTMESG", "Hello! If you are reading this, then a human is behind the recipient peer of this message, i.e. YOU! Your ID: " + c.id))
In this example, the other side would see:
>+ + + + +
Received message!
Sender ID: p8vM6FqyBGzm0Sdnr6XCDoZdy
Message type: TESTMESG
Payload length: 135
Payload in Base64: SGVsbG8hIElmIHlvdSBhcmUgcmVhZGluZyB0aGlzLCB0aGVuIGEgaHVtYW4gaXMgYmVoaW5kIHRoZSByZWNpcGllbnQgcGVlciBvZiB0aGlzIG1lc3NhZ2UsIGkuZS4gWU9VISBZb3VyIElEOiBmYzRoME13R3puYUFxT2JZRFdNWFVpQUFa
- - - - -<
The payload is the message you gave, in the third argument in the call to peertable.Message, which return value, in turn, is the 2nd argument to the call to s.send_id.
Using the Library
For a good example, check this out:
import peertable
import random
import base64
class TestApp(peertable.PeerApplication):
def receive(self, server, client, message):
print(">+ + + + +\nReceived message!\nSender ID: {}\nMessage type: {}\nPayload length: {}\nPayload in Base64: {}\n- - - - -<".format(client.id, message.message_type, len(message.payload), base64.b64encode(message.payload).decode('utf-8')))
if __name__ == "__main__":
print("Insert your new peer's listen port: (defaults to 2912)")
port = int(input() or 2912)
print()
print("Insert your machine's public IP address (so others can connect to you, etc):")
my_addr = input()
print()
print("Insert this server's public port, in case you use a tunnel or port forward (or none otherwise):")
my_port = int(input() or port)
s = peertable.PeerServer(my_addr, port=port, remote_port=my_port)
s.start_loop()
s.register_app(TestApp())
print()
print("My port: " + str(s.port))
print("My ID: " + str(s.id))
print()
print("Insert target IP:port addresses, separated by space:")
addrs = input()
for addr in addrs.split(' '):
try:
addr = addr.split(':')
if len(addr) < 2:
raise ValueError("-----")
addr[1] = int(addr[1])
s.connect(tuple(addr))
except ValueError:
pass
And before you ask, yes, this is the script that is run when you do python3 -i -m peertable.
Metadata
Release files for Peertable 0.1.3.6
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 | |
|---|---|---|---|---|
| Peertable-0.1.3.6.tar.gz | 6.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Peertable-0.1.3.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.9 kB
Release files / Peertable-0.1.3.6.tar.gz
| Download URL | Peertable-0.1.3.6.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6b5ec6cbec6fe114c63a9397d3795bb35352f2dcd8b52a5f42ea26a595d220a
|
|
BLAKE2b-256 checksum How to use checksums |
b4f4b5e986d8ac03fde2dc66baf53b3b68cccccf2eddbbf75f5dc13ceee0b88e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
|
Release files / Peertable-0.1.3.6-py3-none-any.whl
| Download URL | Peertable-0.1.3.6-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dabf59603cf53adcb0fd85dc1b3796e101adb44c061c90605f4e48f2ba17e571
|
|
BLAKE2b-256 checksum How to use checksums |
179af78264188cd3066912b423d10b3b1abae4f0115a882eefe81081821af0f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
|
Security for Peertable 0.1.3.6
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.