From 4c69b0d12e79f2187e3dc068b92f36672ab20d91 Mon Sep 17 00:00:00 2001 From: idksomeguy Date: Thu, 23 May 2024 10:22:31 +0200 Subject: [PATCH] added support for custom port --- config.schema.json | 6 ++++++ package-lock.json | 8 ++++---- src/config.ts | 2 ++ src/network-device.ts | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/config.schema.json b/config.schema.json index b3f8701..bd90841 100644 --- a/config.schema.json +++ b/config.schema.json @@ -76,6 +76,12 @@ "type": "string", "required": false }, + "port": { + "title": "Port", + "description": "The target port to send packet to. Defaults to 9", + "type": "number", + "required": false + }, "broadcastAddress": { "title": "Broadcast address", "description": "The broadcast address to use when sending the Wake on LAN packet, such as 172.16.1.255.", diff --git a/package-lock.json b/package-lock.json index 5c787b3..c2ff334 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebridge-wol", - "version": "5.0.1", + "version": "6.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "homebridge-wol", - "version": "5.0.1", + "version": "6.0.1", "license": "MIT", "dependencies": { "ping": "^0.4.4", @@ -23,8 +23,8 @@ "typescript": "^5.3.3" }, "engines": { - "homebridge": "^1.6.0", - "node": "^18 || ^20" + "homebridge": ">=1.0.0", + "node": ">=10.0.0" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/src/config.ts b/src/config.ts index fd6bf45..c01dd6c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -17,6 +17,7 @@ export class NetworkDeviceConfig { pingCommandTimeout = 0; mac: string | null = null; + port = 9; broadcastAddress: string | null = null; startCommand: string | null = null; startCommandTimeout = 0; @@ -75,6 +76,7 @@ export class NetworkDeviceConfig { 1000; this.mac = this.getString(config, "mac", this.mac); + this.port = this.getNumber(config, "port", this.port); this.broadcastAddress = this.getString( config, "broadcastAddress", diff --git a/src/network-device.ts b/src/network-device.ts index ab0a329..02e60a8 100644 --- a/src/network-device.ts +++ b/src/network-device.ts @@ -176,6 +176,7 @@ export default class NetworkDevice { try { await wake(this.config.mac, { address: this.config.broadcastAddress as string | undefined, + port: this.config.port }); } catch (error) { this.log.error(