Skip to content

Commit

Permalink
Revert "test: don't assume broadcast traffic is unfiltered"
Browse files Browse the repository at this point in the history
This reverts commit 52e600a.

Reverted for:

* making the test fail with ENETUNREACH on OS X 10.8, and

* making the test fail with EHOSTDOWN on OS X 10.9 and 10.10 when there
  is no network connectivity, and

* leaving behind orphan processes that make subsequent tests fail with
  EADDRINUSE errors

PR-URL: #259
Reviewed-By: Rod Vagg <rod@vagg.org>
  • Loading branch information
bnoordhuis committed Jan 8, 2015
1 parent 4519db0 commit df3c4ca
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test/parallel/test-dgram-broadcast-multi-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var common = require('../common'),
assert = require('assert'),
dgram = require('dgram'),
util = require('util'),
networkInterfaces = require('os').networkInterfaces(),
Buffer = require('buffer').Buffer,
fork = require('child_process').fork,
LOCAL_BROADCAST_HOST = '255.255.255.255',
Expand All @@ -34,6 +35,19 @@ var common = require('../common'),
new Buffer('Fourth message to send')
];

// take the first non-internal interface as the address for binding
get_bindAddress: for (var name in networkInterfaces) {
var interfaces = networkInterfaces[name];
for(var i = 0; i < interfaces.length; i++) {
var localInterface = interfaces[i];
if (!localInterface.internal && localInterface.family === 'IPv4') {
var bindAddress = localInterface.address;
break get_bindAddress;
}
}
}
assert.ok(bindAddress);

if (process.argv[2] !== 'child') {
var workers = {},
listeners = 3,
Expand Down Expand Up @@ -150,7 +164,7 @@ if (process.argv[2] !== 'child') {

// bind the address explicitly for sending
// INADDR_BROADCAST to only one interface
sendSocket.bind(common.PORT, '127.0.0.1');
sendSocket.bind(common.PORT, bindAddress);
sendSocket.on('listening', function () {
sendSocket.setBroadcast(true);
});
Expand Down Expand Up @@ -197,7 +211,7 @@ if (process.argv[2] === 'child') {

listenSocket.on('message', function(buf, rinfo) {
// receive udp messages only sent from parent
if (rinfo.address !== '127.0.0.1') return;
if (rinfo.address !== bindAddress) return;

console.error('[CHILD] %s received %s from %j',
process.pid,
Expand Down

0 comments on commit df3c4ca

Please sign in to comment.