Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
addr = maddr.nodeAddress()
} catch (_) {
// Might explode if maddr does not have an IP or cannot be converted
// to a node address. This might happen if it's a relay. We do not print
// or handle the error, otherwise we would get perhaps thousands of logs.
return { isPrivate, isNearby }
}
// At this point, addr.address and publicIP must be valid IP addresses. Hence,
// none of the calls bellow for ip library should fail.
isPrivate = ip.isPrivate(addr.address)
if (publicIP) {
if (ip.isV4Format(addr.address)) {
isNearby = ip.cidrSubnet(`${publicIP}/24`).contains(addr.address)
} else if (ip.isV6Format(addr.address)) {
isNearby = ip.cidrSubnet(`${publicIP}/48`).contains(addr.address) &&
!ip.cidrSubnet('fc00::/8').contains(addr.address)
// peerIP6 ∉ fc00::/8 to fix case of cjdns where IPs are not spatial allocated.
}
}
return { isPrivate, isNearby }
}
responseTimer = null;
var msg = 'Response timeout for ' + responseTimeout + 'ms';
var errorName = 'ResponseTimeoutError';
__err = new Error(msg);
__err.name = errorName;
__err.requestId = reqId;
debug('ResponseTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
abortRequest();
}, responseTimeout);
}
if (args.checkAddress) {
var hostname = parsedUrl.hostname;
// if request hostname is ip, custom lookup wont excute
var family = null;
if (ip.isV4Format(hostname)) {
family = 4;
} else if (ip.isV6Format(hostname)) {
family = 6;
}
if (family) {
if (!args.checkAddress(hostname, family)) {
var err = new Error('illegal address');
err.name = 'IllegalAddressError';
err.hostname = hostname;
err.ip = hostname;
err.family = family;
return done(err);
}
}
}
srtp_salt: srtpSalt
}
response['audio'] = audioResp
sessionInfo['audio_port'] = targetPort
sessionInfo['audio_srtp'] = Buffer.concat([srtpKey, srtpSalt])
sessionInfo['audio_ssrc'] = ssrc
}
let currentAddress = ip.address()
var addressResp = {
address: currentAddress
}
if (ip.isV4Format(currentAddress)) {
addressResp['type'] = 'v4'
} else {
addressResp['type'] = 'v6'
}
response['address'] = addressResp
this.pendingSessions[this.hap.uuid.unparse(sessionID)] = sessionInfo
callback(response)
}
ip(str) {
return ip.isV4Format(str);
},
/**
function ipHmac(key, uid, addr) {
if (ip.isV4Format(addr)) {
addr = '::' + addr
}
addr = ip.toBuffer(addr)
var hmac = crypto.createHmac('sha256', key)
hmac.update(uid)
hmac.update(addr)
return hmac.digest()
}
function encode (addr, buf) {
if (ip.isV4Format(addr)) {
IPV4_PREFIX.copy(buf)
ip.toBuffer(addr, buf, 12)
} else if (ip.isV6Format(addr)) {
ip.toBuffer(addr, buf)
} else {
throw new Error('Invalid IP address value')
}
},
function decode (buf, d) {
var audioResp = {
port: targetPort,
ssrc: 1,
srtp_key: srtp_key,
srtp_salt: srtp_salt
};
response["audio"] = audioResp;
sessionInfo["audio_port"] = targetPort;
sessionInfo["audio_srtp"] = Buffer.concat([srtp_key, srtp_salt]);
sessionInfo["audio_ssrc"] = 1;
}
var currentAddress = ip.address();
var addressResp = {
address: currentAddress
};
if (ip.isV4Format(currentAddress)) {
addressResp["type"] = "v4";
}
else {
addressResp["type"] = "v6";
}
response["address"] = addressResp;
this.pendingSessions[hap_nodejs_1.uuid.unparse(sessionID, 0)] = sessionInfo;
callback(response);
};
THomeKitIPCamera.prototype.handleStreamRequest = function (request) {
ip(str) {
return ip.isV4Format(str);
},
/**
addresses = addresses.filter(address => ip.isV4Format(address))
return addresses