Base128 encoding of minidumps before uploading.

This commit is contained in:
/dev/urandom 2016-08-28 22:46:23 +02:00
parent 01a90e42e4
commit f9e2eeca7b
No known key found for this signature in database
GPG Key ID: 41322B973E0F295E
7 changed files with 83 additions and 1 deletions

3
.gitmodules vendored
View File

@ -32,3 +32,6 @@
[submodule "deps/bitmrc"] [submodule "deps/bitmrc"]
path = deps/bitmrc path = deps/bitmrc
url = git@github.com:iw4x-dev-urandom/BitMRC.git url = git@github.com:iw4x-dev-urandom/BitMRC.git
[submodule "deps/base128"]
path = deps/base128
url = https://github.com/seizu/base128.git

1
deps/base128 vendored Submodule

@ -0,0 +1 @@
Subproject commit 64c8ab2755e14d316b18aff9746f0180f5fe301b

54
premake/base128.lua Normal file
View File

@ -0,0 +1,54 @@
base128 = {
settings = nil
}
function base128.setup(settings)
if not settings.source then error("Missing source.") end
base128.settings = settings
end
function base128.import()
if not base128.settings then error("Run base128.setup first") end
base128.links()
base128.includes()
end
function base128.links()
if not base128.settings then error("Run base128.setup first") end
links { "base128" }
end
function base128.includes()
if not base128.settings then error("Run base128.setup first") end
includedirs { path.join(base128.settings.source, "cpp") }
end
function base128.project()
if not base128.settings then error("Run base128.setup first") end
project "base128"
language "C++"
base128.includes()
files
{
path.join(base128.settings.source, "cpp/*.cpp"),
path.join(base128.settings.source, "cpp/*.h"),
}
removefiles
{
"**/demo.*",
}
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
defines { "_LIB" }
removedefines { "_USRDLL", "_DLL" }
kind "StaticLib"
end

View File

@ -140,6 +140,7 @@ newaction {
depsBasePath = "./deps" depsBasePath = "./deps"
require "premake/base128"
require "premake/bitmrc" require "premake/bitmrc"
require "premake/fmt" require "premake/fmt"
require "premake/json11" require "premake/json11"
@ -153,6 +154,10 @@ require "premake/sqlite3"
require "premake/winksignals" require "premake/winksignals"
require "premake/zlib" require "premake/zlib"
base128.setup
{
source = path.join(depsBasePath, "base128"),
}
bitmrc.setup bitmrc.setup
{ {
source = path.join(depsBasePath, "bitmrc"), source = path.join(depsBasePath, "bitmrc"),
@ -290,6 +295,7 @@ workspace "iw4x"
if not _OPTIONS["disable-bitmessage"] then if not _OPTIONS["disable-bitmessage"] then
bitmrc.import() bitmrc.import()
end end
base128.import()
fmt.import() fmt.import()
json11.import() json11.import()
libtomcrypt.import() libtomcrypt.import()
@ -398,6 +404,7 @@ workspace "iw4x"
libcryptopp.project() libcryptopp.project()
sqlite3.project() sqlite3.project()
end end
base128.project()
fmt.project() fmt.project()
json11.project() json11.project()
libtomcrypt.project() libtomcrypt.project()

View File

@ -279,6 +279,11 @@ namespace Components
std::string compressedMinidump = Utils::Compression::ZLib::Compress(minidump->ToString()); std::string compressedMinidump = Utils::Compression::ZLib::Compress(minidump->ToString());
#ifndef DISABLE_BASE128
extraHeaders["Encoding"] = "base128";
compressedMinidump = Utils::String::EncodeBase128(compressedMinidump);
#endif
Logger::Print("Uploading minidump...\n"); Logger::Print("Uploading minidump...\n");
#ifdef DISABLE_BITMESSAGE #ifdef DISABLE_BITMESSAGE
@ -345,7 +350,8 @@ namespace Components
std::string marker = "MINIDUMP"; std::string marker = "MINIDUMP";
std::stringstream output; std::stringstream output;
extraHeaders["Encoding"] = "raw"; if (extraHeaders.find("Encoding") == extraHeaders.end())
extraHeaders["Encoding"] = "raw";
extraHeaders["Version"] = VERSION_STR; extraHeaders["Version"] = VERSION_STR;
output << "-----BEGIN " << marker << "-----\n"; output << "-----BEGIN " << marker << "-----\n";

View File

@ -1,4 +1,5 @@
#include "STDInclude.hpp" #include "STDInclude.hpp"
#include "base128.h"
namespace Utils namespace Utils
{ {
@ -131,6 +132,14 @@ namespace Utils
return EncodeBase64(input.c_str(), input.size()); return EncodeBase64(input.c_str(), input.size());
} }
// Encodes a given string in Base128
std::string EncodeBase128(const std::string& input) {
auto encoder = new base128();
auto buffer = encoder->encode(const_cast<void*>(static_cast<const void*>(input.data())), input.size());
delete encoder;
return std::string(buffer);
}
// Generates a UUID and returns the string representation of it // Generates a UUID and returns the string representation of it
std::string GenerateUUIDString() { std::string GenerateUUIDString() {
// Generate UUID data // Generate UUID data

View File

@ -43,6 +43,8 @@ namespace Utils
std::string EncodeBase64(const char* input, const unsigned long inputSize); std::string EncodeBase64(const char* input, const unsigned long inputSize);
std::string EncodeBase64(const std::string& input); std::string EncodeBase64(const std::string& input);
std::string EncodeBase128(const std::string& input);
std::string GenerateUUIDString(); std::string GenerateUUIDString();
} }
} }