| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ce05b70 commit bec1cca
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,15 +20,17 @@ if (common.inFreeBSDJail) { | |||
| 20 | 20 | return; | |
| 21 | 21 | } | |
| 22 | 22 | ||
| 23 | + let bindAddress = null; | ||
| 24 | + | ||
| 23 | 25 | // Take the first non-internal interface as the address for binding. | |
| 24 | 26 | // Ideally, this should check for whether or not an interface is set up for | |
| 25 | 27 | // BROADCAST and favor internal/private interfaces. | |
| 26 | - get_bindAddress: for (var name in networkInterfaces) { | ||
| 27 | - var interfaces = networkInterfaces[name]; | ||
| 28 | - for (var i = 0; i < interfaces.length; i++) { | ||
| 29 | - var localInterface = interfaces[i]; | ||
| 28 | + get_bindAddress: for (const name in networkInterfaces) { | ||
| 29 | + const interfaces = networkInterfaces[name]; | ||
| 30 | + for (let i = 0; i < interfaces.length; i++) { | ||
| 31 | + const localInterface = interfaces[i]; | ||
| 30 | 32 | if (!localInterface.internal && localInterface.family === 'IPv4') { | |
| 31 | - var bindAddress = localInterface.address; | ||
| 33 | + bindAddress = localInterface.address; | ||
| 32 | 34 | break get_bindAddress; | |
| 33 | 35 | } | |
| 34 | 36 | } | |
@@ -56,9 +58,9 @@ if (process.argv[2] !== 'child') { | |||
| 56 | 58 | }, TIMEOUT); | |
| 57 | 59 | ||
| 58 | 60 | //launch child processes | |
| 59 | - for (var x = 0; x < listeners; x++) { | ||
| 61 | + for (let x = 0; x < listeners; x++) { | ||
| 60 | 62 | (function() { | |
| 61 | - var worker = fork(process.argv[1], ['child']); | ||
| 63 | + const worker = fork(process.argv[1], ['child']); | ||
| 62 | 64 | workers[worker.pid] = worker; | |
| 63 | 65 | ||
| 64 | 66 | worker.messagesReceived = []; | |
@@ -68,7 +70,7 @@ if (process.argv[2] !== 'child') { | |||
| 68 | 70 | // don't consider this the true death if the worker | |
| 69 | 71 | // has finished successfully | |
| 70 | 72 | // or if the exit code is 0 | |
| 71 | - if (worker.isDone || code == 0) { | ||
| 73 | + if (worker.isDone || code === 0) { | ||
| 72 | 74 | return; | |
| 73 | 75 | } | |
| 74 | 76 | ||
@@ -113,12 +115,12 @@ if (process.argv[2] !== 'child') { | |||
| 113 | 115 | 'messages. Will now compare.'); | |
| 114 | 116 | ||
| 115 | 117 | Object.keys(workers).forEach(function(pid) { | |
| 116 | - var worker = workers[pid]; | ||
| 118 | + const worker = workers[pid]; | ||
| 117 | 119 | ||
| 118 | - var count = 0; | ||
| 120 | + let count = 0; | ||
| 119 | 121 | ||
| 120 | 122 | worker.messagesReceived.forEach(function(buf) { | |
| 121 | - for (var i = 0; i < messages.length; ++i) { | ||
| 123 | + for (let i = 0; i < messages.length; ++i) { | ||
| 122 | 124 | if (buf.toString() === messages[i].toString()) { | |
| 123 | 125 | count++; | |
| 124 | 126 | break; | |
@@ -130,8 +132,11 @@ if (process.argv[2] !== 'child') { | |||
| 130 | 132 | worker.pid, | |
| 131 | 133 | count); | |
| 132 | 134 | ||
| 133 | - assert.equal(count, messages.length, | ||
| 134 | - 'A worker received an invalid multicast message'); | ||
| 135 | + assert.strictEqual( | ||
| 136 | + count, | ||
| 137 | + messages.length, | ||
| 138 | + 'A worker received an invalid multicast message' | ||
| 139 | + ); | ||
| 135 | 140 | }); | |
| 136 | 141 | ||
| 137 | 142 | clearTimeout(timer); | |
@@ -143,7 +148,7 @@ if (process.argv[2] !== 'child') { | |||
| 143 | 148 | })(x); | |
| 144 | 149 | } | |
| 145 | 150 | ||
| 146 | - var sendSocket = dgram.createSocket({ | ||
| 151 | + const sendSocket = dgram.createSocket({ | ||
| 147 | 152 | type: 'udp4', | |
| 148 | 153 | reuseAddr: true | |
| 149 | 154 | }); | |
@@ -160,7 +165,7 @@ if (process.argv[2] !== 'child') { | |||
| 160 | 165 | }); | |
| 161 | 166 | ||
| 162 | 167 | sendSocket.sendNext = function() { | |
| 163 | - var buf = messages[i++]; | ||
| 168 | + const buf = messages[i++]; | ||
| 164 | 169 | ||
| 165 | 170 | if (!buf) { | |
| 166 | 171 | try { sendSocket.close(); } catch (e) {} | |
@@ -186,15 +191,15 @@ if (process.argv[2] !== 'child') { | |||
| 186 | 191 | ||
| 187 | 192 | function killChildren(children) { | |
| 188 | 193 | Object.keys(children).forEach(function(key) { | |
| 189 | - var child = children[key]; | ||
| 194 | + const child = children[key]; | ||
| 190 | 195 | child.kill(); | |
| 191 | 196 | }); | |
| 192 | 197 | } | |
| 193 | 198 | } | |
| 194 | 199 | ||
| 195 | 200 | if (process.argv[2] === 'child') { | |
| 196 | - var receivedMessages = []; | ||
| 197 | - var listenSocket = dgram.createSocket({ | ||
| 201 | + const receivedMessages = []; | ||
| 202 | + const listenSocket = dgram.createSocket({ | ||
| 198 | 203 | type: 'udp4', | |
| 199 | 204 | reuseAddr: true | |
| 200 | 205 | }); | |
@@ -212,7 +217,7 @@ if (process.argv[2] === 'child') { | |||
| 212 | 217 | ||
| 213 | 218 | process.send({message: buf.toString()}); | |
| 214 | 219 | ||
| 215 | - if (receivedMessages.length == messages.length) { | ||
| 220 | + if (receivedMessages.length === messages.length) { | ||
| 216 | 221 | process.nextTick(function() { | |
| 217 | 222 | listenSocket.close(); | |
| 218 | 223 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments