From f20c6ab43a722d271a412d5f3f022646ae91a593 Mon Sep 17 00:00:00 2001 From: hmt Date: Wed, 28 Apr 2021 09:49:50 +0200 Subject: [PATCH] default strict mode --- README.md | 6 +++--- app.ts | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d826160..34e556b 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,13 @@ Then create a `servers.json` file like this here: Now you are ready to start the script with setting a port and a secret: - TINYSCALE_SECRET=some_secret_string deno run --allow-net --allow-read --allow-env https://deno.land/x/tinyscale@v1.4.0/mod.ts + TINYSCALE_SECRET=some_secret_string deno run --allow-net --allow-read --allow-env https://deno.land/x/tinyscale@v1.5.0/mod.ts -tinyscales then runs on port 3005 and you will have to set up your reverse proxy so that it can pick up requests or you leave it on that port. If you prefer a different port you can set one with another env-var: `PORT 3006` +tinyscale then runs on port 3005 and you will have to set up your reverse proxy so that it can pick up requests or you leave it on that port. If you prefer a different port you can set one with another env var: `PORT 3006` When started, tinyscale will connect to each server and make a single call to check if your configuration is correct. If there is a problem tinyscale will abort. If your configuration works you can start using it in your environment by replacing your existing BBB settings with the new tinyscale url in your third party apps. Make sure to also replace the BBB secrets with your new `TINYSCALE_SECRET`. -If you set the additional env var `TINYSCALE_STRICT=true` you can have tinyscale only switch servers when called with a `create`. This may result in better server handling (ymmv). +If you set the additional env var `TINYSCALE_STRICT=false` tinyscale will switch servers with every call to a room that doesn't exist. This might result in a more random distribution of room creations (ymmv). tinyscale has been tested to work with NextCloud, Moodle and Greenlight. diff --git a/app.ts b/app.ts index 9950f16..6181a3e 100644 --- a/app.ts +++ b/app.ts @@ -2,20 +2,21 @@ import { opine, ErrorRequestHandler, Router, createHash, server, createError, Co import { BBB } from './bbb.ts'; const date = () => new Date().toLocaleTimeString('de') -const VERSION = 'v1.4.0' -const tinyscale_strict: boolean = Deno.env.get("TINYSCALE_STRICT") === 'true'|| '1' ? true : false -console.log(date() + Color.green(` Starting tinyscale ${VERSION} in ${tinyscale_strict ? 'strict':'loose'} mode`)) +const VERSION = 'v1.5.0' // give your tinyscale server a secret so it looks like a BBB server -const secret = Deno.env.get("TINYSCALE_SECRET") || "" +const secret: string = Deno.env.get("TINYSCALE_SECRET") || "" if (!secret) throw "No secret set for tinyscale" +const tinyscale_strict: boolean = Deno.env.get("TINYSCALE_STRICT") === 'false' ? false : true +console.log(date() + Color.green(` Starting tinyscale ${VERSION} in ${tinyscale_strict ? 'strict':'loose'} mode`)) +console.log(`Your secret is set to ${Color.green(secret)}`) // store your BBB servers in servers.json const file: string = await Deno.readTextFile('servers.json') const servers: server[] = JSON.parse(file) // create an iterator so that we can treat all servers equally let iterator = servers[Symbol.iterator](); -console.log(servers) console.log('Checking servers first …') +console.log(servers) // check servers for connectivity and if the secret is correct servers.forEach(async s => { const hash = createHash("sha1");