From 906ea8676312b60642f87b0cf4f15736f28bb941 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 7 Mar 2019 10:09:29 -0600 Subject: [PATCH] Initial commit --- README.md | 123 +++++++++++++++++++++++++++++++++++++++++++++++ easy-script.bash | 35 ++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 README.md create mode 100755 easy-script.bash diff --git a/README.md b/README.md new file mode 100644 index 0000000..f6bccd6 --- /dev/null +++ b/README.md @@ -0,0 +1,123 @@ +# Weechat & Matrix + Encryption + +This repository contains helpful information on how to setup Weechat as a Matrix +client with end-to-end encryption support. + +## TL;DR + +Run `git clone +https://git.faceless.lytedev.io/lytedev/weechat-matrix-encryption-guide.git +/tmp/wmeg && /tmp/wmeg/easy-script.bash` and skip to the end. + +## Guide + +There's a new-fangled [`weechat-matrix`][weechat-matrix] Python library that +supports end-to-end encryption. This guide will walk you through what is +currently a semi-annoying setup, as the entire project is still under heavy +development. + +### Python Versions + +We need to establish which version of Python your WeeChat is using. You can find +this out in WeeChat with `/python version`. In my case, my `python` binary is +3.7.2 (`python -V`) while my WeeChat Python version is 2.7.15. + +### Dependencies + +There are a number of dependencies we can go ahead and start grabbing. The main +repository lists a number of them in the `README`, so we will grab those. We +also need to install `libolm` however you would do that for your environment. + +``` +sudo pip2 install pyOpenSSL typing webcolors future atomicwrites attrs logbook pygments +pacaur -S libolm # or for Ubuntu (and maybe Debian?): sudo apt-get install libolm-dev +``` + +Notice that we left out the [`matrix-nio`][matrix-nio] dependency. It's not in +PyPi, so we can't just `pip2 install matrix-nio` (yet!) and PyPi's `nio` package +is something probably unrelated, so we'll need to install it manually. + +### `matrix-nio` + +Let's go ahead and clone down the repository and get ready to do some stuff: + +``` +git clone https://github.com/poljar/matrix-nio.git +cd matrix-nio +``` + +If you're looking around, documentation seems a bit sparse on how to do this, +but it has a mostly normal manual Python package installation workflow. + +First, lets grab all the dependencies specific to the `matrix-nio` package: + +``` +sudo pip2 install -r ./rtd-requirements.txt +``` + +And now we expect to be able to install it: + +``` +sudo python2 ./setup.py install +``` + +But you'll see the install script pauses for a second before we get an odd +error: + +``` +Processing dependencies for matrix-nio==0.1 +Searching for python-olm@ git+https://github.com/poljar/python-olm.git@master#egg=python-olm-0 +Reading https://pypi.org/simple/python-olm/ +Couldn't find index page for 'python-olm' (maybe misspelled?) +Scanning index of all packages (this may take a while) +Reading https://pypi.org/simple/ +No local packages or working download links found for python-olm@ git+https://github.com/poljar/python-olm.git@master#egg=python-olm-0 +error: Could not find suitable distribution for Requirement.parse('python-olm@ git+https://github.com/poljar/python-olm.git@master#egg=python-olm-0') +``` + +Out of the box, Python packages' `setup.py` scripts seem to not know how to +handle packages whose URL specifies to grab it via VCS, such as `git+`. So we'll +just help it out and grab it ourselves (instead of tinkering with anybody's +scripts): + +``` +sudo pip2 install -e git+https://github.com/poljar/python-olm.git@master#egg=python-olm-0 +``` + +*Now* we should have everything we need to install the `matrix-nio` Python +package: + +``` +sudo python2 ./setup.py install +``` + +Once we've done that, we should have all the dependencies for `weechat-matrix`, +so let's go ahead and clone that and install it! + +``` +git clone https://github.com/poljar/weechat-matrix.git +cd weechat-matrix +make install +``` + +Done! The rest is up to you! You'll need to [configure your Matrix servers +within WeeChat][weechat-matrix-config] and then verify keys. Verifying keys +isn't a particularly clean process at the moment, but I expect it shall improve. +For now, I followed this basic process in WeeChat: + ++ Open a split at your status window so you can see it and the encrypted channel + at the same time. (`/window splitv`) ++ Open the encrypted channel whose keys you need to verify. ++ List the unverified keys in the current channel. (`/olm info unverified`) ++ For each user with keys listed there, verify all of their listed keys via your + preferred method. Alternatively, you can do this on a per-device basis. See + `/help olm` for details. ++ Once all keys are verified, tell WeeChat you have done so. (`/olm verify + @username:homeserver.example.com`) ++ Repeat until there are no unverified keys remaining in the current channel and + repeat for each channel. Whew! + + +[weechat-matrix]: https://github.com/poljar/weechat-matrix +[weechat-matrix-config]: https://github.com/poljar/weechat-matrix#Configuration +[matrix-nio]: https://github.com/poljar/matrix-nio diff --git a/easy-script.bash b/easy-script.bash new file mode 100755 index 0000000..13d8f77 --- /dev/null +++ b/easy-script.bash @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# python 3 is supposed to work fine, but my weechat was compiled with python 2 support only +pip_bin="pip2" +py_bin="python2" +source_dir="$HOME/code/open-source" + +# OPTIONAL: configure upload helper scripts as described here: +# https://github.com/poljar/weechat-matrix#uploads + +# you will need libolm: `pacaur -S libolm` or `sudo apt-get install libolm-dev` + +pushd "$source_dir" || exit 1 + +git clone https://github.com/poljar/weechat-matrix.git "$source_dir/weechat-matrix" +git clone https://github.com/poljar/matrix-nio.git "$source_dir/matrix-nio" + +sudo "$pip_bin" install pyOpenSSL typing webcolors future atomicwrites attrs logbook pygments +sudo "$pip_bin" install -e git+https://github.com/poljar/python-olm.git@master#egg=python-olm-0 + +popd || exit 2 +pushd "$source_dir/matrix-nio" || exit 3 + +sudo "$pip_bin" install -r ./rtd-requirements.txt/ +sudo "$py_bin" ./setup.py install + +popd || exit 4 +pushd "$source_dir/weechat-matrix" || exit 5 + +make install + +popd || exit 6 + +# done! (re)start weechat and proceed to configure: +# https://github.com/poljar/weechat-matrix#configuration