From 24e3806b255693e7658214b8a2e420b22e279ff6 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Mon, 15 Apr 2024 01:18:12 +0700 Subject: [PATCH] webrtc: updated credentials (#4011) * webrtc: updated credentials * no udp * change * stuns * added stun back --------- Co-authored-by: Evgeny Poberezkin --- apps/ios/Shared/Views/Call/WebRTC.swift | 7 ++++--- apps/ios/Shared/Views/Call/WebRTCClient.swift | 8 ++++---- .../kotlin/chat/simplex/common/views/call/WebRTC.kt | 7 ++++--- .../common/src/commonMain/resources/assets/www/call.js | 5 +++-- packages/simplex-chat-webrtc/src/call.ts | 5 +++-- website/src/call/call.js | 3 ++- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/apps/ios/Shared/Views/Call/WebRTC.swift b/apps/ios/Shared/Views/Call/WebRTC.swift index 919b1e14e7..333dc082d5 100644 --- a/apps/ios/Shared/Views/Call/WebRTC.swift +++ b/apps/ios/Shared/Views/Call/WebRTC.swift @@ -431,17 +431,18 @@ struct RTCIceServer: Codable, Equatable { } // the servers are expected in this format: -// stun:stun.simplex.im:443?transport=tcp -// turn:private:yleob6AVkiNI87hpR94Z@turn.simplex.im:443?transport=tcp +// stuns:stun.simplex.im:443?transport=tcp +// turns:private2:Hxuq2QxUjnhj96Zq2r4HjqHRj@turn.simplex.im:443?transport=tcp func parseRTCIceServer(_ str: String) -> RTCIceServer? { var s = replaceScheme(str, "stun:") + s = replaceScheme(s, "stuns:") s = replaceScheme(s, "turn:") s = replaceScheme(s, "turns:") if let u: URL = URL(string: s), let scheme = u.scheme, let host = u.host, let port = u.port, - u.path == "" && (scheme == "stun" || scheme == "turn" || scheme == "turns") { + u.path == "" && (scheme == "stun" || scheme == "stuns" || scheme == "turn" || scheme == "turns") { let query = u.query == nil || u.query == "" ? "" : "?" + (u.query ?? "") return RTCIceServer( urls: ["\(scheme):\(host):\(port)\(query)"], diff --git a/apps/ios/Shared/Views/Call/WebRTCClient.swift b/apps/ios/Shared/Views/Call/WebRTCClient.swift index 834af4a2c1..ff36241daf 100644 --- a/apps/ios/Shared/Views/Call/WebRTCClient.swift +++ b/apps/ios/Shared/Views/Call/WebRTCClient.swift @@ -65,14 +65,14 @@ final class WebRTCClient: NSObject, RTCVideoViewDelegate, RTCFrameEncryptorDeleg self.localRendererAspectRatio = localRendererAspectRatio rtcAudioSession.useManualAudio = CallController.useCallKit() rtcAudioSession.isAudioEnabled = !CallController.useCallKit() - logger.debug("WebRTCClient: rtcAudioSession has manual audio \(self.rtcAudioSession.useManualAudio) and audio enabled \(self.rtcAudioSession.isAudioEnabled)}") + logger.debug("WebRTCClient: rtcAudioSession has manual audio \(self.rtcAudioSession.useManualAudio) and audio enabled \(self.rtcAudioSession.isAudioEnabled)") super.init() } let defaultIceServers: [WebRTC.RTCIceServer] = [ - WebRTC.RTCIceServer(urlStrings: ["stun:stun.simplex.im:443"]), - WebRTC.RTCIceServer(urlStrings: ["turn:turn.simplex.im:443?transport=udp"], username: "private", credential: "yleob6AVkiNI87hpR94Z"), - WebRTC.RTCIceServer(urlStrings: ["turn:turn.simplex.im:443?transport=tcp"], username: "private", credential: "yleob6AVkiNI87hpR94Z"), + WebRTC.RTCIceServer(urlStrings: ["stuns:stun.simplex.im:443"]), + //WebRTC.RTCIceServer(urlStrings: ["turns:turn.simplex.im:443?transport=udp"], username: "private2", credential: "Hxuq2QxUjnhj96Zq2r4HjqHRj"), + WebRTC.RTCIceServer(urlStrings: ["turns:turn.simplex.im:443?transport=tcp"], username: "private2", credential: "Hxuq2QxUjnhj96Zq2r4HjqHRj"), ] func initializeCall(_ iceServers: [WebRTC.RTCIceServer]?, _ mediaType: CallMediaType, _ aesKey: String?, _ relay: Bool?) -> Call { diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/WebRTC.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/WebRTC.kt index 754878e9fb..4991cf13bc 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/WebRTC.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/call/WebRTC.kt @@ -187,10 +187,11 @@ data class ConnectionState( ) // the servers are expected in this format: -// stun:stun.simplex.im:443?transport=tcp -// turn:private:yleob6AVkiNI87hpR94Z@turn.simplex.im:443?transport=tcp +// stuns:stun.simplex.im:443?transport=tcp +// turns:private2:Hxuq2QxUjnhj96Zq2r4HjqHRj@turn.simplex.im:443?transport=tcp fun parseRTCIceServer(str: String): RTCIceServer? { var s = replaceScheme(str, "stun:") + s = replaceScheme(s, "stuns:") s = replaceScheme(s, "turn:") s = replaceScheme(s, "turns:") val u = runCatching { URI(s) }.getOrNull() @@ -198,7 +199,7 @@ fun parseRTCIceServer(str: String): RTCIceServer? { val scheme = u.scheme val host = u.host val port = u.port - if (u.path == "" && (scheme == "stun" || scheme == "turn" || scheme == "turns")) { + if (u.path == "" && (scheme == "stun" || scheme == "stuns" || scheme == "turn" || scheme == "turns")) { val userInfo = u.userInfo?.split(":") val query = if (u.query == null || u.query == "") "" else "?${u.query}" return RTCIceServer( diff --git a/apps/multiplatform/common/src/commonMain/resources/assets/www/call.js b/apps/multiplatform/common/src/commonMain/resources/assets/www/call.js index 5ea2f062b0..a2cc4a2f27 100644 --- a/apps/multiplatform/common/src/commonMain/resources/assets/www/call.js +++ b/apps/multiplatform/common/src/commonMain/resources/assets/www/call.js @@ -36,9 +36,10 @@ var localizedState = ""; var localizedDescription = ""; const processCommand = (function () { const defaultIceServers = [ + { urls: ["stuns:stun.simplex.im:443"] }, { urls: ["stun:stun.simplex.im:443"] }, - { urls: ["turn:turn.simplex.im:443?transport=udp"], username: "private", credential: "yleob6AVkiNI87hpR94Z" }, - { urls: ["turn:turn.simplex.im:443?transport=tcp"], username: "private", credential: "yleob6AVkiNI87hpR94Z" }, + //{ urls: ["turns:turn.simplex.im:443?transport=udp"], username: "private2", credential: "Hxuq2QxUjnhj96Zq2r4HjqHRj" }, + { urls: ["turns:turn.simplex.im:443?transport=tcp"], username: "private2", credential: "Hxuq2QxUjnhj96Zq2r4HjqHRj" }, ]; function getCallConfig(encodedInsertableStreams, iceServers, relay) { return { diff --git a/packages/simplex-chat-webrtc/src/call.ts b/packages/simplex-chat-webrtc/src/call.ts index accbebb22d..f3b9af784b 100644 --- a/packages/simplex-chat-webrtc/src/call.ts +++ b/packages/simplex-chat-webrtc/src/call.ts @@ -245,9 +245,10 @@ const processCommand = (function () { } const defaultIceServers: RTCIceServer[] = [ + {urls: ["stuns:stun.simplex.im:443"]}, {urls: ["stun:stun.simplex.im:443"]}, - {urls: ["turn:turn.simplex.im:443?transport=udp"], username: "private", credential: "yleob6AVkiNI87hpR94Z"}, - {urls: ["turn:turn.simplex.im:443?transport=tcp"], username: "private", credential: "yleob6AVkiNI87hpR94Z"}, + //{urls: ["turns:turn.simplex.im:443?transport=udp"], username: "private2", credential: "Hxuq2QxUjnhj96Zq2r4HjqHRj"}, + {urls: ["turns:turn.simplex.im:443?transport=tcp"], username: "private2", credential: "Hxuq2QxUjnhj96Zq2r4HjqHRj"}, ] function getCallConfig(encodedInsertableStreams: boolean, iceServers?: RTCIceServer[], relay?: boolean): CallConfig { diff --git a/website/src/call/call.js b/website/src/call/call.js index b247431f4b..8104470686 100644 --- a/website/src/call/call.js +++ b/website/src/call/call.js @@ -24,8 +24,9 @@ var TransformOperation; let activeCall; const processCommand = (function () { const defaultIceServers = [ + { urls: ["stuns:stun.simplex.im:443"] }, { urls: ["stun:stun.simplex.im:443"] }, - { urls: ["turn:turn.simplex.im:443"], username: "private", credential: "yleob6AVkiNI87hpR94Z" }, + { urls: ["turns:turn.simplex.im:443"], username: "private2", credential: "Hxuq2QxUjnhj96Zq2r4HjqHRj" }, ]; function getCallConfig(encodedInsertableStreams, iceServers, relay) { return {