Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
, idStr;
idBuf.fill(0);
idBuf.writeUInt16BE(socket.remotePort, 16);
if (net.isIPv4(socket.remoteAddress)) {
idBuf.writeUInt8(4, 18);
idBuf = socket.remoteAddress.split('.')
.reduce(
function (o, v, i) {
o.writeUInt8(v, i);
return o;
}
, idBuf
);
} else {
idBuf.writeUInt8(6, 18);
idBuf = (new ip.v6.Address(socket.remoteAddress)).parsedAddress
.reduce(
function (o, v, i) {
o.writeUInt16BE(v, i * 2);
return o;
}
, idBuf
);
}
idStr = idBuf.toString('hex');
this.client_sockets[idStr] = socket;
this.connection.sendUTF('NEW ' + idStr);
socket.on('close', function () {
self.connection.sendUTF('END ' + idStr);
delete self.client_sockets[idStr];
});
var addresses6 = addresses.filter(function (address) {
if (address.family !== 'IPv6') {
return false;
}
var v6 = new ip.v6.Address(address.address);
return v6.isValid() &&
(v6.getScope() === 'Global' || v6.getScope() === 'Reserved');
}).map(function (address) {
return {
'use strict';
var IPv6 = require('ip-address').v6;
var IPv4 = require('ip-address').v4;
exports.parseIPv4 = function parseIPv4(ip) {
var v4Address = new IPv4.Address(ip);
if (!v4Address.isValid()) {
throw new Error("Invalid IPv4 address");
}
return v4Address.parsedAddress;
};
exports.parseIPv6 = function parseIPv6(ip) {
var v6Address = new IPv6.Address(ip);
if (!v6Address.isValid()) {
throw new Error("Invalid IPv6 address");
}
return v6Address.parsedAddress;
self.connectivityQueue.push(function (cb) {
if (self.connectivity[service.host]) {
return cb();
}
var v6 = new ip.v6.Address(address);
var hostBase;
if (v6.isValid()) {
if (v6.getScope() !== 'Global') {
self.debug('using hostname in favor of scoped IPv6 address');
hostBase = 'http://' + service.hostname + ':' + service.port + '/';
} else {
hostBase = v6.href(service.port);
}
} else {
hostBase = 'http://' + address + ':' + service.port + '/';
}
var url = hostBase + 'connectivity';