Skip to content

Commit

Permalink
fix webrtc file upload maybe #6309
Browse files Browse the repository at this point in the history
Signed-off-by: si458 <simonsmith5521@gmail.com>
  • Loading branch information
si458 committed Sep 3, 2024
1 parent ac0d805 commit e8cbeba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions views/default-mobile.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -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&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 files;
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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); }
Expand Down
6 changes: 4 additions & 2 deletions views/default.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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); }
Expand Down
2 changes: 1 addition & 1 deletion views/sharing-mobile.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down
2 changes: 1 addition & 1 deletion views/sharing.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit e8cbeba

Please sign in to comment.