X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzleinserter.cpp;h=9bb4da8a32a8cf1ac2096b935467d0fb7a0fdacc;hb=14fff12d9df0ee30e2df4bf9d22c2e83065816df;hp=9dca8e095ccfc1e9d79677f8da5e0e9702c781b8;hpb=964f55fd550fc711c0320ce6a24ad713040695d0;p=fms.git diff --git a/src/freenet/introductionpuzzleinserter.cpp b/src/freenet/introductionpuzzleinserter.cpp index 9dca8e0..9bb4da8 100644 --- a/src/freenet/introductionpuzzleinserter.cpp +++ b/src/freenet/introductionpuzzleinserter.cpp @@ -22,8 +22,8 @@ IntroductionPuzzleInserter::IntroductionPuzzleInserter(FCPv2 *fcp):IFCPConnected void IntroductionPuzzleInserter::CheckForNeededInsert() { - // select all local ids that aren't single use and that aren't currently inserting a puzzle - SQLite3DB::Recordset rs=m_db->Query("SELECT LocalIdentityID FROM tblLocalIdentity WHERE SingleUse='false' AND InsertingPuzzle='false' AND PrivateKey IS NOT NULL AND PrivateKey <> '' ORDER BY LastInsertedPuzzle;"); + // select all local ids that aren't single use and that aren't currently inserting a puzzle and are publishing a trust list + SQLite3DB::Recordset rs=m_db->Query("SELECT LocalIdentityID FROM tblLocalIdentity WHERE PublishTrustList='true' AND SingleUse='false' AND InsertingPuzzle='false' AND PrivateKey IS NOT NULL AND PrivateKey <> '' ORDER BY LastInsertedPuzzle;"); while(!rs.AtEnd()) { @@ -201,7 +201,9 @@ void IntroductionPuzzleInserter::StartInsert(const long localidentityid) FCPMessage message; std::string xmldata; std::string xmldatasizestr; - std::string privatekey; + std::string privatekey=""; + std::string publickey=""; + std::string keypart=""; StringFunctions::Convert(localidentityid,idstring); now.SetToGMTime(); @@ -217,20 +219,29 @@ void IntroductionPuzzleInserter::StartInsert(const long localidentityid) } StringFunctions::Convert(index,indexstr); - SQLite3DB::Recordset rs2=m_db->Query("SELECT PrivateKey FROM tblLocalIdentity WHERE LocalIdentityID="+idstring+";"); + SQLite3DB::Recordset rs2=m_db->Query("SELECT PrivateKey,PublicKey FROM tblLocalIdentity WHERE LocalIdentityID="+idstring+";"); if(rs2.Empty()==false && rs2.GetField(0)!=NULL) { privatekey=rs2.GetField(0); + if(rs2.GetField(1)) + { + publickey=rs2.GetField(1); + } + if(publickey.size()>=50) + { + // remove - and ~ + keypart=StringFunctions::Replace(StringFunctions::Replace(publickey.substr(4,43),"-",""),"~",""); + } } - Option::instance()->Get("MessageBase",messagebase); + Option::Instance()->Get("MessageBase",messagebase); GenerateCaptcha(encodedpuzzle,solutionstring); xml.SetType("captcha"); - xml.SetUUID(uuid.Generate()); + xml.SetUUID(uuid.Generate()+"@"+keypart); xml.SetPuzzleData(encodedpuzzle); - xml.SetMimeType("bitmap/image"); + xml.SetMimeType("image/bmp"); xmldata=xml.GetXML(); StringFunctions::Convert(xmldata.size(),xmldatasizestr);