Update to socket.io v4

jitsi-changes
Mirco 5 months ago
parent 79b77da808
commit 4272e5f598

@ -4,9 +4,9 @@ from pybuilder.core import task, init
from ddadevops import *
name = "c4k-jitsi"
MODULE = "excalidraw-backend"
MODULE = "excalidraw-testbackend"
PROJECT_ROOT_PATH = "../.."
version = "1.5.2-SNAPSHOT"
version = "1.0.1-SNAPSHOT"
@init

@ -1,10 +1,10 @@
#!/bin/bash
set -Eeo pipefail
set -eux
apt-get update > /dev/null
apt-get upgrade -y > /dev/null
apt-get clean
npm install -g npm
npm install -g npm@latest
npm ci
npm run build

@ -3,8 +3,8 @@
import debug from 'debug';
import dotenv from 'dotenv';
import express from 'express';
import http from 'http';
import {Server} from 'socket.io';
import { createServer } from 'node:http';
import { Server } from 'socket.io';
/*
import * as prometheus from 'socket.io-prometheus-metrics';
@ -13,10 +13,12 @@ wich is moderate vulnerable to regular expression denial of service when untrust
input is passed into the o formatter.
alternatively could be used prom-client
import
*/
const serverDebug = debug('server');
const serverDebug = debug('httpServer');
const app = express();
const port = process.env.PORT || 80; // default port to listen
const httpServer = createServer(app);
dotenv.config(
process.env.NODE_ENV === 'development'
@ -24,25 +26,24 @@ dotenv.config(
: { path: '.env.production' }
);
const app = express();
const port = process.env.PORT || 80; // default port to listen
app.get('/', (req, res) => {
res.send('Excalidraw backend is up :)');
});
const server = http.createServer(app);
server.listen(port, () => {
httpServer.listen(port, () => {
serverDebug(`listening on port: ${port}`);
});
const io = require("socket.io")(Server, {
cors: {
origin: "https://jitsi.test.meissa.de",
credentials: true
},
maxHttpBufferSize: 10e6,
const corsOptions = {
origin: 'https://meet.jit.si',
methods: ["GET", "POST"],
credentials: true
};
const io = new Server(httpServer, {
allowEIO3: true,
cors: corsOptions,
maxHttpBufferSize: 1e6,
pingTimeout: 10000
});
@ -65,21 +66,19 @@ or more:
https://codersociety.com/blog/articles/nodejs-application-monitoring-with-prometheus-and-grafana
*/
io.on('connection', socket => {
io.on('connection', (socket) => {
serverDebug(`connection established! ${socket.conn.request.url}`);
io.to(`${socket.id}`).emit('init-room');
socket.on('join-room', roomID => {
serverDebug(`${socket.id} has joined ${roomID} for url ${socket.conn.request.url}`);
socket.join(roomID);
if (io.sockets.adapter.rooms[roomID].length <= 1) {
if (io.sockets.adapter.rooms.get(roomID)?.size ?? 0 <= 1) {
io.to(`${socket.id}`).emit('first-in-room');
} else {
socket.broadcast.to(roomID).emit('new-user', socket.id);
}
io.in(roomID).emit(
'room-user-change',
Object.keys(io.sockets.adapter.rooms[roomID].sockets)
'room-user-change', Array.from(io.sockets.adapter.rooms.get(roomID) ?? [])
);
});
@ -87,8 +86,7 @@ io.on('connection', socket => {
'server-broadcast',
(roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => {
socket.broadcast.to(roomID).emit('client-broadcast', encryptedData, iv);
}
);
});
socket.on(
'server-volatile-broadcast',
@ -96,15 +94,14 @@ io.on('connection', socket => {
socket.volatile.broadcast
.to(roomID)
.emit('client-broadcast', encryptedData, iv);
}
);
});
socket.on('disconnecting', () => {
const rooms = io.sockets.adapter.rooms;
for (const roomID of Object.keys(socket.rooms)) {
const clients = Object.keys(rooms[roomID].sockets).filter(id => id !== socket.id);
const clients = Array.from(rooms.get(roomID) ?? []).filter(id => id !== socket.id);
if (roomID !== socket.id) {
socket.to(roomID).emit('user has left', socket.id);
}

@ -12,7 +12,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"outDir": "dist",
"noImplicitAny": false
//"noImplicitAny": false
}
}

@ -4,9 +4,9 @@ from pybuilder.core import task, init
from ddadevops import *
name = "c4k-jitsi"
MODULE = "web"
MODULE = "webtest"
PROJECT_ROOT_PATH = "../.."
version = "1.5.2-SNAPSHOT"
version = "1.0.1-SNAPSHOT"
@init

@ -1,5 +1,5 @@
#!/bin/bash
set -Eeo pipefail
set -eux
apt-get update > /dev/null
apt-get upgrade -y > /dev/null

@ -2,7 +2,7 @@
"name": "c4k-jitsi",
"description": "Generate c4k yaml for a jitsi deployment.",
"author": "meissa GmbH",
"version": "1.5.2-SNAPSHOT",
"version": "1.6.0-SNAPSHOT",
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-jitsi#readme",
"repository": "https://www.npmjs.com/package/c4k-jitsi",
"license": "APACHE2",

@ -1,11 +1,11 @@
(defproject org.domaindrivenarchitecture/c4k-jitsi "1.5.2-SNAPSHOT"
(defproject org.domaindrivenarchitecture/c4k-jitsi "1.6.0-SNAPSHOT"
:description "jitsi c4k-installation package"
:url "https://domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0"
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
:dependencies [[org.clojure/clojure "1.11.1"]
[org.clojure/tools.reader "1.3.6"]
[org.domaindrivenarchitecture/c4k-common-clj "6.0.3"]
[org.clojure/tools.reader "1.3.7"]
[org.domaindrivenarchitecture/c4k-common-clj "6.1.0"]
[hickory "0.7.1" :exclusions [viebel/codox-klipse-theme]]]
:target-path "target/%s/"
:source-paths ["src/main/cljc"

@ -4,7 +4,7 @@
"src/test/cljc"
"src/test/cljs"
"src/test/resources"]
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.0.3"]
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.1.0"]
[hickory "0.7.1"]]
:builds {:frontend {:target :browser
:modules {:main {:init-fn dda.c4k-jitsi.browser/init}}

@ -8,7 +8,8 @@
[dda.c4k-common.common :as cm]
[dda.c4k-common.ingress :as ing]
[dda.c4k-common.base64 :as b64]
[dda.c4k-common.predicate :as cp]))
[dda.c4k-common.predicate :as cp]
#?(:cljs [dda.c4k-common.macros :refer-macros [inline-resources]])))
(s/def ::fqdn cp/fqdn-string?)
(s/def ::issuer cp/letsencrypt-issuer?)
@ -25,16 +26,8 @@
#?(:cljs
(defmethod yaml/load-resource :jitsi [resource-name]
(case resource-name
"jitsi/deployment.yaml" (rc/inline "jitsi/deployment.yaml")
"jitsi/etherpad-service.yaml" (rc/inline "jitsi/etherpad-service.yaml")
"jitsi/jvb-service.yaml" (rc/inline "jitsi/jvb-service.yaml")
"jitsi/excalidraw-backend-service.yaml" (rc/inline "jitsi/excalidraw-backend-service.yaml")
"jitsi/excalidraw-deployment.yaml" (rc/inline "jitsi/excalidraw-deployment.yaml")
"jitsi/secret.yaml" (rc/inline "jitsi/secret.yaml")
"jitsi/web-service.yaml" (rc/inline "jitsi/web-service.yaml")
(throw (js/Error. "Undefined Resource!")))))
(get (inline-resources "jitsi") resource-name)))
(defn-spec generate-ingress-web cp/map-or-seq?
[config config?]
(ing/generate-ingress-and-cert

@ -68,7 +68,7 @@ spec:
- name: JVB_TCP_HARVESTER_DISABLED
value: "true"
- name: web
image: domaindrivenarchitecture/c4k-jitsi-web
image: domaindrivenarchitecture/c4k-jitsi-webtest
imagePullPolicy: IfNotPresent
env:
- name: PUBLIC_URL

@ -17,4 +17,4 @@ spec:
spec:
containers:
- name: excalidraw-backend
image: domaindrivenarchitecture/c4k-jitsi-excalidraw-backend
image: domaindrivenarchitecture/c4k-jitsi-excalidraw-testbackend

@ -19,7 +19,7 @@
:spec
{:containers
[{:name "jicofo",
:image "jitsi/jicofo:stable-8922-1",
:image "jitsi/jicofo:stable-8960-1",
:imagePullPolicy "IfNotPresent",
:env
[{:name "XMPP_SERVER", :value "localhost"}
@ -29,7 +29,7 @@
{:name "JICOFO_AUTH_PASSWORD", :valueFrom {:secretKeyRef {:name "jitsi-config", :key "JICOFO_AUTH_PASSWORD"}}}
{:name "TZ", :value "Europe/Berlin"}]}
{:name "prosody",
:image "jitsi/prosody:stable-8922-1",
:image "jitsi/prosody:stable-8960-1",
:imagePullPolicy "IfNotPresent",
:env
[{:name "PUBLIC_URL", :value "xy.xy.xy"}
@ -62,7 +62,7 @@
{:name "WHITEBOARD_ENABLED", :value "true"}
{:name "WHITEBOARD_COLLAB_SERVER_PUBLIC_URL", :value "https://excalidraw-backend.xy.xy.xy"}]}
{:name "jvb",
:image "jitsi/jvb:stable-8922-1",
:image "jitsi/jvb:stable-8960-1",
:imagePullPolicy "IfNotPresent",
:env
[{:name "PUBLIC_URL", :value "xy.xy.xy"}
@ -76,7 +76,7 @@
{:name "JICOFO_AUTH_PASSWORD", :valueFrom {:secretKeyRef {:name "jitsi-config", :key "JICOFO_AUTH_PASSWORD"}}}
{:name "TZ", :value "Europe/Berlin"}]}
{:name "etherpad",
:image "etherpad/etherpad:1.9.2",
:image "etherpad/etherpad:1.9.3",
:env
[{:name "XMPP_SERVER", :value "localhost"}
{:name "JICOFO_COMPONENT_SECRET",

Loading…
Cancel
Save