Browse Source

feat: Adds new module to unlimit jicofo and jvb connections.

In case limited those connection will be whitelisted and unlimited. Updates existing configurations to make sure prosody update will not break it by limiting too much.

Uses 28c16c93d7 version of the module: https://modules.prosody.im/mod_limits_exception.html
Will be available in prosody 0.12.
j8
damencho 3 years ago
parent
commit
15c08f90c4

+ 12
- 5
debian/jitsi-meet-prosody.postinst View File

@@ -125,11 +125,11 @@ case "$1" in
125 125
 
126 126
         # Check whether prosody config has the internal muc, if not add it,
127 127
         # as we are migrating configs
128
-        if [ -f $PROSODY_HOST_CONFIG ] && ! grep -q "internal.auth.$JVB_HOSTNAME" $PROSODY_HOST_CONFIG; then
129
-            echo -e "\nComponent \"internal.auth.$JVB_HOSTNAME\" \"muc\"" >> $PROSODY_HOST_CONFIG
128
+        if [ -f $PROSODY_HOST_CONFIG ] && ! grep -q "internal.$JICOFO_AUTH_DOMAIN" $PROSODY_HOST_CONFIG; then
129
+            echo -e "\nComponent \"internal.$JICOFO_AUTH_DOMAIN\" \"muc\"" >> $PROSODY_HOST_CONFIG
130 130
             echo -e "    storage = \"memory\"" >> $PROSODY_HOST_CONFIG
131 131
             echo -e "    modules_enabled = { \"ping\"; }" >> $PROSODY_HOST_CONFIG
132
-            echo -e "    admins = { \"$JICOFO_AUTH_USER@auth.$JVB_HOSTNAME\", \"jvb@auth.$JVB_HOSTNAME\" }" >> $PROSODY_HOST_CONFIG
132
+            echo -e "    admins = { \"$JICOFO_AUTH_USER@$JICOFO_AUTH_DOMAIN\", \"jvb@$JICOFO_AUTH_DOMAIN\" }" >> $PROSODY_HOST_CONFIG
133 133
         fi
134 134
 
135 135
         # Convert the old focus component config to the new one.
@@ -140,7 +140,7 @@ case "$1" in
140 140
         # Component "focus.jitmeet.example.com" "client_proxy"
141 141
         #    target_address = "focus@auth.jitmeet.example.com"
142 142
         if grep -q "Component \"focus.$JVB_HOSTNAME\"" $PROSODY_HOST_CONFIG && ! grep "Component \"focus.$JVB_HOSTNAME\" \"client_proxy\"" $PROSODY_HOST_CONFIG ;then
143
-            sed -i "s/Component \"focus.$JVB_HOSTNAME\"/Component \"focus.$JVB_HOSTNAME\" \"client_proxy\"\n    target_address = \"$JICOFO_AUTH_USER@auth.$JVB_HOSTNAME\"/g" $PROSODY_HOST_CONFIG
143
+            sed -i "s/Component \"focus.$JVB_HOSTNAME\"/Component \"focus.$JVB_HOSTNAME\" \"client_proxy\"\n    target_address = \"$JICOFO_AUTH_USER@$JICOFO_AUTH_DOMAIN\"/g" $PROSODY_HOST_CONFIG
144 144
             PROSODY_CONFIG_PRESENT="false"
145 145
         fi
146 146
 
@@ -155,10 +155,17 @@ case "$1" in
155 155
         MAIN_MUC_PATTERN="Component \"conference.$JVB_HOSTNAME\" \"muc\""
156 156
         if ! grep -A 2 -- "${MAIN_MUC_PATTERN}" $PROSODY_HOST_CONFIG | grep -q "restrict_room_creation" ;then
157 157
             sed -i "s/${MAIN_MUC_PATTERN}/${MAIN_MUC_PATTERN}\n    restrict_room_creation = true/g" $PROSODY_HOST_CONFIG
158
+            PROSODY_CONFIG_PRESENT="false"
159
+        fi
160
+
161
+        if ! grep -q -- 'unlimited_jids' $PROSODY_HOST_CONFIG ;then
162
+            sed -i "1s/^/unlimited_jids = { \"$JICOFO_AUTH_USER@$JICOFO_AUTH_DOMAIN\", \"jvb@$JICOFO_AUTH_DOMAIN\" }\n/" $PROSODY_HOST_CONFIG
163
+            sed -i "s/VirtualHost \"$JICOFO_AUTH_DOMAIN\"/VirtualHost \"$JICOFO_AUTH_DOMAIN\"\n    modules_enabled = { \"limits_exception\"; }/g" $PROSODY_HOST_CONFIG
164
+            PROSODY_CONFIG_PRESENT="false"
158 165
         fi
159 166
 
160 167
         # Make sure the focus@auth user's roster includes the proxy component (this is idempotent)
161
-        prosodyctl mod_roster_command subscribe focus.$JVB_HOSTNAME $JICOFO_AUTH_USER@auth.$JVB_HOSTNAME
168
+        prosodyctl mod_roster_command subscribe focus.$JVB_HOSTNAME $JICOFO_AUTH_USER@$JICOFO_AUTH_DOMAIN
162 169
 
163 170
         if [ ! -f /var/lib/prosody/$JVB_HOSTNAME.crt ]; then
164 171
             # prosodyctl takes care for the permissions

+ 8
- 0
doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example View File

@@ -20,6 +20,11 @@ ssl = {
20 20
     ciphers = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"
21 21
 }
22 22
 
23
+unlimited_jids = {
24
+    "focusUser@auth.jitmeet.example.com",
25
+    "jvb@auth.jitmeet.example.com"
26
+}
27
+
23 28
 VirtualHost "jitmeet.example.com"
24 29
     -- enabled = false -- Remove this line to enable this host
25 30
     authentication = "anonymous"
@@ -77,6 +82,9 @@ Component "internal.auth.jitmeet.example.com" "muc"
77 82
     muc_room_default_public_jids = true
78 83
 
79 84
 VirtualHost "auth.jitmeet.example.com"
85
+    modules_enabled = {
86
+        "limits_exception";
87
+    }
80 88
     authentication = "internal_hashed"
81 89
 
82 90
 -- Proxy to jicofo's user JID, so that it doesn't have to register as a component.

+ 24
- 0
resources/prosody-plugins/mod_limits_exception.lua View File

@@ -0,0 +1,24 @@
1
+-- we use async to detect Prosody 0.10 and earlier
2
+local have_async = pcall(require, 'util.async');
3
+
4
+if not have_async then
5
+	return;
6
+end
7
+
8
+local unlimited_jids = module:get_option_inherited_set("unlimited_jids", {});
9
+
10
+if unlimited_jids:empty() then
11
+	return;
12
+end
13
+
14
+module:hook("authentication-success", function (event)
15
+	local session = event.session;
16
+	local jid = session.username .. "@" .. session.host;
17
+	if unlimited_jids:contains(jid) then
18
+		if session.conn and session.conn.setlimit then
19
+			session.conn:setlimit(0);
20
+		elseif session.throttle then
21
+			session.throttle = nil;
22
+		end
23
+	end
24
+end);

Loading…
Cancel
Save