From 2d9e1ae5c6f9069f370f58dd896336df2c7c8f22 Mon Sep 17 00:00:00 2001 From: Marcin Wilk Date: Tue, 5 Jul 2022 13:28:18 +0200 Subject: [PATCH 01/13] Polish translation update --- translate/translate.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/translate/translate.json b/translate/translate.json index c4194355..390fb24d 100644 --- a/translate/translate.json +++ b/translate/translate.json @@ -28180,6 +28180,7 @@ { "en": "Gateway: {0}", "nl": "Gateway: {0}", + "pl": "Brama: {0}", "xloc": [ "default-mobile.handlebars->11->556", "default.handlebars->45->1453" @@ -29326,6 +29327,7 @@ "de": "HTTP Verbindung", "en": "HTTP Connection", "nl": "HTTP verbinding", + "pl": "Połączenie HTTP", "xloc": [ "default.handlebars->45->750" ] @@ -29333,6 +29335,7 @@ { "en": "HTTP remote connection port:", "nl": "HTTP poort voor externe verbinding:", + "pl": "HTTP zdalny port połączenia:", "xloc": [ "default.handlebars->45->749" ] @@ -29366,6 +29369,7 @@ "de": "HTTPS Verbindung", "en": "HTTPS Connection", "nl": "HTTPS verbinding", + "pl": "Połączenie HTTPS", "xloc": [ "default.handlebars->45->752" ] @@ -29373,6 +29377,7 @@ { "en": "HTTPS remote connection port:", "nl": "HTTPS poort voor externe verbinding:", + "pl": "HTTPS zdalny port połączenia:", "xloc": [ "default.handlebars->45->751" ] @@ -39186,6 +39191,7 @@ { "en": "Mask: {0}", "nl": "Mask: {0}", + "pl": "Maska: {0}", "xloc": [ "default-mobile.handlebars->11->555", "default.handlebars->45->1452" From d16523af7b5be616732be0262c96bdf4c8be88ef Mon Sep 17 00:00:00 2001 From: Simon Smith Date: Tue, 5 Jul 2022 18:42:00 +0100 Subject: [PATCH 02/13] fix backup code visibility --- webserver.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webserver.js b/webserver.js index a80e1c89..a6812019 100644 --- a/webserver.js +++ b/webserver.js @@ -2972,8 +2972,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF if (domain.devicesearchbarserverandclientname) { features2 += 0x00008000; } // Search bar will find both server name and client name if (domain.ipkvm) { features2 += 0x00010000; } // Indicates support for IP KVM device groups if ((domain.passwordrequirements) && (domain.passwordrequirements.otp2factor == false)) { features2 += 0x00020000; } // Indicates support for OTP 2FA is disabled - if ((typeof domain.passwordrequirements != 'object') || (domain.passwordrequirements.backupcode2factor === false)) { features2 += 0x00040000; } // Indicates 2FA backup codes are disabled - if ((typeof domain.passwordrequirements != 'object') || (domain.passwordrequirements.single2factorwarning === false)) { features2 += 0x00080000; } // Indicates no warning if a single 2FA is in use + if ((typeof domain.passwordrequirements == 'object') && (domain.passwordrequirements.backupcode2factor === false)) { features2 += 0x00040000; } // Indicates 2FA backup codes are disabled + if ((typeof domain.passwordrequirements == 'object') && (domain.passwordrequirements.single2factorwarning === false)) { features2 += 0x00080000; } // Indicates no warning if a single 2FA is in use if (domain.nightmode === 1) { features2 += 0x00100000; } // Always night mode if (domain.nightmode === 2) { features2 += 0x00200000; } // Always day mode if (domain.allowsavingdevicecredentials == false) { features2 += 0x00400000; } // Do not allow device credentials to be saved on the server From e71ebdcb15e545607bc575e1b1eebf43fd1fef8e Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 5 Jul 2022 11:47:32 -0700 Subject: [PATCH 03/13] Version 1.0.46 --- agents/agent-translations.json | 4 ++-- emails/translations/account-login_de.html | 2 +- emails/translations/account-login_de.txt | 2 +- emails/translations/mesh-invite_de.html | 6 +++--- emails/translations/mesh-invite_de.txt | 2 +- package.json | 2 +- translate/translate.json | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/agents/agent-translations.json b/agents/agent-translations.json index 0394e050..4832b66b 100644 --- a/agents/agent-translations.json +++ b/agents/agent-translations.json @@ -69,7 +69,7 @@ "meshId": "Gruppen-ID", "serverId": "Server-ID", "setup": "Konfiguration", - "update": "Updates", + "update": "Aktualisierung", "install": "Installieren", "uninstall": "Deinstallation", "connect": "Verbinden", @@ -86,7 +86,7 @@ "GESTARTET", "NICHT GESTARTET" ], - "statusDescription": "Aktueller Agentenstatus", + "statusDescription": "Aktueller Agentstatus", "agentVersion": "Neue Version", "elevation": "Zum Installieren/Deinstallieren dieser Software sind erhöhte Berechtigungen erforderlich.", "graphicalerror": "Die grafische Version dieses Installationsprogramms kann auf diesem System nicht ausgeführt werden", diff --git a/emails/translations/account-login_de.html b/emails/translations/account-login_de.html index da766021..9047666c 100644 --- a/emails/translations/account-login_de.html +++ b/emails/translations/account-login_de.html @@ -7,6 +7,6 @@ -

Ihr Login-Token lautet: [[[TOKEN]]]

+

Ihr Anmelde-Token lautet: [[[TOKEN]]]

Dieser Token kann nur einmal verwendet werden und ist 5 Minuten gültig.

\ No newline at end of file diff --git a/emails/translations/account-login_de.txt b/emails/translations/account-login_de.txt index 0208acd6..0f97eb94 100644 --- a/emails/translations/account-login_de.txt +++ b/emails/translations/account-login_de.txt @@ -1,4 +1,4 @@ [[[SERVERNAME]]] - Konto-Login -Ihr Login-Token lautet: [[[TOKEN]]] +Ihr Anmelde-Token lautet: [[[TOKEN]]] ~ Dieser Token kann nur einmal verwendet werden und ist 5 Minuten gültig. \ No newline at end of file diff --git a/emails/translations/mesh-invite_de.html b/emails/translations/mesh-invite_de.html index 9c37ee5c..072daa0d 100644 --- a/emails/translations/mesh-invite_de.html +++ b/emails/translations/mesh-invite_de.html @@ -3,7 +3,7 @@
- [[[SERVERNAME]]] - Agenteninstallation + [[[SERVERNAME]]] - Agent-Installation
@@ -15,7 +15,7 @@

Benutzer [[[USERNAME]]] auf dem Server [[[SERVERNAME]]] fordert Sie auf, Software zu installieren, um eine Fernsteuerungssitzung zu starten.

- Botschaft: [[[MSG]]] + Nachricht: [[[MSG]]]

@@ -28,7 +28,7 @@

- Schneiden Sie unter Linux Folgendes aus und fügen Sie es in ein Terminal ein, um den Agenten zu installieren:
+ Schneiden Sie unter Linux Folgendes aus und fügen Sie es in ein Terminal ein, um den Agent zu installieren:

wget -q "[[[SERVERURL]]]/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh [[[SERVERURL]]] \'[[[MESHIDHEX]]]\'

diff --git a/emails/translations/mesh-invite_de.txt b/emails/translations/mesh-invite_de.txt index 976e83f6..b4f55fb2 100644 --- a/emails/translations/mesh-invite_de.txt +++ b/emails/translations/mesh-invite_de.txt @@ -21,7 +21,7 @@ Nagivieren Sie unter Apple OSX den folgenden Link, um den Vorgang abzuschließen ~ ~ ~ -Schneiden Sie unter Linux Folgendes aus und fügen Sie es in ein Terminal ein, um den Agenten zu installieren: +Schneiden Sie unter Linux Folgendes aus und fügen Sie es in ein Terminal ein, um den Agent zu installieren: ~ ~wget -q "[[[SERVERURL]]]/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh [[[SERVERURL]]] '[[[MESHIDHEX]]]' ~ diff --git a/package.json b/package.json index 644f28f1..75183b52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "1.0.45", + "version": "1.0.46", "keywords": [ "Remote Device Management", "Remote Device Monitoring", diff --git a/translate/translate.json b/translate/translate.json index c4194355..b6646fa3 100644 --- a/translate/translate.json +++ b/translate/translate.json @@ -75878,4 +75878,4 @@ ] } ] -} +} \ No newline at end of file From e6c98d20c8d7d8850d9dfaed79443ff4d69a48be Mon Sep 17 00:00:00 2001 From: petervanv <58996467+petervanv@users.noreply.github.com> Date: Tue, 5 Jul 2022 21:56:05 +0200 Subject: [PATCH 04/13] added some translations edit layout polish, added some (simple) string translations --- translate/translate.json | 100 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 7 deletions(-) diff --git a/translate/translate.json b/translate/translate.json index 25428cef..83bc776d 100644 --- a/translate/translate.json +++ b/translate/translate.json @@ -961,6 +961,13 @@ }, { "en": ", 16 grays", + "cs": ", 16 šedá", + "da": ", 16 grå", + "de": ", 16 grå", + "fi": ", 16 grå", + "pt": ", 16 cinza", + "pt-br": ", 16 cinza", + "it": ", 16 grigi", "fr": ", 16 gris", "nl": ", 16 grijstinten", "pl": ", 16 odcieni szarości", @@ -971,6 +978,13 @@ }, { "en": ", 256 grays", + "cs": ", 256 šedá", + "da": ", 256 grå", + "de": ", 256 grå", + "fi": ", 256 grå", + "pt": ", 256 cinza", + "pt-br": ", 256 cinza", + "it": ", 256 grigi", "fr": ", 256 gris", "nl": ", 256 grijstinten", "pl": ", 256 odcieni szarości", @@ -1112,6 +1126,15 @@ "pl": ", RDP", "ru": ", RDP", "fr": ", RDP", + "de": ", RDP", + "de": ", RDP", + "da": ", RDP", + "cs": ", RDP", + "es": ", RDP", + "fi": ", RDP", + "it": ", RDP", + "pt": ", RDP", + "pt-br": ", RDP", "xloc": [ "default.handlebars->45->1244" ] @@ -1191,10 +1214,18 @@ }, { "en": ", SFTP", + "cs": ", SFTP", + "es": ", SFTP", + "da": ", SFTP", + "de": ", SFTP", + "fr": ", SFTP", + "fi": ", SFTP", + "it": ", SFTP", "nl": ", SFTP", "pl": ", SFTP", + "pt": ", SFTP", + "pt-br": ", SFTP", "ru": ", SFTP", - "fr": ", SFTP", "xloc": [ "default-mobile.handlebars->11->468", "default.handlebars->45->1352" @@ -1206,6 +1237,14 @@ "pl": ", SSH", "ru": ", SSH", "fr": ", SSH", + "de": ", SSH", + "da": ", SSH", + "cs": ", SSH", + "es": ", SSH", + "fi": ", SSH", + "it": ", SSH", + "pt": ", SSH", + "pt-br": ", SSH", "xloc": [ "default.handlebars->45->1320" ] @@ -2540,6 +2579,7 @@ { "cs": "1024×768", "da": "1024×768", + "de": "1024×768", "en": "1024x768", "es": "1024×768", "fi": "1024×768", @@ -2560,6 +2600,7 @@ { "cs": "1024×768", "da": "1024×768", + "de": "1024×768", "en": "1024×768", "es": "1024×768", "fi": "1024×768", @@ -2699,6 +2740,7 @@ { "cs": "1280x800", "da": "1280x800", + "de": "1280×800", "en": "1280×800", "es": "1280x800", "fi": "1280x800", @@ -2719,6 +2761,7 @@ { "cs": "1440x900", "da": "1440x900", + "de": "1440x900", "en": "1440x900", "es": "1440x900", "fi": "1440x900", @@ -2739,6 +2782,7 @@ { "cs": "1440x900", "da": "1440x900", + "de": "1440x900", "en": "1440×900", "es": "1440x900", "fi": "1440x900", @@ -2811,6 +2855,7 @@ { "cs": "1600x900", "da": "1600x900", + "de": "1600x900", "en": "1600x900", "es": "1600x900", "fi": "1600x900", @@ -2831,6 +2876,7 @@ { "cs": "1600x900", "da": "1600x900", + "de": "1600x900", "en": "1600×900", "es": "1600x900", "fi": "1600x900", @@ -2851,6 +2897,7 @@ { "cs": "1680x1050", "da": "1680x1050", + "de": "1600x1050", "en": "1680x1050", "es": "1680x1050", "fi": "1680x1050", @@ -2871,6 +2918,7 @@ { "cs": "1680x1050", "da": "1680x1050", + "de": "1600x1050", "en": "1680×1050", "es": "1680x1050", "fi": "1680x1050", @@ -2891,6 +2939,7 @@ { "cs": "1920x1080", "da": "1920x1080", + "de": "1920x1080", "en": "1920x1080", "es": "1920x1080", "fi": "1920x1080", @@ -2911,6 +2960,7 @@ { "cs": "1920x1080", "da": "1920x1080", + "de": "1920x1080", "en": "1920×1080", "es": "1920x1080", "fi": "1920x1080", @@ -4015,6 +4065,7 @@ { "cs": "640x480", "da": "640x480", + "de": "640x480", "en": "640x480", "es": "640x480", "fi": "640x480", @@ -4035,6 +4086,7 @@ { "cs": "640x480", "da": "640x480", + "de": "640x480", "en": "640×480", "es": "640x480", "fi": "640x480", @@ -4174,7 +4226,13 @@ }, { "en": "7 days", + "da": "7 Dages", + "de": "7 Tage", + "cs": "7 dní", + "es": "7 días", "nl": "7 dagen", + "fi": "7 päivääs", + "it": "7 giorni", "pl": "7 dni", "pt-br": "7 dias", "ru": "7 дней", @@ -28180,7 +28238,7 @@ { "en": "Gateway: {0}", "nl": "Gateway: {0}", - "pl": "Brama: {0}", + "pl": "Brama: {0}", "xloc": [ "default-mobile.handlebars->11->556", "default.handlebars->45->1453" @@ -29327,7 +29385,7 @@ "de": "HTTP Verbindung", "en": "HTTP Connection", "nl": "HTTP verbinding", - "pl": "Połączenie HTTP", + "pl": "Połączenie HTTP", "xloc": [ "default.handlebars->45->750" ] @@ -29369,7 +29427,7 @@ "de": "HTTPS Verbindung", "en": "HTTPS Connection", "nl": "HTTPS verbinding", - "pl": "Połączenie HTTPS", + "pl": "Połączenie HTTPS", "xloc": [ "default.handlebars->45->752" ] @@ -29377,7 +29435,7 @@ { "en": "HTTPS remote connection port:", "nl": "HTTPS poort voor externe verbinding:", - "pl": "HTTPS zdalny port połączenia:", + "pl": "HTTPS zdalny port połączenia:", "xloc": [ "default.handlebars->45->751" ] @@ -32756,16 +32814,36 @@ }, { "en": "Intel®AMT", + "cs": "Intel®AMT", + "da": "Intel®AMT", + "de": "Intel®AMT", "nl": "Intel®AMT", "pl": "Intel®AMT", + "es": "Intel®AMT", + "fi": "Intel®AMT", + "fr": "Intel®AMT", + "it": "Intel®AMT", + "pt-br": "Intel®AMT", + "ru": "Intel®AMT", + "tr": "Intel®AMT", "xloc": [ "default.handlebars->45->965" ] }, { "en": "Intel®SM", + "cs": "Intel®SM", + "da": "Intel®SM", + "de": "Intel®SM", "nl": "Intel®SM", "pl": "Intel®SM", + "es": "Intel®SM", + "fi": "Intel®SM", + "fr": "Intel®SM", + "it": "Intel®SM", + "pt-br": "Intel®SM", + "ru": "Intel®SM", + "tr": "Intel®SM", "xloc": [ "default.handlebars->45->963" ] @@ -39191,7 +39269,7 @@ { "en": "Mask: {0}", "nl": "Mask: {0}", - "pl": "Maska: {0}", + "pl": "Maska: {0}", "xloc": [ "default-mobile.handlebars->11->555", "default.handlebars->45->1452" @@ -45635,11 +45713,16 @@ }, { "de": "Optionen", + "da": "Muligheder", "en": "Options", + "es": "Opciones", + "cs": "Možnosti", + "it": "Opzioni", "nl": "Opties", "pl": "Opcje", "ru": "Опции", "fr": "Options", + "fi": "Vaihtoehdot", "xloc": [ "default.handlebars->container->dialog->dialogBody->dialog7->d7rdpkvm->5->1" ] @@ -70845,6 +70928,7 @@ "de": "X", "en": "X", "es": "X", + "fi": "X", "fr": "X", "it": "X", "ja": "バツ", @@ -74696,6 +74780,7 @@ "ja": "{0}分", "nl": "{0} minuut", "pl": "{0} minuta", + "pt": "{0} minuto", "pt-br": "{0} minuto", "ru": "{0} минута", "tr": "{0} dakika", @@ -74716,6 +74801,7 @@ "ja": "{0}分", "nl": "{0} minuten", "pl": "{0} minut", + "pt": "{0} minutos", "pt-br": "{0} minutos", "ru": "{0} минут", "tr": "{0} dakika", @@ -75884,4 +75970,4 @@ ] } ] -} \ No newline at end of file +} From 568097597c240a301a53506be8626245e395aa01 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 5 Jul 2022 13:21:14 -0700 Subject: [PATCH 05/13] Web relay with DNS now uses the main HTTPS alias port when set, #4210. --- webserver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webserver.js b/webserver.js index a6812019..6faf5ed4 100644 --- a/webserver.js +++ b/webserver.js @@ -2864,7 +2864,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF webstate: encodeURIComponent(webstate).replace(/'/g, '%27'), amtscanoptions: amtscanoptions, pluginHandler: (parent.pluginHandler == null) ? 'null' : parent.pluginHandler.prepExports(), - webRelayPort: ((typeof args.relaydns == 'string') ? args.port : ((parent.webrelayserver != null) ? ((typeof args.relayaliasport == 'number') ? args.relayaliasport : parent.webrelayserver.port) : 0)), + webRelayPort: ((typeof args.relaydns == 'string') ? ((typeof args.aliasport == 'number') ? args.aliasport : args.port) : ((parent.webrelayserver != null) ? ((typeof args.relayaliasport == 'number') ? args.relayaliasport : parent.webrelayserver.port) : 0)), webRelayDns: ((typeof args.relaydns == 'string') ? args.relaydns : '') }, dbGetFunc.req, domain), user); } From 6920134caf787706b41ffd9bc982a00d2e13f320 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 5 Jul 2022 13:25:34 -0700 Subject: [PATCH 06/13] Fixed web relay host header. --- apprelays.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apprelays.js b/apprelays.js index 375f00ba..2a33729a 100644 --- a/apprelays.js +++ b/apprelays.js @@ -223,8 +223,7 @@ module.exports.CreateWebRelay = function (parent, db, args, domain) { // Construct the HTTP request var request = req.method + ' ' + req.url + ' HTTP/' + req.httpVersion + '\r\n'; - const blockedHeaders = ['host', 'origin', 'cookie', 'upgrade-insecure-requests', 'sec-ch-ua', 'sec-ch-ua-mobile', 'dnt', 'sec-fetch-user', 'sec-ch-ua-platform', 'sec-fetch-site', 'sec-fetch-mode', 'sec-fetch-dest']; // These are headers we do not forward - request += 'host: central.mesh.meshcentral.com\r\n'; + const blockedHeaders = ['origin', 'cookie', 'upgrade-insecure-requests', 'sec-ch-ua', 'sec-ch-ua-mobile', 'dnt', 'sec-fetch-user', 'sec-ch-ua-platform', 'sec-fetch-site', 'sec-fetch-mode', 'sec-fetch-dest']; // These are headers we do not forward for (var i in req.headers) { if (blockedHeaders.indexOf(i) == -1) { request += i + ': ' + req.headers[i] + '\r\n'; } } var cookieStr = ''; for (var i in parent.webCookies) { if (cookieStr != '') { cookieStr += '; ' } cookieStr += (i + '=' + parent.webCookies[i].value); } From b8fa2c9b3791c40b868bc6149b5bc5a2a69d3c49 Mon Sep 17 00:00:00 2001 From: petervanv <58996467+petervanv@users.noreply.github.com> Date: Tue, 5 Jul 2022 22:33:50 +0200 Subject: [PATCH 07/13] repaired some reverted text --- translate/translate.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/translate/translate.json b/translate/translate.json index 83bc776d..01a4085d 100644 --- a/translate/translate.json +++ b/translate/translate.json @@ -963,8 +963,8 @@ "en": ", 16 grays", "cs": ", 16 šedá", "da": ", 16 grå", - "de": ", 16 grå", - "fi": ", 16 grå", + "de": ", 16 Grautöne", + "fi": ", 16 harmaata", "pt": ", 16 cinza", "pt-br": ", 16 cinza", "it": ", 16 grigi", @@ -980,8 +980,8 @@ "en": ", 256 grays", "cs": ", 256 šedá", "da": ", 256 grå", - "de": ", 256 grå", - "fi": ", 256 grå", + "de": ", 256 Grautöne", + "fi": ", 256 harmaata", "pt": ", 256 cinza", "pt-br": ", 256 cinza", "it": ", 256 grigi", From acd281c990359ee0279a74137ac8473e22778233 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 5 Jul 2022 13:44:24 -0700 Subject: [PATCH 08/13] Added new rootCertCommonName option is config.json setting to change the default root common name when generating the root certificate, #4221 --- certoperations.js | 8 +++++++- meshcentral-config-schema.json | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/certoperations.js b/certoperations.js index dd441e50..80d3b394 100644 --- a/certoperations.js +++ b/certoperations.js @@ -1006,7 +1006,13 @@ module.exports.CertificateOperations = function (parent) { if (r.root == null) { // If the root certificate does not exist, create one console.log("Generating root certificate..."); - rootCertAndKey = obj.GenerateRootCertificate(true, 'MeshCentralRoot', null, null, strongCertificate); + if (typeof args.rootcertcommonname == 'string') { + // If a root certificate common name is specified, use it. + rootCertAndKey = obj.GenerateRootCertificate(false, args.rootcertcommonname, null, null, strongCertificate); + } else { + // A root certificate common name is not specified, use the default one. + rootCertAndKey = obj.GenerateRootCertificate(true, 'MeshCentralRoot', null, null, strongCertificate); + } rootCertificate = obj.pki.certificateToPem(rootCertAndKey.cert); rootPrivateKey = obj.pki.privateKeyToPem(rootCertAndKey.key); obj.fs.writeFileSync(parent.getConfigFilePath('root-cert-public.crt'), rootCertificate); diff --git a/meshcentral-config-schema.json b/meshcentral-config-schema.json index 655f788d..09153ca4 100644 --- a/meshcentral-config-schema.json +++ b/meshcentral-config-schema.json @@ -199,7 +199,7 @@ "type": "object", "properties": { "mongoDumpPath": { "type": "string" }, - "mysqlDumpPath": { "type": "string"}, + "mysqlDumpPath": { "type": "string" }, "backupIntervalHours": { "type": "integer" }, "keepLastDaysBackup": { "type": "integer" }, "zipPassword": { "type": "string" }, @@ -250,6 +250,7 @@ } } }, + "rootCertCommonName" : { "type": "string", "default": "MeshCentralRoot-XXXXXX", "description": "The common name of the MeshCentral server root certificate. By default it's 'MeshCentralRoot-' followed by the first 6 HEX digits of the public key fingerprint. For this setting to take effect, all generated certificates need to be deleted and reset. Existing agents will not be able to connect anymore." }, "redirects": { "type": "object" }, "maxInvalidLogin": { "type": "object", From e89effac46ac1d659eeeed27991c16a12f91047e Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 5 Jul 2022 14:25:38 -0700 Subject: [PATCH 09/13] Added options to remove the SSH Connect and SFTP connect from the terminal and files tab when other options exist, #4214 --- meshcentral-config-schema.json | 10 +++++++++- views/default.handlebars | 4 ++-- webserver.js | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/meshcentral-config-schema.json b/meshcentral-config-schema.json index 09153ca4..544fbfc1 100644 --- a/meshcentral-config-schema.json +++ b/meshcentral-config-schema.json @@ -616,10 +616,18 @@ "MaxSingleUserSessions": { "type": "integer", "default": null, "description": "Maximum number of sessions a single user can have. Each time a user opens a new browser tab or opens a new browser on a different computer, a new user session is created." } } }, + "files": { + "type": "object", + "description": "Values that affect the files feature", + "properties": { + "sftpConnect" : { "type": "boolean", "default": true, "description": "When false, removes the 'SFTP Connect' button from the files tab unless this is the only possible option." } + } + }, "terminal": { "type": "object", "description": "Values that affect the terminal feature", "properties": { + "sshConnect" : { "type": "boolean", "default": true, "description": "When false, removes the 'SSH Connect' button from the terminal tab unless this is the only possible option." }, "linuxShell": { "type": "string", "enum": [ "any", "root", "user", "login" ], @@ -637,7 +645,7 @@ }, "desktop": { "type": "object", - "description": "Values that affect the remote desktop feature", + "description": "Values that affect the desktop feature", "properties": { "viewonly": { "type": "boolean", diff --git a/views/default.handlebars b/views/default.handlebars index 6c722c92..037fcfc6 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -9726,7 +9726,7 @@ // Show the right buttons QV('disconnectbutton2span', (termState == true)); QV('connectbutton2span', (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.mtype != 3)); - QV('connectbutton2sspan', (features2 & 0x00000200) && (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.agent.id != 3) && (terminalNode.agent.id != 4)); + QV('connectbutton2sspan', (features2 & 0x00000200) && (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.agent.id != 3) && (terminalNode.agent.id != 4) && ((features2 & 0x1000000) == 0)); if (terminalNode.mtype == 1) { QV('connectbutton2hspan', (termState == false) && (terminalNode.intelamt != null) && (terminalNode.intelamt.state == 2)); QV('terminalSizeDropDown', (termState == false) && (terminalNode.intelamt != null) && (terminalNode.intelamt.state == 2)); @@ -10160,7 +10160,7 @@ QE('p13Connect', online); QE('p13Connects', online); QV('p13Connect', (files == null) && (filesNode.mtype == 2)); - QV('p13Connects', (files == null) && (filesNode.agent != null) && (filesNode.agent.id != 3) && (filesNode.agent.id != 4)); + QV('p13Connects', (features2 & 0x200) && (files == null) && (filesNode.agent != null) && (filesNode.agent.id != 3) && (filesNode.agent.id != 4) && ((features2 & 0x800000) == 0)); QV('p13Disconnect', files != null); if (((samenode == false) || (online == false)) && files) { files.Stop(); files = null; } p13setActions(); diff --git a/webserver.js b/webserver.js index 6faf5ed4..fbf20ddd 100644 --- a/webserver.js +++ b/webserver.js @@ -2977,6 +2977,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF if (domain.nightmode === 1) { features2 += 0x00100000; } // Always night mode if (domain.nightmode === 2) { features2 += 0x00200000; } // Always day mode if (domain.allowsavingdevicecredentials == false) { features2 += 0x00400000; } // Do not allow device credentials to be saved on the server + if ((typeof domain.files == 'object') && (domain.files.sftpconnect === false)) { features2 += 0x00800000; } // Remove the "SFTP Connect" button in the "Files" tab when the device is agent managed + if ((typeof domain.terminal == 'object') && (domain.terminal.sshconnect === false)) { features2 += 0x01000000; } // Remove the "SSH Connect" button in the "Terminal" tab when the device is agent managed return { features: features, features2: features2 }; } From 73b052eacb3edaa29b0cb45149932fd8214149d6 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 5 Jul 2022 18:05:58 -0700 Subject: [PATCH 10/13] Added Read Disk Information and Get Performance command to Intel AMT IDER code. --- amt/amt-ider-module.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/amt/amt-ider-module.js b/amt/amt-ider-module.js index b76b6c5d..a28b89c5 100644 --- a/amt/amt-ider-module.js +++ b/amt/amt-ider-module.js @@ -83,6 +83,9 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { var IDE_ModeSence_Ls120Error_Recovery_Array = String.fromCharCode(0x00, 0x12, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00); var IDE_ModeSence_CDError_Recovery_Array = String.fromCharCode(0x00, 0x0E, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00); + // CD info and performance + var RD_CD_DiskInfo = String.fromCharCode(0x00, 0x20, 0x0e, 0x01, 0x01, 0x01, 0x01, 0x20, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); + var RD_CD_Performance = String.fromCharCode(0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00); // Private method, called by parent when it change state obj.xxStateChange = function (newstate) { @@ -589,6 +592,12 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { obj.SendDataToHost(dev, true, r, featureRegister & 1); } break; + case 0x51: // READ_DISK_INFORMATION + obj.SendDataToHost(dev, true, RD_CD_DiskInfo, featureRegister & 1); + break; + case 0xAC: // GET_PERFORMANCE + obj.SendDataToHost(dev, true, RD_CD_Performance, featureRegister & 1); + break; default: // UNKNOWN COMMAND debug("IDER: Unknown SCSI command", cdb.charCodeAt(0)); obj.SendCommandEndResponse(0, 0x05, dev, 0x20, 0x00); From 4c45dca3d602190d3638e0abfd188bc1e1de986a Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 5 Jul 2022 21:23:56 -0700 Subject: [PATCH 11/13] Improvements to Intel AMT server IDE-Redirect support. --- amt/amt-ider-module.js | 430 ++++++++++---------- amt/amt-redir-mesh.js | 27 +- public/commander.htm | 890 +++++++++++++++++++++-------------------- 3 files changed, 680 insertions(+), 667 deletions(-) diff --git a/amt/amt-ider-module.js b/amt/amt-ider-module.js index a28b89c5..60483c1d 100644 --- a/amt/amt-ider-module.js +++ b/amt/amt-ider-module.js @@ -30,7 +30,6 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { const fs = require('fs'); var obj = {}; - obj.debug = false; obj.protocol = 3; // IDER obj.bytesToAmt = 0; obj.bytesFromAmt = 0; @@ -38,7 +37,7 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { obj.tx_timeout = 0; // Default 0 obj.heartbeat = 20000; // Default 20000 obj.version = 1; - obj.acc = ""; + obj.acc = null; obj.inSequence = 0; obj.outSequence = 0; obj.iderinfo = null; @@ -46,50 +45,50 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { obj.iderStart = 0; // OnReboot = 0, Graceful = 1, Now = 2 obj.floppy = null; obj.cdrom = null; - obj.floppySize = null; - obj.cdromSize = null; obj.floppyReady = false; obj.cdromReady = false; + //obj.pingTimer = null; obj.sectorStats = null; + obj.debug = false; // Private method function debug() { if (obj.debug) { console.log(...arguments); } } // Mode Sense - var IDE_ModeSence_LS120Disk_Page_Array = String.fromCharCode(0x00, 0x26, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x10, 0xA9, 0x08, 0x20, 0x02, 0x00, 0x03, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00); - var IDE_ModeSence_3F_LS120_Array = String.fromCharCode(0x00, 0x5c, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x16, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x10, 0xA9, 0x08, 0x20, 0x02, 0x00, 0x03, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x11, 0x24, 0x31); - var IDE_ModeSence_FloppyDisk_Page_Array = String.fromCharCode(0x00, 0x26, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x04, 0xB0, 0x02, 0x12, 0x02, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00); - var IDE_ModeSence_3F_Floppy_Array = String.fromCharCode(0x00, 0x5c, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x16, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x05, 0x1e, 0x04, 0xb0, 0x02, 0x12, 0x02, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xd0, 0x00, 0x00, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x11, 0x24, 0x31); - var IDE_ModeSence_CD_1A_Array = String.fromCharCode(0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - //var IDE_ModeSence_CD_1B_Array = String.fromCharCode(0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - var IDE_ModeSence_CD_1D_Array = String.fromCharCode(0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - var IDE_ModeSence_CD_2A_Array = String.fromCharCode(0x00, 0x20, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - //var IDE_ModeSence_CD_01_Array = String.fromCharCode(0x00, 0x0E, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00); - var IDE_ModeSence_3F_CD_Array = String.fromCharCode(0x00, 0x28, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); + var IDE_ModeSence_LS120Disk_Page_Array = Buffer.from([0x00, 0x26, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x10, 0xA9, 0x08, 0x20, 0x02, 0x00, 0x03, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00]); + var IDE_ModeSence_3F_LS120_Array = Buffer.from([0x00, 0x5c, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x16, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x10, 0xA9, 0x08, 0x20, 0x02, 0x00, 0x03, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x11, 0x24, 0x31]); + var IDE_ModeSence_FloppyDisk_Page_Array = Buffer.from([0x00, 0x26, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x04, 0xB0, 0x02, 0x12, 0x02, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00]); + var IDE_ModeSence_3F_Floppy_Array = Buffer.from([0x00, 0x5c, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x16, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x05, 0x1e, 0x04, 0xb0, 0x02, 0x12, 0x02, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xd0, 0x00, 0x00, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x11, 0x24, 0x31]); + var IDE_ModeSence_CD_1A_Array = Buffer.from([0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); + //var IDE_ModeSence_CD_1B_Array = Buffer.from([0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); + var IDE_ModeSence_CD_1D_Array = Buffer.from([0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); + var IDE_ModeSence_CD_2A_Array = Buffer.from([0x00, 0x20, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); + //var IDE_ModeSence_CD_01_Array = Buffer.from([0x00, 0x0E, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00]); + var IDE_ModeSence_3F_CD_Array = Buffer.from([0x00, 0x28, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); // 0x46 constant data - var IDE_CD_ConfigArrayHeader = String.fromCharCode(0x00, 0x00,0x00, 0x28, 0x00, 0x00, 0x00, 0x08); - var IDE_CD_ConfigArrayProfileList = String.fromCharCode(0x00, 0x00, 0x03, 0x04, 0x00, 0x08, 0x01, 0x00); - var IDE_CD_ConfigArrayCore = String.fromCharCode(0x00, 0x01, 0x03, 0x04, 0x00, 0x00, 0x00, 0x02); - var IDE_CD_Morphing = String.fromCharCode(0x00, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00); - var IDE_CD_ConfigArrayRemovable = String.fromCharCode(0x00, 0x03, 0x03, 0x04, 0x29, 0x00, 0x00, 0x02); - var IDE_CD_ConfigArrayRandom = String.fromCharCode(0x00, 0x10, 0x01, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00); - var IDE_CD_Read = String.fromCharCode(0x00, 0x1E, 0x03, 0x00); - var IDE_CD_PowerManagement = String.fromCharCode(0x01, 0x00, 0x03, 0x00); - var IDE_CD_Timeout = String.fromCharCode(0x01, 0x05, 0x03, 0x00); + var IDE_CD_ConfigArrayHeader = Buffer.from([0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x08]); + var IDE_CD_ConfigArrayProfileList = Buffer.from([0x00, 0x00, 0x03, 0x04, 0x00, 0x08, 0x01, 0x00]); + var IDE_CD_ConfigArrayCore = Buffer.from([0x00, 0x01, 0x03, 0x04, 0x00, 0x00, 0x00, 0x02]); + var IDE_CD_Morphing = Buffer.from([0x00, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00]); + var IDE_CD_ConfigArrayRemovable = Buffer.from([0x00, 0x03, 0x03, 0x04, 0x29, 0x00, 0x00, 0x02]); + var IDE_CD_ConfigArrayRandom = Buffer.from([0x00, 0x10, 0x01, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00]); + var IDE_CD_Read = Buffer.from([0x00, 0x1E, 0x03, 0x00]); + var IDE_CD_PowerManagement = Buffer.from([0x01, 0x00, 0x03, 0x00]); + var IDE_CD_Timeout = Buffer.from([0x01, 0x05, 0x03, 0x00]); // 0x01 constant data - var IDE_ModeSence_FloppyError_Recovery_Array = String.fromCharCode(0x00, 0x12, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00); - var IDE_ModeSence_Ls120Error_Recovery_Array = String.fromCharCode(0x00, 0x12, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00); - var IDE_ModeSence_CDError_Recovery_Array = String.fromCharCode(0x00, 0x0E, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00); + var IDE_ModeSence_FloppyError_Recovery_Array = Buffer.from([0x00, 0x12, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00]); + var IDE_ModeSence_Ls120Error_Recovery_Array = Buffer.from([0x00, 0x12, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00]); + var IDE_ModeSence_CDError_Recovery_Array = Buffer.from([0x00, 0x0E, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00]); // CD info and performance - var RD_CD_DiskInfo = String.fromCharCode(0x00, 0x20, 0x0e, 0x01, 0x01, 0x01, 0x01, 0x20, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - var RD_CD_Performance = String.fromCharCode(0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00); + var RD_CD_DiskInfo = Buffer.from([0x00, 0x20, 0x0e, 0x01, 0x01, 0x01, 0x01, 0x20, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); + var RD_CD_Performance = Buffer.from([0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00]); // Private method, called by parent when it change state obj.xxStateChange = function (newstate) { - debug("IDER-StateChange", newstate); + if (obj.debug) console.log("IDER-StateChange", newstate); if (newstate == 0) { obj.Stop(); } if (newstate == 3) { obj.Start(); } } @@ -103,8 +102,7 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { if (fs.existsSync(floppyPath) == false) { return 1; } // Floppy disk image does not exist var stats = fs.statSync(floppyPath); if ((stats.size % 512) != 0) { return 2; } // Invalid floppy disk image - obj.floppySize = stats.size; - obj.floppy = fs.openSync(floppyPath, 'r'); + obj.floppy = { size: stats.size, ptr: fs.openSync(floppyPath, 'r') }; } catch (ex) { return 3; } // Unable to open floppy disk image } @@ -114,8 +112,7 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { if (fs.existsSync(cdromPath) == false) { return 4; } // CDROM disk image does not exist var stats = fs.statSync(cdromPath); if ((stats.size % 512) != 0) { return 5; } // Invalid CDROM disk image - obj.cdromSize = stats.size; - obj.cdrom = fs.openSync(cdromPath, 'r'); + obj.cdrom = { size: stats.size, ptr: fs.openSync(cdromPath, 'r') }; } catch (ex) { return 6; } // Unable to open CDROM disk image } @@ -125,9 +122,7 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { } obj.Start = function () { - debug("IDER-Start"); - - // Get ready + if (obj.debug) { console.log("IDER-Start"); console.log(obj.floppy, obj.cdrom); } obj.bytesToAmt = 0; obj.bytesFromAmt = 0; obj.inSequence = 0; @@ -135,87 +130,80 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { g_readQueue = []; // Send first command, OPEN_SESSION - obj.SendCommand(0x40, webserver.common.ShortToStrX(obj.rx_timeout) + webserver.common.ShortToStrX(obj.tx_timeout) + webserver.common.ShortToStrX(obj.heartbeat) + webserver.common.IntToStrX(obj.version)); + obj.SendCommand(0x40, Buffer.concat([ShortToStrX(obj.rx_timeout), ShortToStrX(obj.tx_timeout), ShortToStrX(obj.heartbeat), IntToStrX(obj.version)])); // Send sector stats if (obj.sectorStats) { - obj.sectorStats(0, 0, obj.floppy ? (obj.floppySize >> 9) : 0); - obj.sectorStats(0, 1, obj.cdrom ? (obj.cdromSize >> 11) : 0); + obj.sectorStats(0, 0, obj.floppy ? (obj.floppy.size >> 9) : 0); + obj.sectorStats(0, 1, obj.cdrom ? (obj.cdrom.size >> 11) : 0); } + + // Setup the ping timer + //obj.pingTimer = setInterval(function () { obj.SendCommand(0x44); }, 5000); } obj.Stop = function () { - debug("IDER-Stop"); - - // Close the files - if (obj.floppy) { fs.close(obj.floppy); delete obj.floppy; } - if (obj.cdrom) { fs.close(obj.cdrom); delete obj.cdrom; } - - // Clean up - obj.floppySize = 0; - obj.cdromSize = 0; - obj.floppyReady = false; - obj.cdromReady = false; - - // Stop the redirection connection + if (obj.debug) console.log("IDER-Stop"); + //if (obj.pingTimer) { clearInterval(obj.pingTimer); obj.pingTimer = null; } obj.parent.Stop(); } // Private method obj.ProcessData = function (data) { + data = Buffer.from(data, 'binary'); obj.bytesFromAmt += data.length; - obj.acc += data; - debug('IDER-ProcessData', obj.acc.length, webserver.common.rstr2hex(obj.acc)); + if (obj.acc == null) { obj.acc = data; } else { obj.acc = Buffer.concat(obj.acc, data); } + if (obj.debug) console.log('IDER-ProcessData', obj.acc.length, obj.acc.toString('hex')); // Process as many commands as possible - while (true) { + while (obj.acc != null) { var len = obj.ProcessDataEx(); if (len == 0) return; - if (obj.inSequence != webserver.common.ReadIntX(obj.acc, 4)) { - debug('ERROR: Out of sequence', obj.inSequence, webserver.common.ReadIntX(obj.acc, 4)); + if (obj.inSequence != ReadIntX(obj.acc, 4)) { + if (obj.debug) console.log('ERROR: Out of sequence', obj.inSequence, ReadIntX(obj.acc, 4)); obj.Stop(); return; } obj.inSequence++; - obj.acc = obj.acc.substring(len); + if (len == obj.acc.length) { obj.acc = null; } else { obj.acc = obj.acc.slice(len); } } } // Private method obj.SendCommand = function (cmdid, data, completed, dma) { - if (data == null) { data = ''; } + if (data == null) { data = Buffer.alloc(0); } var attributes = ((cmdid > 50) && (completed == true)) ? 2 : 0; if (dma) { attributes += 1; } - var x = String.fromCharCode(cmdid, 0, 0, attributes) + webserver.common.IntToStrX(obj.outSequence++) + data; + var x = Buffer.concat([Buffer.from([cmdid, 0, 0, attributes]), IntToStrX(obj.outSequence++), data]); obj.parent.xxSend(x); obj.bytesToAmt += x.length; - if (cmdid != 0x4B) { debug('IDER-SendData', x.length, webserver.common.rstr2hex(x)); } + //if (cmdid != 0x4B) { console.log('IDER-SendData', x.length, x.toString('hex')); } } // CommandEndResponse (SCSI_SENSE) obj.SendCommandEndResponse = function (error, sense, device, asc, asq) { - if (error) { obj.SendCommand(0x51, String.fromCharCode(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc5, 0, 3, 0, 0, 0, device, 0x50, 0, 0, 0), true); } - else { obj.SendCommand(0x51, String.fromCharCode(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x87, (sense << 4), 3, 0, 0, 0, device, 0x51, sense, asc, asq), true); } + if (error) { obj.SendCommand(0x51, Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc5, 0, 3, 0, 0, 0, device, 0x50, 0, 0, 0]), true); } + else { obj.SendCommand(0x51, Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x87, (sense << 4), 3, 0, 0, 0, device, 0x51, sense, asc, asq]), true); } } // DataToHost (SCSI_READ) obj.SendDataToHost = function (device, completed, data, dma) { var dmalen = (dma) ? 0 : data.length; if (completed == true) { - obj.SendCommand(0x54, String.fromCharCode(0, (data.length & 0xff), (data.length >> 8), 0, dma ? 0xb4 : 0xb5, 0, 2, 0, (dmalen & 0xff), (dmalen >> 8), device, 0x58, 0x85, 0, 3, 0, 0, 0, device, 0x50, 0, 0, 0, 0, 0, 0) + data, completed, dma); + obj.SendCommand(0x54, Buffer.concat([Buffer.from([0, (data.length & 0xff), (data.length >> 8), 0, dma ? 0xb4 : 0xb5, 0, 2, 0, (dmalen & 0xff), (dmalen >> 8), device, 0x58, 0x85, 0, 3, 0, 0, 0, device, 0x50, 0, 0, 0, 0, 0, 0]), data]), completed, dma); } else { - obj.SendCommand(0x54, String.fromCharCode(0, (data.length & 0xff), (data.length >> 8), 0, dma ? 0xb4 : 0xb5, 0, 2, 0, (dmalen & 0xff), (dmalen >> 8), device, 0x58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + data, completed, dma); + obj.SendCommand(0x54, Buffer.concat([Buffer.from([0, (data.length & 0xff), (data.length >> 8), 0, dma ? 0xb4 : 0xb5, 0, 2, 0, (dmalen & 0xff), (dmalen >> 8), device, 0x58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), data]), completed, dma); } } // GetDataFromHost (SCSI_CHUNK) obj.SendGetDataFromHost = function (device, chunksize) { - obj.SendCommand(0x52, String.fromCharCode(0, (chunksize & 0xff), (chunksize >> 8), 0, 0xb5, 0, 0, 0, (chunksize & 0xff), (chunksize >> 8), device, 0x58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), false); + obj.SendCommand(0x52, Buffer.from([0, (chunksize & 0xff), (chunksize >> 8), 0, 0xb5, 0, 0, 0, (chunksize & 0xff), (chunksize >> 8), device, 0x58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), false); } // DisableEnableFeatures (STATUS_DATA) // If type is REGS_TOGGLE (3), 4 bytes of data must be provided. - obj.SendDisableEnableFeatures = function (type, data) { if (data == null) { data = ''; } obj.SendCommand(0x48, String.fromCharCode(type) + data); } + obj.SendDisableEnableFeatures = function (type, data) { if (data == null) { data = ''; } obj.SendCommand(0x48, Buffer.concat([Buffer.from([type]), data])); } // Private method obj.ProcessDataEx = function () { @@ -223,130 +211,128 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { // First 8 bytes are the header // CommandID + 0x000000 + Sequence Number + //console.log('ProcessDataEx', obj.acc[0], obj.acc); - switch(obj.acc.charCodeAt(0)) { + switch (obj.acc[0]) { case 0x41: // OPEN_SESSION if (obj.acc.length < 30) return 0; - var len = obj.acc.charCodeAt(29); + var len = obj.acc[29]; if (obj.acc.length < (30 + len)) return 0; obj.iderinfo = {}; - obj.iderinfo.major = obj.acc.charCodeAt(8); - obj.iderinfo.minor = obj.acc.charCodeAt(9); - obj.iderinfo.fwmajor = obj.acc.charCodeAt(10); - obj.iderinfo.fwminor = obj.acc.charCodeAt(11); - obj.iderinfo.readbfr = webserver.common.ReadShortX(obj.acc, 16); - obj.iderinfo.writebfr = webserver.common.ReadShortX(obj.acc, 18); - obj.iderinfo.proto = obj.acc.charCodeAt(21); - obj.iderinfo.iana = webserver.common.ReadIntX(obj.acc, 25); - debug(obj.iderinfo); + obj.iderinfo.major = obj.acc[8]; + obj.iderinfo.minor = obj.acc[9]; + obj.iderinfo.fwmajor = obj.acc[10]; + obj.iderinfo.fwminor = obj.acc[11]; + obj.iderinfo.readbfr = ReadShortX(obj.acc, 16); + obj.iderinfo.writebfr = ReadShortX(obj.acc, 18); + obj.iderinfo.proto = obj.acc[21]; + obj.iderinfo.iana = ReadIntX(obj.acc, 25); + if (obj.debug) console.log(obj.iderinfo); if (obj.iderinfo.proto != 0) { - debug("Unknown proto", obj.iderinfo.proto); + if (obj.debug) console.log("Unknown proto", obj.iderinfo.proto); obj.Stop(); } if (obj.iderinfo.readbfr > 8192) { - debug("Illegal read buffer size", obj.iderinfo.readbfr); + if (obj.debug) console.log("Illegal read buffer size", obj.iderinfo.readbfr); obj.Stop(); } if (obj.iderinfo.writebfr > 8192) { - debug("Illegal write buffer size", obj.iderinfo.writebfr); + if (obj.debug) console.log("Illegal write buffer size", obj.iderinfo.writebfr); obj.Stop(); } - if (obj.iderStart == 0) { obj.SendDisableEnableFeatures(3, webserver.common.IntToStrX(0x01 + 0x08)); } // OnReboot - else if (obj.iderStart == 1) { obj.SendDisableEnableFeatures(3, webserver.common.IntToStrX(0x01 + 0x10)); } // Graceful - else if (obj.iderStart == 2) { obj.SendDisableEnableFeatures(3, webserver.common.IntToStrX(0x01 + 0x18)); } // Now + if (obj.iderStart == 0) { obj.SendDisableEnableFeatures(3, IntToStrX(0x01 + 0x08)); } // OnReboot + else if (obj.iderStart == 1) { obj.SendDisableEnableFeatures(3, IntToStrX(0x01 + 0x10)); } // Graceful + else if (obj.iderStart == 2) { obj.SendDisableEnableFeatures(3, IntToStrX(0x01 + 0x18)); } // Now //obj.SendDisableEnableFeatures(1); // GetSupportedFeatures return 30 + len; case 0x43: // CLOSE - debug('CLOSE'); + if (obj.debug) console.log('CLOSE'); obj.Stop(); return 8; case 0x44: // KEEPALIVEPING obj.SendCommand(0x45); // Send PONG back return 8; case 0x45: // KEEPALIVEPONG - debug('PONG'); + if (obj.debug) console.log('PONG'); return 8; case 0x46: // RESETOCCURED if (obj.acc.length < 9) return 0; - var resetMask = obj.acc.charCodeAt(8); + var resetMask = obj.acc[8]; if (g_media === null) { // No operations are pending obj.SendCommand(0x47); // Send ResetOccuredResponse - debug('RESETOCCURED1', resetMask); + if (obj.debug) console.log('RESETOCCURED1', resetMask); } else { // Operations are being done, sent the reset once completed. g_reset = true; - debug('RESETOCCURED2', resetMask); + if (obj.debug) console.log('RESETOCCURED2', resetMask); } return 9; case 0x49: // STATUS_DATA - DisableEnableFeaturesReply if (obj.acc.length < 13) return 0; - var type = obj.acc.charCodeAt(8); - var value = webserver.common.ReadIntX(obj.acc, 9); - debug('STATUS_DATA', type, value); - switch (type) - { + var type = obj.acc[8]; + var value = ReadIntX(obj.acc, 9); + if (obj.debug) console.log('STATUS_DATA', type, value); + switch (type) { case 1: // REGS_AVAIL if (value & 1) { - if (obj.iderStart == 0) { obj.SendDisableEnableFeatures(3, webserver.common.IntToStrX(0x01 + 0x08)); } // OnReboot - else if (obj.iderStart == 1) { obj.SendDisableEnableFeatures(3, webserver.common.IntToStrX(0x01 + 0x10)); } // Graceful - else if (obj.iderStart == 2) { obj.SendDisableEnableFeatures(3, webserver.common.IntToStrX(0x01 + 0x18)); } // Now + if (obj.iderStart == 0) { obj.SendDisableEnableFeatures(3, IntToStrX(0x01 + 0x08)); } // OnReboot + else if (obj.iderStart == 1) { obj.SendDisableEnableFeatures(3, IntToStrX(0x01 + 0x10)); } // Graceful + else if (obj.iderStart == 2) { obj.SendDisableEnableFeatures(3, IntToStrX(0x01 + 0x18)); } // Now } break; case 2: // REGS_STATUS obj.enabled = (value & 2) ? true : false; - debug("IDER Status: " + obj.enabled); + if (obj.debug) console.log("IDER Status: " + obj.enabled); break; case 3: // REGS_TOGGLE if (value != 1) { - debug("Register toggle failure"); + if (obj.debug) console.log("Register toggle failure"); } //else { obj.SendDisableEnableFeatures(2); } break; } return 13; case 0x4A: // ERROR OCCURED if (obj.acc.length < 11) return 0; - debug('IDER: ABORT', obj.acc.charCodeAt(8)); + if (obj.debug) console.log('IDER: ABORT', obj.acc[8]); //obj.Stop(); return 11; case 0x4B: // HEARTBEAT - //debug('HEARTBEAT'); + //console.log('HEARTBEAT'); return 8; case 0x50: // COMMAND WRITTEN if (obj.acc.length < 28) return 0; - var device = (obj.acc.charCodeAt(14) & 0x10) ? 0xB0 : 0xA0; - var deviceFlags = obj.acc.charCodeAt(14); - var cdb = obj.acc.substring(16, 28); - var featureRegister = obj.acc.charCodeAt(9); - debug('SCSI_CMD', device, webserver.common.rstr2hex(cdb), featureRegister, deviceFlags); + var device = (obj.acc[14] & 0x10) ? 0xB0 : 0xA0; + var deviceFlags = obj.acc[14]; + var cdb = obj.acc.slice(16, 28); + var featureRegister = obj.acc[9]; + if (obj.debug) console.log('SCSI_CMD', device, cdb.toString('hex'), featureRegister, deviceFlags); handleSCSI(device, cdb, featureRegister, deviceFlags); return 28; case 0x53: // DATA FROM HOST if (obj.acc.length < 14) return 0; - var len = webserver.common.ReadShortX(obj.acc, 9); + var len = ReadShortX(obj.acc, 9); if (obj.acc.length < (14 + len)) return 0; - debug('SCSI_WRITE, len = ' + (14 + len)); - obj.SendCommand(0x51, String.fromCharCode(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x70, 0x03, 0x00, 0x00, 0x00, 0xa0, 0x51, 0x07, 0x27, 0x00), true); + if (obj.debug) console.log('SCSI_WRITE, len = ' + (14 + len)); + obj.SendCommand(0x51, Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x70, 0x03, 0x00, 0x00, 0x00, 0xa0, 0x51, 0x07, 0x27, 0x00]), true); return 14 + len; default: - debug('Unknown IDER command', obj.acc[0]); + if (obj.debug) console.log('Unknown IDER command', obj.acc[0]); obj.Stop(); break; } return 0; } - function handleSCSI(dev, cdb, featureRegister, deviceFlags) - { + function handleSCSI(dev, cdb, featureRegister, deviceFlags) { var lba; var len; - switch(cdb.charCodeAt(0)) - { + switch (cdb[0]) { case 0x00: // TEST_UNIT_READY: - debug("SCSI: TEST_UNIT_READY", dev); + if (obj.debug) console.log("SCSI: TEST_UNIT_READY", dev); switch (dev) { case 0xA0: // DEV_FLOPPY if (obj.floppy == null) { obj.SendCommandEndResponse(1, 0x02, dev, 0x3a, 0x00); return -1; } @@ -357,34 +343,34 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { if (obj.cdromReady == false) { obj.cdromReady = true; obj.SendCommandEndResponse(1, 0x06, dev, 0x28, 0x00); return -1; } // Switch to ready break; default: - debug("SCSI Internal error 3", dev); + if (obj.debug) console.log("SCSI Internal error 3", dev); return -1; } obj.SendCommandEndResponse(1, 0x00, dev, 0x00, 0x00); // Indicate ready break; case 0x08: // READ_6 - lba = ((cdb.charCodeAt(1) & 0x1f) << 16) + (cdb.charCodeAt(2) << 8) + cdb.charCodeAt(3); - len = cdb.charCodeAt(4); + lba = ((cdb[1] & 0x1f) << 16) + (cdb[2] << 8) + cdb[3]; + len = cdb[4]; if (len == 0) { len = 256; } - debug("SCSI: READ_6", dev, lba, len); + if (obj.debug) console.log("SCSI: READ_6", dev, lba, len); sendDiskData(dev, lba, len, featureRegister); break; case 0x0a: // WRITE_6 - lba = ((cdb.charCodeAt(1) & 0x1f) << 16) + (cdb.charCodeAt(2) << 8) + cdb.charCodeAt(3); - len = cdb.charCodeAt(4); + lba = ((cdb[1] & 0x1f) << 16) + (cdb[2] << 8) + cdb[3]; + len = cdb[4]; if (len == 0) { len = 256; } - debug("SCSI: WRITE_6", dev, lba, len); + if (obj.debug) console.log("SCSI: WRITE_6", dev, lba, len); obj.SendCommandEndResponse(1, 0x02, dev, 0x3a, 0x00); // Write is not supported, remote no medium. return -1; - /* - case 0x15: // MODE_SELECT_6: - debug("SCSI ERROR: MODE_SELECT_6", dev); - obj.SendCommandEndResponse(1, 0x05, dev, 0x20, 0x00); - return -1; - */ + /* + case 0x15: // MODE_SELECT_6: + console.log("SCSI ERROR: MODE_SELECT_6", dev); + obj.SendCommandEndResponse(1, 0x05, dev, 0x20, 0x00); + return -1; + */ case 0x1a: // MODE_SENSE_6 - debug("SCSI: MODE_SENSE_6", dev); - if ((cdb.charCodeAt(2) == 0x3f) && (cdb.charCodeAt(3) == 0x00)) { + if (obj.debug) console.log("SCSI: MODE_SENSE_6", dev); + if ((cdb[2] == 0x3f) && (cdb[3] == 0x00)) { var a = 0, b = 0; switch (dev) { case 0xA0: // DEV_FLOPPY @@ -398,90 +384,89 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { b = 0x80; break; default: - debug("SCSI Internal error 6", dev); + if (obj.debug) console.log("SCSI Internal error 6", dev); return -1; } - obj.SendDataToHost(dev, true, String.fromCharCode(0, a, b, 0), featureRegister & 1); + obj.SendDataToHost(dev, true, Buffer.from([0, a, b, 0]), featureRegister & 1); return; } obj.SendCommandEndResponse(1, 0x05, dev, 0x24, 0x00); break; case 0x1b: // START_STOP (Called when you eject the CDROM) - //var immediate = cdb.charCodeAt(1) & 0x01; - //var loej = cdb.charCodeAt(4) & 0x02; - //var start = cdb.charCodeAt(4) & 0x01; + //var immediate = cdb[1] & 0x01; + //var loej = cdb[4] & 0x02; + //var start = cdb[4] & 0x01; obj.SendCommandEndResponse(1, 0, dev); break; case 0x1e: // LOCK_UNLOCK - ALLOW_MEDIUM_REMOVAL - debug("SCSI: ALLOW_MEDIUM_REMOVAL", dev); + if (obj.debug) console.log("SCSI: ALLOW_MEDIUM_REMOVAL", dev); if ((dev == 0xA0) && (obj.floppy == null)) { obj.SendCommandEndResponse(1, 0x02, dev, 0x3a, 0x00); return -1; } if ((dev == 0xB0) && (obj.cdrom == null)) { obj.SendCommandEndResponse(1, 0x02, dev, 0x3a, 0x00); return -1; } obj.SendCommandEndResponse(1, 0x00, dev, 0x00, 0x00); break; case 0x23: // READ_FORMAT_CAPACITIES (Floppy only) - debug("SCSI: READ_FORMAT_CAPACITIES", dev); - var buflen = webserver.common.ReadShort(cdb, 7); + if (obj.debug) console.log("SCSI: READ_FORMAT_CAPACITIES", dev); + var buflen = ReadShort(cdb, 7); var mediaStatus = 0, sectors; var mcSize = buflen / 8; // Capacity descriptor size is 8 switch (dev) { case 0xA0: // DEV_FLOPPY - if ((obj.floppy == null) || (obj.floppySize == 0)) { obj.SendCommandEndResponse(0, 0x05, dev, 0x24, 0x00); return -1; } - sectors = (obj.floppySize >> 9) - 1; + if ((obj.floppy == null) || (obj.floppy.size == 0)) { obj.SendCommandEndResponse(0, 0x05, dev, 0x24, 0x00); return -1; } + sectors = (obj.floppy.size >> 9) - 1; break; case 0xB0: // DEV_CDDVD - if ((obj.cdrom == null) || (obj.cdromSize == 0)) { obj.SendCommandEndResponse(0, 0x05, dev, 0x24, 0x00); return -1; } - sectors = (obj.cdromSize >> 11) - 1; // Number 2048 byte blocks + if ((obj.cdrom == null) || (obj.cdrom.size == 0)) { obj.SendCommandEndResponse(0, 0x05, dev, 0x24, 0x00); return -1; } + sectors = (obj.cdrom.size >> 11) - 1; // Number 2048 byte blocks break; default: - debug("SCSI Internal error 4", dev); + if (obj.debug) console.log("SCSI Internal error 4", dev); return -1; } - obj.SendDataToHost(dev, true, webserver.common.IntToStr(8) + String.fromCharCode(0x00, 0x00, 0x0b, 0x40, 0x02, 0x00, 0x02, 0x00), featureRegister & 1); + obj.SendDataToHost(dev, true, Buffer.concat([IntToStr(8), Buffer.from([0x00, 0x00, 0x0b, 0x40, 0x02, 0x00, 0x02, 0x00])]), featureRegister & 1); break; case 0x25: // READ_CAPACITY - debug("SCSI: READ_CAPACITY", dev); + if (obj.debug) console.log("SCSI: READ_CAPACITY", dev); var len = 0; - switch(dev) - { + switch (dev) { case 0xA0: // DEV_FLOPPY - if ((obj.floppy == null) || (obj.floppySize == 0)) { obj.SendCommandEndResponse(0, 0x02, dev, 0x3a, 0x00); return -1; } - if (obj.floppy != null) { len = (obj.floppySize >> 9) - 1; } - debug('DEV_FLOPPY', len); // Number 512 byte blocks + if ((obj.floppy == null) || (obj.floppy.size == 0)) { obj.SendCommandEndResponse(0, 0x02, dev, 0x3a, 0x00); return -1; } + if (obj.floppy != null) { len = (obj.floppy.size >> 9) - 1; } + if (obj.debug) console.log('DEV_FLOPPY', len); // Number 512 byte blocks break; case 0xB0: // DEV_CDDVD - if ((obj.floppy == null) || (obj.floppySize == 0)) { obj.SendCommandEndResponse(0, 0x02, dev, 0x3a, 0x00); return -1; } - if (obj.cdrom != null) { len = (obj.cdromSize >> 11) - 1; } // Number 2048 byte blocks - debug('DEV_CDDVD', len); + if ((obj.cdrom == null) || (obj.cdrom.size == 0)) { obj.SendCommandEndResponse(0, 0x02, dev, 0x3a, 0x00); return -1; } + if (obj.cdrom != null) { len = (obj.cdrom.size >> 11) - 1; } // Number 2048 byte blocks + if (obj.debug) console.log('DEV_CDDVD', len); break; default: - debug("SCSI Internal error 4", dev); + if (obj.debug) console.log("SCSI Internal error 4", dev); return -1; } //if (dev == 0xA0) { dev = 0x00; } else { dev = 0x10; } // Weird but seems to work. - debug("SCSI: READ_CAPACITY2", dev, deviceFlags); - obj.SendDataToHost(deviceFlags, true, webserver.common.IntToStr(len) + String.fromCharCode(0, 0, ((dev == 0xB0) ? 0x08 : 0x02), 0), featureRegister & 1); + if (obj.debug) console.log("SCSI: READ_CAPACITY2", dev, deviceFlags); + obj.SendDataToHost(deviceFlags, true, Buffer.concat([IntToStr(len), Buffer.from([0, 0, ((dev == 0xB0) ? 0x08 : 0x02), 0])]), featureRegister & 1); break; case 0x28: // READ_10 - lba = webserver.common.ReadInt(cdb, 2); - len = webserver.common.ReadShort(cdb, 7); - debug("SCSI: READ_10", dev, lba, len); + lba = ReadInt(cdb, 2); + len = ReadShort(cdb, 7); + if (obj.debug) console.log("SCSI: READ_10", dev, lba, len); sendDiskData(dev, lba, len, featureRegister); break; case 0x2a: // WRITE_10 (Floppy only) case 0x2e: // WRITE_AND_VERIFY (Floppy only) - lba = webserver.common.ReadInt(cdb, 2); - len = webserver.common.ReadShort(cdb, 7); - debug("SCSI: WRITE_10", dev, lba, len); + lba = ReadInt(cdb, 2); + len = ReadShort(cdb, 7); + if (obj.debug) console.log("SCSI: WRITE_10", dev, lba, len); obj.SendGetDataFromHost(dev, 512 * len); // Floppy writes only, accept sectors of 512 bytes break; case 0x43: // READ_TOC (CD Audio only) - var buflen = webserver.common.ReadShort(cdb, 7); - var msf = cdb.charCodeAt(1) & 0x02; - var format = cdb.charCodeAt(2) & 0x07; - if (format == 0) { format = cdb.charCodeAt(9) >> 6; } - debug("SCSI: READ_TOC, dev=" + dev + ", buflen=" + buflen + ", msf=" + msf + ", format=" + format); + var buflen = ReadShort(cdb, 7); + var msf = cdb[1] & 0x02; + var format = cdb[2] & 0x07; + if (format == 0) { format = cdb[9] >> 6; } + if (obj.debug) console.log("SCSI: READ_TOC, dev=" + dev + ", buflen=" + buflen + ", msf=" + msf + ", format=" + format); switch (dev) { case 0xA0: // DEV_FLOPPY @@ -491,96 +476,100 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { // NOP break; default: - debug("SCSI Internal error 9", dev); + if (obj.debug) console.log("SCSI Internal error 9", dev); return -1; } - if (format == 1) { obj.SendDataToHost(dev, true, String.fromCharCode(0x00, 0x0a, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00), featureRegister & 1); } + if (format == 1) { obj.SendDataToHost(dev, true, Buffer.from([0x00, 0x0a, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00]), featureRegister & 1); } else if (format == 0) { if (msf) { - obj.SendDataToHost(dev, true, String.fromCharCode(0x00, 0x12, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x14, 0xaa, 0x00, 0x00, 0x00, 0x34, 0x13), featureRegister & 1); + obj.SendDataToHost(dev, true, Buffer.from([0x00, 0x12, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x14, 0xaa, 0x00, 0x00, 0x00, 0x34, 0x13]), featureRegister & 1); } else { - obj.SendDataToHost(dev, true, String.fromCharCode(0x00, 0x12, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00), featureRegister & 1); + obj.SendDataToHost(dev, true, Buffer.from([0x00, 0x12, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00]), featureRegister & 1); } } break; case 0x46: // GET_CONFIGURATION - var sendall = (cdb.charCodeAt(1) != 2); - var firstcode = webserver.common.ReadShort(cdb, 2); - var buflen = webserver.common.ReadShort(cdb, 7); + var sendall = (cdb[1] != 2); + var firstcode = ReadShort(cdb, 2); + var buflen = ReadShort(cdb, 7); - debug("SCSI: GET_CONFIGURATION", dev, sendall, firstcode, buflen); - - if (buflen == 0) { obj.SendDataToHost(dev, true, webserver.common.IntToStr(0x003c) + webserver.common.IntToStr(0x0008), featureRegister & 1); return -1; } // TODO: Fixed this return, it's not correct. + if (obj.debug) console.log("SCSI: GET_CONFIGURATION", dev, sendall, firstcode, buflen); + if (buflen == 0) { obj.SendDataToHost(dev, true, Buffer.concat([IntToStr(0x003c), IntToStr(0x0008)]), featureRegister & 1); return -1; } // TODO: Fixed this return, it's not correct. // Set the header - var r = webserver.common.IntToStr(0x0008); + var r = null; // Add the data - if (firstcode == 0) { r += IDE_CD_ConfigArrayProfileList; } - if ((firstcode == 0x1) || (sendall && (firstcode < 0x1))) { r += IDE_CD_ConfigArrayCore; } - if ((firstcode == 0x2) || (sendall && (firstcode < 0x2))) { r += IDE_CD_Morphing; } - if ((firstcode == 0x3) || (sendall && (firstcode < 0x3))) { r += IDE_CD_ConfigArrayRemovable; } - if ((firstcode == 0x10) || (sendall && (firstcode < 0x10))) { r += IDE_CD_ConfigArrayRandom; } - if ((firstcode == 0x1E) || (sendall && (firstcode < 0x1E))) { r += IDE_CD_Read; } - if ((firstcode == 0x100) || (sendall && (firstcode < 0x100))) { r += IDE_CD_PowerManagement; } - if ((firstcode == 0x105) || (sendall && (firstcode < 0x105))) { r += IDE_CD_Timeout; } + if (firstcode == 0) { r = IDE_CD_ConfigArrayProfileList; } + if ((firstcode == 0x1) || (sendall && (firstcode < 0x1))) { r = IDE_CD_ConfigArrayCore; } + if ((firstcode == 0x2) || (sendall && (firstcode < 0x2))) { r = IDE_CD_Morphing; } + if ((firstcode == 0x3) || (sendall && (firstcode < 0x3))) { r = IDE_CD_ConfigArrayRemovable; } + if ((firstcode == 0x10) || (sendall && (firstcode < 0x10))) { r = IDE_CD_ConfigArrayRandom; } + if ((firstcode == 0x1E) || (sendall && (firstcode < 0x1E))) { r = IDE_CD_Read; } + if ((firstcode == 0x100) || (sendall && (firstcode < 0x100))) { r = IDE_CD_PowerManagement; } + if ((firstcode == 0x105) || (sendall && (firstcode < 0x105))) { r = IDE_CD_Timeout; } - // Set the length - r = webserver.common.IntToStr(r.length) + r; + if (r == null) { + //console.log('NOT RIGHT', sendall, firstcode, cdb[2], cdb[3]); + //process.exit(0); + r = Buffer.concat([IntToStr(0x0008), IntToStr(4)]); + } else { + r = Buffer.concat([IntToStr(0x0008), IntToStr(r.length + 4), r]); + } // Cut the length to buflen if needed - if (r.length > buflen) { r = r.substring(0, buflen); } + if (r.length > buflen) { r = r.slice(0, buflen); } obj.SendDataToHost(dev, true, r, featureRegister & 1); return -1; case 0x4a: // GET_EV_STATUS - GET_EVENT_STATUS_NOTIFICATION - //var buflen = (cdb.charCodeAt(7) << 8) + cdb.charCodeAt(8); - //if (buflen == 0) { obj.SendDataToHost(dev, true, webserver.common.IntToStr(0x003c) + webserver.common.IntToStr(0x0008), featureRegister & 1); return -1; } // TODO: Fixed this return, it's not correct. - debug("SCSI: GET_EVENT_STATUS_NOTIFICATION", dev, cdb.charCodeAt(1), cdb.charCodeAt(4), cdb.charCodeAt(9)); - if ((cdb.charCodeAt(1) != 0x01) && (cdb.charCodeAt(4) != 0x10)) { - debug('SCSI ERROR'); + //var buflen = (cdb[7] << 8) + cdb[8]; + //if (buflen == 0) { obj.SendDataToHost(dev, true, Buffer.concat([IntToStr(0x003c), IntToStr(0x0008)]), featureRegister & 1); return -1; } // TODO: Fixed this return, it's not correct. + if (obj.debug) console.log("SCSI: GET_EVENT_STATUS_NOTIFICATION", dev, cdb[1], cdb[4], cdb[9]); + if ((cdb[1] != 0x01) && (cdb[4] != 0x10)) { + if (obj.debug) console.log('SCSI ERROR'); obj.SendCommandEndResponse(1, 0x05, dev, 0x26, 0x01); break; } var present = 0x00; if ((dev == 0xA0) && (obj.floppy != null)) { present = 0x02; } else if ((dev == 0xB0) && (obj.cdrom != null)) { present = 0x02; } - obj.SendDataToHost(dev, true, String.fromCharCode(0x00, present, 0x80, 0x00), featureRegister & 1); // This is the original version, 4 bytes long + obj.SendDataToHost(dev, true, Buffer.from([0x00, present, 0x80, 0x00]), featureRegister & 1); // This is the original version, 4 bytes long break; case 0x4c: - obj.SendCommand(0x51, webserver.common.IntToStrX(0) + webserver.common.IntToStrX(0) + webserver.common.IntToStrX(0) + String.fromCharCode(0x87, 0x50, 0x03, 0x00, 0x00, 0x00, 0xb0, 0x51, 0x05, 0x20, 0x00), true); + obj.SendCommand(0x51, Buffer.concat([IntToStrX(0), IntToStrX(0), IntToStrX(0), Buffer.from([0x87, 0x50, 0x03, 0x00, 0x00, 0x00, 0xb0, 0x51, 0x05, 0x20, 0x00])]), true); break; case 0x51: // READ_DISC_INFO - debug("SCSI READ_DISC_INFO", dev); + if (obj.debug) console.log("SCSI READ_DISC_INFO", dev); obj.SendCommandEndResponse(0, 0x05, dev, 0x20, 0x00); // Correct return -1; case 0x55: // MODE_SELECT_10: - debug("SCSI ERROR: MODE_SELECT_10", dev); + if (obj.debug) console.log("SCSI ERROR: MODE_SELECT_10", dev); obj.SendCommandEndResponse(1, 0x05, dev, 0x20, 0x00); return -1; case 0x5a: // MODE_SENSE_10 - debug("SCSI: MODE_SENSE_10", dev, cdb.charCodeAt(2) & 0x3f); - var buflen = webserver.common.ReadShort(cdb, 7); - //var pc = cdb.charCodeAt(2) & 0xc0; + if (obj.debug) console.log("SCSI: MODE_SENSE_10", dev, cdb[2] & 0x3f); + var buflen = ReadShort(cdb, 7); + //var pc = cdb[2] & 0xc0; var r = null; - - if (buflen == 0) { obj.SendDataToHost(dev, true, webserver.common.IntToStr(0x003c) + webserver.common.IntToStr(0x0008), featureRegister & 1); return -1; } // TODO: Fixed this return, it's not correct. + + if (buflen == 0) { obj.SendDataToHost(dev, true, Buffer.concat([IntToStr(0x003c), IntToStr(0x0008)]), featureRegister & 1); return -1; } // TODO: Fixed this return, it's not correct. // 1.44 mb floppy or LS120 (sectorCount == 0x3c300) var sectorCount = 0; if (dev == 0xA0) { - if (obj.floppy != null) { sectorCount = (obj.floppySize >> 9); } + if (obj.floppy != null) { sectorCount = (obj.floppy.size >> 9); } } else { - if (obj.cdrom != null) { sectorCount = (obj.cdromSize >> 11); } + if (obj.cdrom != null) { sectorCount = (obj.cdrom.size >> 11); } } - switch (cdb.charCodeAt(2) & 0x3f) { - case 0x01: if (dev == 0xA0) { r = (sectorCount <= 0xb40)?IDE_ModeSence_FloppyError_Recovery_Array:IDE_ModeSence_Ls120Error_Recovery_Array; } else { r = IDE_ModeSence_CDError_Recovery_Array; } break; - case 0x05: if (dev == 0xA0) { r = (sectorCount <= 0xb40)?IDE_ModeSence_FloppyDisk_Page_Array:IDE_ModeSence_LS120Disk_Page_Array; } break; - case 0x3f: if (dev == 0xA0) { r = (sectorCount <= 0xb40)?IDE_ModeSence_3F_Floppy_Array:IDE_ModeSence_3F_LS120_Array; } else { r = IDE_ModeSence_3F_CD_Array; } break; + switch (cdb[2] & 0x3f) { + case 0x01: if (dev == 0xA0) { r = (sectorCount <= 0xb40) ? IDE_ModeSence_FloppyError_Recovery_Array : IDE_ModeSence_Ls120Error_Recovery_Array; } else { r = IDE_ModeSence_CDError_Recovery_Array; } break; + case 0x05: if (dev == 0xA0) { r = (sectorCount <= 0xb40) ? IDE_ModeSence_FloppyDisk_Page_Array : IDE_ModeSence_LS120Disk_Page_Array; } break; + case 0x3f: if (dev == 0xA0) { r = (sectorCount <= 0xb40) ? IDE_ModeSence_3F_Floppy_Array : IDE_ModeSence_3F_LS120_Array; } else { r = IDE_ModeSence_3F_CD_Array; } break; case 0x1A: if (dev == 0xB0) { r = IDE_ModeSence_CD_1A_Array; } break; - case 0x1D: if (dev == 0xB0) { r = IDE_ModeSence_CD_1D_Array; } break; + case 0x1D: if (dev == 0xB0) { r = IDE_ModeSence_CD_1D_Array; } break; case 0x2A: if (dev == 0xB0) { r = IDE_ModeSence_CD_2A_Array; } break; } @@ -599,7 +588,7 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { obj.SendDataToHost(dev, true, RD_CD_Performance, featureRegister & 1); break; default: // UNKNOWN COMMAND - debug("IDER: Unknown SCSI command", cdb.charCodeAt(0)); + if (obj.debug) console.log("IDER: Unknown SCSI command", cdb[0]); obj.SendCommandEndResponse(0, 0x05, dev, 0x20, 0x00); return -1; } @@ -609,8 +598,8 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { function sendDiskData(dev, lba, len, featureRegister) { var media = null; var mediaBlocks = 0; - if (dev == 0xA0) { media = obj.floppy; if (obj.floppy != null) { mediaBlocks = (obj.floppySize >> 9); } } - if (dev == 0xB0) { media = obj.cdrom; if (obj.cdrom != null) { mediaBlocks = (obj.cdromSize >> 11); } } + if (dev == 0xA0) { media = obj.floppy; if (obj.floppy != null) { mediaBlocks = (obj.floppy.size >> 9); } } + if (dev == 0xB0) { media = obj.cdrom; if (obj.cdrom != null) { mediaBlocks = (obj.cdrom.size >> 11); } } if ((len < 0) || (lba + len > mediaBlocks)) { obj.SendCommandEndResponse(1, 0x05, dev, 0x21, 0x00); return 0; } if (len == 0) { obj.SendCommandEndResponse(1, 0x00, dev, 0x00, 0x00); return 0; } if (media != null) { @@ -637,9 +626,10 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { if (g_len > obj.iderinfo.readbfr) { len = obj.iderinfo.readbfr; } g_len -= len; g_lba += len; + var buffer = Buffer.alloc(len); - fs.read(g_media, buffer, 0, len, lba, function (error, bytesRead, buffer) { - obj.SendDataToHost(g_dev, (g_len == 0), buffer.toString('binary'), featureRegister & 1); + fs.read(g_media.ptr, buffer, 0, len, lba, function (error, bytesRead, buffer) { + obj.SendDataToHost(g_dev, (g_len == 0), buffer, featureRegister & 1); if ((g_len > 0) && (g_reset == false)) { sendDiskDataEx(featureRegister); } else { @@ -652,3 +642,13 @@ module.exports.CreateAmtRemoteIder = function (webserver, meshcentral) { return obj; } + +function ShortToStr(v) { return Buffer.from([(v >> 8) & 0xFF, v & 0xFF]); } +function ShortToStrX(v) { return Buffer.from([v & 0xFF, (v >> 8) & 0xFF]); } +function IntToStr(v) { return Buffer.from([(v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF]); } +function IntToStrX(v) { return Buffer.from([v & 0xFF, (v >> 8) & 0xFF, (v >> 16) & 0xFF, (v >> 24) & 0xFF]); } +function ReadShort(v, p) { return (v[p] << 8) + v[p + 1]; } +function ReadShortX(v, p) { return (v[p + 1] << 8) + v[p]; } +function ReadInt(v, p) { return (v[p] * 0x1000000) + (v[p + 1] << 16) + (v[p + 2] << 8) + v[p + 3]; } // We use "*0x1000000" instead of "<<24" because the shift converts the number to signed int32. +function ReadSInt(v, p) { return (v[p] << 24) + (v[p + 1] << 16) + (v[p + 2] << 8) + v[p + 3]; } +function ReadIntX(v, p) { return (v[p + 3] * 0x1000000) + (v[p + 2] << 16) + (v[p + 1] << 8) + v[p]; } \ No newline at end of file diff --git a/amt/amt-redir-mesh.js b/amt/amt-redir-mesh.js index 28f6e481..cdc49342 100644 --- a/amt/amt-redir-mesh.js +++ b/amt/amt-redir-mesh.js @@ -44,10 +44,10 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me obj.redirTrace = false; obj.tls1only = 0; // TODO - obj.amtaccumulator = ""; + obj.amtaccumulator = ''; obj.amtsequence = 1; obj.amtkeepalivetimer = null; - obj.authuri = "/RedirectionService"; + obj.authuri = '/RedirectionService'; obj.onStateChanged = null; obj.forwardclient = null; @@ -71,7 +71,7 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me const SITERIGHT_LOCKED = 32; function Debug(lvl) { - if ((arguments.length < 2) || (lvl > meshcentral.debugLevel)) return; + if ((arguments.length < 2) || (meshcentral.debugLevel == null) || (lvl > meshcentral.debugLevel)) return; var a = []; for (var i = 1; i < arguments.length; i++) { a.push(arguments[i]); } console.log(...a); } @@ -81,7 +81,7 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me var obj = new require('stream').Duplex(options); obj.forwardwrite = null; obj.updateBuffer = function (chunk) { this.push(chunk); }; - obj._write = function (chunk, encoding, callback) { if (obj.forwardwrite != null) { obj.forwardwrite(chunk); } else { console.err("Failed to fwd _write."); } if (callback) callback(); }; // Pass data written to forward + obj._write = function (chunk, encoding, callback) { if (obj.forwardwrite != null) { obj.forwardwrite(chunk); } else { console.err('Failed to fwd _write.'); } if (callback) callback(); }; // Pass data written to forward obj._read = function (size) { }; // Push nothing, anything to read should be pushed from updateBuffer() return obj; } @@ -478,10 +478,21 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me } obj.xxSend = function (x) { - if (obj.redirTrace) { console.log("REDIR-SEND(" + x.length + "): " + Buffer.from(x, "binary").toString('hex'), typeof x); } - //obj.Debug("Send(" + x.length + "): " + webserver.common.rstr2hex(x)); - //obj.forwardclient.write(x); // FIXES CIRA - obj.forwardclient.write(Buffer.from(x, "binary")); + if (typeof x == 'string') { + //if (obj.redirTrace) { + //console.log("REDIR-SEND1(" + x.length + "): " + Buffer.from(x, 'binary').toString('hex'), typeof x); + //} + //obj.Debug("Send(" + x.length + "): " + webserver.common.rstr2hex(x)); + //obj.forwardclient.write(x); // FIXES CIRA + obj.forwardclient.write(Buffer.from(x, 'binary')); + } else { + //if (obj.redirTrace) { + //console.log("REDIR-SEND2(" + x.length + "): " + x.toString('hex'), typeof x); + //} + //obj.Debug("Send(" + x.length + "): " + webserver.common.rstr2hex(x)); + //obj.forwardclient.write(x); // FIXES CIRA + obj.forwardclient.write(x); + } } obj.Send = function (x) { diff --git a/public/commander.htm b/public/commander.htm index 2960fab3..5e128dd8 100644 --- a/public/commander.htm +++ b/public/commander.htm @@ -1,4 +1,4 @@ -
  
Disconnected