Skip to content

Instantly share code, notes, and snippets.

@richvdh
richvdh / output.txt
Created April 9, 2021 22:47
twisted starttls test
Started to connect.
Connected.
Protocol lost connection. Reason: VerificationError(errors=[DNSMismatch(mismatched_id=DNS_ID(hostname=b'not-google.com'))])
Factory lost connection. Reason: Connection was aborted locally using ITCPTransport.abortConnection.
@richvdh
richvdh / synapse-test.sh
Created September 4, 2020 09:13
Run sytest in a loop for git bisect
#!/bin/bash
set +x
function run_test {
run=$1
for i in `seq 1 10`; do
docker run --rm --name=sytest$run -e POSTGRES=true -e WORKERS=true \
-e xOFFLINE=1 \
-v `pwd`:/src:ro \
@richvdh
richvdh / 09local_rejections_stream.sql
Created July 10, 2020 09:35
synapse 1.16.0 incorrect table
/* Copyright 2020 The Matrix.org Foundation C.I.C
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@richvdh
richvdh / trains.md
Last active February 25, 2020 21:39
courchevel trains

Outbound

  • 0831 St P - 1152 GdN
  • 1259 GdL - 1456 Lyon
  • 1556 Lyon - 1912 Moutiers

£109.50 + €89 = £184

{
"WellKnownResult": {
"m.server": "",
"result": "invalid character '\u003c' looking for beginning of value"
},
"DNSResult": {
"SRVCName": "_matrix._tcp.tahvok.com.",
"SRVRecords": [
{
"Target": "matrix.tahvok.com.",
@richvdh
richvdh / 0.99.5.sql.diff
Created December 24, 2019 00:08
Diffs between databases created with synapse_port_db and a clean db
-CREATE TABLE _extremities_to_check (
- event_id text
-);
-CREATE INDEX _extremities_to_check_id ON _extremities_to_check USING btree (event_id);
+CREATE INDEX access_tokens_device_id ON access_tokens USING btree (user_id, device_id);
+CREATE INDEX current_state_events_member_index ON current_state_events USING btree (state_key) WHERE (type = 'm.room.member'::text);
-CREATE INDEX device_inbox_stream_id ON device_inbox USING btree (stream_id);
+CREATE INDEX device_inbox_stream_id_user_id ON device_inbox USING btree (stream_id, user_id);
+CREATE UNIQUE INDEX device_lists_remote_cache_unique_id ON device_lists_remote_cache USING btree (user_id, device_id);
+CREATE UNIQUE INDEX device_lists_remote_extremeties_unique_idx ON device_lists_remote_extremeties USING btree (user_id);
try:
is_auth_blocking = False
if self._config.mau_limit_alerting:
try:
# Normally should always pass in user_id to check_auth_blocking
# if you have it, but in this case are checking what would happen
# to other users if they were to arrive.
yield self._auth.check_auth_blocking()
except ResourceLimitError as e:
is_auth_blocking = True
2019-07-15 19:33:52,959 - synapse.http.server - 111 - ERROR - PUT-3- Failed handle request via 'FederationSendJoinServlet': <SynapseRequest at 0x7fcd6c995400 method='PUT' uri='/_matrix/federation/v1/send_join/!bWwoVQiFyuPnyFKXZt:localhost:8800/$0:localhost:33777' clientproto='HTTP/1.1' site=8800>
Capture point (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/rav/work/synapse/synapse/app/homeserver.py", line 658, in <module>
main()
File "/home/rav/work/synapse/synapse/app/homeserver.py", line 654, in main
run(hs)

I've now seen several people point at synapse#5133 and say "federation is broken in synapse 0.99.2".

I would never want to discourage people from upgrading, since each release usually comes with a raft of general bug fixes and performance improvements. However, there seems to be a lot of confusion around this point, so I'd like to clear some things up.

The confusion appears to arise from Synapse's implementation of the /_matrix/federation/v1/send/{txnId} federation REST endpoint. Up to, and including, Synapse 0.99.2, this was implemented in a way that was not compliant with the Matrix spec - in particular, it added a trailing slash to the URI (thus making it /_matrix/federation/v1/send/{txnId}/) to outbound requests, and required that trailing slash on inbound requests.

This was fixed in Synapse 0.99.3 by:

  1. Accepting inbound requests without the trailing
@richvdh
richvdh / test.py
Created October 9, 2018 11:30
Demonstration of `x not in list` exception
#!/usr/bin/env python
import socket
from StringIO import StringIO
from time import sleep
from twisted.internet import reactor
from twisted.web.client import Agent, FileBodyProducer
def snoozer():