Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 839f9b9

Browse files
committedJun 17, 2019
One shot demo server startup
Configure the demo servers to use untrusted tls certs so that they communicate with each other. This configuration makes them very unsafe so I've added warnings about it in the readme.
1 parent 9b14a81 commit 839f9b9

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed
 

‎demo/README

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
DO NOT USE THESE DEMO SERVERS IN PRODUCTION
2+
13
Requires you to have done:
24
python setup.py develop
35

46

5-
The demo start.sh will start three synapse servers on ports 8080, 8081 and 8082, with host names localhost:$port. This can be easily changed to `hostname`:$port in start.sh if required.
6-
It will also start a web server on port 8000 pointed at the webclient.
7+
The demo start.sh will start three synapse servers on ports 8080, 8081 and 8082, with host names localhost:$port. This can be easily changed to `hostname`:$port in start.sh if required.
8+
9+
To enable the servers to communicate untrusted ssl certs are used. In order to do this the servers do not check the certs
10+
and are configured in a highly insecure way. Do not use these configuration files in production.
711

812
stop.sh will stop the synapse servers and the webclient.
913

‎demo/start.sh

+64-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,70 @@ for port in 8080 8081 8082; do
2727
--config-path "$DIR/etc/$port.config" \
2828
--report-stats no
2929

30-
printf '\n\n# Customisation made by demo/start.sh\n' >> $DIR/etc/$port.config
31-
echo 'enable_registration: true' >> $DIR/etc/$port.config
30+
if ! grep -F "Customisation made by demo/start.sh" -q $DIR/etc/$port.config; then
31+
printf '\n\n# Customisation made by demo/start.sh\n' >> $DIR/etc/$port.config
32+
33+
echo 'enable_registration: true' >> $DIR/etc/$port.config
34+
35+
# Warning, this heredoc depends on the interaction of tabs and spaces. Please don't
36+
# accidentaly bork me with your fancy settings.
37+
listeners=$(cat <<-PORTLISTENERS
38+
# Configure server to listen on both $https_port and $port
39+
# This overides some of the default settings above
40+
listeners:
41+
- port: $https_port
42+
type: http
43+
tls: true
44+
resources:
45+
- names: [client, federation]
46+
47+
- port: $port
48+
tls: false
49+
bind_addresses: ['::1', '127.0.0.1']
50+
type: http
51+
x_forwarded: true
52+
resources:
53+
- names: [client, federation]
54+
compress: false
55+
PORTLISTENERS
56+
)
57+
echo "${listeners}" >> $DIR/etc/$port.config
58+
59+
# Disable tls for the servers
60+
printf '\n\n# Disable tls on the servers.' >> $DIR/etc/$port.config
61+
echo '# DO NOT USE IN PRODUCTION' >> $DIR/etc/$port.config
62+
echo 'use_insecure_ssl_client_just_for_testing_do_not_use: true' >> $DIR/etc/$port.config
63+
echo 'federation_verify_certificates: false' >> $DIR/etc/$port.config
64+
65+
# Set tls paths
66+
echo "tls_certificate_path: \"$DIR/etc/localhost:$https_port.tls.crt\"" >> $DIR/etc/$port.config
67+
echo "tls_private_key_path: \"$DIR/etc/localhost:$https_port.tls.key\"" >> $DIR/etc/$port.config
68+
69+
# Generate tls keys
70+
openssl req -x509 -newkey rsa:4096 -keyout $DIR/etc/localhost\:$https_port.tls.key -out $DIR/etc/localhost\:$https_port.tls.crt -days 365 -nodes -subj "/O=matrix"
71+
72+
# Ignore keys from the trusted keys server
73+
echo '# Ignore keys from the trusted keys server' >> $DIR/etc/$port.config
74+
echo 'trusted_key_servers:' >> $DIR/etc/$port.config
75+
echo ' - server_name: "matrix.org"' >> $DIR/etc/$port.config
76+
echo ' accept_keys_insecurely: true' >> $DIR/etc/$port.config
77+
78+
# Reduce the blacklist
79+
blacklist=$(cat <<-BLACK
80+
# Set the blacklist so that it doesn't include 127.0.0.1
81+
federation_ip_range_blacklist:
82+
- '10.0.0.0/8'
83+
- '172.16.0.0/12'
84+
- '192.168.0.0/16'
85+
- '100.64.0.0/10'
86+
- '169.254.0.0/16'
87+
- '::1/128'
88+
- 'fe80::/64'
89+
- 'fc00::/7'
90+
BLACK
91+
)
92+
echo "${blacklist}" >> $DIR/etc/$port.config
93+
fi
3294

3395
# Check script parameters
3496
if [ $# -eq 1 ]; then

0 commit comments

Comments
 (0)
This repository has been archived.