
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@mhycy/routeros-client
Advanced tools
MikroTik RouterOS API client for node.js.
$ npm install @mhycy/routeros-client
const RouterClient = require('@mhycy/routeros-client');
const USER = "admin";
const PASSWD = "test"
// connect options
const connectOptions = {
host: '192.168.1.254',
// port: 8728,
// encoding: 'gbk',
debug: true
};
// create client instance
const client = RouterClient.createClient(connectOptions);
// async request
(async function() {
// login helper function
await client.login(USER, PASSWD);
// login use command builder
await client.command("/login").setAttrs({
name: USER,
password: PASSWD
}).send();
// get interfaces that 'type' attribute equal 'pppoe-out'
await client.command("/interface/print")
.equal("type", "pppoe-out")
.send();
client.close();
})();
Helper for new module.Client(options)
Command sentences chainable query builder.
Query word see offical wiki: Mikrotik-Wiki-API
Example:
let sentences = new CommandBuilder("/interface/print")
.equal('type', 'pppoe-out')
.get();
/* sentences
[
'/interface/print',
'?type=pppoe-out'
]
*/
command
<string>
command word. Example: /interface/print
callback
<Function>
use for .get()
method. Defualt: (sentences) => { return sentences; }
sentences
<array>
sentences array.Create a new CommandBuilder object.
Example:
new CommandBuilder('/login', (sentences) => {
console.log(sentences);
})
.setAttrs({
name: 'admin',
password: 'test'
})
.get();
// console.log output
// [
// '/login',
// '=name=admin',
// '=password=test',
// ]
name
<string>
attribute name.value
<string>
attributes value.Add an attribute value to exists attributes object.
Example:
let sentences = new CommandBuilder('/login')
.setAttr(name, 'admin')
.setAttr(password, 'test')
.get();
attrs
<object>
attributes object.Overwrite attributes object.
Example:
let sentences = new CommandBuilder('/login')
.setAttrs({
name: 'admin',
password: 'test'
})
.get();
name
<string>
property name.Query word ?name
, check property name
exists.
name
<string>
property name.Query word ?-name
, check property name
doesn't exists.
name
<string>
property name.value
<string>
attributes value.Query word ?name=value
, check property name
has value equal to value
.
name
<string>
property name.value
<string>
attributes value.Query word ?<name=value
, check property name
has value less than value
.
name
<string>
property name.value
<string>
attributes value.Query word ?>name=value
, check property name
has value greater than value
.
operation
<string>
operation word < |
, &
, !
, .
> .Operation word see Mikrotik-Wiki-API.
options
host
<string>
Router hostname or ipport
<number>
api port, doesn't support ssl. Default: 8728
.encoding
<string>
sentences enc/dec encoding, it equal windows environment encode. (MikroTik WinBox used it) Default: gbk
.debug
<boolean>
if true
print debug infomation to console. Default: false
.Create a new Client object.
<object>
sentences decode object.// '!done'
{
status: true
}
// '!re'
// ......
// '!re'
// ......
{
'status': true,
'replies': [
{
'.id': '*9',
name: 'pppoe-out1',
type: 'pppoe-out',
'link-downs': '0',
'rx-byte': '0',
'tx-byte': '0',
'rx-packet': '0',
'tx-packet': '0',
'rx-drop': '0',
'tx-drop': '0',
'tx-queue-drop': '0',
'rx-error': '0',
'tx-error': '0',
'fp-rx-byte': '0',
'fp-tx-byte': '0',
'fp-rx-packet': '0',
'fp-tx-packet': '0',
running: 'false',
'tx-queue-drop': '0',
'rx-error': '0',
'tx-error': '0',
'fp-rx-byte': '0',
'fp-tx-byte': '0',
'fp-rx-packet': '0',
'fp-tx-packet': '0',
running: 'true',
disabled: 'false',
comment: 'ChinaNet 500M'
}
]
}
// '!trap'
// '=message=invalid user name or password (6)'
{
status: false,
message: 'invalid user name or password (6)'
}
// '!fatal',
// 'not logged in',
{
status: false,
message: 'not logged in'
}
<net.Socket>
instance.
Close Client.socket
. Call <net.Socket.end()>
to close.
sentences
<array>
sentences array.Direct write a sentences, you need set listener to listen Event::receive
by your self.
sentences
<array>
sentences array.Return: <Promise>
Promise resolve an object. see: Usage
command
<string>
command words. Example: /login
or /interface/print
Return: <CommandBuilder>
Return chainable query builder. CommandBuilder.get()
method will send sentences request. (Use: Client.sendSentencesSync()
)
name
<string>
user name.password
<string>
user password.Return: <Promise>
Promise resolve an object. see: Usage
logger
<object>
new logger instance.Logger instance need implementing some method. see src/logger.js
source code.
Module logger, export api see src/logger.js
source code.
Module utilities, export api see src/utils.js
source code.
FAQs
RouterOS api client
The npm package @mhycy/routeros-client receives a total of 1 weekly downloads. As such, @mhycy/routeros-client popularity was classified as not popular.
We found that @mhycy/routeros-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.