diff options
| author | Omar Roth <omarroth@protonmail.com> | 2020-03-15 17:39:21 -0400 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2020-03-15 17:47:16 -0400 |
| commit | 59a15ceef6e5f02a0e16e6604bc61ce41227d413 (patch) | |
| tree | b46f7b01cd99c23395692232421d8d79e6185362 | |
| parent | 4011a113ccc1241b60f607ce76db982625f7b9b1 (diff) | |
| download | invidious-59a15ceef6e5f02a0e16e6604bc61ce41227d413.tar.gz invidious-59a15ceef6e5f02a0e16e6604bc61ce41227d413.tar.bz2 invidious-59a15ceef6e5f02a0e16e6604bc61ce41227d413.zip | |
Remove VarInt class
| -rw-r--r-- | src/invidious/helpers/utils.cr | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index a0a619fa..d0892862 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -325,43 +325,6 @@ def get_referer(env, fallback = "/", unroll = true) return referer end -struct VarInt - def self.from_io(io : IO, format = IO::ByteFormat::NetworkEndian) : Int32 - result = 0_u32 - num_read = 0 - - loop do - byte = io.read_byte - raise "Invalid VarInt" if !byte - value = byte & 0x7f - - result |= value.to_u32 << (7 * num_read) - num_read += 1 - - break if byte & 0x80 == 0 - raise "Invalid VarInt" if num_read > 5 - end - - result.to_i32 - end - - def self.to_io(io : IO, value : Int32) - io.write_byte 0x00 if value == 0x00 - value = value.to_u32 - - while value != 0 - byte = (value & 0x7f).to_u8 - value >>= 7 - - if value != 0 - byte |= 0x80 - end - - io.write_byte byte - end - end -end - def sha256(text) digest = OpenSSL::Digest.new("SHA256") digest << text |
