version 0.0.3
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Fri, 18 Jan 2008 17:18:00 +0000 (18:18 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 18 Jan 2008 17:18:00 +0000 (18:18 +0100)
CMakeLists.txt [new file with mode: 0644]
admin/introduce.php
include/identitytestglobal.h
src/freenet/captcha/simplecaptcha.cpp
src/freenet/freenetmasterthread.cpp
src/freenet/identityinserter.cpp
src/freenet/trustlistrequester.cpp
src/freenet/trustlistxml.cpp
src/identitytestglobal.cpp
src/identitytestmain.cpp [deleted file]
src/main.cpp [new file with mode: 0644]

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