From e8cbebaffe8c1defaf4c29b133dcdf4ed5257a6e Mon Sep 17 00:00:00 2001 From: si458 Date: Tue, 3 Sep 2024 14:46:25 +0100 Subject: [PATCH] fix webrtc file upload maybe #6309 Signed-off-by: si458 --- views/default-mobile.handlebars | 8 ++++++-- views/default.handlebars | 6 ++++-- views/sharing-mobile.handlebars | 2 +- views/sharing.handlebars | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 2fb82d44..e323a934 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -1338,6 +1338,8 @@ var serverPublicNamePort = '{{{serverDnsName}}}:{{{serverPublicPort}}}'; var debugmode = false; var attemptWebRTC = ((features & 128) != 0); + var webrtcconfiguration = '{{{webrtcconfig}}}'; + if (webrtcconfiguration == '') { webrtcconfiguration = null; } else { try { webrtcconfiguration = JSON.parse(decodeURIComponent(webrtcconfiguration)); } catch (ex) { console.log('Invalid WebRTC config: "' + webrtcconfiguration + '".'); webrtcconfiguration = null; } } var StatusStrs = ["Disconnected", "Connecting...", "Setup...", "Connected", "Intel® AMT Connected"]; var agentsStr = ["Unknown", "Windows 32bit console", "Windows 64bit console", "Windows 32bit service", "Windows 64bit service", "Linux 32bit", "Linux 64bit", "MIPS", "XENx86", "Android ARM", "Linux ARM", "macOS x86-32bit", "Android x86", "PogoPlug ARM", "Android", "Linux Poky x86-32bit", "macOS x86-64bit", "ChromeOS", "Linux Poky x86-64bit", "Linux NoKVM x86-32bit", "Linux NoKVM x86-64bit", "Windows MinCore console", "Windows MinCore service", "NodeJS", "ARM-Linaro", "ARMv6l / ARMv7l", "ARMv8 64bit", "ARMv6l / ARMv7l / NoKVM", "MIPS24KC (OpenWRT)", "Apple Silicon", "FreeBSD x86-64", "Unknown", "Linux ARM 64 bit (glibc/2.24 NOKVM)", "Alpine Linux x86 64 Bit (MUSL)", "Assistant (Windows)", "Armada370 - ARM32/HF (libc/2.26)", "OpenWRT x86-64", "OpenBSD x86-64", "Unknown", "Unknown", "MIPSEL24KC (OpenWRT)", "ARMADA/CORTEX-A53/MUSL (OpenWRT)", "Windows ARM 64bit console", "Windows ARM 64bit service"]; var files; @@ -4565,6 +4567,7 @@ desktop.debugmode = debugmode; desktop.m.debugmode = debugmode; desktop.attemptWebRTC = attemptWebRTC; + desktop.webrtcconfig = webrtcconfiguration; desktop.options = {}; if (tsid != null) { desktop.options.tsid = tsid; } if (consent != null) { desktop.options.consent = consent; } @@ -5566,6 +5569,7 @@ if (contype == 2) { files.urlname = 'sshfilesrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay. files.contype = contype; files.attemptWebRTC = attemptWebRTC; + files.webrtcconfig = webrtcconfiguration; files.onStateChanged = onFilesStateChange; files.onConsoleMessageChange = function () { if (files.consoleMessage) { @@ -6083,7 +6087,7 @@ if (start >= data.byteLength) { files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr })); } else { - var end = uploadFile.xptr + 65565; + var end = uploadFile.xptr + (attemptWebRTC ? 16384 : 65536); if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; } var dataslice = new Uint8Array(data.slice(start, end)) if ((dataslice[0] == 123) || (dataslice[0] == 0)) { @@ -6099,7 +6103,7 @@ } else if (uploadFile.xfile) { if (uploadFile.xreader != null) return; // Data reading already in process if (uploadFile.xptr >= uploadFile.xfile.size) return; - var end = uploadFile.xptr + 65565; + var end = uploadFile.xptr + (attemptWebRTC ? 16384 : 65536); if (end > uploadFile.xfile.size) { if (dataPriming == true) { return; } end = uploadFile.xfile.size; } uploadFile.xreader = new FileReader(); uploadFile.xreader.onerror = function (err) { console.log(err); } diff --git a/views/default.handlebars b/views/default.handlebars index 85ba49a1..a2621050 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -5215,6 +5215,7 @@ desk.m.mouseCursorActive(xxcurrentView == 11); desk.shortid = shortid; desk.attemptWebRTC = attemptWebRTC; + desk.webrtcconfig = webrtcconfiguration; desk.onStateChanged = onMultiDesktopStateChange; //desk.onConsoleMessageChange = function () { console.log('CONSOLEMSG:', desk.consoleMessage); } desk.m.ImageType = multidesktopsettings.agentencoding; // Send 4 if WebP is supported, otherwise send 1 for JPEG. @@ -11020,6 +11021,7 @@ files.contype = contype; files.options = { consent: consent } files.attemptWebRTC = attemptWebRTC; + files.webrtcconfig = webrtcconfiguration; files.onStateChanged = onFilesStateChange; files.onConsoleMessageChange = function () { if (files.consoleMessage) { @@ -11760,7 +11762,7 @@ if (start >= data.byteLength) { files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr })); } else { - var end = uploadFile.xptr + 65565; + var end = uploadFile.xptr + (attemptWebRTC ? 16384 : 65536); if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; } var dataslice = new Uint8Array(data.slice(start, end)) if ((dataslice[0] == 123) || (dataslice[0] == 0)) { @@ -11776,7 +11778,7 @@ } else if (uploadFile.xfile) { if (uploadFile.xreader != null) return; // Data reading already in process if (uploadFile.xptr >= uploadFile.xfile.size) return; - var end = uploadFile.xptr + 65565; + var end = uploadFile.xptr + (attemptWebRTC ? 16384 : 65536); if (end > uploadFile.xfile.size) { if (dataPriming == true) { return; } end = uploadFile.xfile.size; } uploadFile.xreader = new FileReader(); uploadFile.xreader.onerror = function (err) { console.log(err); } diff --git a/views/sharing-mobile.handlebars b/views/sharing-mobile.handlebars index 0064531c..cc8a9d03 100644 --- a/views/sharing-mobile.handlebars +++ b/views/sharing-mobile.handlebars @@ -2363,7 +2363,7 @@ function p13uploadNextPart(dataPriming) { if (uploadFile.xreader != null) return; // Data reading already in process if (uploadFile.xptr >= uploadFile.xfile.size) return; - var end = uploadFile.xptr + 65565; + var end = uploadFile.xptr + 65536; if (end > uploadFile.xfile.size) { if (dataPriming == true) { return; } end = uploadFile.xfile.size; } uploadFile.xreader = new FileReader(); uploadFile.xreader.onerror = function (err) { console.log(err); } diff --git a/views/sharing.handlebars b/views/sharing.handlebars index 0b0987f4..8cf9e694 100644 --- a/views/sharing.handlebars +++ b/views/sharing.handlebars @@ -2193,7 +2193,7 @@ if (start >= data.byteLength) { files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr })); } else { - var end = uploadFile.xptr + 65565; + var end = uploadFile.xptr + 65536; if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; } var dataslice = new Uint8Array(data.slice(start, end)) if ((dataslice[0] == 123) || (dataslice[0] == 0)) {