aboutsummaryrefslogtreecommitdiff
path: root/client-web
diff options
context:
space:
mode:
Diffstat (limited to 'client-web')
-rw-r--r--client-web/source/index.ts38
-rw-r--r--client-web/source/preferences/decl.ts6
-rw-r--r--client-web/source/preferences/mod.ts1
-rw-r--r--client-web/source/room.ts2
-rw-r--r--client-web/source/user/remote.ts4
5 files changed, 34 insertions, 17 deletions
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index 4772f94..4590625 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -17,18 +17,14 @@ import { Room } from "./room.ts"
export const VERSION = "0.1.12"
export const ROOM_CONTAINER = esection({ class: "room", aria_label: "user list" })
-export const RTC_CONFIG: RTCConfiguration = {
- iceServers: [
- {
- urls: [
- "turn:meet.metamuffin.org:16900",
- "stun:meet.metamuffin.org:16900"
- ],
- username: "keksmeet",
- credential: "ujCmetg6bm0"
- },
- ],
- iceCandidatePoolSize: 10,
+export interface ClientConfig {
+ appearance: { accent: string }
+ webrtc: {
+ stun: string,
+ turn?: string,
+ turn_user?: string,
+ turn_cred?: string
+ }
}
export interface User {
@@ -51,7 +47,12 @@ window.onbeforeunload = ev => {
let r: Room;
export async function main() {
document.body.append(LOGGER_CONTAINER)
- log("*", "starting up")
+ log("*", "loading client config")
+ const config_res = await fetch("/config.json")
+ if (!config_res.ok) return log({ scope: "*", error: true }, "cannot load config")
+ const config: ClientConfig = await config_res.json()
+ log("*", "config loaded. starting")
+
document.body.querySelectorAll("p").forEach(e => e.remove())
const room_secret = load_params().rsecret
@@ -64,7 +65,16 @@ export async function main() {
if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room secret now - e2ee is insecure!")
const conn = await (new SignalingConnection().connect(room_secret))
- r = new Room(conn)
+ const rtc_config: RTCConfiguration = {
+ iceCandidatePoolSize: 10,
+ iceServers: [{
+ urls: [config.webrtc.stun, ...(config.webrtc.turn ? [config.webrtc.turn] : [])],
+ credential: config.webrtc.turn_cred,
+ username: config.webrtc.turn_user,
+ }]
+ }
+
+ r = new Room(conn, rtc_config)
setup_keybinds(r)
r.on_ready = () => {
diff --git a/client-web/source/preferences/decl.ts b/client-web/source/preferences/decl.ts
index f3f8e84..68cb9ee 100644
--- a/client-web/source/preferences/decl.ts
+++ b/client-web/source/preferences/decl.ts
@@ -18,7 +18,13 @@ export const PREF_DECLS = {
username: { type: string, default: "guest-" + hex_id(), description: "Username", allow_url: true },
warn_redirect: { type: bool, hidden: true, default: false, description: "Internal option that is set by a server redirect.", allow_url: true },
image_view_popup: { type: bool, default: true, description: "Open image in popup instead of new tab" },
+
+ // TODO!
+ /* WEBRTC */
webrtc_debug: { type: bool, default: false, description: "Show additional information for WebRTC related stuff" },
+ webrtc_stun: { type: string, default: "stun:meet.metamuffin.org:16900", description: "Custom STUN server (all participants must use the same server)" },
+ webrtc_turn: { type: optional(string), default: "turn:meet.metamuffin.org:16900", description: "Custom TURN server (all participants must use the same server)" },
+ webrtc_turn_cred: { type: optional(string), description: "TURN server credentials" },
/* MEDIA */
microphone_enabled: { type: bool, default: false, description: "Add one microphone track on startup" },
diff --git a/client-web/source/preferences/mod.ts b/client-web/source/preferences/mod.ts
index 04fae2c..8aefb0f 100644
--- a/client-web/source/preferences/mod.ts
+++ b/client-web/source/preferences/mod.ts
@@ -15,6 +15,7 @@ export interface PrefDecl<T> {
optional?: boolean,
hidden?: boolean
allow_url?: boolean
+ require_reload?: boolean,
}
type Type = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
diff --git a/client-web/source/room.ts b/client-web/source/room.ts
index a685f1d..27d2327 100644
--- a/client-web/source/room.ts
+++ b/client-web/source/room.ts
@@ -20,7 +20,7 @@ export class Room {
public on_ready = () => { };
- constructor(public signaling: SignalingConnection) {
+ constructor(public signaling: SignalingConnection, public rtc_config: RTCConfiguration) {
this.signaling.control_handler = (a) => this.control_handler(a)
this.signaling.relay_handler = (a, b) => this.relay_handler(a, b)
}
diff --git a/client-web/source/user/remote.ts b/client-web/source/user/remote.ts
index bd89e0e..5e81cf7 100644
--- a/client-web/source/user/remote.ts
+++ b/client-web/source/user/remote.ts
@@ -7,7 +7,7 @@
import { RelayMessage } from "../../../common/packets.d.ts";
import { notify } from "../helper.ts";
-import { ROOM_CONTAINER, RTC_CONFIG } from "../index.ts"
+import { ROOM_CONTAINER } from "../index.ts"
import { log } from "../logger.ts"
import { PREFS } from "../preferences/mod.ts";
import { new_remote_resource, RemoteResource } from "../resource/mod.ts";
@@ -28,7 +28,7 @@ export class RemoteUser extends User {
room.remote_users.set(id, this)
log("usermodel", `added remote user: ${this.display_name}`)
- this.pc = new RTCPeerConnection(RTC_CONFIG)
+ this.pc = new RTCPeerConnection(room.rtc_config)
this.pc.onicecandidate = ev => {
if (!ev.candidate) return
room.signaling.send_relay({ ice_candidate: ev.candidate.toJSON() }, this.id)