X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fidentityintroductionrequester.cpp;h=951e12dc85f308e3a53786afcfe253bd01ba2320;hb=c0ebc7b53a977885ebc2d3a679c586ae20c0bc4a;hp=7def9f2c00e4d830605f691992b98884d9b6a204;hpb=dec33c63afafabf83c3039e916725cac6faef9b3;p=fms.git diff --git a/src/freenet/identityintroductionrequester.cpp b/src/freenet/identityintroductionrequester.cpp index 7def9f2..951e12d 100644 --- a/src/freenet/identityintroductionrequester.cpp +++ b/src/freenet/identityintroductionrequester.cpp @@ -61,10 +61,13 @@ const bool IdentityIntroductionRequester::HandleAllData(FCPMessage &message) // receive the file data.resize(datalength); - m_fcp->ReceiveRaw(&data[0],datalength); + if(data.size()>0) + { + m_fcp->ReceiveRaw(&data[0],datalength); + } // parse file into xml and update the database - if(xml.ParseXML(std::string(data.begin(),data.end()))==true) + if(data.size()>0 && xml.ParseXML(std::string(data.begin(),data.end()))==true) { ssk.SetPublicKey(xml.GetIdentity()); @@ -181,17 +184,16 @@ const bool IdentityIntroductionRequester::HandleMessage(FCPMessage &message) void IdentityIntroductionRequester::Initialize() { - std::string tempval=""; - Option::Instance()->Get("MaxIdentityIntroductionRequests",tempval); - StringFunctions::Convert(tempval,m_maxrequests); + m_maxrequests=0; + Option::Instance()->GetInt("MaxIdentityIntroductionRequests",m_maxrequests); if(m_maxrequests<1) { m_maxrequests=1; - m_log->error("Option MaxIdentityIntroductionRequests is currently set at "+tempval+". It must be 1 or greater."); + m_log->error("Option MaxIdentityIntroductionRequests is currently less than 1. It must be 1 or greater."); } if(m_maxrequests>100) { - m_log->warning("Option MaxIdentityIntroductionRequests is currently set at "+tempval+". This value might be incorrectly configured."); + m_log->warning("Option MaxIdentityIntroductionRequests is currently set at more than 100. This value might be incorrectly configured."); } Option::Instance()->Get("MessageBase",m_messagebase); m_tempdate=Poco::Timestamp(); @@ -277,7 +279,6 @@ void IdentityIntroductionRequester::StartRequest(const std::string &UUID) { std::string day; std::string solution; -// std::vector solutionhash; std::string encodedhash; FCPMessage message; SQLite3DB::Statement st=m_db->Prepare("SELECT Day, PuzzleSolution FROM tblIntroductionPuzzleInserts WHERE FoundSolution='false' AND UUID=?;"); @@ -289,16 +290,12 @@ void IdentityIntroductionRequester::StartRequest(const std::string &UUID) st.ResultText(0,day); st.ResultText(1,solution); + // get the hash of the solution Poco::SHA1Engine sha1; sha1.update(solution); encodedhash=Poco::DigestEngine::digestToHex(sha1.digest()); StringFunctions::UpperCase(encodedhash,encodedhash); - // get the hash of the solution -// solutionhash.resize(20); -// sha1((unsigned char *)solution.c_str(),solution.size(),&solutionhash[0]); -// Hex::Encode(solutionhash,encodedhash); - //start request for the solution message.SetName("ClientGet"); message["URI"]="KSK@"+m_messagebase+"|"+day+"|"+UUID+"|"+encodedhash+".xml";