@gibme/mikrotik 2.0.0 → 2.0.2
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.d.ts +2 -2
- package/dist/index.js +23 -3
- package/dist/types.d.ts +9 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -108,12 +108,12 @@ export default class Mikrotik extends SSH {
|
|
|
108
108
|
* @param command
|
|
109
109
|
* @protected
|
|
110
110
|
*/
|
|
111
|
-
|
|
111
|
+
terse<Type extends object = any>(command: string): Promise<Type[]>;
|
|
112
112
|
/**
|
|
113
113
|
* Executes a command that expects the result as a 'table' of key-value pairs separated by a colon (:)
|
|
114
114
|
*
|
|
115
115
|
* @param command
|
|
116
116
|
* @protected
|
|
117
117
|
*/
|
|
118
|
-
|
|
118
|
+
kvs<Type extends object = any>(command: string): Promise<Type>;
|
|
119
119
|
}
|
package/dist/index.js
CHANGED
|
@@ -375,14 +375,34 @@ 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
|
-
|
|
383
|
+
let command = `/tool bandwidth-test protocol=${options.protocol} ` +
|
|
380
384
|
`user=${username} password=${password} ` +
|
|
381
385
|
`duration=${options.duration}s direction=${options.direction} ` +
|
|
382
|
-
`address=${target} random-data=${options.random_data ? 'yes' : 'no'} interval=1s
|
|
386
|
+
`address=${target} random-data=${options.random_data ? 'yes' : 'no'} interval=1s`;
|
|
387
|
+
if (options.local_tx_speed) {
|
|
388
|
+
command += ` local-tx-speed=${options.local_tx_speed}M`;
|
|
389
|
+
}
|
|
390
|
+
if (options.remote_tx_speed) {
|
|
391
|
+
command += ` remote-tx-speed=${options.remote_tx_speed}M`;
|
|
392
|
+
}
|
|
393
|
+
const cancel = yield this.stream(command, {
|
|
383
394
|
separator: '\r\n\r\n'
|
|
384
395
|
});
|
|
385
|
-
|
|
396
|
+
this.once('stream_complete', () => __awaiter(this, void 0, void 0, function* () {
|
|
397
|
+
yield cleanup();
|
|
398
|
+
}));
|
|
399
|
+
this.once('stream_cancelled', () => __awaiter(this, void 0, void 0, function* () {
|
|
400
|
+
yield cleanup();
|
|
401
|
+
return reject(new Error('Bandwidth Test Cancelled'));
|
|
402
|
+
}));
|
|
403
|
+
if (options.timeout) {
|
|
404
|
+
setTimeout(cancel, options.timeout);
|
|
405
|
+
}
|
|
386
406
|
}));
|
|
387
407
|
});
|
|
388
408
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -35,6 +35,15 @@ export declare namespace BandwidthTest {
|
|
|
35
35
|
protocol: Protocol;
|
|
36
36
|
random_data: boolean;
|
|
37
37
|
callback: (frame: Update) => void;
|
|
38
|
+
timeout: number;
|
|
39
|
+
/**
|
|
40
|
+
* In Megabits
|
|
41
|
+
*/
|
|
42
|
+
local_tx_speed: number;
|
|
43
|
+
/**
|
|
44
|
+
* In Megabits
|
|
45
|
+
*/
|
|
46
|
+
remote_tx_speed: number;
|
|
38
47
|
}
|
|
39
48
|
export {};
|
|
40
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gibme/mikrotik",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
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"
|