Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions lua/gm_express/sh_helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,13 @@ function express:_put( data, cb )
error( "Express: Tried to send empty data!" )
end

data = pon.encode( data )
data = sfs.encode( data )

if string.len( data ) > self._maxDataSize then
data = "<enc>" .. util.Compress( data )
assert( data, "Express: Failed to compress data!" )
assert(data, "Express: Failed to encode data")

local dataLen = string.len( data )
if dataLen > self._maxDataSize then
error( "Express: Data too large (" .. dataLen .. " bytes)" )
end
local dataLen = string.len( data )
if dataLen > self._maxDataSize then
error( "Express: Data too large (" .. dataLen .. " bytes)" )
end

local hash = util.SHA1( data )
Expand Down
11 changes: 2 additions & 9 deletions lua/gm_express/sh_init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AddCSLuaFile()

require( "pon" )
require( "sfs" )
if SERVER then
util.AddNetworkString( "express" )
util.AddNetworkString( "express_proof" )
Expand Down Expand Up @@ -50,15 +50,8 @@ function express:Get( id, cb, _attempts )
print( "express:Get() succeeded after " .. _attempts .. " attempts: " .. id )
end

if string.StartWith( body, "<enc>" ) then
body = util.Decompress( string.sub( body, 6 ) )
if ( not body ) or #body == 0 then
error( "Express: Failed to decompress data for ID '" .. id .. "'." )
end
end

local hash = util.SHA1( body )
local decodedData = pon.decode( body )
local decodedData = sfs.decode( body )
cb( decodedData, hash )
end

Expand Down
Loading