@gibme/mikrotik 1.0.1 → 1.1.0
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 +19 -8
- package/dist/index.js +3 -8
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import SSH from '@gibme/ssh';
|
|
2
2
|
import { BandwidthTest, Response } from './types';
|
|
3
3
|
import Cache from '@gibme/cache/memory';
|
|
4
|
-
export {
|
|
4
|
+
export { ConnectConfig } from '@gibme/ssh';
|
|
5
|
+
export type Direction = BandwidthTest.Direction;
|
|
6
|
+
export type Protocol = BandwidthTest.Protocol;
|
|
7
|
+
export type Status = BandwidthTest.Status;
|
|
8
|
+
export type Update = BandwidthTest.Update;
|
|
9
|
+
export type Options = BandwidthTest.Options;
|
|
10
|
+
export type Address = Response.Address;
|
|
11
|
+
export type Interface = Response.Interface;
|
|
12
|
+
export type Route = Response.Route;
|
|
13
|
+
export type RouteCount = Response.RouteCount;
|
|
14
|
+
export type Ping = Response.Ping;
|
|
15
|
+
export type Traceroute = Response.Traceroute;
|
|
5
16
|
export default class Mikrotik extends SSH {
|
|
6
17
|
protected static cache: Cache;
|
|
7
18
|
/**
|
|
@@ -10,15 +21,15 @@ export default class Mikrotik extends SSH {
|
|
|
10
21
|
* @param min_distance
|
|
11
22
|
* @param vrf
|
|
12
23
|
*/
|
|
13
|
-
get_ip_routes(min_distance?: number, vrf?: string): Promise<
|
|
24
|
+
get_ip_routes(min_distance?: number, vrf?: string): Promise<Route[]>;
|
|
14
25
|
/**
|
|
15
26
|
* Retrieves the IP addresses active on the system
|
|
16
27
|
*/
|
|
17
|
-
get_ip_addresses(): Promise<
|
|
28
|
+
get_ip_addresses(): Promise<Address[]>;
|
|
18
29
|
/**
|
|
19
30
|
* Retrieves the interfaces active on the system
|
|
20
31
|
*/
|
|
21
|
-
get_interfaces(): Promise<
|
|
32
|
+
get_interfaces(): Promise<Interface[]>;
|
|
22
33
|
/**
|
|
23
34
|
* For all device IP addresses, counts the routes that exit (either directly or tunneled)
|
|
24
35
|
* the device using each IP address
|
|
@@ -26,7 +37,7 @@ export default class Mikrotik extends SSH {
|
|
|
26
37
|
* @param min_distance
|
|
27
38
|
* @param vrf
|
|
28
39
|
*/
|
|
29
|
-
get_route_counts(min_distance?: number, vrf?: string): Promise<Record<string,
|
|
40
|
+
get_route_counts(min_distance?: number, vrf?: string): Promise<Record<string, RouteCount>>;
|
|
30
41
|
/**
|
|
31
42
|
* Executes a bandwidth test
|
|
32
43
|
*
|
|
@@ -39,21 +50,21 @@ export default class Mikrotik extends SSH {
|
|
|
39
50
|
* @param password
|
|
40
51
|
* @param options
|
|
41
52
|
*/
|
|
42
|
-
bandwidth_test(target: string, username: string, password: string, options?: Partial<
|
|
53
|
+
bandwidth_test(target: string, username: string, password: string, options?: Partial<Options>): Promise<Update>;
|
|
43
54
|
/**
|
|
44
55
|
* Pings the target IP address from the source IP address (if supplied)
|
|
45
56
|
*
|
|
46
57
|
* @param target
|
|
47
58
|
* @param source
|
|
48
59
|
*/
|
|
49
|
-
ping(target: string, source?: string): Promise<
|
|
60
|
+
ping(target: string, source?: string): Promise<Ping>;
|
|
50
61
|
/**
|
|
51
62
|
* Performs a traceroute to the target IP address from the source IP address (if supplied)
|
|
52
63
|
*
|
|
53
64
|
* @param target
|
|
54
65
|
* @param source
|
|
55
66
|
*/
|
|
56
|
-
traceroute(target: string, source?: string): Promise<
|
|
67
|
+
traceroute(target: string, source?: string): Promise<Traceroute[]>;
|
|
57
68
|
/**
|
|
58
69
|
* Executes a command with expected terse response and parses it accordingly
|
|
59
70
|
*
|
package/dist/index.js
CHANGED
|
@@ -31,10 +31,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
32
|
};
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.BandwidthTest = void 0;
|
|
35
34
|
const ssh_1 = __importDefault(require("@gibme/ssh"));
|
|
36
35
|
const types_1 = require("./types");
|
|
37
|
-
Object.defineProperty(exports, "BandwidthTest", { enumerable: true, get: function () { return types_1.BandwidthTest; } });
|
|
38
36
|
const ip_1 = __importDefault(require("ip"));
|
|
39
37
|
const memory_1 = __importDefault(require("@gibme/cache/memory"));
|
|
40
38
|
const dns_1 = require("dns");
|
|
@@ -228,8 +226,7 @@ class Mikrotik extends ssh_1.default {
|
|
|
228
226
|
direction: 'both',
|
|
229
227
|
protocol: 'udp',
|
|
230
228
|
random_data: false,
|
|
231
|
-
callback: () => {
|
|
232
|
-
}
|
|
229
|
+
callback: () => { }
|
|
233
230
|
}) {
|
|
234
231
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
235
232
|
const $ = this;
|
|
@@ -241,8 +238,7 @@ class Mikrotik extends ssh_1.default {
|
|
|
241
238
|
(_b = options.direction) !== null && _b !== void 0 ? _b : (options.direction = 'both');
|
|
242
239
|
(_c = options.protocol) !== null && _c !== void 0 ? _c : (options.protocol = 'udp');
|
|
243
240
|
(_d = options.random_data) !== null && _d !== void 0 ? _d : (options.random_data = false);
|
|
244
|
-
(_e = options.callback) !== null && _e !== void 0 ? _e : (options.callback = () => {
|
|
245
|
-
});
|
|
241
|
+
(_e = options.callback) !== null && _e !== void 0 ? _e : (options.callback = () => { });
|
|
246
242
|
/**
|
|
247
243
|
* This serves as a lazy "mutex" that prevents us from running
|
|
248
244
|
* a bandwidth test for against a target host that is already
|
|
@@ -342,8 +338,7 @@ class Mikrotik extends ssh_1.default {
|
|
|
342
338
|
});
|
|
343
339
|
}
|
|
344
340
|
this.on('stream', handleStream);
|
|
345
|
-
// set our mutex
|
|
346
|
-
yield Mikrotik.cache.set(target, target, options.duration);
|
|
341
|
+
yield Mikrotik.cache.set(target, target, options.duration); // set our mutex
|
|
347
342
|
yield this.stream(`/tool bandwidth-test protocol=${options.protocol} ` +
|
|
348
343
|
`user=${username} password=${password} ` +
|
|
349
344
|
`duration=${options.duration}s direction=${options.direction} ` +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gibme/mikrotik",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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.1",
|
|
60
60
|
"@types/ip": "^1.1.3",
|
|
61
61
|
"ip": "^2.0.1"
|
|
62
62
|
}
|