fix webrtc file upload maybe #6309

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Sep 3, 2024 at 14:46 UTC e8cbebaffe8c1defaf4c29b133dcdf4ed5257a6e
4 files changed +12 -6
views/default-mobile.handlebars
+6 -2
@@ -1338,6 +1338,8 @@
1338 var serverPublicNamePort = '{{{serverDnsName}}}:{{{serverPublicPort}}}';
1339 var debugmode = false;
1340 var attemptWebRTC = ((features & 128) != 0);
1341 + var webrtcconfiguration = '{{{webrtcconfig}}}';
1342 + if (webrtcconfiguration == '') { webrtcconfiguration = null; } else { try { webrtcconfiguration = JSON.parse(decodeURIComponent(webrtcconfiguration)); } catch (ex) { console.log('Invalid WebRTC config: "' + webrtcconfiguration + '".'); webrtcconfiguration = null; } }
1343 var StatusStrs = ["Disconnected", "Connecting...", "Setup...", "Connected", "Intel&reg; AMT Connected"];
1344 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"];
1345 var files;
@@ -4565,6 +4567,7 @@
4567 desktop.debugmode = debugmode;
4568 desktop.m.debugmode = debugmode;
4569 desktop.attemptWebRTC = attemptWebRTC;
4570 + desktop.webrtcconfig = webrtcconfiguration;
4571 desktop.options = {};
4572 if (tsid != null) { desktop.options.tsid = tsid; }
4573 if (consent != null) { desktop.options.consent = consent; }
@@ -5566,6 +5569,7 @@
5569 if (contype == 2) { files.urlname = 'sshfilesrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay.
5570 files.contype = contype;
5571 files.attemptWebRTC = attemptWebRTC;
5572 + files.webrtcconfig = webrtcconfiguration;
5573 files.onStateChanged = onFilesStateChange;
5574 files.onConsoleMessageChange = function () {
5575 if (files.consoleMessage) {
@@ -6083,7 +6087,7 @@
6087 if (start >= data.byteLength) {
6088 files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr }));
6089 } else {
6086 - var end = uploadFile.xptr + 65565;
6090 + var end = uploadFile.xptr + (attemptWebRTC ? 16384 : 65536);
6091 if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; }
6092 var dataslice = new Uint8Array(data.slice(start, end))
6093 if ((dataslice[0] == 123) || (dataslice[0] == 0)) {
@@ -6099,7 +6103,7 @@
6103 } else if (uploadFile.xfile) {
6104 if (uploadFile.xreader != null) return; // Data reading already in process
6105 if (uploadFile.xptr >= uploadFile.xfile.size) return;
6102 - var end = uploadFile.xptr + 65565;
6106 + var end = uploadFile.xptr + (attemptWebRTC ? 16384 : 65536);
6107 if (end > uploadFile.xfile.size) { if (dataPriming == true) { return; } end = uploadFile.xfile.size; }
6108 uploadFile.xreader = new FileReader();
6109 uploadFile.xreader.onerror = function (err) { console.log(err); }
views/default.handlebars
+4 -2
@@ -5215,6 +5215,7 @@
5215 desk.m.mouseCursorActive(xxcurrentView == 11);
5216 desk.shortid = shortid;
5217 desk.attemptWebRTC = attemptWebRTC;
5218 + desk.webrtcconfig = webrtcconfiguration;
5219 desk.onStateChanged = onMultiDesktopStateChange;
5220 //desk.onConsoleMessageChange = function () { console.log('CONSOLEMSG:', desk.consoleMessage); }
5221 desk.m.ImageType = multidesktopsettings.agentencoding; // Send 4 if WebP is supported, otherwise send 1 for JPEG.
@@ -11020,6 +11021,7 @@
11021 files.contype = contype;
11022 files.options = { consent: consent }
11023 files.attemptWebRTC = attemptWebRTC;
11024 + files.webrtcconfig = webrtcconfiguration;
11025 files.onStateChanged = onFilesStateChange;
11026 files.onConsoleMessageChange = function () {
11027 if (files.consoleMessage) {
@@ -11760,7 +11762,7 @@
11762 if (start >= data.byteLength) {
11763 files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr }));
11764 } else {
11763 - var end = uploadFile.xptr + 65565;
11765 + var end = uploadFile.xptr + (attemptWebRTC ? 16384 : 65536);
11766 if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; }
11767 var dataslice = new Uint8Array(data.slice(start, end))
11768 if ((dataslice[0] == 123) || (dataslice[0] == 0)) {
@@ -11776,7 +11778,7 @@
11778 } else if (uploadFile.xfile) {
11779 if (uploadFile.xreader != null) return; // Data reading already in process
11780 if (uploadFile.xptr >= uploadFile.xfile.size) return;
11779 - var end = uploadFile.xptr + 65565;
11781 + var end = uploadFile.xptr + (attemptWebRTC ? 16384 : 65536);
11782 if (end > uploadFile.xfile.size) { if (dataPriming == true) { return; } end = uploadFile.xfile.size; }
11783 uploadFile.xreader = new FileReader();
11784 uploadFile.xreader.onerror = function (err) { console.log(err); }
views/sharing-mobile.handlebars
+1 -1
@@ -2363,7 +2363,7 @@
2363 function p13uploadNextPart(dataPriming) {
2364 if (uploadFile.xreader != null) return; // Data reading already in process
2365 if (uploadFile.xptr >= uploadFile.xfile.size) return;
2366 - var end = uploadFile.xptr + 65565;
2366 + var end = uploadFile.xptr + 65536;
2367 if (end > uploadFile.xfile.size) { if (dataPriming == true) { return; } end = uploadFile.xfile.size; }
2368 uploadFile.xreader = new FileReader();
2369 uploadFile.xreader.onerror = function (err) { console.log(err); }
views/sharing.handlebars
+1 -1
@@ -2193,7 +2193,7 @@
2193 if (start >= data.byteLength) {
2194 files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr }));
2195 } else {
2196 - var end = uploadFile.xptr + 65565;
2196 + var end = uploadFile.xptr + 65536;
2197 if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; }
2198 var dataslice = new Uint8Array(data.slice(start, end))
2199 if ((dataslice[0] == 123) || (dataslice[0] == 0)) {