diff --git a/type/__matrix_synapse/files/homeserver.yaml.sh b/type/__matrix_synapse/files/homeserver.yaml.sh index 6ee035c..3ec4ba2 100755 --- a/type/__matrix_synapse/files/homeserver.yaml.sh +++ b/type/__matrix_synapse/files/homeserver.yaml.sh @@ -1,8 +1,19 @@ #!/bin/sh -# Note: template originally generated from synapse's 1.26.0 sample config. +# Note: template originally generated from synapse's 1.26.0 sample config set -e +generate_bind_addresses () { + if [ -n "$BIND_ADDRESSES" ]; then + echo "bind_addresses:" + for addr in $BIND_ADDRESSES; do + echo " - '$addr'" + done + else + echo "bind_addresses: []" + fi +} + cat << EOF ############################################################### # THIS FILE HAS BEEN GENERATED BY CDIST. DO NOT EDIT BY HAND. # @@ -263,7 +274,7 @@ listeners: tls: false type: http x_forwarded: true - bind_addresses: ['::1', '127.0.0.1'] + $(generate_bind_addresses) resources: - names: ${MAIN_LISTENER_RESOURCES:?} @@ -273,7 +284,8 @@ EOF if [ -n "$ENABLE_REPLICATION" ]; then cat << EOF - port: 9093 - bind_addresses: ['::1', '127.0.0.1'] + $(generate_bind_addresses) + type: http resources: - names: [replication] diff --git a/type/__matrix_synapse/man.rst b/type/__matrix_synapse/man.rst index 94c6e34..b1799b6 100644 --- a/type/__matrix_synapse/man.rst +++ b/type/__matrix_synapse/man.rst @@ -167,6 +167,10 @@ registration-shared-secret If set, allows registration of standard or admin accounts by anyone who has the shared secret, even if registration is otherwise disabled. +bind-address + Address used to bind the synapse listeners. Can be specified multiple times. + Defaults to '::1' and '127.0.0.1'. + extra-setting Arbitrary string to be added to the configuration file. Can be specified multiple times. diff --git a/type/__matrix_synapse/manifest b/type/__matrix_synapse/manifest index 9fad88e..c2167af 100755 --- a/type/__matrix_synapse/manifest +++ b/type/__matrix_synapse/manifest @@ -108,8 +108,9 @@ MAX_UPLOAD_SIZE=$(cat "$__object/parameter/max-upload-size") EXPOSE_METRICS=$(get_boolean_for 'expose-metrics') WEB_CLIENT_URL=$(cat "$__object/parameter/web-client-url") ROOM_ENCRYPTION_POLICY=$(cat "$__object/parameter/room-encryption-policy") +BIND_ADDRESSES=$(cat "$__object/parameter/bind-address") export SERVER_NAME BASE_URL REPORT_STATS MAX_UPLOAD_SIZE EXPOSE_METRICS \ - WEB_CLIENT_URL ROOM_ENCRYPTION_POLICY + WEB_CLIENT_URL ROOM_ENCRYPTION_POLICY BIND_ADDRESSES if [ -f "$__object/parameter/enable-server-notices" ]; then export ENABLE_SERVER_NOTICES=1 diff --git a/type/__matrix_synapse/parameter/default/bind-address b/type/__matrix_synapse/parameter/default/bind-address new file mode 100644 index 0000000..260d4de --- /dev/null +++ b/type/__matrix_synapse/parameter/default/bind-address @@ -0,0 +1 @@ +::1 127.0.0.1 diff --git a/type/__matrix_synapse/parameter/optional_multiple b/type/__matrix_synapse/parameter/optional_multiple index c292cd7..8aa5c29 100644 --- a/type/__matrix_synapse/parameter/optional_multiple +++ b/type/__matrix_synapse/parameter/optional_multiple @@ -3,3 +3,4 @@ registration-allows-email-pattern auto-join-room app-service-config-file extra-setting +bind-address diff --git a/type/__matrix_synapse_worker/files/worker.yaml.sh b/type/__matrix_synapse_worker/files/worker.yaml.sh index a21d64c..d7303c7 100755 --- a/type/__matrix_synapse_worker/files/worker.yaml.sh +++ b/type/__matrix_synapse_worker/files/worker.yaml.sh @@ -1,5 +1,16 @@ #!/bin/sh +generate_bind_addresses () { + if [ -n "$WORKER_BIND_ADDRESSES" ]; then + echo "bind_addresses:" + for addr in $WORKER_BIND_ADDRESSES; do + echo " - '$addr'" + done + else + echo "bind_addresses: []" + fi +} + cat << EOF worker_app: "${WORKER_APP:?}" worker_name: "${WORKER_NAME:?}" @@ -12,7 +23,7 @@ worker_listeners: - type: http port: ${WORKER_PORT:?} x_forwarded: true - bind_addresses: ['::1', '127.0.0.1'] + $(generate_bind_addresses) resources: - names: EOF diff --git a/type/__matrix_synapse_worker/man.rst b/type/__matrix_synapse_worker/man.rst index c8150f6..7f9269d 100644 --- a/type/__matrix_synapse_worker/man.rst +++ b/type/__matrix_synapse_worker/man.rst @@ -27,9 +27,6 @@ app port Port on which this worker will listen. -resource - Resources to be served by this worker. Can be specified multiple times. - OPTIONAL PARAMETERS ------------------- replication-host @@ -43,6 +40,15 @@ log-config Path to log configuration. Defaults to synapse's main process log configuration. +resource + Resources to be served by this worker. Can be specified multiple times. + Defaults to 'client' and 'federation'. + +bind-address + Address used to bind the synapse listeners. Can be specified multiple times. + Defaults to '::1' and '127.0.0.1'. + + EXAMPLES -------- diff --git a/type/__matrix_synapse_worker/manifest b/type/__matrix_synapse_worker/manifest index fdbcbf4..81db378 100755 --- a/type/__matrix_synapse_worker/manifest +++ b/type/__matrix_synapse_worker/manifest @@ -32,7 +32,8 @@ WORKER_NAME=$__object_id WORKER_APP=$(cat "$__object/parameter/app") WORKER_PORT=$(cat "$__object/parameter/port") WORKER_RESOURCES=$(cat "$__object/parameter/resource") -export WORKER_APP WORKER_NAME WORKER_PORT WORKER_RESOURCES +WORKER_BIND_ADDRESSES=$(cat "$__object/parameter/bind-address") +export WORKER_APP WORKER_NAME WORKER_PORT WORKER_RESOURCES WORKER_BIND_ADDRESSES if [ -f "$__object/parameter/log-config" ]; then WORKER_LOG_CONFIG=$(cat "$__object/parameter/log-config") diff --git a/type/__matrix_synapse_worker/parameter/default/bind-address b/type/__matrix_synapse_worker/parameter/default/bind-address new file mode 100644 index 0000000..260d4de --- /dev/null +++ b/type/__matrix_synapse_worker/parameter/default/bind-address @@ -0,0 +1 @@ +::1 127.0.0.1 diff --git a/type/__matrix_synapse_worker/parameter/default/resource b/type/__matrix_synapse_worker/parameter/default/resource new file mode 100644 index 0000000..16378ec --- /dev/null +++ b/type/__matrix_synapse_worker/parameter/default/resource @@ -0,0 +1 @@ +client federation diff --git a/type/__matrix_synapse_worker/parameter/optional_multiple b/type/__matrix_synapse_worker/parameter/optional_multiple index 91e75c6..d777f84 100644 --- a/type/__matrix_synapse_worker/parameter/optional_multiple +++ b/type/__matrix_synapse_worker/parameter/optional_multiple @@ -1 +1,2 @@ resource +bind-address