X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Ftrustlistrequester.cpp;h=668cdb9299a5be6819c1c8671227e499382dc025;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hp=89da83a989ef62a05219b91c7e44c967cecd4d86;hpb=175f098e7e712b839db433b93fe8649a402c6784;p=fms.git diff --git a/src/freenet/trustlistrequester.cpp b/src/freenet/trustlistrequester.cpp index 89da83a..668cdb9 100644 --- a/src/freenet/trustlistrequester.cpp +++ b/src/freenet/trustlistrequester.cpp @@ -3,6 +3,8 @@ #include "../../include/stringfunctions.h" #include "../../include/freenet/trustlistxml.h" +#include + #ifdef XMEM #include #endif @@ -19,7 +21,7 @@ TrustListRequester::TrustListRequester(FCPv2 *fcp):IIndexRequester(fcp) const bool TrustListRequester::HandleAllData(FCPMessage &message) { - DateTime now; + Poco::DateTime now; SQLite3DB::Statement st; SQLite3DB::Statement trustst; std::vector idparts; @@ -29,7 +31,6 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) long identityid; long index; - now.SetToGMTime(); StringFunctions::Split(message["Identifier"],"|",idparts); StringFunctions::Convert(message["DataLength"],datalength); StringFunctions::Convert(idparts[1],identityid); @@ -98,7 +99,7 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) if(st.RowReturned()==false) { idinsert.Bind(0,identity); - idinsert.Bind(1,now.Format("%Y-%m-%d %H:%M:%S")); + idinsert.Bind(1,Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S")); idinsert.Bind(2,"trust list of "+publisherid); idinsert.Step(true); id=idinsert.GetLastInsertRowID(); @@ -157,7 +158,7 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"TrustListRequester::HandleAllData parsed TrustList XML file : "+message["Identifier"]); + m_log->debug("TrustListRequester::HandleAllData parsed TrustList XML file : "+message["Identifier"]); } else { @@ -169,7 +170,7 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"TrustListRequester::HandleAllData error parsing TrustList XML file : "+message["Identifier"]); + m_log->error("TrustListRequester::HandleAllData error parsing TrustList XML file : "+message["Identifier"]); } // remove this identityid from request list @@ -181,13 +182,11 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) const bool TrustListRequester::HandleGetFailed(FCPMessage &message) { - DateTime now; SQLite3DB::Statement st; std::vector idparts; long identityid; long index; - now.SetToGMTime(); StringFunctions::Split(message["Identifier"],"|",idparts); StringFunctions::Convert(idparts[1],identityid); StringFunctions::Convert(idparts[2],index); @@ -202,7 +201,7 @@ const bool TrustListRequester::HandleGetFailed(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"TrustListRequester::HandleGetFailed fatal error requesting "+message["Identifier"]); + m_log->error("TrustListRequester::HandleGetFailed fatal error requesting "+message["Identifier"]); } // remove this identityid from request list @@ -221,26 +220,24 @@ void TrustListRequester::Initialize() if(m_maxrequests<1) { m_maxrequests=1; - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"Option MaxTrustListRequests is currently set at "+tempval+". It must be 1 or greater."); + m_log->error("Option MaxTrustListRequests is currently set at "+tempval+". It must be 1 or greater."); } if(m_maxrequests>100) { - m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"Option MaxTrustListRequests is currently set at "+tempval+". This value might be incorrectly configured."); + m_log->warning("Option MaxTrustListRequests is currently set at "+tempval+". This value might be incorrectly configured."); } - m_tempdate.SetToGMTime(); + m_tempdate=Poco::Timestamp(); } void TrustListRequester::PopulateIDList() { - DateTime date; + Poco::DateTime date; int id; std::string sql; - date.SetToGMTime(); - // select identities we want to query (we've seen them today and they are publishing trust list) - sort by their trust level (descending) with secondary sort on how long ago we saw them (ascending) sql="SELECT IdentityID FROM tblIdentity "; - sql+="WHERE Name IS NOT NULL AND Name <> '' AND PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+date.Format("%Y-%m-%d")+"' AND PublishTrustList='true' AND LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust') AND ( PeerTrustListTrust IS NULL OR PeerTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerTrustListTrust') )"; + sql+="WHERE Name IS NOT NULL AND Name <> '' AND PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+Poco::DateTimeFormatter::format(date,"%Y-%m-%d")+"' AND PublishTrustList='true' AND LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust') AND ( PeerTrustListTrust IS NULL OR PeerTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerTrustListTrust') )"; sql+="ORDER BY LocalTrustListTrust DESC, LastSeen;"; SQLite3DB::Statement st=m_db->Prepare(sql); @@ -258,7 +255,7 @@ void TrustListRequester::PopulateIDList() void TrustListRequester::StartRequest(const long &identityid) { - DateTime now; + Poco::DateTime now; FCPMessage message; std::string publickey; int index; @@ -273,10 +270,8 @@ void TrustListRequester::StartRequest(const long &identityid) { st.ResultText(0,publickey); - now.SetToGMTime(); - SQLite3DB::Statement st2=m_db->Prepare("SELECT MAX(RequestIndex) FROM tblTrustListRequests WHERE Day=? AND IdentityID=?;"); - st2.Bind(0,now.Format("%Y-%m-%d")); + st2.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d")); st2.Bind(1,identityid); st2.Step(); @@ -295,7 +290,7 @@ void TrustListRequester::StartRequest(const long &identityid) StringFunctions::Convert(identityid,identityidstr); message.SetName("ClientGet"); - message["URI"]=publickey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|TrustList|"+indexstr+".xml"; + message["URI"]=publickey+m_messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"|TrustList|"+indexstr+".xml"; message["Identifier"]=m_fcpuniquename+"|"+identityidstr+"|"+indexstr+"|"+message["URI"]; message["ReturnType"]="direct"; message["MaxSize"]="1000000"; // 1 MB