From e18f5f5ed20557eee2db0cfe8b38450b2adcacb1 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 26 Feb 2019 17:55:41 +0100 Subject: [PATCH] new: [synapse] support ``server-name``. Notice that you have to add a special DNS rule in the ``server-name`` zone:: _matrix._tcp.example.com 3600 IN SRV 10 0 8448 matrix.example.com This is to declare that ``matrix.example.com`` is matrix server for domain ``example.com``. --- synapse/hooks/init | 2 ++ synapse/hooks/web_proxy-relation-joined | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/synapse/hooks/init b/synapse/hooks/init index 0ad6d36..dfdcbf8 100755 --- a/synapse/hooks/init +++ b/synapse/hooks/init @@ -19,6 +19,8 @@ options="$(e "$service_def" | shyaml -y get-value options)" || true SYNAPSE_OPTIONS=( + + server-name:string ## The server name report-stats:bool ## Enable anon stat reporting back to the Matrix project enable-registration:bool ## Enable registration on the Synapse instance. allow-guest:bool ## allow guest joining this server. diff --git a/synapse/hooks/web_proxy-relation-joined b/synapse/hooks/web_proxy-relation-joined index 4e3e1f2..742f0e0 100755 --- a/synapse/hooks/web_proxy-relation-joined +++ b/synapse/hooks/web_proxy-relation-joined @@ -4,20 +4,23 @@ set -e . lib/common -DOMAIN=$(relation-get domain) || exit 1 +env=() url=$(relation-get url) - if [ "${url%://*}" == "https" ]; then - no_tls=" SYNAPSE_NO_TLS: 'yes'" -else - no_tls= + env+=(SYNAPSE_NO_TLS "'yes'") +fi + +server_name=$(options-get "server-name") || true +if [ -z "$server_name" ]; then + DOMAIN=$(relation-get domain) || exit 1 + env+=(SYNAPSE_SERVER_NAME "$DOMAIN") fi -init-config-add " +if [ "${#env[@]}" -gt 0 ]; then + init-config-add " $SERVICE_NAME: environment: - SYNAPSE_SERVER_NAME: $DOMAIN -$no_tls +$(printf " %s: %s\n" "${env[@]}") " || exit 1 - +fi \ No newline at end of file