--- /dev/null
+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
print "<br>";\r
}\r
?>\r
- <input type="submit">\r
+ <input type="submit" value="Announce">\r
</form> \r
<?php \r
}\r
#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
\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
#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
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
\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
// 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
{\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
\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
{\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
// 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
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
\r
node=node->NextSibling("Trust");\r
}\r
+ return true;\r
\r
}\r
else\r
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
// 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
+++ /dev/null
-#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
--- /dev/null
+#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