Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nioc/synology-srm-nodejs-api
Unofficial dependency-free Node.js wrapper for Synology SRM API
https://github.com/nioc/synology-srm-nodejs-api
router srm synology
Last synced: 2 months ago
JSON representation
Unofficial dependency-free Node.js wrapper for Synology SRM API
- Host: GitHub
- URL: https://github.com/nioc/synology-srm-nodejs-api
- Owner: nioc
- License: agpl-3.0
- Created: 2022-10-10T22:46:31.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-03T23:31:47.000Z (about 1 year ago)
- Last Synced: 2024-10-22T21:41:53.057Z (2 months ago)
- Topics: router, srm, synology
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/synology-srm-nodejs-api
- Size: 437 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# synology-srm-nodejs-api
[![license: AGPLv3](https://img.shields.io/badge/license-AGPLv3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
[![Build Status](https://img.shields.io/github/actions/workflow/status/nioc/synology-srm-nodejs-api/commit.yml)](https://github.com/nioc/synology-srm-nodejs-api/actions/workflows/commit.yml)
[![Coverage Status](https://coveralls.io/repos/github/nioc/synology-srm-nodejs-api/badge.svg?branch=master)](https://coveralls.io/github/nioc/synology-srm-nodejs-api?branch=master)
[![GitHub release](https://img.shields.io/github/release/nioc/synology-srm-nodejs-api.svg)](https://github.com/nioc/synology-srm-nodejs-api/releases/latest)
[![npms.io (final)](https://img.shields.io/npms-io/final-score/synology-srm-nodejs-api)](https://www.npmjs.com/package/synology-srm-nodejs-api)
[![npm](https://img.shields.io/npm/dt/synology-srm-nodejs-api)](https://www.npmjs.com/package/synology-srm-nodejs-api)Unofficial dependency-free Node.js wrapper for Synology SRM API.
## Key features
- authentication,
- get WAN status,
- get WAN connection (ip, status, interface name),
- get network utilization,
- get devices with status, IP, etc... ,
- get wifi devices with link quality, signal strength, max rate, band used, etc... ,
- get devices traffic usage (live, day, week, month),
- get mesh nodes with status, connected devices, etc... ,
- get and update policy rules,
- get access control groups with devices, online status, etc... ,
- get Quality Of Service rules by devices,
- get Smart WAN configuration (gateways list with status, load balancing / failover),
- set Smart WAN configuration and switch WAN gateway,
- get and set Wi-Fi configuration,
- enable or disable a Wi-Fi radio by its SSID,
- get wake-on-lan devices,
- add wake-on-lan on a device,
- wake-on-lan a device.## Installation
``` bash
npm install synology-srm-nodejs-api
```## Usage
### Disclaimer
This library lets you **modify SRM's configuration**. Its use is entirely at **your own risk**.
We cannot be held responsible for any damage resulting from misuse or bugs.### SRM version
This library has been checked with SRM version `1.3.1-9346 Update 8`.
Please note that future SRM updates may break its functionality, in which case please create a [bug report](https://github.com/nioc/synology-srm-nodejs-api/issues/new).
### Basic example
```js
const { SrmClient } = require('synology-srm-nodejs-api')// you need to set your own information
const baseUrl = 'https://10.0.0.1:8001'
const login = 'admin-user'
const password = 'admin-password'
let sid = null
const outputInline = falsefunction output (label, data) {
if (outputInline) {
console.log(`${label}: ${JSON.stringify(data)}`)
return
}
console.log(label + ':')
console.dir(data, { depth: null, colors: true })
}async function main () {
try {
// create client
const client = new SrmClient(baseUrl, sid, { timeout: 5000 })// authenticate
if (sid === null) {
sid = await client.authenticate(login, password)
output('Session Id for further usage', sid)
}// get WAN status
const wanStatus = await client.getWanStatus()
output('WAN is connected', wanStatus)// get WAN connection
const wanConnection = await client.getWanConnectionStatus()
output('WAN connection', wanConnection)// get devices traffic
const traffic = await client.getTraffic('live')
// [optionnal] add protocol label on each device/recording
traffic
.forEach(device => device.recs
.forEach(record => record.protocollist
.forEach(proto => {
proto.label = client.getProtocolLabel(proto.protocol)
})))
output('Devices traffic', traffic)// get utilization by network
const networkUtilization = await client.getNetworkUtilization()
output('Utilization by network', networkUtilization)// get known devices
const devices = await client.getDevices()
output('Devices', devices)// get control groups
const groups = await client.getAccessControlGroups(false)
output('Control groups', groups)client.computeAccessControlGroupStatus(groups, devices)
output('Control groups with online status and onlines devices count', groups)// get policy rules
const rules = await client.getPolicyRoutes()
output('Policy rules', rules)// update policy rules
/* Commented in this sample code because it updates the configuration
// change something in `rules` before request
await client.setPolicyRoutes(rules)
*/// get Wi-Fi devices
const wifiDevices = await client.getWifiDevices()
output('Wi-Fi devices', wifiDevices)// get mesh nodes
const meshNodes = await client.getMeshNodes()
output('Mesh nodes', meshNodes)// get smart WAN gateways
const smartWanGateways = await client.getSmartWanGateway()
output('Smart WAN gateways', smartWanGateways)// get smart WAN configuration
const smartWanConfiguration = await client.getSmartWan()
output('Smart WAN configuration', smartWanConfiguration)// update smart WAN configuration
/* Commented in this sample code because it updates the configuration
// change something in `smartWanConfiguration` before request
const updatedSmartWanConfiguration = await client.setSmartWan(smartWanConfiguration)
output('Updated smart WAN gateways', updatedSmartWanConfiguration)
*/// switch smart WAN interfaces
/* Commented in this sample code because it updates the configuration
const switchedSmartWanConfiguration = await client.switchSmartWan()
output('Updated smart WAN gateways (switch interfaces)', switchedSmartWanConfiguration)
*/// get wake on lan devices
const wolDevices = await client.getWakeOnLanDevices()
output('Wake on lan devices', wolDevices)// add a wake on lan device
/* Commented in this sample code because it updates the configuration
const mac = '00:00:00:00:00:00'
const host = 'my-device'
const wolDevice = await client.addWakeOnLan(mac, host)
output('Added wake on lan device', wolDevice)
*/// wake on lan a device
/* Commented in this sample code because it updates the configuration
const mac = '00:00:00:00:00:00'
await client.wakeOnLan(mac)
*/// get Quality Of Service rules by devices
const qosRules = await client.getQos()
output('Quality Of Service rules by devices', qosRules)// get Wi-Fi settings
const wifiSettings = await client.getWifiSettings()
output('Wi-Fi settings', wifiSettings)// switch Wi-Fi radio for SSID `Guests-Network`
/* Commented in this sample code because it updates the configuration
await client.switchWifiRadio('Guests-Network')
*/
} catch (error) {
output('Error during main process', error)
}
}main()
```## Versioning
synology-srm-nodejs-api is maintained under the [semantic versioning](https://semver.org/) guidelines.
See the [releases](https://github.com/nioc/synology-srm-nodejs-api/releases) on this repository for changelog.
## License
This project is licensed under the GNU Affero General Public License v3.0 - see the [LICENSE](LICENSE.md) file for details