Skip to content

Repository files navigation

ShortMesh Client

Contents

Installation

MacOS (M-series)

brew install libolm
export LIBRARY_PATH="/opt/homebrew/lib:$LIBRARY_PATH"export CPATH="/opt/homebrew/include:$CPATH"

Bridge setups

Configure self signing in bridge to avoid error:

failed to decrypt megolm event: no session with given ID found

bridge.conf file:

encryption > self_sign = true

Description

ShortMesh Client is a Matrix protocol client that provides messaging capabilities across multiple Matrix bridges.
The project is built to work with any Matrix homeserver and any number of Matrix bridges can be configured to work on it.

Requirements

  • A running Matrix homeserver
  • Bridges configured on homeserver which can be activated in the conf.yaml file
  • RabbitMQ
  • golang
  • swagger
go install github.com/swaggo/swag/cmd/swag@latest
go get github.com/swaggo/http-swagger
go get github.com/swaggo/files # optional, but useful for serving the swagger filesexport PATH=$PATH:$(go env GOPATH)/bin
  • libolm

Mac OS

brew install libolm
export CGO_CFLAGS="-I/opt/homebrew/include"export CGO_LDFLAGS="-L/opt/homebrew/lib"

Ubuntu

sudo apt install libolm-dev

Running

You can configure the bridges supported by your Homeserver in conf.yaml. The client would try to create Rooms and synchronize for your users for every Bridge it comes across in conf.yaml.

For signal to work please make sure your homeserver is set to put phone numbers in topic

network:
...in_topics: true

You can modify the conf.yaml file after you make a copy. Place in the following:

  • homeserver
  • homeserver_domain
  • mas_client_id
  • mas_client_secret
  • db_key #should be a high entropy string
cp conf.yaml.example conf.yaml
swag init
go mod tidy
go run .

Docker Setup

Build and Run

# Build
docker build -t matrix-client .# Run
docker run -d --name matrix-client -p 8080:8080 \
-v $(pwd)/db:/app/db \
-v $(pwd)/downloads:/app/downloads \
-v $(pwd)/conf.yaml:/app/conf.yaml \
matrix-client
# View logs
docker logs -f matrix-client

Docker Compose

version: '3.8'services:
rabbitmq:
image: rabbitmq:3-management-alpineports:
- "5672:5672"
- "15672:15672"environment:
RABBITMQ_DEFAULT_USER: guestRABBITMQ_DEFAULT_PASS: guestmatrix-client:
build: .ports:
- "8080:8080"volumes:
- ./db:/app/db
- ./downloads:/app/downloads
- ./conf.yaml:/app/conf.yamlenvironment:
- HOST=0.0.0.0
- PORT=8080depends_on:
- rabbitmq
docker-compose up -d
# View logs
docker-compose logs -f matrix-client

API docs

You can configure your API address in conf.yaml. This would be same address you can access your generated swagger API docs.

swag init

[host]/docs/index.html

Adding devices Queue

The incoming messages for adding devices routed to the queue:

exchange: "bridges.topic"binding key: "bridges.topic.add_new_device"queue name: {username}_add_new_device

Incoming messages Queue

The incoming messages are routed to the queue:

exchange: "contacts.topic"binding key: "contacts.topic.incoming_messages"queue name: {username}_incoming_messages

Payload Text|Media

{
"IsContact": true|false,"Type": "",
"From": "",
"To": "",
"Message": "",
"DeviceId": "",
"Media": {
"Content": bytes,"Info": {
"Size": 0# float64 (Double),"MimeType": "",
"Width": 0, "Height": 0,
"BlurHash": ""
}
}
}

Notes

Postgres issues

Snaypse

server{listen443ssl http2;server_name matrix.example.com;ssl_certificate /etc/letsencrypt/live/matrix.example.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/matrix.example.com/privkey.pem;client_max_body_size50M; # IMPORTANT: MAS SHOULD COME BEFORE SYNAPSE FOR REGEX NGINX REASONS # MAS-backed client auth routeslocation~ ^/_matrix/client/(v3|v1)/(login|logout|refresh|auth_metadata|capabilities){proxy_passhttp://127.0.0.1:8080;proxy_http_version 1.1;proxy_set_header Host $host;proxy_set_header X-Forwarded-For $remote_addr;proxy_set_header X-Forwarded-Proto $scheme;} # Synapse endpointslocation~ ^(/_matrix|/_synapse/client|/_synapse/mas){proxy_passhttp://127.0.0.1:8008;proxy_http_version 1.1;proxy_set_header Host $host;proxy_set_header X-Forwarded-For $remote_addr;proxy_set_header X-Forwarded-Proto $scheme;} # .well-knownlocation /.well-known/matrix/ {alias /var/www/matrix/.well-known/matrix/;default_type application/json;add_header Access-Control-Allow-Origin *;}}

.well-known/client

{
"m.homeserver": {
"base_url": "https://matrix.example.com"
},
"org.matrix.msc2965.authentication": {
"issuer": "https://auth.example.com/",
"account": "https://auth.example.com/account/"
}
}

MAS

configuration

services:
matrix-auth-service:
image: ghcr.io/element-hq/matrix-authentication-service:latestcontainer_name: matrix-auth-serviceenvironment:
- MAS_CONFIG=/app/config/config.yamlports:
- "8080:8080"
- "8081:8081"# health endpointvolumes:
- ./config.yaml:/app/config/config.yaml:rorestart: unless-stoppednetwork_mode: "host"

config.yaml

http:
listeners:
- name: webresources:
- name: discovery
- name: human
- name: oauth
- name: compat
- name: graphql
- name: assetsbinds:
# - address: '[::]:8080'
- host: 0.0.0.0port: 8080proxy_protocol: false
- name: internalresources:
- name: healthbinds:
- host: localhostport: 8081proxy_protocol: falsetrusted_proxies:
- 192.168.0.0/16
- 172.16.0.0/12
- 10.0.0.0/10
- 127.0.0.1/8
- fd00::/8
- ::1/128public_base: https://auth.example.com/issuer: https://auth.example.com/
...
matrix:
kind: synapsehomeserver: matrix.example.comendpoint: https://matrix.sherlockwisdom.com/secret: R8PHHknWdVHIsIgUODRuFcN9XYINtrNOaccount:
password_registration_enabled: truepassword_recovery_enabled: trueaccount_deactivation_allowed: truelogin_with_email_allowed: true

TBD

  • When the user logs in on new device, all synced devices get logged out

About

This is a headless Matrix Client

Resources

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages