@gibme/mikrotik 20.0.1 → 22.0.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/README.md +101 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +579 -616
- package/package.json +19 -22
package/README.md
CHANGED
|
@@ -1,5 +1,105 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gibme/mikrotik
|
|
2
|
+
|
|
3
|
+
A TypeScript helper/wrapper for managing MikroTik RouterOS devices over SSH.
|
|
2
4
|
|
|
3
5
|
## Documentation
|
|
4
6
|
|
|
5
7
|
[https://gibme-npm.github.io/mikrotik/](https://gibme-npm.github.io/mikrotik/)
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- Node.js >= 22
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @gibme/mikrotik
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn add @gibme/mikrotik
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import Mikrotik from '@gibme/mikrotik';
|
|
27
|
+
|
|
28
|
+
const device = new Mikrotik({
|
|
29
|
+
host: '192.168.1.1',
|
|
30
|
+
username: 'admin',
|
|
31
|
+
password: 'password'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await device.connect();
|
|
35
|
+
|
|
36
|
+
const identity = await device.identity();
|
|
37
|
+
console.log(`Connected to: ${identity}`);
|
|
38
|
+
|
|
39
|
+
const routes = await device.get_ip_routes();
|
|
40
|
+
console.log(`Route count: ${routes.length}`);
|
|
41
|
+
|
|
42
|
+
await device.destroy();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## API
|
|
46
|
+
|
|
47
|
+
### Connection
|
|
48
|
+
|
|
49
|
+
| Method | Description |
|
|
50
|
+
|--------|-------------|
|
|
51
|
+
| `connect()` | Connects to the device over SSH |
|
|
52
|
+
| `destroy()` | Closes the SSH connection and stops internal timers |
|
|
53
|
+
|
|
54
|
+
### Device Information
|
|
55
|
+
|
|
56
|
+
| Method | Return Type | Description |
|
|
57
|
+
|--------|-------------|-------------|
|
|
58
|
+
| `identity()` | `string` | Device identity name |
|
|
59
|
+
| `version()` | `string` | RouterOS version string |
|
|
60
|
+
| `semantic_version()` | `{major, minor, patch}` | Parsed semantic version |
|
|
61
|
+
| `routerboard()` | `Mikrotik.Response.Routerboard` | Board info (model, firmware, serial) |
|
|
62
|
+
| `resource()` | `Mikrotik.Response.Resource` | System resources (CPU, memory, uptime) |
|
|
63
|
+
| `health()` | `Mikrotik.Response.V6.Health \| V7.Health` | Temperature, voltage, fan data (version-aware) |
|
|
64
|
+
|
|
65
|
+
### Networking
|
|
66
|
+
|
|
67
|
+
| Method | Return Type | Description |
|
|
68
|
+
|--------|-------------|-------------|
|
|
69
|
+
| `get_interfaces(active_only?)` | `Mikrotik.Response.Interface[]` | Network interfaces with tunnel details |
|
|
70
|
+
| `get_ip_addresses(active_only?)` | `Mikrotik.Response.Address[]` | IP addresses assigned to interfaces |
|
|
71
|
+
| `get_ip_routes(min_distance?, vrf?, active_only?)` | `Mikrotik.Response.Route[]` | Routing table entries |
|
|
72
|
+
| `get_route_counts(min_distance?, vrf?)` | `Record<string, Route.Count>` | Route counts per IP with active marking |
|
|
73
|
+
| `ping(target, source?)` | `Mikrotik.Response.Ping` | Ping with latency measurement |
|
|
74
|
+
| `traceroute(target, source?)` | `Mikrotik.Response.Traceroute[]` | Traceroute with reverse DNS on hops |
|
|
75
|
+
|
|
76
|
+
### Bandwidth Testing
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const result = await device.bandwidth_test(
|
|
80
|
+
'target-host',
|
|
81
|
+
'username',
|
|
82
|
+
'password',
|
|
83
|
+
{
|
|
84
|
+
duration: 10,
|
|
85
|
+
direction: 'both',
|
|
86
|
+
protocol: 'udp',
|
|
87
|
+
callback: (update) => {
|
|
88
|
+
console.log(`${update.status}: ${update.transmit?.current} bps`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Supports `AbortSignal` for cancellation and real-time progress via callback.
|
|
95
|
+
|
|
96
|
+
### Raw Commands
|
|
97
|
+
|
|
98
|
+
| Method | Description |
|
|
99
|
+
|--------|-------------|
|
|
100
|
+
| `terse<Type>(command)` | Execute a command and parse terse (space-separated key=value) output |
|
|
101
|
+
| `kvs<Type>(command)` | Execute a command and parse colon-separated key-value output |
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import SSH from '@gibme/ssh';
|
|
2
2
|
import Cache from '@gibme/cache/memory';
|
|
3
|
-
import { AbortController, AbortSignal } from 'abort-controller';
|
|
4
|
-
export { AbortController, AbortSignal };
|
|
5
3
|
export type { ConnectConfig } from '@gibme/ssh';
|
|
6
4
|
export declare class Mikrotik extends SSH {
|
|
7
5
|
protected static cache: Cache;
|
|
@@ -102,6 +100,10 @@ export declare class Mikrotik extends SSH {
|
|
|
102
100
|
* @protected
|
|
103
101
|
*/
|
|
104
102
|
kvs<Type extends object = any>(command: string): Promise<Type>;
|
|
103
|
+
/**
|
|
104
|
+
* Destroys the SSH connection and stops the internal cache timer
|
|
105
|
+
*/
|
|
106
|
+
destroy(): Promise<void>;
|
|
105
107
|
}
|
|
106
108
|
export declare namespace Mikrotik {
|
|
107
109
|
namespace BandwidthTest {
|