Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(idStr, sendData) {
this.id = idStr;
this.idBuf = new EndianBuffer(idStr);
var host_type = this.idBuf.readUInt8(18);
if (host_type === 4) {
this.host_type = 'Internet';
this.host = Array.apply(null, new Array(4))
.map(function (v, i) {
console.log(i)
return this.idBuf.readUInt8(i);
}, this)
.join('.');
} else {
this.host_type = 'InternetV6';
this.host = (new v6.Address(
Array.apply(null, new Array(8))
.map(function (v, i) {
return this.idBuf.readUInt16(i * 2)
}, this)
.join(':')
)).correctForm()
}
this.port = this.idBuf.readUInt16(16);
this.idLog = this.host_type + '[' + this.host + ']' + this.port
this.sendData = sendData;
this.endian = false;
this.state = 0;
this.sequence = 1;
}
end() {
exports.parseIPv6 = function parseIPv6(ip) {
var v6Address = new IPv6.Address(ip);
if (!v6Address.isValid()) {
throw new Error("Invalid IPv6 address");
}
return v6Address.parsedAddress;
};