From b66aa7408e832daf283f849ecf306db5fed92032 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 10 Dec 2014 12:07:25 -0500 Subject: [PATCH] use Inflator instead Gunzip --- Reseed.cpp | 22 ++++++++++++---------- i2p.cpp | 13 ++----------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Reseed.cpp b/Reseed.cpp index ed09e2f5..78b4522f 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include "I2PEndian.h" #include "Reseed.h" #include "Log.h" @@ -138,6 +138,7 @@ namespace data LogPrint (eLogError, "Unexpected SU3 magic number"); return; } + s.seekg (1, std::ios::cur); // su3 file format version SigningKeyType signatureType; s.read ((char *)&signatureType, 2); // signature type signatureType = be16toh (signatureType); @@ -158,7 +159,7 @@ namespace data s.read ((char *)&fileType, 1); // file type if (fileType != 0x00) // zip file { - LogPrint (eLogError, "Can't handle file type ", fileType); + LogPrint (eLogError, "Can't handle file type ", (int)fileType); return; } s.seekg (1, std::ios::cur); // unused @@ -166,7 +167,7 @@ namespace data s.read ((char *)&contentType, 1); // content type if (contentType != 0x03) // reseed data { - LogPrint (eLogError, "Unexpected content type ", contentType); + LogPrint (eLogError, "Unexpected content type ", (int)contentType); return; } s.seekg (12, std::ios::cur); // unused @@ -174,11 +175,10 @@ namespace data s.seekg (versionLength, std::ios::cur); // skip version s.seekg (signerIDLength, std::ios::cur); // skip signer ID - size_t contentRead = 0; // handle content - while (contentRead < contentLength && !s.eof ()) - { - size_t start = s.tellg (); + size_t contentPos = s.tellg (); + while (!s.eof ()) + { uint32_t signature; s.read ((char *)&signature, 4); if (signature == headerSignature) @@ -199,12 +199,11 @@ namespace data s.read (localFileName, fileNameLength); localFileName[fileNameLength] = 0; s.seekg (extraFieldLength, std::ios::cur); + LogPrint (eLogDebug, "Proccessing file ", localFileName, " ", compressedSize, " bytes"); uint8_t * compressed = new uint8_t[compressedSize]; s.read ((char *)compressed, compressedSize); - contentRead = s.tellg () - start; - - CryptoPP::Gunzip decompressor; + CryptoPP::Inflator decompressor; decompressor.Put (compressed, compressedSize); delete[] compressed; if (decompressor.MaxRetrievable () <= uncompressedSize) @@ -219,6 +218,9 @@ namespace data } else break; // no more files + size_t end = s.tellg (); + if (end - contentPos >= contentLength) + break; // we are beyond contentLength } } else diff --git a/i2p.cpp b/i2p.cpp index 89966328..898dae07 100644 --- a/i2p.cpp +++ b/i2p.cpp @@ -1,18 +1,9 @@ #include #include #include "Daemon.h" +#include "Reseed.h" int main( int argc, char* argv[] ) { - Daemon.init(argc, argv); - if (Daemon.start()) - { - while (Daemon.running) - { - //TODO Meeh: Find something better to do here. - std::this_thread::sleep_for (std::chrono::seconds(1)); - } - } - Daemon.stop(); - return EXIT_SUCCESS; + i2p::data::ProcessSU3File ("/home/roman/tmp/i2pseeds.su3"); }