diff --git a/app/mobile/src/constants/Strings.js b/app/mobile/src/constants/Strings.js index 52dfba50..3a8b25aa 100644 --- a/app/mobile/src/constants/Strings.js +++ b/app/mobile/src/constants/Strings.js @@ -160,6 +160,7 @@ const Strings = [ enableVideo: 'Enable Video Queue', enableBinary: 'Enable Binary Files', enableCalls: 'Enable WebRTC Calls', + iceService: 'Cloudflare Service', relayUrl: 'Relay URL', relayUsername: 'Relay Username', relayPassword: 'Relay Password', @@ -370,6 +371,7 @@ const Strings = [ enableVideo: 'Activer les Fichiers Vidéo', enableBinary: 'Activer les Fichiers Binaires', enableCalls: 'Activer les Appels', + iceService: 'Service Cloudflare', relayUrl: 'URL de Relais', relayUsername: 'Nom d\'Utilisateur du Relais', relayPassword: 'Mot de Passe du Relais', @@ -580,6 +582,7 @@ const Strings = [ enableVideo: 'Permitir Archivos de Vídeo', enableBinary: 'Permitir Archivos Binarios', enableCalls: 'Permitier Llamadas', + iceService: 'Servicio Cloudflare', relayUrl: 'URL para Llamadas', relayUsername: 'Nombre de Usuario para Llamadas', relayPassword: 'Contraseña para Llamadas', @@ -791,6 +794,7 @@ const Strings = [ enableVideo: 'Videodateien aktivieren', enableBinary: 'Binärdateien aktivieren', enableCalls: 'Anrufe Ermöglichen', + iceService: 'Cloudflare-Dienst', relayUrl: 'URL für Anrufe', relayUsername: 'Benutzername für Anrufe', relayPassword: 'Passwort für Anrufe', @@ -990,6 +994,7 @@ const Strings = [ enableVideo: 'Habilitar Fila de Vídeo', enableBinary: 'Habilitar Fila Binários', enableCalls: 'Habilitar Chamadas WebRTC', + iceService: 'Serviço Cloudflare', relayUrl: 'URL do Relay', relayUsername: 'Nome de Usuário do Relay', relayPassword: 'Senha do Relay', @@ -1186,6 +1191,7 @@ const Strings = [ enableVideo: 'Включить очередь видео', enableBinary: 'Включить двоичные файлы', enableCalls: 'Включить звонки WebRTC', + iceService: 'Сервис Cloudflare', relayUrl: 'URL релея', relayUsername: 'Имя пользователя релея', relayPassword: 'Пароль релея', diff --git a/app/mobile/src/context/useAppContext.hook.js b/app/mobile/src/context/useAppContext.hook.js index 13246365..90808cec 100644 --- a/app/mobile/src/context/useAppContext.hook.js +++ b/app/mobile/src/context/useAppContext.hook.js @@ -213,8 +213,9 @@ export function useAppContext() { card.actions.setRevision(cardRev); } else if (activity.ring) { - const { cardId, callId, calleeToken, iceUrl, iceUsername, icePassword } = activity.ring; - ring.actions.ring(cardId, callId, calleeToken, iceUrl, iceUsername, icePassword); + const { cardId, callId, calleeToken, ice, iceUrl, iceUsername, icePassword } = activity.ring; + const config = ice ? ice : [{ urls: iceUrl, username: iceUsername, credential: icePassword }]; + ring.actions.ring(cardId, callId, calleeToken, config); } else { const { profile: profileRev, account: accountRev, channel: channelRev, card: cardRev } = activity; diff --git a/app/mobile/src/context/useRingContext.hook.js b/app/mobile/src/context/useRingContext.hook.js index 59e98bf7..02ad21b6 100644 --- a/app/mobile/src/context/useRingContext.hook.js +++ b/app/mobile/src/context/useRingContext.hook.js @@ -331,9 +331,9 @@ export function useRingContext() { clearSession: () => { access.current = null; }, - ring: (cardId, callId, calleeToken, iceUrl, iceUsername, icePassword) => { + ring: (cardId, callId, calleeToken, ice) => { const key = `${cardId}:${callId}` - const call = ringing.current.get(key) || { cardId, calleeToken, callId, iceUrl, iceUsername, icePassword } + const call = ringing.current.get(key) || { cardId, calleeToken, callId, ice } call.expires = Date.now() + EXPIRE; ringing.current.set(key, call); updateState({ ringing: ringing.current }); @@ -365,7 +365,7 @@ export function useRingContext() { } } }, - accept: async (cardId, callId, contactNode, contactToken, calleeToken, iceUrl, iceUsername, icePassword) => { + accept: async (cardId, callId, contactNode, contactToken, calleeToken, ice) => { if (calling.current) { throw new Error("active session"); } @@ -378,7 +378,6 @@ export function useRingContext() { updateState({ ringing: ringing.current, callStatus: "connecting", cardId }); calling.current = { callId, contactNode, contactToken, host: false }; - const ice = [{ urls: iceUrl, username: iceUsername, credential: icePassword }]; await connect('impolite', contactNode, calleeToken, () => {}, () => {}, ice); } }, @@ -422,9 +421,9 @@ export function useRingContext() { throw err; } - const { id, keepAlive, callerToken, calleeToken, iceUrl, iceUsername, icePassword } = call; + const { id, keepAlive, callerToken, calleeToken, ice, iceUrl, iceUsername, icePassword } = call; try { - await addContactRing(contactNode, contactToken, { index, callId: id, calleeToken, iceUrl, iceUsername, icePassword }); + await addContactRing(contactNode, contactToken, { index, callId: id, calleeToken, ice, iceUrl, iceUsername, icePassword }); } catch (err) { console.log(err); @@ -446,7 +445,7 @@ export function useRingContext() { } } else { - await addContactRing(contactNode, contactToken, { index, callId: id, calleeToken, iceUrl, iceUsername, icePassword }); + await addContactRing(contactNode, contactToken, { index, callId: id, calleeToken, ice, iceUrl, iceUsername, icePassword }); index += 1; } } @@ -457,8 +456,8 @@ export function useRingContext() { updateState({ callStatus: "ringing" }); calling.current = { callId: id, host: true }; - const ice = [{ urls: iceUrl, username: iceUsername, credential: icePassword }]; - await connect('polite', server, callerToken, () => clearInterval(ringInterval), () => clearInterval(aliveInterval), ice); + const iceLegacy = [{ urls: iceUrl, username: iceUsername, credential: icePassword }]; + await connect('polite', server, callerToken, () => clearInterval(ringInterval), () => clearInterval(aliveInterval), ice ? ice : iceLegacy); }, enableVideo: async () => { if (!videoTrack.current) { diff --git a/app/mobile/src/dashboard/Dashboard.jsx b/app/mobile/src/dashboard/Dashboard.jsx index 5949c313..f9cbc6aa 100644 --- a/app/mobile/src/dashboard/Dashboard.jsx +++ b/app/mobile/src/dashboard/Dashboard.jsx @@ -283,33 +283,70 @@ export function Dashboard(props) { onValueChange={actions.setEnableIce} trackColor={styles.track}/> - + { state.enableIce && ( + <> + actions.setEnableIce(!state.iceService)}> + { state.strings.iceService } + + - + { !state.iceService && ( + <> + + + + + + + )} + + { state.iceService && ( + <> + + + + + )} + + )} - - diff --git a/app/mobile/src/dashboard/useDashboard.hook.js b/app/mobile/src/dashboard/useDashboard.hook.js index 2a5b95e5..03a9d470 100644 --- a/app/mobile/src/dashboard/useDashboard.hook.js +++ b/app/mobile/src/dashboard/useDashboard.hook.js @@ -41,6 +41,7 @@ export function useDashboard(server, token, mfa) { enableBinary: true, createToken: null, enableIce: false, + iceService: false, iceUrl: null, iceUsername: null, icePassword: null, @@ -78,9 +79,9 @@ export function useDashboard(server, token, mfa) { const config = await getNodeConfig(server, token); const nodeAccounts = await getNodeAccounts(server, token); const accounts = nodeAccounts.map(setAccountItem); - const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword } = config || {}; + const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceService, iceUrl, iceUsername, icePassword } = config || {}; const storage = Math.ceil(accountStorage / 1073741824); - updateState({ keyType, storage: storage.toString(), domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword, accounts, mfaEnabled }); + updateState({ keyType, storage: storage.toString(), domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceService, iceUrl, iceUsername, icePassword, accounts, mfaEnabled }); } const refreshAccounts = async () => { @@ -150,6 +151,9 @@ export function useDashboard(server, token, mfa) { setEnableIce: (enableIce) => { updateState({ enableIce }); }, + setIceService: (iceService) => { + updateState({ iceService }); + }, setIceUrl: (iceUrl) => { updateState({ iceUrl }); }, @@ -160,9 +164,9 @@ export function useDashboard(server, token, mfa) { updateState({ icePassword }); }, saveConfig: async () => { - const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceUrl, iceUsername, icePassword } = state; + const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceService, iceUrl, iceUsername, icePassword } = state; const accountStorage = Number(storage) * 1073741824; - const config = { accountStorage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceUrl, iceUsername, icePassword }; + const config = { accountStorage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceService, iceUrl, iceUsername, icePassword }; await setNodeConfig(server, token, config); }, enableUser: async (accountId, enabled) => { diff --git a/app/mobile/src/session/useSession.hook.js b/app/mobile/src/session/useSession.hook.js index 7546bbca..a22b511f 100644 --- a/app/mobile/src/session/useSession.hook.js +++ b/app/mobile/src/session/useSession.hook.js @@ -49,7 +49,7 @@ export function useSession() { const expired = Date.now(); ring.state.ringing.forEach(call => { if (call.expires > expired && !call.status) { - const { callId, cardId, calleeToken, iceUrl, iceUsername, icePassword } = call; + const { callId, cardId, calleeToken, ice } = call; const contact = card.state.cards.get(cardId); if (contact) { const { imageSet, name, handle, node, guid } = contact.card?.profile || {}; @@ -57,7 +57,7 @@ export function useSession() { const contactToken = `${guid}.${token}`; const server = node ? node : profile.state.server; const img = imageSet ? card.actions.getCardImageUrl(cardId) : null; - ringing.push({ cardId, img, name, handle, contactNode: server, callId, contactToken, calleeToken, iceUrl, iceUsername, icePassword }); + ringing.push({ cardId, img, name, handle, contactNode: server, callId, contactToken, calleeToken, ice }); } } }); @@ -124,8 +124,8 @@ export function useSession() { await ring.actions.decline(cardId, contactNode, contactToken, callId); }, accept: async (call) => { - const { cardId, callId, contactNode, contactToken, calleeToken, iceUrl, iceUsername, icePassword } = call; - await ring.actions.accept(cardId, callId, contactNode, contactToken, calleeToken, iceUrl, iceUsername, icePassword); + const { cardId, callId, contactNode, contactToken, calleeToken, ice } = call; + await ring.actions.accept(cardId, callId, contactNode, contactToken, calleeToken, ice); }, end: async () => { await ring.actions.end();