From: SomeDude Date: Fri, 18 Jan 2008 17:18:00 +0000 (+0100) Subject: version 0.0.3 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9048d8e482c91960265f29c2b5b3112f2a52f3d8;p=fms.git version 0.0.3 --- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8cace60 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,62 @@ +PROJECT(fms) + +SET(FMS_SRC +src/base64.cpp +src/commandthread.cpp +src/datetime.cpp +src/hex.cpp +src/identitytestglobal.cpp +src/logfile.cpp +src/main.cpp +src/option.cpp +src/socketdefines.cpp +src/stringfunctions.cpp +src/uuidgenerator.cpp +src/db/sqlite3db.cpp +src/db/sqlite3recordset.cpp +src/db/sqlite3statement.cpp +src/freenet/fcpv2.cpp +src/freenet/freenetmasterthread.cpp +src/freenet/freenetssk.cpp +src/freenet/identityinserter.cpp +src/freenet/identityintroductioninserter.cpp +src/freenet/identityintroductionrequester.cpp +src/freenet/identityintroductionxml.cpp +src/freenet/identityrequester.cpp +src/freenet/identityxml.cpp +src/freenet/introductionpuzzleinserter.cpp +src/freenet/introductionpuzzleremover.cpp +src/freenet/introductionpuzzlerequester.cpp +src/freenet/introductionpuzzlexml.cpp +src/freenet/trustlistinserter.cpp +src/freenet/trustlistrequester.cpp +src/freenet/trustlistxml.cpp +src/freenet/unkeyedidcreator.cpp +src/freenet/captcha/simplecaptcha.cpp +src/freenet/captcha/easybmp/EasyBMP.cpp +src/freenet/captcha/easybmp/EasyBMP_Font.cpp +src/freenet/captcha/easybmp/EasyBMP_Geometry.cpp +src/xyssl/sha1.c +) + +ADD_DEFINITIONS(-DTIXML_USE_STL) + +ADD_EXECUTABLE(fms ${FMS_SRC}) + +FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 sqlite3_s) +FIND_LIBRARY(TINYXML_LIBRARY NAMES tinyxml tinyxml_s) +FIND_LIBRARY(ZTHREADS_LIBRARY NAMES zthread zthread_s) + +IF(WIN32) + TARGET_LINK_LIBRARIES(fms ws2_32) +ENDIF(WIN32) + +IF(SQLITE3_LIBRARY) + TARGET_LINK_LIBRARIES(fms ${SQLITE3_LIBRARY}) +ENDIF(SQLITE3_LIBRARY) +IF(TINYXML_LIBRARY) + TARGET_LINK_LIBRARIES(fms ${TINYXML_LIBRARY}) +ENDIF(TINYXML_LIBRARY) +IF(ZTHREADS_LIBRARY) + TARGET_LINK_LIBRARIES(fms ${ZTHREADS_LIBRARY}) +ENDIF(ZTHREADS_LIBRARY) diff --git a/admin/introduce.php b/admin/introduce.php index f2103a8..3d38737 100644 --- a/admin/introduce.php +++ b/admin/introduce.php @@ -65,7 +65,7 @@ function content() print "
"; } ?> - + #include -#define FMS_VERSION "0.0.2" +#define FMS_VERSION "0.0.3" // opens database and creates tables and initial inserts if necessary void SetupDB(); diff --git a/src/freenet/captcha/simplecaptcha.cpp b/src/freenet/captcha/simplecaptcha.cpp index c030bca..2d4a4ae 100644 --- a/src/freenet/captcha/simplecaptcha.cpp +++ b/src/freenet/captcha/simplecaptcha.cpp @@ -56,7 +56,8 @@ void SimpleCaptcha::Generate() const std::string SimpleCaptcha::GenerateRandomString(const int len) { - static std::string chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + // no l,1 O,0 because they look too much alike + static std::string chars="abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789"; std::string temp=""; for(int i=0; i @@ -233,6 +234,7 @@ void FreenetMasterThread::Setup() m_registrables.push_back(new IntroductionPuzzleRemover()); m_registrables.push_back(new IdentityIntroductionInserter(&m_fcp)); m_registrables.push_back(new TrustListInserter(&m_fcp)); + m_registrables.push_back(new TrustListRequester(&m_fcp)); for(std::vector::iterator i=m_registrables.begin(); i!=m_registrables.end(); i++) { @@ -243,9 +245,9 @@ void FreenetMasterThread::Setup() void FreenetMasterThread::Shutdown() { - // delete each registerable object + // delete each registrable object for(std::vector::iterator i=m_registrables.begin(); i!=m_registrables.end(); i++) { delete (*i); } -} \ No newline at end of file +} diff --git a/src/freenet/identityinserter.cpp b/src/freenet/identityinserter.cpp index 028f495..4fac82f 100644 --- a/src/freenet/identityinserter.cpp +++ b/src/freenet/identityinserter.cpp @@ -26,10 +26,13 @@ void IdentityInserter::CheckForNeededInsert() // set date to 1 hour back date.Add(0,0,-1); - // Because of importance of Identity.xml, if we are now at the next day we immediately want to insert identities so change the date back to now + // Because of importance of Identity.xml, if we are now at the next day we immediately want to insert identities so change the date back to 12:00 AM so we find all identities not inserted yet today if(date.GetDay()!=now.GetDay()) { date=now; + date.SetHour(0); + date.SetMinute(0); + date.SetSecond(0); } SQLite3DB::Recordset rs=m_db->Query("SELECT LocalIdentityID FROM tblLocalIdentity WHERE PrivateKey IS NOT NULL AND PrivateKey <> '' AND InsertingIdentity='false' AND (LastInsertedIdentity<'"+date.Format("%Y-%m-%d %H:%M:%S")+"' OR LastInsertedIdentity IS NULL) ORDER BY LastInsertedIdentity;"); @@ -79,7 +82,7 @@ const bool IdentityInserter::HandleMessage(FCPMessage &message) { m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false', LastInsertedIdentity='"+now.Format("%Y-%m-%d %H:%M:%S")+"' WHERE LocalIdentityID="+idparts[1]+";"); m_db->Execute("INSERT INTO tblLocalIdentityInserts(LocalIdentityID,Day,InsertIndex) VALUES("+idparts[1]+",'"+idparts[4]+"',"+idparts[2]+");"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" inserted identity xml"); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" inserted Identity xml"); return true; } @@ -195,7 +198,7 @@ void IdentityInserter::StartInsert(const long localidentityid) if(rs.GetField(4)) { - publishboardlist=rs.GetField(3); + publishboardlist=rs.GetField(4); } publishboardlist=="true" ? idxml.SetPublishBoardList(true) : idxml.SetPublishBoardList(false); diff --git a/src/freenet/trustlistrequester.cpp b/src/freenet/trustlistrequester.cpp index f5e4be9..5b13a6d 100644 --- a/src/freenet/trustlistrequester.cpp +++ b/src/freenet/trustlistrequester.cpp @@ -32,6 +32,7 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) { DateTime now; SQLite3DB::Statement st; + SQLite3DB::Statement trustst; std::vector idparts; long datalength; std::vector data; @@ -64,23 +65,45 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) // parse file into xml and update the database if(xml.ParseXML(std::string(data.begin(),data.end()))==true) { + + // drop all existing peer trust from this identity - we will rebuild it when we go through each trust in the xml file + st=m_db->Prepare("DELETE FROM tblPeerTrust WHERE IdentityID=?;"); + st.Bind(0,identityid); + st.Step(); + st.Finalize(); + st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey=?;"); + trustst=m_db->Prepare("INSERT INTO tblPeerTrust(IdentityID,TargetIdentityID,MessageTrust,TrustListTrust) VALUES(?,?,?,?);"); // loop through all trust entries in xml and add to database if we don't already know them for(long i=0; iExecute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('"+identity+"','"+now.Format("%Y-%m-%d %H:%M:%S")+"');"); + m_db->ExecuteInsert("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('"+identity+"','"+now.Format("%Y-%m-%d %H:%M:%S")+"');",(long &)id); + } + else + { + st.ResultInt(0,id); } st.Reset(); + + //insert trust for this identity + trustst.Bind(0,identityid); + trustst.Bind(1,id); + trustst.Bind(2,xml.GetMessageTrust(i)); + trustst.Bind(3,xml.GetTrustListTrust(i)); + trustst.Step(); + trustst.Reset(); + } + trustst.Finalize(); + st.Finalize(); st=m_db->Prepare("INSERT INTO tblTrustListRequests(IdentityID,Day,RequestIndex,Found) VALUES(?,?,?,'true');"); st.Bind(0,identityid); @@ -89,7 +112,7 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" parsed Identity XML file : "+message["Identifier"]); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" parsed TrustList XML file : "+message["Identifier"]); } else { diff --git a/src/freenet/trustlistxml.cpp b/src/freenet/trustlistxml.cpp index 45af43e..1b36aa3 100644 --- a/src/freenet/trustlistxml.cpp +++ b/src/freenet/trustlistxml.cpp @@ -139,6 +139,7 @@ const bool TrustListXML::ParseXML(const std::string &xml) node=node->NextSibling("Trust"); } + return true; } else diff --git a/src/identitytestglobal.cpp b/src/identitytestglobal.cpp index 9297101..4b40288 100644 --- a/src/identitytestglobal.cpp +++ b/src/identitytestglobal.cpp @@ -132,7 +132,7 @@ void SetupDB() ROUND(SUM(MessageTrust*(LocalMessageTrust/100.0))/SUM(LocalMessageTrust/100.0),0) AS 'PeerMessageTrust', \ ROUND(SUM(TrustListTrust*(LocalTrustListTrust/100.0))/SUM(LocalTrustListTrust/100.0),0) AS 'PeerTrustListTrust' \ FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.IdentityID=tblIdentity.IdentityID \ - WHERE LocalTrustListTrust>(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust') \ + WHERE LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust') \ GROUP BY TargetIdentityID;"); // update PeerTrustLevel when deleting a record from tblPeerTrust @@ -186,7 +186,7 @@ void SetupDefaultOptions() // StartFreenetUpdater st.Bind(0,"StartFreenetUpdater"); st.Bind(1,"true"); - st.Bind(2,"Start Freenet Updater."); + st.Bind(2,"Start Freenet Updater thread."); st.Step(); st.Reset(); diff --git a/src/identitytestmain.cpp b/src/identitytestmain.cpp deleted file mode 100644 index 21244df..0000000 --- a/src/identitytestmain.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "../include/identitytestglobal.h" -#include "../include/commandthread.h" - -#include - -#ifdef XMEM - #include -#endif - -int main() -{ - - #ifdef XMEM - xmem_disable_print(); - #endif - - std::vector threads; - - srand(time(NULL)); - - SetupDB(); - SetupDefaultOptions(); - - SetupLogFile(); - - SetupNetwork(); - - LogFile::instance()->WriteLog(LogFile::LOGLEVEL_INFO,"FMS startup v"FMS_VERSION); - - - StartThreads(threads); - - - ZThread::Thread commandthread(new CommandThread()); - commandthread.wait(); - - - ShutdownThreads(threads); - - ShutdownNetwork(); - - LogFile::instance()->WriteLog(LogFile::LOGLEVEL_INFO,"FMS shutdown"); - LogFile::instance()->WriteNewLine(); - - return 0; -} diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..21244df --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,46 @@ +#include "../include/identitytestglobal.h" +#include "../include/commandthread.h" + +#include + +#ifdef XMEM + #include +#endif + +int main() +{ + + #ifdef XMEM + xmem_disable_print(); + #endif + + std::vector threads; + + srand(time(NULL)); + + SetupDB(); + SetupDefaultOptions(); + + SetupLogFile(); + + SetupNetwork(); + + LogFile::instance()->WriteLog(LogFile::LOGLEVEL_INFO,"FMS startup v"FMS_VERSION); + + + StartThreads(threads); + + + ZThread::Thread commandthread(new CommandThread()); + commandthread.wait(); + + + ShutdownThreads(threads); + + ShutdownNetwork(); + + LogFile::instance()->WriteLog(LogFile::LOGLEVEL_INFO,"FMS shutdown"); + LogFile::instance()->WriteNewLine(); + + return 0; +}