@gibme/mikrotik 2.0.0 → 2.0.1
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/dist/index.js +15 -2
- package/dist/types.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -375,14 +375,27 @@ class Mikrotik extends ssh_1.default {
|
|
|
375
375
|
});
|
|
376
376
|
}
|
|
377
377
|
this.on('stream', handleStream);
|
|
378
|
+
const cleanup = () => __awaiter(this, void 0, void 0, function* () {
|
|
379
|
+
this.off('stream', handleStream);
|
|
380
|
+
yield Mikrotik.cache.del(target);
|
|
381
|
+
});
|
|
378
382
|
yield Mikrotik.cache.set(target, target, options.duration); // set our mutex
|
|
379
|
-
yield this.stream(`/tool bandwidth-test protocol=${options.protocol} ` +
|
|
383
|
+
const cancel = yield this.stream(`/tool bandwidth-test protocol=${options.protocol} ` +
|
|
380
384
|
`user=${username} password=${password} ` +
|
|
381
385
|
`duration=${options.duration}s direction=${options.direction} ` +
|
|
382
386
|
`address=${target} random-data=${options.random_data ? 'yes' : 'no'} interval=1s`, {
|
|
383
387
|
separator: '\r\n\r\n'
|
|
384
388
|
});
|
|
385
|
-
|
|
389
|
+
this.once('stream_complete', () => __awaiter(this, void 0, void 0, function* () {
|
|
390
|
+
yield cleanup();
|
|
391
|
+
}));
|
|
392
|
+
this.once('stream_cancelled', () => __awaiter(this, void 0, void 0, function* () {
|
|
393
|
+
yield cleanup();
|
|
394
|
+
return reject(new Error('Bandwidth Test Cancelled'));
|
|
395
|
+
}));
|
|
396
|
+
if (options.timeout) {
|
|
397
|
+
setTimeout(cancel, options.timeout);
|
|
398
|
+
}
|
|
386
399
|
}));
|
|
387
400
|
});
|
|
388
401
|
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gibme/mikrotik",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A simple mikrotik helper/wrapper",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@gibme/cache": "^1.1.5",
|
|
59
|
-
"@gibme/ssh": "^1.0.
|
|
59
|
+
"@gibme/ssh": "^1.0.3",
|
|
60
60
|
"@types/jsbn": "^1.2.33",
|
|
61
61
|
"ip-address": "^9.0.5",
|
|
62
62
|
"semver": "^7.6.2"
|