Skip to content

Commit

Permalink
udp also handle bind to ipv6 multicast if
Browse files Browse the repository at this point in the history
tidy prompts to suit new function
  • Loading branch information
Dave Conway-Jones committed Apr 18, 2018
1 parent 8a08c20 commit 1bdd244
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion nodes/core/io/32-udp.html
Expand Up @@ -29,7 +29,7 @@
</div>
<div class="form-row node-input-iface">
<label for="node-input-iface"><i class="fa fa-random"></i> <span data-i18n="udp.label.interface"></span></label>
<input type="text" id="node-input-iface" data-i18n="[placeholder]udp.label.interfaceprompt">
<input type="text" id="node-input-iface" data-i18n="[placeholder]udp.placeholder.interfaceprompt">
</div>
<div class="form-row">
<label for="node-input-port"><i class="fa fa-sign-in"></i> <span data-i18n="udp.label.onport"></span></label>
Expand Down
28 changes: 22 additions & 6 deletions nodes/core/io/32-udp.js
Expand Up @@ -32,12 +32,20 @@ module.exports = function(RED) {
var node = this;

if (node.iface && node.iface.indexOf(".") === -1) {
try { // using ip4 in preference if specifying interface only.
try {
if ((os.networkInterfaces())[node.iface][0].hasOwnProperty("scopeid")) {
node.iface = (os.networkInterfaces())[node.iface][1].address;
if (node.ipv === "udp4") {
node.iface = (os.networkInterfaces())[node.iface][1].address;
} else {
node.iface = (os.networkInterfaces())[node.iface][0].address;
}
}
else {
node.iface = (os.networkInterfaces())[node.iface][0].address;
if (node.ipv === "udp4") {
node.iface = (os.networkInterfaces())[node.iface][0].address;
} else {
node.iface = (os.networkInterfaces())[node.iface][1].address;
}
}
}
catch(e) {
Expand Down Expand Up @@ -138,12 +146,20 @@ module.exports = function(RED) {
var node = this;

if (node.iface && node.iface.indexOf(".") === -1) {
try { // using ip4 in preference if specifying interface only.
try {
if ((os.networkInterfaces())[node.iface][0].hasOwnProperty("scopeid")) {
node.iface = (os.networkInterfaces())[node.iface][1].address;
if (node.ipv === "udp4") {
node.iface = (os.networkInterfaces())[node.iface][1].address;
} else {
node.iface = (os.networkInterfaces())[node.iface][0].address;
}
}
else {
node.iface = (os.networkInterfaces())[node.iface][0].address;
if (node.ipv === "udp4") {
node.iface = (os.networkInterfaces())[node.iface][0].address;
} else {
node.iface = (os.networkInterfaces())[node.iface][1].address;
}
}
}
catch(e) {
Expand Down
6 changes: 3 additions & 3 deletions nodes/core/locales/en-US/messages.json
Expand Up @@ -489,15 +489,15 @@
"using": "using",
"output": "Output",
"group": "Group",
"interface": "Local IP",
"interfaceprompt": "(optional) local ip address to bind to",
"interface": "Local IF",
"send": "Send a",
"toport": "to port",
"address": "Address",
"decode-base64": "Decode Base64 encoded payload?"
},
"placeholder": {
"interface": "(optional) ip address of eth0",
"interface": "(optional) local interface or address to bind to",
"interfaceprompt": "(optional) local interface or address to bind to",
"address": "destination ip"
},
"udpmsgs": "udp messages",
Expand Down

0 comments on commit 1bdd244

Please sign in to comment.