From df3c4ca16ed2c72b72ea261753a910548d097e87 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 8 Jan 2015 11:42:34 +0100 Subject: [PATCH 1/2] Revert "test: don't assume broadcast traffic is unfiltered" This reverts commit 52e600a9c8655f578fae55d85e778b58d731201a. 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: https://github.com/iojs/io.js/pull/259 Reviewed-By: Rod Vagg --- .../test-dgram-broadcast-multi-process.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-dgram-broadcast-multi-process.js b/test/parallel/test-dgram-broadcast-multi-process.js index b05abd8d4fb589..4d9eebc1012de7 100644 --- a/test/parallel/test-dgram-broadcast-multi-process.js +++ b/test/parallel/test-dgram-broadcast-multi-process.js @@ -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', @@ -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, @@ -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); }); @@ -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, From 7266b75779f149ef3c394925b29e6a8295f75a36 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 8 Jan 2015 11:46:21 +0100 Subject: [PATCH 2/2] test: move broadcast/multicast test to internet/ Move parallel/test-dgram-broadcast-multi-process to test/internet. The test does not play nice with firewalls that restrict broadcast or multicast traffic, nor can it be rewritten to use only loopback traffic without running into platform-specific limitations, see also commits 52e600a and 236533c (TODO: update second one before landing.) PR-URL: https://github.com/iojs/io.js/pull/259 Reviewed-By: Rod Vagg --- test/{parallel => internet}/test-dgram-broadcast-multi-process.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{parallel => internet}/test-dgram-broadcast-multi-process.js (100%) diff --git a/test/parallel/test-dgram-broadcast-multi-process.js b/test/internet/test-dgram-broadcast-multi-process.js similarity index 100% rename from test/parallel/test-dgram-broadcast-multi-process.js rename to test/internet/test-dgram-broadcast-multi-process.js