@iobroker/socket-classes 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/lib/socketCommands.js +25 -27
- package/lib/socketCommandsAdmin.js +1 -0
- package/lib/socketCommon.js +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/socketCommands.js
CHANGED
|
@@ -626,34 +626,32 @@ class SocketCommands {
|
|
|
626
626
|
// host can answer following commands: cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo,
|
|
627
627
|
// delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost
|
|
628
628
|
if (this._checkPermissions(socket, protectedCommands.includes(command) ? 'cmdExec' : 'sendToHost', callback, command)) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
if (!zipFiles) {
|
|
635
|
-
const utils = require('@iobroker/adapter-core'); // Get common adapter utils
|
|
636
|
-
zipFiles = require(utils.controllerDir + '/lib/zipFiles.js');
|
|
637
|
-
}
|
|
638
|
-
zipFiles
|
|
639
|
-
.writeDirAsZip(
|
|
640
|
-
this.adapter, // normally we have to pass here the internal "objects" object, but as
|
|
641
|
-
// only writeFile is used, and it has the same name we can pass here the
|
|
642
|
-
// adapter, which has the function with the same name and arguments
|
|
643
|
-
message.id,
|
|
644
|
-
message.name,
|
|
645
|
-
Buffer.from(message.data, 'base64'),
|
|
646
|
-
message.options,
|
|
647
|
-
error => callback({ error }) // this is for back compatibility with js-controller@4.0 or older
|
|
648
|
-
)
|
|
649
|
-
.then(() => callback({}))
|
|
650
|
-
.catch(error => {
|
|
651
|
-
this.adapter.log.error(`Cannot write zip file as folder: ${error}`);
|
|
652
|
-
callback({ error });
|
|
653
|
-
});
|
|
654
|
-
} else {
|
|
655
|
-
this.adapter.sendToHost(host, command, message, callback);
|
|
629
|
+
// Try to decode this file locally as redis has a limitation for files bigger than 20MB
|
|
630
|
+
if (command === 'writeDirAsZip' && message && message.data.length > 1024 * 1024) {
|
|
631
|
+
if (!zipFiles) {
|
|
632
|
+
const utils = require('@iobroker/adapter-core'); // Get common adapter utils
|
|
633
|
+
zipFiles = require(utils.controllerDir + '/lib/zipFiles.js');
|
|
656
634
|
}
|
|
635
|
+
zipFiles
|
|
636
|
+
.writeDirAsZip(
|
|
637
|
+
this.adapter, // normally we have to pass here the internal "objects" object, but as
|
|
638
|
+
// only writeFile is used, and it has the same name we can pass here the
|
|
639
|
+
// adapter, which has the function with the same name and arguments
|
|
640
|
+
message.id,
|
|
641
|
+
message.name,
|
|
642
|
+
Buffer.from(message.data, 'base64'),
|
|
643
|
+
message.options,
|
|
644
|
+
error => callback({ error }) // this is for back compatibility with js-controller@4.0 or older
|
|
645
|
+
)
|
|
646
|
+
.then(() => callback({}))
|
|
647
|
+
.catch(error => {
|
|
648
|
+
this.adapter.log.error(`Cannot write zip file as folder: ${error}`);
|
|
649
|
+
callback({ error });
|
|
650
|
+
});
|
|
651
|
+
} else if (this._sendToHost) {
|
|
652
|
+
this._sendToHost(host, command, message, callback);
|
|
653
|
+
} else {
|
|
654
|
+
this.adapter.sendToHost(host, command, message, callback);
|
|
657
655
|
}
|
|
658
656
|
}
|
|
659
657
|
};
|
|
@@ -171,6 +171,7 @@ class SocketCommandsAdmin extends SocketCommands {
|
|
|
171
171
|
delete this.cache[hash];
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
+
|
|
174
175
|
this.adapter.sendToHost(host, command, message, res => {
|
|
175
176
|
if (!message && SocketCommandsAdmin.ALLOW_CACHE.includes(command)) {
|
|
176
177
|
this.cache[hash] = {ts: Date.now(), res: JSON.stringify(res)};
|
package/lib/socketCommon.js
CHANGED
|
@@ -108,14 +108,23 @@ class SocketCommon {
|
|
|
108
108
|
this.server.on('error', (error, details) => {
|
|
109
109
|
// ignore "failed connection" as it already shown
|
|
110
110
|
if (!error || !error.message || !error.message.includes('failed connection')) {
|
|
111
|
-
|
|
111
|
+
if (error && error.message && error.message.includes('authentication failed')) {
|
|
112
|
+
this.adapter.log.debug(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
|
|
113
|
+
} else {
|
|
114
|
+
this.adapter.log.error(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
|
|
115
|
+
}
|
|
112
116
|
}
|
|
113
117
|
});
|
|
118
|
+
|
|
114
119
|
// support of dynamic namespaces (because of reverse proxy)
|
|
115
120
|
this.allNamespaces && this.allNamespaces.on('error', (error, details) => {
|
|
116
121
|
// ignore "failed connection" as it already shown
|
|
117
122
|
if (!error || !error.message || !error.message.includes('failed connection')) {
|
|
118
|
-
|
|
123
|
+
if (error && error.message && error.message.includes('authentication failed')) {
|
|
124
|
+
this.adapter.log.debug(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
|
|
125
|
+
} else {
|
|
126
|
+
this.adapter.log.error(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
|
|
127
|
+
}
|
|
119
128
|
}
|
|
120
129
|
});
|
|
121
130
|
|