IntroductionPuzzleXML xml;\r
long identityid;\r
long index;\r
+ bool validmessage=true;\r
\r
now.SetToGMTime();\r
StringFunctions::Split(message["Identifier"],"|",idparts);\r
// parse file into xml and update the database\r
if(xml.ParseXML(std::string(data.begin(),data.end()))==true)\r
{\r
+\r
+ // check if last part of UUID matches first part of public key of identity who inserted it\r
+ st=m_db->Prepare("SELECT PublicKey FROM tblIdentity WHERE IdentityID=?;");\r
+ st.Bind(0,identityid);\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ std::vector<std::string> uuidparts;\r
+ std::vector<std::string> keyparts;\r
+ std::string keypart="";\r
+ std::string publickey="";\r
+\r
+ st.ResultText(0,publickey);\r
+\r
+ StringFunctions::SplitMultiple(publickey,"@,",keyparts);\r
+ StringFunctions::SplitMultiple(xml.GetUUID(),"@",uuidparts);\r
+\r
+ if(uuidparts.size()>1 && keyparts.size()>1)\r
+ {\r
+ keypart=StringFunctions::Replace(StringFunctions::Replace(keyparts[1],"-",""),"~","");\r
+ if(keypart!=uuidparts[1])\r
+ {\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData UUID in IntroductionPuzzle doesn't match public key of identity : "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData Error with identity's public key or UUID : "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
+\r
+ }\r
+ else\r
+ {\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData Error couldn't find identity : "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
+\r
st=m_db->Prepare("INSERT INTO tblIntroductionPuzzleRequests(IdentityID,Day,RequestIndex,Found,UUID,Type,MimeType,PuzzleData) VALUES(?,?,?,?,?,?,?,?);");\r
st.Bind(0,identityid);\r
st.Bind(1,idparts[4]);\r
st.Bind(2,index);\r
- st.Bind(3,"true");\r
- st.Bind(4,xml.GetUUID());\r
- st.Bind(5,xml.GetType());\r
- st.Bind(6,xml.GetMimeType());\r
- st.Bind(7,xml.GetPuzzleData());\r
+ if(validmessage)\r
+ {\r
+ st.Bind(3,"true");\r
+ st.Bind(4,xml.GetUUID());\r
+ st.Bind(5,xml.GetType());\r
+ st.Bind(6,xml.GetMimeType());\r
+ st.Bind(7,xml.GetPuzzleData());\r
+ }\r
+ else\r
+ {\r
+ st.Bind(3,"false");\r
+ st.Bind(4);\r
+ st.Bind(5);\r
+ st.Bind(6);\r
+ st.Bind(7);\r
+ }\r
st.Step();\r
st.Finalize();\r
\r
\r
now.SetToGMTime();\r
\r
- // select identities that aren't single use and have been seen today ( order by trust DESC and limit to limitnum )\r
- st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+now.Format("%Y-%m-%d")+"' ORDER BY LocalMessageTrust LIMIT 0,"+limitnum+";");\r
+ // select identities that aren't single use, are publishing a trust list, and have been seen today ( order by trust DESC and limit to limitnum )\r
+ st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublishTrustList='true' AND PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+now.Format("%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";");\r
st.Step();\r
\r
m_ids.clear();\r