Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorry, a noob here, but how can I install this? #10

Open
dfalfan opened this issue Jun 5, 2022 · 6 comments
Open

Sorry, a noob here, but how can I install this? #10

dfalfan opened this issue Jun 5, 2022 · 6 comments

Comments

@dfalfan
Copy link

dfalfan commented Jun 5, 2022

First than anything thank you for your work, I have a lot of time searching for something like this.

I already have my matrix-synapse server up and running, I want to install this module but documentation about pluggable modules is limited or I don't understand yet. Inicially, how can I install the .py file before I can edit the homeserver.yaml? I tried everything but cannot install (I'm really new with python packages, sorry) multiple errors with pip like "cannot import module_api from synapse" and others. Please explain like I'm five, your work could save many lives in my organization.

Thanks.

Edit: I already installed the python plugin. but now I can't make it work in the yaml file.

This is how it looks but it give me errors everytime

imagen

imagen

@jdfalls
Copy link

jdfalls commented Dec 9, 2022

yes an install guide would be much appreciated! I have a working synapse server with docker compose, but I'm not well versed in Python..

@mhtvsSFrpHdE
Copy link

mhtvsSFrpHdE commented Jan 31, 2023

All commands below may require root or sudo permission to run.

https://matrix-org.github.io/synapse/latest/modules/index.html
This official page is really poorly documented.
It only tells write the file name and class name, but not mentioned where to put these py files.
I must assume there is some hidden common knowledge between python developers...

Do a Google search about matrix synapse modules,
find one of them, "synapse-custom-room-presets" says pip install path/to/synapse-custom-room-presets
The description still blurs, but command pip were surfaced.

They can be pip package

The next is assumed this is a python package able to be installed by pip,
then where does pip put files?
I run synapse with docker, so it has its own independent python instance.
First, start the server normally with docker start synapse, or just make sure docker is running
then try to query pip with docker exec -it synapse which pip,
so we know docker instance did install python as pip instead of pip3 which is Debian default.

pip package location

Where does pip install its packages?
As far as I remember, pip can upgrade itself, so it may be also a package.
To further know pip install location, query with command docker exec -it synapse pip show pip,
will get these on screen:

Name: pip
Version: 22.0.4
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig@python.org
License: MIT
Location: /usr/local/lib/python3.9/site-packages
Requires: 
Required-by: 

In this case, if pip is available to system,
other py file under /usr/local/lib/python3.9/site-packages may also available to system.

Docker path

This path also is docker path not exist on host system.
To copy them into docker, if you install synapse docker image with official command,
there will be a volume mounted at /var/lib/docker/volumes/synapse-data/_data/,
run this on host os: cp <downloaded matrix_e2ee_filter.py> /var/lib/docker/volumes/synapse-data/_data/
So this file available inside docker.
Continue to run: docker exec -it synapse cp /data/matrix_e2ee_filter.py /usr/local/lib/python3.9/site-packages/
Now the module is installed and ready to go.
Because py file is copied again, file permission usually won't be wrong.

homeserver.yaml

Stop docker server while editing homeserver.yaml

server_name: "<example.org>"
...
modules:
  - module: "matrix_e2ee_filter.EncryptedRoomFilter"
    config:
      deny_encryption_for_users_of: ['<example.org>']
      deny_encryption_for_rooms_of: ['<example.org>']
...

Non-standard usage

matrix-org/synapse#4401
According to collected information, start direct chat is assumed to force E2EE enabled,
therefore, clients like nheko or element Android can't perfectly handle non-E2EE direct chat.

You will start direct chat on element Android, it will prompt encryption is enabled anyway,
ignore this and send your first message, the app will hang for a while,
later will say failed to send message, but invite is actually sent,
just ignore this, back to main interface, and ask your friend to accept the invite.
During your waiting, do not send the message again, or delete the failed message,
or leave created empty room.

Once the friend joins room, click on room to open chat interface,
every function will work as intended, and you have a direct chat without encryption.
If you have manually created 2 user non encrypted room with same user before, leave the room,
(these room won't be recognized as direct chat on nheko)
otherwise, you can't use function like change display name in room locally like
/myroomnick <display-name> on element Android.

This information above is based on experiments and statistics,
I have zero knowledge about how code is actually run and what happened on the server.

@jdfalls
Copy link

jdfalls commented Feb 9, 2023

@mhtvsSFrpHdE thanks for the helpful tips!

I was able to follow your steps so that the container runs properly. Instead of having to do the cp <downloaded matrix_e2ee_filter.py> /var/lib/docker/volumes/synapse-data/_data/ command every time I have a new container, I just made a Dockerfile that does the copy and made a new image.

However, it looks to me like it's not actually preventing the encryption.

If I go into the postgresql database (which is running in a separate docker container), I can see in the public.event_json table the messages going through as both unencrypted and encrypted. When it's unencrypted you can see where it says "body:" with the actual chat message. When it's encrypted it references sha256 and you just see gibberish.

Whenever I turn on encryption in Element, the messages show up encrypted in the database. So unless I'm just looking in the wrong place in postgresql (which is entirely possible), I'm not sure it's actually preventing it.

@mhtvsSFrpHdE
Copy link

mhtvsSFrpHdE commented Feb 9, 2023

@jdfalls On client side, encrypted message always come with a shield icon. If you don't see that icon and you don't verify your device, but still able to view these message, then they are certainly is not encrypted.

I use this plugin to create direct message room without encryption and it did work. For other use case, create new issue to plugin author.

Check README.md again may also can help you identify if a problem is known.
For example, it says it will work on "newly created rooms: after this plugin is installed" may not containing exist rooms created before this plugin installed.

@SimpleUniversalModOrganizer
Copy link

SimpleUniversalModOrganizer commented Oct 25, 2023

If you are using docker-compose:

  1. Save the python file next to your docker-compose.yaml file (or anywhere).
volumes:
   - ./matrix_e2ee_filter.py:/usr/local/lib/python3.11/site-packages/matrix_e2ee_filter/__init__.py:ro
  1. Enjoy

@Tesla2k
Copy link

Tesla2k commented Apr 18, 2024

It would be so nice If such things where always documented. For installing it in a non docker environment (Ubuntu). This worked for me:

 source  /opt/venvs/matrix-synapse/bin/activate
 pip install -e "git+https://github.com/digitalentity/matrix_encryption_disabler.git#egg=matrix-e2ee-filter"

Git and pip must be installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants