This commit is contained in:
Bel LaPointe
2021-02-21 21:43:51 -06:00
parent 17979240dd
commit 7216ac1620
31 changed files with 5 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
server_name: scratch.com
pid_file: "/var/run/matrix-synapse.pid"
federation_ip_range_blacklist:
- '127.0.0.0/8'
- '10.0.0.0/8'
- '172.16.0.0/12'
- '192.168.0.0/16'
- '100.64.0.0/10'
- '169.254.0.0/16'
- '::1/128'
- 'fe80::/64'
- 'fc00::/7'
listeners:
- port: 39987
tls: false
type: http
x_forwarded: false
bind_addresses: ['::']
resources:
- names: [client, federation]
compress: false
retention:
acme:
enabled: false
port: 80
bind_addresses: ['::', '0.0.0.0']
reprovision_threshold: 30
domain: matrix.example.com
account_key_file: /var/lib/matrix-synapse/acme_account.key
database:
name: "sqlite3"
args:
database: "/mnt/homeserver.db"
log_config: "/etc/matrix-synapse/log.yaml"
media_store_path: "/var/lib/matrix-synapse/media"
enable_registration: true
account_validity:
account_threepid_delegates:
metrics_flags:
signing_key_path: "/etc/matrix-synapse/homeserver.signing.key"
old_signing_keys:
trusted_key_servers:
- server_name: "matrix.org"
saml2_config:
user_mapping_provider:
config:
sso:
password_config:
email:
enable_group_creation: true
opentracing:

119
.old/testdata/matrix-sandbox/build.sh vendored Normal file
View File

@@ -0,0 +1,119 @@
#! /bin/bash
if ! ps aux | grep -v grep | grep homeserver; then
cp synapse-test.key /tmp/
cp synapse-test-log.yaml /tmp/
homeserver -c config.yaml &> /tmp/synapse-test.log &
disown
fi
# pick a username
username="$(cat /proc/sys/kernel/random/uuid)"
# register
out="$(
curl -sS http://localhost:39487/_matrix/client/r0/register \
-X POST \
-H 'content-type: application/json' \
-d "$(
printf '{
"username": "%s",
"password": "%s",
"auth": {
"type": "m.login.dummy"
}
}' "$username"
)"
)"
printf "%s\n" "$out"
access_token="$(echo "$out" | jq -r .access_token)"
user_id="$(echo "$out" | jq -r .user_id)"
home_server="$(echo "$out" | jq -r .home_server)"
# create a room
room="$(cat /proc/sys/kernel/random/uuid)"
out="$(
curl -sS http://localhost:39487/_matrix/client/r0/createRoom\
-X POST \
-H 'content-type: application/json' \
-H 'Authorization: Bearer '"$access_token" \
-d "$(
printf '{
"room_alias_name": "%s"
}' "$room"
)"
)"
printf "%s\n" "$out"
room_id="$(echo "$out" | jq -r .room_id)"
# join a room by name
# curl -XPOST -d '{}' "https://localhost:8448/_matrix/client/r0/join/%21asfLdzLnOdGRkdPZWu:localhost?access_token=YOUR_ACCESS_TOKEN"
curl -sS "http://localhost:39487/_matrix/client/r0/join/$room_id" \
-X POST \
-H 'Authorization: Bearer '"$access_token" \
-d '{}'
# send message
# curl -XPOST -d '{"msgtype":"m.text", "body":"hello"}' "https://localhost:8448/_matrix/client/r0/rooms/%21asfLdzLnOdGRkdPZWu:localhost/send/m.room.message?access_token=YOUR_ACCESS_TOKEN"
#PUT /_matrix/client/r0/rooms/%21636q39766251%3Aexample.com/send/m.room.message/35 HTTP/1.1 Content-Type: application/json {"msgtype": "m.text","body": "hello"}
txid="$(cat /proc/sys/kernel/random/uuid)"
message="hello wurl"
out="$(
curl -sS "http://localhost:39487/_matrix/client/r0/rooms/$room_id/send/m.room.message/$txid" \
-X PUT \
-H 'content-type: application/json' \
-H 'Authorization: Bearer '"$access_token" \
-d "$(
printf '{
"msgtype": "m.text",
"body": "%s"
}' "$message"
)"
)"
printf "%s\n" "$out"
# get recent messages
# curl --globoff -XGET 'https://localhost:8448/_matrix/client/r0/sync?filter={"room":{"timeline":{"limit":1}}}&access_token=YOUR_ACCESS_TOKEN'
out="$(
curl -sS "http://localhost:39487/_matrix/client/r0/sync" \
-X GET \
-H 'content-type: application/json' \
-H 'Authorization: Bearer '"$access_token" \
| jq '{"timeline": .rooms.join[].timeline.events[], "next": .next_batch}' \
| jq '{"content": .timeline.content, "sender": .timeline.sender, "next": .next}' \
)"
printf "%s\n" "$out" | jq .
since="$(
echo "$out" \
| jq -r .next | tail -n 1)"
# send new message
txid="$(cat /proc/sys/kernel/random/uuid)"
message="hello wurl2"
out="$(
curl -sS "http://localhost:39487/_matrix/client/r0/rooms/$room_id/send/m.room.message/$txid" \
-X PUT \
-H 'content-type: application/json' \
-H 'Authorization: Bearer '"$access_token" \
-d "$(
printf '{
"msgtype": "m.text",
"body": "%s"
}' "$message"
)"
)"
printf "%s\n" "$out"
# get second recent messages
# curl --globoff -XGET 'https://localhost:8448/_matrix/client/r0/sync?filter={"room":{"timeline":{"limit":1}}}&access_token=YOUR_ACCESS_TOKEN'
curl -sS "http://localhost:39487/_matrix/client/r0/sync?since=$since" \
-X GET \
-H 'content-type: application/json' \
-H 'Authorization: Bearer '"$access_token" \
| jq '{"timeline": .rooms.join[].timeline.events[], "next": .next_batch}' \
| jq '{"content": .timeline.content, "sender": .timeline.sender, "next": .next}' \
| jq .

