From ae9a99a6dc566cefd47daa115bebeb9b2ebf8ef3 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 29 May 2015 21:05:00 -0700 Subject: [PATCH] add node 0.10 support back after PR --- server.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 9db7d80..ed90ea5 100644 --- a/server.js +++ b/server.js @@ -66,12 +66,18 @@ function Server (opts) { // start a udp tracker unless the user explicitly says no if (opts.udp !== false) { - self.udp4 = self.udp = dgram.createSocket({type: 'udp4', reuseAddr: true}) + var isNode10 = /^v0.10./.test(process.version) + + self.udp4 = self.udp = dgram.createSocket( + isNode10 ? 'udp4' : { type: 'udp4', reuseAddr: true } + ) self.udp4.on('message', self.onUdpRequest.bind(self)) self.udp4.on('error', self._onError.bind(self)) self.udp4.on('listening', onListening) - self.udp6 = dgram.createSocket({type: 'udp6', reuseAddr: true}) + self.udp6 = dgram.createSocket( + isNode10 ? 'udp6' : { type: 'udp6', reuseAddr: true } + ) self.udp6.on('message', self.onUdpRequest.bind(self)) self.udp6.on('error', self._onError.bind(self)) self.udp6.on('listening', onListening)