fix webrtc file upload maybe #6309

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
si458 2024-09-03 14:46:25 +01:00
parent ac0d805378
commit e8cbebaffe
4 changed files with 12 additions and 6 deletions

View File

@ -1338,6 +1338,8 @@
var serverPublicNamePort = '{{{serverDnsName}}}:{{{serverPublicPort}}}'; var serverPublicNamePort = '{{{serverDnsName}}}:{{{serverPublicPort}}}';
var debugmode = false; var debugmode = false;
var attemptWebRTC = ((features & 128) != 0); 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&reg; AMT Connected"]; var StatusStrs = ["Disconnected", "Connecting...", "Setup...", "Connected", "Intel&reg; 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 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; var files;
@ -4565,6 +4567,7 @@
desktop.debugmode = debugmode; desktop.debugmode = debugmode;
desktop.m.debugmode = debugmode; desktop.m.debugmode = debugmode;
desktop.attemptWebRTC = attemptWebRTC; desktop.attemptWebRTC = attemptWebRTC;
desktop.webrtcconfig = webrtcconfiguration;
desktop.options = {}; desktop.options = {};
if (tsid != null) { desktop.options.tsid = tsid; } if (tsid != null) { desktop.options.tsid = tsid; }
if (consent != null) { desktop.options.consent = consent; } 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. 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.contype = contype;
files.attemptWebRTC = attemptWebRTC; files.attemptWebRTC = attemptWebRTC;
files.webrtcconfig = webrtcconfiguration;
files.onStateChanged = onFilesStateChange; files.onStateChanged = onFilesStateChange;
files.onConsoleMessageChange = function () { files.onConsoleMessageChange = function () {
if (files.consoleMessage) { if (files.consoleMessage) {
@ -6083,7 +6087,7 @@
if (start >= data.byteLength) { if (start >= data.byteLength) {
files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr })); files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr }));
} else { } else {
var end = uploadFile.xptr + 65565; var end = uploadFile.xptr + (attemptWebRTC ? 16384 : 65536);
if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; } if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; }
var dataslice = new Uint8Array(data.slice(start, end)) var dataslice = new Uint8Array(data.slice(start, end))
if ((dataslice[0] == 123) || (dataslice[0] == 0)) { if ((dataslice[0] == 123) || (dataslice[0] == 0)) {
@ -6099,7 +6103,7 @@
} else if (uploadFile.xfile) { } else if (uploadFile.xfile) {
if (uploadFile.xreader != null) return; // Data reading already in process if (uploadFile.xreader != null) return; // Data reading already in process
if (uploadFile.xptr >= uploadFile.xfile.size) return; 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; } if (end > uploadFile.xfile.size) { if (dataPriming == true) { return; } end = uploadFile.xfile.size; }
uploadFile.xreader = new FileReader(); uploadFile.xreader = new FileReader();
uploadFile.xreader.onerror = function (err) { console.log(err); } uploadFile.xreader.onerror = function (err) { console.log(err); }

View File

@ -5215,6 +5215,7 @@
desk.m.mouseCursorActive(xxcurrentView == 11); desk.m.mouseCursorActive(xxcurrentView == 11);
desk.shortid = shortid; desk.shortid = shortid;
desk.attemptWebRTC = attemptWebRTC; desk.attemptWebRTC = attemptWebRTC;
desk.webrtcconfig = webrtcconfiguration;
desk.onStateChanged = onMultiDesktopStateChange; desk.onStateChanged = onMultiDesktopStateChange;
//desk.onConsoleMessageChange = function () { console.log('CONSOLEMSG:', desk.consoleMessage); } //desk.onConsoleMessageChange = function () { console.log('CONSOLEMSG:', desk.consoleMessage); }
desk.m.ImageType = multidesktopsettings.agentencoding; // Send 4 if WebP is supported, otherwise send 1 for JPEG. desk.m.ImageType = multidesktopsettings.agentencoding; // Send 4 if WebP is supported, otherwise send 1 for JPEG.
@ -11020,6 +11021,7 @@
files.contype = contype; files.contype = contype;
files.options = { consent: consent } files.options = { consent: consent }
files.attemptWebRTC = attemptWebRTC; files.attemptWebRTC = attemptWebRTC;
files.webrtcconfig = webrtcconfiguration;
files.onStateChanged = onFilesStateChange; files.onStateChanged = onFilesStateChange;
files.onConsoleMessageChange = function () { files.onConsoleMessageChange = function () {
if (files.consoleMessage) { if (files.consoleMessage) {
@ -11760,7 +11762,7 @@
if (start >= data.byteLength) { if (start >= data.byteLength) {
files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr })); files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr }));
} else { } else {
var end = uploadFile.xptr + 65565; var end = uploadFile.xptr + (attemptWebRTC ? 16384 : 65536);
if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; } if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; }
var dataslice = new Uint8Array(data.slice(start, end)) var dataslice = new Uint8Array(data.slice(start, end))
if ((dataslice[0] == 123) || (dataslice[0] == 0)) { if ((dataslice[0] == 123) || (dataslice[0] == 0)) {
@ -11776,7 +11778,7 @@
} else if (uploadFile.xfile) { } else if (uploadFile.xfile) {
if (uploadFile.xreader != null) return; // Data reading already in process if (uploadFile.xreader != null) return; // Data reading already in process
if (uploadFile.xptr >= uploadFile.xfile.size) return; 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; } if (end > uploadFile.xfile.size) { if (dataPriming == true) { return; } end = uploadFile.xfile.size; }
uploadFile.xreader = new FileReader(); uploadFile.xreader = new FileReader();
uploadFile.xreader.onerror = function (err) { console.log(err); } uploadFile.xreader.onerror = function (err) { console.log(err); }

View File

@ -2363,7 +2363,7 @@
function p13uploadNextPart(dataPriming) { function p13uploadNextPart(dataPriming) {
if (uploadFile.xreader != null) return; // Data reading already in process if (uploadFile.xreader != null) return; // Data reading already in process
if (uploadFile.xptr >= uploadFile.xfile.size) return; 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; } if (end > uploadFile.xfile.size) { if (dataPriming == true) { return; } end = uploadFile.xfile.size; }
uploadFile.xreader = new FileReader(); uploadFile.xreader = new FileReader();
uploadFile.xreader.onerror = function (err) { console.log(err); } uploadFile.xreader.onerror = function (err) { console.log(err); }

View File

@ -2193,7 +2193,7 @@
if (start >= data.byteLength) { if (start >= data.byteLength) {
files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr })); files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr }));
} else { } else {
var end = uploadFile.xptr + 65565; var end = uploadFile.xptr + 65536;
if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; } if (end > data.byteLength) { if (dataPriming == true) { return; } end = data.byteLength; }
var dataslice = new Uint8Array(data.slice(start, end)) var dataslice = new Uint8Array(data.slice(start, end))
if ((dataslice[0] == 123) || (dataslice[0] == 0)) { if ((dataslice[0] == 123) || (dataslice[0] == 0)) {