View File

@@ -0,0 +1,52 @@
server_name: 192.168.0.86
pid_file: "/tmp/synapse-test.pid"
federation_ip_range_blacklist:
- '127.0.0.0/8'
- '10.0.0.0/8'
- '172.16.0.0/12'
- '192.168.0.0/16'
- '100.64.0.0/10'
- '169.254.0.0/16'
- '::1/128'
- 'fe80::/64'
- 'fc00::/7'
listeners:
- port: 39487
tls: false
type: http
x_forwarded: false
bind_addresses: ['::']
resources:
- names: [client, federation]
compress: false
retention:
acme:
enabled: false
port: 80
bind_addresses: ['::', '0.0.0.0']
reprovision_threshold: 30
domain: matrix.example.com
account_key_file: /var/lib/matrix-synapse/acme_account.key
database:
name: "sqlite3"
args:
database: "/tmp/synapse-test.db"
log_config: "/tmp/synapse-test-log.yaml"
media_store_path: "/tmp/synapse-test-media"
enable_registration: true
account_validity:
account_threepid_delegates:
metrics_flags:
signing_key_path: "/tmp/synapse-test.key"
old_signing_keys:
trusted_key_servers:
- server_name: "matrix.org"
saml2_config:
user_mapping_provider:
config:
sso:
password_config:
email:
enable_group_creation: true
opentracing:
report_stats: false

View File

@@ -0,0 +1,43 @@
# Log configuration for Synapse.
#
# This is a YAML file containing a standard Python logging configuration
# dictionary. See [1] for details on the valid settings.
#
# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema
version: 1
formatters:
precise:
format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'
filters:
context:
(): synapse.logging.context.LoggingContextFilter
request: ""
handlers:
file:
class: logging.handlers.RotatingFileHandler
formatter: precise
filename: /tmp/synapse-test-real.log
maxBytes: 104857600
backupCount: 10
filters: [context]
encoding: utf8
console:
class: logging.StreamHandler
formatter: precise
filters: [context]
loggers:
synapse.storage.SQL:
# beware: increasing this to DEBUG will make synapse log sensitive
# information such as access tokens.
level: INFO
root:
level: INFO
handlers: [file, console]
disable_existing_loggers: false

View File

@@ -0,0 +1 @@
ed25519 a_RcOc CohEFmFuSDY+kHBbY//SMIUZp+hIuyOMEphT2NLEsDc