| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 347abf3 commit be5386e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,9 @@ if (common.inFreeBSDJail) { | |||
| 20 | 20 | return; | |
| 21 | 21 | } | |
| 22 | 22 | ||
| 23 | - // take the first non-internal interface as the address for binding | ||
| 23 | + // Take the first non-internal interface as the address for binding. | ||
| 24 | + // Ideally, this should check for whether or not an interface is set up for | ||
| 25 | + // BROADCAST and favor internal/private interfaces. | ||
| 24 | 26 | get_bindAddress: for (var name in networkInterfaces) { | |
| 25 | 27 | var interfaces = networkInterfaces[name]; | |
| 26 | 28 | for (var i = 0; i < interfaces.length; i++) { | |
@@ -209,7 +211,7 @@ if (process.argv[2] === 'child') { | |||
| 209 | 211 | ||
| 210 | 212 | receivedMessages.push(buf); | |
| 211 | 213 | ||
| 212 | - process.send({ message: buf.toString() }); | ||
| 214 | + process.send({message: buf.toString()}); | ||
| 213 | 215 | ||
| 214 | 216 | if (receivedMessages.length == messages.length) { | |
| 215 | 217 | process.nextTick(function() { | |
@@ -228,7 +230,7 @@ if (process.argv[2] === 'child') { | |||
| 228 | 230 | }); | |
| 229 | 231 | ||
| 230 | 232 | listenSocket.on('listening', function() { | |
| 231 | - process.send({ listening: true }); | ||
| 233 | + process.send({listening: true}); | ||
| 232 | 234 | }); | |
| 233 | 235 | ||
| 234 | 236 | listenSocket.bind(common.PORT); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,39 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const dgram = require('dgram'); | ||
| 6 | + | ||
| 7 | + const setup = () => { | ||
| 8 | + return dgram.createSocket({type: 'udp4', reuseAddr: true}); | ||
| 9 | + }; | ||
| 10 | + | ||
| 11 | + const teardown = (socket) => { | ||
| 12 | + if (socket.close) | ||
| 13 | + socket.close(); | ||
| 14 | + }; | ||
| 15 | + | ||
| 16 | + const runTest = (testCode, expectError) => { | ||
| 17 | + const socket = setup(); | ||
| 18 | + const assertion = expectError ? assert.throws : assert.doesNotThrow; | ||
| 19 | + const wrapped = () => { testCode(socket); }; | ||
| 20 | + assertion(wrapped, expectError); | ||
| 21 | + teardown(socket); | ||
| 22 | + }; | ||
| 23 | + | ||
| 24 | + // Should throw EBADF if socket is never bound. | ||
| 25 | + runTest((socket) => { socket.setBroadcast(true); }, /EBADF/); | ||
| 26 | + | ||
| 27 | + // Should not throw if broadcast set to false after binding. | ||
| 28 | + runTest((socket) => { | ||
| 29 | + socket.bind(common.PORT, common.localhostIPv4, () => { | ||
| 30 | + socket.setBroadcast(false); | ||
| 31 | + }); | ||
| 32 | + }); | ||
| 33 | + | ||
| 34 | + // Should not throw if broadcast set to true after binding. | ||
| 35 | + runTest((socket) => { | ||
| 36 | + socket.bind(common.PORT, common.localhostIPv4, () => { | ||
| 37 | + socket.setBroadcast(true); | ||
| 38 | + }); | ||
| 39 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments