#include "../../include/freenet/identityintroductioninserter.h"\r
#include "../../include/freenet/identityintroductionxml.h"\r
-#include "../../include/xyssl/sha1.h"\r
#include "../../include/stringfunctions.h"\r
#include "../../include/hex.h"\r
#include "../../include/option.h"\r
\r
+#include <Poco/SHA1Engine.h>\r
+\r
#ifdef XMEM\r
#include <xmem.h>\r
#endif\r
if(message["Fatal"]=="true" || message["Code"]=="9")\r
{\r
m_db->Execute("DELETE FROM tblIdentityIntroductionInserts WHERE UUID='"+idparts[3]+"';");\r
- m_log->WriteLog(LogFile::LOGLEVEL_WARNING,__FUNCTION__" received fatal error trying to insert IdentityIntroduction "+idparts[3]);\r
+ // update the puzzle from the request table (set to not found) because we don't need it anymore and don't want to user tyring to solve it again\r
+ m_db->Execute("UPDATE tblIntroductionPuzzleRequests SET Found='false' WHERE UUID='"+idparts[3]+"';");\r
+ m_log->warning("IdentityIntroductionInserter::HandleMessage received fatal error trying to insert IdentityIntroduction "+idparts[3]);\r
}\r
m_inserting=false;\r
return true;\r
{\r
m_db->Execute("UPDATE tblIdentityIntroductionInserts SET Inserted='true' WHERE UUID='"+idparts[3]+"';");\r
m_inserting=false;\r
- m_log->WriteLog(LogFile::LOGLEVEL_INFO,__FUNCTION__" successfully inserted IdentityIntroduction "+idparts[3]);\r
+ m_log->information("IdentityIntroductionInserter::HandleMessage successfully inserted IdentityIntroduction "+idparts[3]);\r
return true;\r
}\r
\r
void IdentityIntroductionInserter::Initialize()\r
{\r
m_inserting=false;\r
- Option::instance()->Get("MessageBase",m_messagebase);\r
+ Option::Instance()->Get("MessageBase",m_messagebase);\r
}\r
\r
void IdentityIntroductionInserter::Process()\r
{\r
- DateTime now;\r
- now.SetToGMTime();\r
+ Poco::DateTime now;\r
\r
// only do 1 insert at a time\r
- if(!m_inserting && m_lastchecked<(now-(1.0/1440.0)))\r
+ if(!m_inserting && m_lastchecked<(now-Poco::Timespan(0,0,1,0,0)))\r
{\r
CheckForNewInserts();\r
m_lastchecked=now;\r
std::string publickey;\r
std::string data;\r
std::string datasizestr;\r
- std::vector<unsigned char> hash;\r
+// std::vector<unsigned char> hash;\r
std::string encodedhash;\r
\r
SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey FROM tblLocalIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LocalIdentityID=?;");\r
data=xml.GetXML();\r
StringFunctions::Convert(data.size(),datasizestr);\r
\r
- hash.resize(20);\r
- sha1((unsigned char *)solution.c_str(),solution.size(),&hash[0]);\r
- Hex::Encode(hash,encodedhash);\r
+ Poco::SHA1Engine sha1;\r
+ sha1.update(solution);\r
+ encodedhash=Poco::DigestEngine::digestToHex(sha1.digest());\r
+ StringFunctions::UpperCase(encodedhash,encodedhash);\r
+\r
+// hash.resize(20);\r
+// sha1((unsigned char *)solution.c_str(),solution.size(),&hash[0]);\r
+// Hex::Encode(hash,encodedhash);\r
\r
message.SetName("ClientPut");\r
message["URI"]="KSK@"+m_messagebase+"|"+day+"|"+UUID+"|"+encodedhash+".xml";\r
}\r
else\r
{\r
- m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" could not find a public key for identity. It is probably a new identity that doesn't have a key yet.");\r
+ m_log->debug("IdentityIntroductionInserter::StartInsert could not find a public key for identity. It is probably a new identity that doesn't have a key yet.");\r
}\r
\r
-}
\ No newline at end of file
+}\r