aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2022-09-09 14:43:19 +0200
committermetamuffin <metamuffin@disroot.org>2022-09-09 14:43:19 +0200
commit32373fd18a05663c3bb7d9b1d9fa0a21d909c784 (patch)
tree8a165f64f09d5fb40c80bc80951ab4e615021cde
parentd101fb7f77822aac2a3d42ca1529028405cfad0d (diff)
downloadkeks-meet-32373fd18a05663c3bb7d9b1d9fa0a21d909c784.tar
keks-meet-32373fd18a05663c3bb7d9b1d9fa0a21d909c784.tar.bz2
keks-meet-32373fd18a05663c3bb7d9b1d9fa0a21d909c784.tar.zst
redirect
-rw-r--r--client-web/source/index.ts10
-rw-r--r--client-web/source/preferences.ts7
-rw-r--r--server/src/main.rs14
3 files changed, 26 insertions, 5 deletions
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index 502ab98..0249d4d 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -3,6 +3,7 @@
import { ediv } from "./helper.ts";
import { log } from "./logger.ts"
import { create_menu } from "./menu.ts";
+import { PREFS } from "./preferences.ts";
import { SignalingConnection } from "./protocol/mod.ts";
import { Room } from "./room.ts"
@@ -24,10 +25,17 @@ export interface User {
window.onload = () => main()
export async function main() {
- document.body.querySelectorAll("p").forEach(e => e.remove())
log("*", "starting up")
+ document.body.querySelectorAll("p").forEach(e => e.remove())
const room_name = window.location.hash.substring(1)
+
+ if (!globalThis.RTCPeerConnection) return log({ scope: "webrtc", error: true }, "WebRTC not supported.")
+ if (!globalThis.isSecureContext) log({ scope: "*", warn: true }, "This page is not in a 'Secure Context'")
+ if (!globalThis.crypto.subtle) return log({ scope: "crypto", error: true }, "SubtleCrypto not availible")
+ if (room_name.length < 8) log({ scope: "crypto", warn: true }, "Room name is very short. e2ee is insecure!")
if (room_name.length == 0) window.location.href = "/" // send them back to the start page
+ if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows you room name now - e2ee is insecure!")
+
const conn = await (new SignalingConnection().connect(room_name))
new Room(conn)
create_menu()
diff --git a/client-web/source/preferences.ts b/client-web/source/preferences.ts
index 63efeb2..c25cece 100644
--- a/client-web/source/preferences.ts
+++ b/client-web/source/preferences.ts
@@ -28,7 +28,9 @@ export function register_prefs<T extends Record<string, PrefDecl<unknown>>>(ds:
const raw_params = load_query_params();
export function load_query_params(): { [key: string]: string } {
const q: { [key: string]: string } = {}
- for (const kv of window.location.hash.substring(1).split("&")) {
+ const params = window.location.hash.substring(1).split("?")[1]
+ if (!params) return {}
+ for (const kv of params.split("&")) {
const [key, value] = kv.split("=")
if (key == "prototype") continue
q[decodeURIComponent(key)] = decodeURIComponent(value)
@@ -62,6 +64,7 @@ const PREF_DECLS = {
microphone_enabled: { name: "microphone_enabled", default: false, description: "Add one microphone track on startup" },
camera_enabled: { name: "camera_enabled", default: false, description: "Add one camera track on startup" },
screencast_enabled: { name: "screencast_enabled", default: false, description: "Add one screencast track on startup" },
- camera_facing_mode: { name: "camera_facing_mode", default: undefined as undefined | string, type: "string" as const, possible_values: ["environment", "user", undefined], description: "Prefer user-facing or env-facing camera" }
+ camera_facing_mode: { name: "camera_facing_mode", default: undefined as undefined | string, type: "string" as const, possible_values: ["environment", "user", undefined], description: "Prefer user-facing or env-facing camera" },
+ warn_redirect: { name: "warn_redirect", default: false, description: "Interal option that is set by a server redirect." },
}
export const PREFS = register_prefs(PREF_DECLS)
diff --git a/server/src/main.rs b/server/src/main.rs
index 3787783..dae6662 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -1,17 +1,18 @@
pub mod protocol;
pub mod room;
-use hyper::StatusCode;
+use hyper::{header, StatusCode, Uri};
use listenfd::ListenFd;
use log::error;
use room::Room;
use std::collections::HashMap;
use std::convert::Infallible;
+use std::str::FromStr;
use std::sync::Arc;
use tokio::sync::RwLock;
use warp::hyper::Server;
use warp::ws::WebSocket;
-use warp::{Filter, Rejection, Reply};
+use warp::{reply, Filter, Rejection, Reply};
type Rooms = Arc<RwLock<HashMap<String, Arc<Room>>>>;
@@ -38,12 +39,21 @@ async fn run() {
let room: _ = warp::path!("room").and(warp::fs::file("../client-web/public/app.html"));
let assets: _ = warp::path("assets").and(warp::fs::dir("../client-web/public/assets"));
let favicon: _ = warp::path!("favicon.ico").map(|| "");
+ let old_format_redirect: _ = warp::path!("room" / String).map(|rname| {
+ reply::with_header(
+ StatusCode::MOVED_PERMANENTLY,
+ header::LOCATION,
+ format!("/room#{rname}?warn_redirect=true"),
+ )
+ .into_response()
+ });
let routes = assets
.or(room)
.or(index)
.or(signaling)
.or(favicon)
+ .or(old_format_redirect)
.recover(handle_rejection)
.with(warp::log("stuff"));