@iobroker/socket-classes 0.4.7 → 0.4.10

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 CHANGED
@@ -69,6 +69,12 @@ io.close();
69
69
  -->
70
70
 
71
71
  ## Changelog
72
+ ### 0.4.10 (2022-06-22)
73
+ * (bluefox) Corrected getAdapterInstances
74
+
75
+ ### 0.4.9 (2022-06-20)
76
+ * (bluefox) Do not show error with failed authentication
77
+
72
78
  ### 0.4.7 (2022-06-20)
73
79
  * (bluefox) Allowed to overload system language
74
80
 
@@ -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
- if (this.sendToHost) {
630
- this.sendToHost(host, command, message, callback);
631
- } else {
632
- // Try to decode this file locally as redis has a limitation for files bigger than 20MB
633
- if (command === 'writeDirAsZip' && message && message.data.length > 1024 * 1024) {
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
  };
@@ -887,9 +885,9 @@ class SocketCommands {
887
885
  this.commands['getAdapterInstances'] = (socket, adapterName, callback) => {
888
886
  if (typeof callback === 'function') {
889
887
  if (this._checkPermissions(socket, 'getObject', callback)) {
890
- let _adapterName = adapterName || this.adapterName || '';
888
+ let _adapterName = adapterName !== undefined && adapterName !== null ? adapterName : this.adapterName || '';
891
889
  if (_adapterName) {
892
- _adapterName += '.'
890
+ _adapterName += '.';
893
891
  }
894
892
  this.adapter.getObjectView('system', 'instance',
895
893
  {startkey: `system.adapter.${_adapterName}`, endkey: `system.adapter.${_adapterName}\u9999`},
@@ -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)};
@@ -108,14 +108,25 @@ 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
- this.adapter.log.error(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
111
+ if ((error && error.message && error.message.includes('authentication failed') ||
112
+ (details && details.includes('authentication failed')))
113
+ ) {
114
+ this.adapter.log.debug(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
115
+ } else {
116
+ this.adapter.log.error(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
117
+ }
112
118
  }
113
119
  });
120
+
114
121
  // support of dynamic namespaces (because of reverse proxy)
115
122
  this.allNamespaces && this.allNamespaces.on('error', (error, details) => {
116
123
  // ignore "failed connection" as it already shown
117
124
  if (!error || !error.message || !error.message.includes('failed connection')) {
118
- this.adapter.log.error(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
125
+ if (error && error.message && error.message.includes('authentication failed')) {
126
+ this.adapter.log.debug(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
127
+ } else {
128
+ this.adapter.log.error(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
129
+ }
119
130
  }
120
131
  });
121
132
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/socket-classes",
3
- "version": "0.4.7",
3
+ "version": "0.4.10",
4
4
  "description": "ioBroker server-side web sockets",
5
5
  "author": {
6
6
  "name": "bluefox",