From 88bb1bccd09231766f94e7ef2dd3eb977e446a72 Mon Sep 17 00:00:00 2001 From: Aaron van Meerten Date: Tue, 3 May 2022 08:40:52 -0500 Subject: [PATCH] feature: support multiple XMPP servers via list (#1276) --- jibri/rootfs/defaults/jibri.conf | 38 ++++---- .../defaults/sip-communicator.properties | 88 ++++++++++--------- jvb/rootfs/defaults/jvb.conf | 20 +++-- 3 files changed, 82 insertions(+), 64 deletions(-) diff --git a/jibri/rootfs/defaults/jibri.conf b/jibri/rootfs/defaults/jibri.conf index 81e0cb9..58ab863 100644 --- a/jibri/rootfs/defaults/jibri.conf +++ b/jibri/rootfs/defaults/jibri.conf @@ -2,6 +2,9 @@ {{ $JIBRI_RECORDING_RESOLUTION := .Env.JIBRI_RECORDING_RESOLUTION | default "1280x720" -}} {{ $XMPP_TRUST_ALL_CERTS := .Env.XMPP_TRUST_ALL_CERTS | default "true" | toBool -}} {{ $XMPP_PORT := .Env.XMPP_PORT | default "5222" -}} +{{ $XMPP_SERVERS := splitList "," .Env.XMPP_SERVER -}} +{{/* assign env from context, preserve during range when . is re-assigned */}} +{{ $ENV := .Env -}} jibri { // A unique identifier for this Jibri @@ -21,49 +24,51 @@ jibri { xmpp { // See example_xmpp_envs.conf for an example of what is expected here environments = [ +{{ range $index, $element := $XMPP_SERVERS -}} +{{ $SERVER := splitn ":" 2 $element }} { // A user-friendly name for this environment - name = "{{ .Env.XMPP_ENV_NAME }}" + name = "{{ $ENV.XMPP_ENV_NAME }}-{{$index}}" // A list of XMPP server hosts to which we'll connect xmpp-server-hosts = [ - "{{ .Env.XMPP_SERVER }}" + "{{ $SERVER._0 }}" ] // The base XMPP domain - xmpp-domain = "{{ .Env.XMPP_DOMAIN }}" + xmpp-domain = "{{ $ENV.XMPP_DOMAIN }}" - {{ if .Env.PUBLIC_URL -}} + {{ if $ENV.PUBLIC_URL -}} // An (optional) base url the Jibri will join if it is set - base-url = "{{ .Env.PUBLIC_URL }}" + base-url = "{{ $ENV.PUBLIC_URL }}" {{ end -}} // The MUC we'll join to announce our presence for // recording and streaming services control-muc { - domain = "{{ .Env.XMPP_INTERNAL_MUC_DOMAIN }}" - room-name = "{{ .Env.JIBRI_BREWERY_MUC }}" - nickname = "{{ .Env.JIBRI_INSTANCE_ID }}" + domain = "{{ $ENV.XMPP_INTERNAL_MUC_DOMAIN }}" + room-name = "{{ $ENV.JIBRI_BREWERY_MUC }}" + nickname = "{{ $ENV.JIBRI_INSTANCE_ID }}" } // The login information for the control MUC control-login { - domain = "{{ .Env.XMPP_AUTH_DOMAIN }}" - port = "{{ $XMPP_PORT }}" - username = "{{ .Env.JIBRI_XMPP_USER }}" - password = "{{ .Env.JIBRI_XMPP_PASSWORD }}" + domain = "{{ $ENV.XMPP_AUTH_DOMAIN }}" + port = "{{ $SERVER._1 | default $XMPP_PORT }}" + username = "{{ $ENV.JIBRI_XMPP_USER }}" + password = "{{ $ENV.JIBRI_XMPP_PASSWORD }}" } // The login information the selenium web client will use call-login { - domain = "{{ .Env.XMPP_RECORDER_DOMAIN }}" - username = "{{ .Env.JIBRI_RECORDER_USER }}" - password = "{{ .Env.JIBRI_RECORDER_PASSWORD }}" + domain = "{{ $ENV.XMPP_RECORDER_DOMAIN }}" + username = "{{ $ENV.JIBRI_RECORDER_USER }}" + password = "{{ $ENV.JIBRI_RECORDER_PASSWORD }}" } // The value we'll strip from the room JID domain to derive // the call URL - strip-from-room-domain = "{{ .Env.JIBRI_STRIP_DOMAIN_JID }}." + strip-from-room-domain = "{{ $ENV.JIBRI_STRIP_DOMAIN_JID }}." // How long Jibri sessions will be allowed to last before // they are stopped. A value of 0 allows them to go on @@ -74,6 +79,7 @@ jibri { // this XMPP domain trust-all-xmpp-certs = {{ $XMPP_TRUST_ALL_CERTS }} } +{{ end }} ] } } diff --git a/jigasi/rootfs/defaults/sip-communicator.properties b/jigasi/rootfs/defaults/sip-communicator.properties index 67c1616..4dd2ac9 100644 --- a/jigasi/rootfs/defaults/sip-communicator.properties +++ b/jigasi/rootfs/defaults/sip-communicator.properties @@ -1,4 +1,7 @@ {{ $XMPP_PORT := .Env.XMPP_PORT | default "5222" -}} +{{ $XMPP_SERVERS := splitList "," .Env.XMPP_SERVER -}} +{{/* assign env from context, preserve during range when . is re-assigned */}} +{{ $ENV := .Env -}} net.java.sip.communicator.impl.protocol.SingleCallInProgressPolicy.enabled=false @@ -62,48 +65,51 @@ net.java.sip.communicator.impl.protocol.sip.acc1.OVERRIDE_ENCODINGS=true net.java.sip.communicator.impl.protocol.sip.acc1.DOMAIN_BASE={{ .Env.XMPP_DOMAIN }} # XMPP account used for control -net.java.sip.communicator.impl.protocol.jabber.acc1=acc1 -net.java.sip.communicator.impl.protocol.jabber.acc1.ACCOUNT_UID=Jabber:{{ .Env.JIGASI_XMPP_USER }}@{{ .Env.XMPP_AUTH_DOMAIN }} -net.java.sip.communicator.impl.protocol.jabber.acc1.USER_ID={{ .Env.JIGASI_XMPP_USER }}@{{ .Env.XMPP_AUTH_DOMAIN }} -net.java.sip.communicator.impl.protocol.jabber.acc1.IS_SERVER_OVERRIDDEN=true -net.java.sip.communicator.impl.protocol.jabber.acc1.SERVER_ADDRESS={{ .Env.XMPP_SERVER }} -net.java.sip.communicator.impl.protocol.jabber.acc1.SERVER_PORT={{ $XMPP_PORT }} -net.java.sip.communicator.impl.protocol.jabber.acc1.PASSWORD={{ .Env.JIGASI_XMPP_PASSWORD | b64enc }} -net.java.sip.communicator.impl.protocol.jabber.acc1.AUTO_GENERATE_RESOURCE=true -net.java.sip.communicator.impl.protocol.jabber.acc1.RESOURCE_PRIORITY=30 -net.java.sip.communicator.impl.protocol.jabber.acc1.IS_CARBON_DISABLED=true -net.java.sip.communicator.impl.protocol.jabber.acc1.DEFAULT_ENCRYPTION=true -net.java.sip.communicator.impl.protocol.jabber.acc1.IS_USE_ICE=true -net.java.sip.communicator.impl.protocol.jabber.acc1.IS_ACCOUNT_DISABLED=false -net.java.sip.communicator.impl.protocol.jabber.acc1.IS_PREFERRED_PROTOCOL=false -net.java.sip.communicator.impl.protocol.jabber.acc1.AUTO_DISCOVER_JINGLE_NODES=false -net.java.sip.communicator.impl.protocol.jabber.acc1.PROTOCOL=Jabber -net.java.sip.communicator.impl.protocol.jabber.acc1.IS_USE_UPNP=false -net.java.sip.communicator.impl.protocol.jabber.acc1.USE_DEFAULT_STUN_SERVER=true -net.java.sip.communicator.impl.protocol.jabber.acc1.ENCRYPTION_PROTOCOL.DTLS-SRTP=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.ENCRYPTION_PROTOCOL_STATUS.DTLS-SRTP=true -net.java.sip.communicator.impl.protocol.jabber.acc1.VIDEO_CALLING_DISABLED=true -net.java.sip.communicator.impl.protocol.jabber.acc1.OVERRIDE_ENCODINGS=true -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.G722/8000=705 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.GSM/8000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.H263-1998/90000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.H264/90000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.PCMA/8000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.PCMU/8000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.SILK/12000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.SILK/16000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.SILK/24000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.SILK/8000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.VP8/90000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.iLBC/8000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.opus/48000=750 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.speex/16000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.speex/32000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.speex/8000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.Encodings.telephone-event/8000=0 -net.java.sip.communicator.impl.protocol.jabber.acc1.BREWERY={{ .Env.JIGASI_BREWERY_MUC }}@{{ .Env.XMPP_INTERNAL_MUC_DOMAIN }} -net.java.sip.communicator.impl.protocol.jabber.acc1.DOMAIN_BASE={{ .Env.XMPP_DOMAIN }} +{{ range $index, $element := $XMPP_SERVERS -}} +{{ $SERVER := splitn ":" 2 $element }} +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}=acc{{ $index }} +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.ACCOUNT_UID=Jabber:{{ $ENV.JIGASI_XMPP_USER }}@{{ $ENV.XMPP_AUTH_DOMAIN }} +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.USER_ID={{ $ENV.JIGASI_XMPP_USER }}@{{ $ENV.XMPP_AUTH_DOMAIN }} +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.IS_SERVER_OVERRIDDEN=true +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.SERVER_ADDRESS={{ $SERVER._0 }} +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.SERVER_PORT={{ $SERVER._1 | default $XMPP_PORT }} +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.PASSWORD={{ $ENV.JIGASI_XMPP_PASSWORD | b64enc }} +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.AUTO_GENERATE_RESOURCE=true +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.RESOURCE_PRIORITY=30 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.IS_CARBON_DISABLED=true +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.DEFAULT_ENCRYPTION=true +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.IS_USE_ICE=true +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.IS_ACCOUNT_DISABLED=false +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.IS_PREFERRED_PROTOCOL=false +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.AUTO_DISCOVER_JINGLE_NODES=false +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.PROTOCOL=Jabber +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.IS_USE_UPNP=false +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.USE_DEFAULT_STUN_SERVER=true +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.ENCRYPTION_PROTOCOL.DTLS-SRTP=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.ENCRYPTION_PROTOCOL_STATUS.DTLS-SRTP=true +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.VIDEO_CALLING_DISABLED=true +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.OVERRIDE_ENCODINGS=true +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.G722/8000=705 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.GSM/8000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.H263-1998/90000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.H264/90000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.PCMA/8000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.PCMU/8000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.SILK/12000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.SILK/16000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.SILK/24000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.SILK/8000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.VP8/90000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.iLBC/8000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.opus/48000=750 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.speex/16000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.speex/32000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.speex/8000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.Encodings.telephone-event/8000=0 +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.BREWERY={{ $ENV.JIGASI_BREWERY_MUC }}@{{ $ENV.XMPP_INTERNAL_MUC_DOMAIN }} +net.java.sip.communicator.impl.protocol.jabber.acc{{ $index }}.DOMAIN_BASE={{ $ENV.XMPP_DOMAIN }} +{{ end -}} org.jitsi.jigasi.BREWERY_ENABLED=true org.jitsi.jigasi.HEALTH_CHECK_SIP_URI={{ .Env.JIGASI_HEALTH_CHECK_SIP_URI | default "" }} diff --git a/jvb/rootfs/defaults/jvb.conf b/jvb/rootfs/defaults/jvb.conf index 6aed978..a1e418a 100644 --- a/jvb/rootfs/defaults/jvb.conf +++ b/jvb/rootfs/defaults/jvb.conf @@ -7,6 +7,9 @@ {{ $WS_DOMAIN := .Env.JVB_WS_DOMAIN | default $PUBLIC_URL_DOMAIN -}} {{ $WS_SERVER_ID := .Env.JVB_WS_SERVER_ID | default .Env.JVB_WS_SERVER_ID_FALLBACK -}} {{ $XMPP_PORT := .Env.XMPP_PORT | default "5222" -}} +{{ $XMPP_SERVERS := splitList "," .Env.XMPP_SERVER -}} +{{/* assign env from context, preserve during range when . is re-assigned */}} +{{ $ENV := .Env -}} videobridge { ice { @@ -17,16 +20,19 @@ videobridge { apis { xmpp-client { configs { - shard { - HOSTNAME = "{{ .Env.XMPP_SERVER }}" - PORT = "{{ $XMPP_PORT }}" - DOMAIN = "{{ .Env.XMPP_AUTH_DOMAIN }}" - USERNAME = "{{ .Env.JVB_AUTH_USER }}" - PASSWORD = "{{ .Env.JVB_AUTH_PASSWORD }}" - MUC_JIDS = "{{ .Env.JVB_BREWERY_MUC }}@{{ .Env.XMPP_INTERNAL_MUC_DOMAIN }}" +{{ range $index, $element := $XMPP_SERVERS -}} +{{ $SERVER := splitn ":" 2 $element }} + shard{{ $index }} { + HOSTNAME = "{{ $SERVER._0 }}" + PORT = "{{ $SERVER._1 | default $XMPP_PORT }}" + DOMAIN = "{{ $ENV.XMPP_AUTH_DOMAIN }}" + USERNAME = "{{ $ENV.JVB_AUTH_USER }}" + PASSWORD = "{{ $ENV.JVB_AUTH_PASSWORD }}" + MUC_JIDS = "{{ $ENV.JVB_BREWERY_MUC }}@{{ $ENV.XMPP_INTERNAL_MUC_DOMAIN }}" MUC_NICKNAME = "{{ $JVB_MUC_NICKNAME }}" DISABLE_CERTIFICATE_VERIFICATION = true } +{{ end }} } } rest {