This script lets you send and receive messages through a swarm
node using pss
. If none of these terms mean anything to you, you have some research to do before reading on. See the references at the end of this README.
Ultimately, the idea is to create a proper shared object plugin which handles encryption internally and uses swarm nodes as multiplexers.
However there is lots to be explored before that. And for this exploration we will use this simple prototype where you remote control a single swarm node, using its public key and address.
Please note that this project is meant to be something of a reference implementation of peer-to-peer communications using combinations of pss and feed. The goal is not to create a production-grade application (but then, who knows where it will end up).
0.4.1 alpha
If you want to help debugging this project I would greatly appreciate it. You can help merely by trying to use it. No need to read code etc. Let me know.
Some code documentation is available inline for Doxygen, config file is in /scripts/python/.
A LaTeX document stub starting to explain the architecture is available in /doc.
Let's use issues on this repo to inform us about trials and errors.
Please add an issue both if you successfully run the plugin and/or if something goes wrong.
The issue should contain the following:
(The versions of the dependencies are not necessarily minimal requirements, but are the versions in which the plugin is being developed in)
scripts/python
in this source tree.swarm.py
and the pss
directory along with its contents to the python
subfolder in your weechat directory (normally this is ~/.weechat/python
)/script load swarm.py
This adds a command /pss
to your weechat instance. You can confirm load with calling the help text with /help pss
Note: if you send a pss message and there is noone listening on the other node, they won't get the message later on. This is regardless of whether the node even is up or not. Feeds, however, will persist (to the extent that they are kept in swarm, of course).
You need a running instance of swarm to connect to. When you run swarm, remember to include the websockets flags, for example:
--ws --wsorigins="*" --wsport 8546
When swarm is running, you can continue.
This pss method is for one-to-one messaging only.
# Connect to a pss node
# this will create a buffer with a node context
# if you don't supply host and port it uses defaults of 127.0.0.1 8546
/pss connect foo 127.0.0.1 8546
# While in the context of node you can issue commands to it
# (ctrl-x changes context, see weechat docs if you don't understand)
# Print public key of node
/pss key
# Print address of node
/pss address
# Add a peer to the node's address book
# After this you can send to the peer, and also incoming msgs matching the key will be marked by the nick you choose
# the key and address below is for _my_ node. If you want to add a different node, you need _that_ node's values.
/pss add lash 0x04578fcba26eb70ff2cef4a1ee6de5bbcac169adc6a067be6dab2e1781234d8ba9e97782ee2e460589e2925762c602d97d463549d4314e104a1d67d283e103c427 0xacae369e3fcef13ec171298c5d9a4ea3631cb4f082d9a72f8f95f27d54b4f145
# Send a message to the peer
# a new buffer will be created with name pss:<nick> (but won't focus automatically)
/pss msg lash the future is now
# you can also send from the node's buffer
# in this case simply prefix the message with the nick
/buffer lash
I said, the future is now
# You can add other nodes to the same weechat instance
# Then you'll probably need different host and/or port other than the one already used
# You will be automatically switched to this node buffer
/pss connect bar 127.0.0.2 8547
# And of course you can even send between these nodes
/pss key
[bar.key] 0xdeadbeef....feca1666
/pss address
[bar.address] 0xdeadbeef....feca1666
/pss add hsal <bar.key> <bar.address>
/pss msg hsal mais plus ça change, plus c'est la même chose
# if you close the other buffer
# it will re-open upon receiving a new message
/close lash
/buffer hsal
if you pardon my french...
# stop means disconnect. you can reconnect again and continue as before
/pss stop
/pss connect
# you can also issue commands from the core buffer, by prefixing the pss node name to the args
/buffer weechat
/pss bar msg lash cheer up, dude
Group chat implementation using swarm feeds.
# if you haven't already, connect to your node
# and add a peer with nick 'hsal' (or other name, you choose) to your address book
# (see above section on pss for details)
/pss connect foo 127.0.0.1 8546
/pss add hsal <key> <address>
# change to pss node buffer if you're not already in it, and "join" chatroom
/buffer foo
# for now you need to manually set your private key
# the key is used to sign the feed updates
# currently it must be the same private key as your pss node is running
# (but this will change)
/pss set pk <privatekey>
# now you can "join" the room.
# This will establish an output feed you can write to
# which are your entries in the room
/pss join fooroom
# now 'invite' someone to the room
# currently that does nothing more than
# make you poll the other party's feed
# and if there are updates on it they will be displayed
/buffer fooroom
/pss invite hsal
# now start a different instance / connect a different node
# and mirror the same steps for this
# then write something in this buffer
# it will echo back AND it will show up in the other buffer
# Unloading the script will kill sub-processes and disconnect from nodes
# Currently it will also erase all settings and nicks you've added
# It also removes the buffer and all messages in it are lost. Any logging of message is purely by accident.
/script unload pss
Although pss
uses safe components for encryption, it is still not weather-tested in any way. Furthermore, this script adds code and traffic beyond the pss node, and at this point in time there's no guaranteeing that that won't break some security premise pss
may already provide.
Most likely something in weechat are even logging the messages you're getting in cleartext, for example.
One thing to keep in mind is that anyone with access to your websocket port can connect to decrypt and see messages you receive.
If you're connecting to a node that's not on your local host but still want to keep the websocket port only available locally on the remote host, you can tunnel to the remote host and connect via localhost there:
ssh -L 8546:localhost:8546 remote.ssh.host
You can now reach that remote socket securely through your localhost 8546
And! Swarm/feed updates are stored unencrypted for now.
GPLv3