Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseHeader(buffer) {
const bytebuf = ByteBuffer.wrap(buffer, true);
return {
magic: bytebuf.readString(8, ByteBuffer.METRICS_BYTES).split("\0", 2)[0],
protocol: bytebuf.readInt32(),
networkProtocol: bytebuf.readInt32(),
serverName: bytebuf
.readString(consts_1.MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
clientName: bytebuf
.readString(consts_1.MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
mapName: bytebuf
.readString(consts_1.MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
gameDirectory: bytebuf
.readString(consts_1.MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
playbackTime: bytebuf.readFloat(),
playbackTicks: bytebuf.readInt32(),
export function parseHeader(buffer: Buffer): IDemoHeader {
const bytebuf = ByteBuffer.wrap(buffer, true);
return {
magic: bytebuf.readString(8, ByteBuffer.METRICS_BYTES).split("\0", 2)[0],
protocol: bytebuf.readInt32(),
networkProtocol: bytebuf.readInt32(),
serverName: bytebuf
.readString(MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
clientName: bytebuf
.readString(MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
mapName: bytebuf
.readString(MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
gameDirectory: bytebuf
.readString(MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
playbackTime: bytebuf.readFloat(),
playbackTicks: bytebuf.readInt32(),
playbackFrames: bytebuf.readInt32(),
signonLength: bytebuf.readInt32()
};
}
export function parseHeader(buffer: Buffer): IDemoHeader {
const bytebuf = ByteBuffer.wrap(buffer, true);
return {
magic: bytebuf.readString(8, ByteBuffer.METRICS_BYTES).split("\0", 2)[0],
protocol: bytebuf.readInt32(),
networkProtocol: bytebuf.readInt32(),
serverName: bytebuf
.readString(MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
clientName: bytebuf
.readString(MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
mapName: bytebuf
.readString(MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
gameDirectory: bytebuf
.readString(MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
playbackTime: bytebuf.readFloat(),
playbackTicks: bytebuf.readInt32(),
function parseHeader(buffer) {
const bytebuf = ByteBuffer.wrap(buffer, true);
return {
magic: bytebuf.readString(8, ByteBuffer.METRICS_BYTES).split("\0", 2)[0],
protocol: bytebuf.readInt32(),
networkProtocol: bytebuf.readInt32(),
serverName: bytebuf
.readString(consts_1.MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
clientName: bytebuf
.readString(consts_1.MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
mapName: bytebuf
.readString(consts_1.MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
gameDirectory: bytebuf
.readString(consts_1.MAX_OSPATH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0],
playbackTime: bytebuf.readFloat(),
playbackTicks: bytebuf.readInt32(),
playbackFrames: bytebuf.readInt32(),
signonLength: bytebuf.readInt32()
};
}
exports.parseHeader = parseHeader;
const bytebuf = ByteBuffer.wrap(buf, ByteBuffer.BIG_ENDIAN);
bytebuf.skip(8);
const hi = bytebuf.readUint32();
const lo = bytebuf.readUint32();
const xuid = Long.fromBits(lo, hi);
const name = bytebuf
.readString(consts_1.MAX_PLAYER_NAME_LENGTH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
const userId = bytebuf.readUint32();
const guid = bytebuf
.readString(consts_1.SIGNED_GUID_LEN + 1, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
bytebuf.skip(3);
const friendsId = bytebuf.readUint32();
const friendsName = bytebuf
.readString(consts_1.MAX_PLAYER_NAME_LENGTH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
const fakePlayer = bytebuf.readByte() !== 0;
bytebuf.skip(3);
const isHltv = bytebuf.readByte() !== 0;
bytebuf.skip(3);
return {
xuid,
name,
userId,
guid,
friendsId,
friendsName,
fakePlayer,
isHltv
};
}
function parseUserInfoData(buf) {
const bytebuf = ByteBuffer.wrap(buf, ByteBuffer.BIG_ENDIAN);
bytebuf.skip(8);
const hi = bytebuf.readUint32();
const lo = bytebuf.readUint32();
const xuid = Long.fromBits(lo, hi);
const name = bytebuf
.readString(consts_1.MAX_PLAYER_NAME_LENGTH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
const userId = bytebuf.readUint32();
const guid = bytebuf
.readString(consts_1.SIGNED_GUID_LEN + 1, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
bytebuf.skip(3);
const friendsId = bytebuf.readUint32();
const friendsName = bytebuf
.readString(consts_1.MAX_PLAYER_NAME_LENGTH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
const fakePlayer = bytebuf.readByte() !== 0;
bytebuf.skip(3);
const isHltv = bytebuf.readByte() !== 0;
bytebuf.skip(3);
return {
xuid,
function parseUserInfoData(buf: Buffer): IPlayerInfo {
const bytebuf = ByteBuffer.wrap(buf, ByteBuffer.BIG_ENDIAN);
bytebuf.skip(8);
const hi = bytebuf.readUint32();
const lo = bytebuf.readUint32();
const xuid = Long.fromBits(lo, hi);
const name = bytebuf
.readString(MAX_PLAYER_NAME_LENGTH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
const userId = bytebuf.readUint32();
const guid = bytebuf
.readString(SIGNED_GUID_LEN + 1, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
bytebuf.skip(3);
const friendsId = bytebuf.readUint32();
const friendsName = bytebuf
.readString(MAX_PLAYER_NAME_LENGTH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
const fakePlayer = bytebuf.readByte() !== 0;
bytebuf.skip(3);
const isHltv = bytebuf.readByte() !== 0;
bytebuf.skip(3);
return {
xuid,
name,
userId,
guid,
function parseUserInfoData(buf: Buffer): IPlayerInfo {
const bytebuf = ByteBuffer.wrap(buf, ByteBuffer.BIG_ENDIAN);
bytebuf.skip(8);
const hi = bytebuf.readUint32();
const lo = bytebuf.readUint32();
const xuid = Long.fromBits(lo, hi);
const name = bytebuf
.readString(MAX_PLAYER_NAME_LENGTH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
const userId = bytebuf.readUint32();
const guid = bytebuf
.readString(SIGNED_GUID_LEN + 1, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
bytebuf.skip(3);
const friendsId = bytebuf.readUint32();
const friendsName = bytebuf
.readString(MAX_PLAYER_NAME_LENGTH, ByteBuffer.METRICS_BYTES)
.split("\0", 2)[0];
const fakePlayer = bytebuf.readByte() !== 0;
bytebuf.skip(3);
const isHltv = bytebuf.readByte() !== 0;
bytebuf.skip(3);
return {