Set WOL node to use more generic broadcast address byt default

This commit is contained in:
Dave Conway-Jones 2018-12-09 11:01:18 +00:00
parent 7113598098
commit 73e4ae574c
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
3 changed files with 11 additions and 5 deletions

View File

@ -5,8 +5,8 @@
<input type="text" id="node-input-mac" placeholder="e.g. DE:AD:BE:EF:FE:ED">
</div>
<div class="form-row">
<label for="node-input-host"><i class="fa fa-globe"></i> Host Address</label>
<input type="text" id="node-input-host" placeholder="e.g. 255.255.255.255">
<label for="node-input-host"><i class="fa fa-globe"></i> Target Address</label>
<input type="text" id="node-input-host" placeholder="e.g. 192.168.1.255 or 10.255.255.255">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
@ -18,7 +18,9 @@
<script type="text/x-red" data-help-name="wake on lan">
<p>Sends a Wake-On-LAN magic packet to the mac address specified.</p>
<p>You may instead set <code>msg.mac</code> to dynamically set the target device mac to wake up.</p>
<p>The target host address can optionally be set using <code>msg.host</code></p>
<p>The address of the target machine can optionally be set using <code>msg.host</code></p>
<p>Setting the target address to the broadcast address of the subnet that the target machine is attached to works best.
For a class C address this is usually just the first three parts of the ip address followed by 255. eg 192.168.1.255.</p>
</script>
<script type="text/javascript">

View File

@ -13,6 +13,10 @@ module.exports = function(RED) {
this.on("input", function(msg) {
var mac = this.mac || msg.mac || null;
var host = this.host || msg.host || '255.255.255.255';
var h = host.split('.');
h.pop();
h.push('255');
host = h.join('.');
if (mac != null) {
if (chk.test(mac)) {
try {
@ -35,7 +39,7 @@ module.exports = function(RED) {
}
else { node.warn("WOL: no mac address specified"); }
});
this.on("close", function () {
node.status({});
})

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-wol",
"version" : "0.0.9",
"version" : "0.0.10",
"description" : "A Node-RED node to send Wake-On-LAN (WOL) magic packets",
"dependencies" : {
"wake_on_lan" : "1.0.0"