\r
// opens database and creates tables and initial inserts if necessary\r
void SetupDB();\r
+// verifies DB isn't corrupt\r
+const bool VerifyDB();\r
\r
#endif // _dbsetup_\r
void Shutdown();\r
\r
std::string m_fcphost;\r
- long m_fcpport;\r
+ int m_fcpport;\r
FCPv2 m_fcp;\r
std::vector<IFreenetRegistrable *> m_registrables;\r
std::vector<IPeriodicProcessor *> m_processors;\r
std::map<long,bool> m_ids;\r
std::vector<std::string> m_requesting;\r
std::string m_messagebase;\r
- long m_maxrequests;\r
+ int m_maxrequests;\r
\r
};\r
\r
std::vector<IDTYPE> m_requesting; // list of ids we are currently requesting from\r
\r
// these MUST be populated by child class\r
- long m_maxrequests;\r
+ int m_maxrequests;\r
std::string m_fcpuniquename;\r
\r
};\r
\r
Poco::DateTime m_tempdate;\r
std::string m_messagebase;\r
- long m_maxrequests;\r
+ int m_maxrequests;\r
std::vector<long> m_requesting; // list of ids we are currently requesting from\r
std::map<long,bool> m_ids; // map of all ids we know and whether we have requested file from them yet\r
\r
const bool SaveToBoard(const std::string &boardname);\r
const std::string GetIdentityName(const long identityid);\r
\r
- long m_maxdaysbackward;\r
- long m_maxpeermessages;\r
- long m_maxboardspermessage;\r
+ int m_maxdaysbackward;\r
+ int m_maxpeermessages;\r
+ int m_maxboardspermessage;\r
bool m_savemessagesfromnewboards;\r
bool m_localtrustoverrides;\r
\r
\r
#define VERSION_MAJOR "0"\r
#define VERSION_MINOR "3"\r
-#define VERSION_RELEASE "18"\r
+#define VERSION_RELEASE "19"\r
#define FMS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE\r
-#define FMS_FREESITE_USK "USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/78/"\r
-#define FMS_VERSION_EDITION "19"\r
+#define FMS_FREESITE_USK "USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/79/"\r
+#define FMS_VERSION_EDITION "20"\r
\r
typedef Poco::ScopedLock<Poco::FastMutex> Guard;\r
\r
{\r
public:\r
const bool Get(const std::string &option, std::string &value);\r
+ const bool GetInt(const std::string &option, int &value);\r
template<class T>\r
void Set(const std::string &option, const T &value);\r
private:\r
db->Execute("ANALYZE;");\r
\r
}\r
+\r
+const bool VerifyDB()\r
+{\r
+ SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+ SQLite3DB::Statement st=db->Prepare("PRAGMA integrity_check;");\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ std::string res="";\r
+ st.ResultText(0,res);\r
+ if(res=="ok")\r
+ {\r
+ return true;\r
+ }\r
+ else\r
+ {\r
+ return false;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ return false;\r
+ }\r
+}\r
// so we need to set the working directory again\r
int rval=chdir(m_workingdirectory.c_str());\r
\r
- if(m_displayhelp)\r
+ if(VerifyDB()==false)\r
+ {\r
+ std::cout << "The FMS database failed verification. It is most likely corrupt!" << std::endl;\r
+ logger().fatal("The FMS database failed verification. It is most likely corrupt!");\r
+ }\r
+ else if(m_displayhelp)\r
{\r
}\r
else if(m_showoptions)\r
m_fcpuniquename="BoardListRequester";\r
m_maxrequests=0;\r
\r
- Option::Instance()->Get("MaxBoardListRequests",tempval);\r
- StringFunctions::Convert(tempval,m_maxrequests);\r
+ Option::Instance()->GetInt("MaxBoardListRequests",m_maxrequests);\r
if(m_maxrequests<0)\r
{\r
m_maxrequests=0;\r
\r
FreenetMasterThread::FreenetMasterThread()\r
{\r
- std::string fcpport;\r
\r
if(Option::Instance()->Get("FCPHost",m_fcphost)==false)\r
{\r
m_fcphost="localhost";\r
Option::Instance()->Set("FCPHost",m_fcphost);\r
}\r
- if(Option::Instance()->Get("FCPPort",fcpport)==false)\r
+ if(Option::Instance()->GetInt("FCPPort",m_fcpport)==false)\r
{\r
- fcpport="9481";\r
- Option::Instance()->Set("FCPPort",fcpport);\r
+ m_fcpport=9481;\r
+ Option::Instance()->Set("FCPPort",m_fcpport);\r
}\r
-\r
- // convert fcp port to long, and make sure it's within the valid port range\r
- if(StringFunctions::Convert(fcpport,m_fcpport)==false)\r
+ else\r
{\r
- m_fcpport=9481;\r
- Option::Instance()->Set("FCPPort","9481");\r
+ if(m_fcpport<1 || m_fcpport>65535)\r
+ {\r
+ m_fcpport=9481;\r
+ Option::Instance()->Set("FCPPort",m_fcpport);\r
+ }\r
}\r
\r
m_receivednodehello=false;\r
\r
void IdentityIntroductionRequester::Initialize()\r
{\r
- std::string tempval="";\r
- Option::Instance()->Get("MaxIdentityIntroductionRequests",tempval);\r
- StringFunctions::Convert(tempval,m_maxrequests);\r
+ m_maxrequests=0;\r
+ Option::Instance()->GetInt("MaxIdentityIntroductionRequests",m_maxrequests);\r
if(m_maxrequests<1)\r
{\r
m_maxrequests=1;\r
- m_log->error("Option MaxIdentityIntroductionRequests is currently set at "+tempval+". It must be 1 or greater.");\r
+ m_log->error("Option MaxIdentityIntroductionRequests is currently less than 1. It must be 1 or greater.");\r
}\r
if(m_maxrequests>100)\r
{\r
- m_log->warning("Option MaxIdentityIntroductionRequests is currently set at "+tempval+". This value might be incorrectly configured.");\r
+ m_log->warning("Option MaxIdentityIntroductionRequests is currently set at more than 100. This value might be incorrectly configured.");\r
}\r
Option::Instance()->Get("MessageBase",m_messagebase);\r
m_tempdate=Poco::Timestamp();\r
\r
void IdentityRequester::Initialize()\r
{\r
- std::string tempval="";\r
m_fcpuniquename="IdentityRequester";\r
- Option::Instance()->Get("MaxIdentityRequests",tempval);\r
- StringFunctions::Convert(tempval,m_maxrequests);\r
+ Option::Instance()->GetInt("MaxIdentityRequests",m_maxrequests);\r
if(m_maxrequests<1)\r
{\r
m_maxrequests=1;\r
- m_log->error("Option MaxIdentityRequests is currently set at "+tempval+". It must be 1 or greater.");\r
+ m_log->error("Option MaxIdentityRequests is currently set at less than 1. It must be 1 or greater.");\r
}\r
if(m_maxrequests>100)\r
{\r
- m_log->warning("Option MaxIdentityRequests is currently set at "+tempval+". This value might be incorrectly configured.");\r
+ m_log->warning("Option MaxIdentityRequests is currently set at more than 100. This value might be incorrectly configured.");\r
}\r
}\r
\r
\r
void IntroductionPuzzleRequester::Initialize()\r
{\r
- std::string tempval="";\r
- Option::Instance()->Get("MaxIntroductionPuzzleRequests",tempval);\r
- StringFunctions::Convert(tempval,m_maxrequests);\r
+ m_maxrequests=0;\r
+ Option::Instance()->GetInt("MaxIntroductionPuzzleRequests",m_maxrequests);\r
if(m_maxrequests<1)\r
{\r
m_maxrequests=1;\r
- m_log->error("Option MaxIntroductionPuzzleRequests is currently set at "+tempval+". It must be 1 or greater.");\r
+ m_log->error("Option MaxIntroductionPuzzleRequests is currently set at less than 1. It must be 1 or greater.");\r
}\r
if(m_maxrequests>100)\r
{\r
- m_log->warning("Option MaxIntroductionPuzzleRequests is currently set at "+tempval+". This value might be incorrectly configured.");\r
+ m_log->warning("Option MaxIntroductionPuzzleRequests is currently set at more than 100. This value might be incorrectly configured.");\r
}\r
Option::Instance()->Get("MessageBase",m_messagebase);\r
m_tempdate=Poco::Timestamp();\r
void MessageListRequester::Initialize()\r
{\r
m_fcpuniquename="MessageListRequester";\r
- std::string tempval;\r
- Option::Instance()->Get("MaxMessageListRequests",tempval);\r
- StringFunctions::Convert(tempval,m_maxrequests);\r
+ std::string tempval="";\r
+\r
+ m_maxrequests=0;\r
+ Option::Instance()->GetInt("MaxMessageListRequests",m_maxrequests);\r
if(m_maxrequests<1)\r
{\r
m_maxrequests=1;\r
{\r
m_fcpuniquename="MessageRequester";\r
std::string tempval;\r
- Option::Instance()->Get("MaxMessageRequests",tempval);\r
- StringFunctions::Convert(tempval,m_maxrequests);\r
+\r
+ m_maxrequests=0;\r
+ Option::Instance()->GetInt("MaxMessageRequests",m_maxrequests);\r
if(m_maxrequests<1)\r
{\r
m_maxrequests=1;\r
{\r
m_log->warning("Option MaxMessageRequests is currently set at "+tempval+". This value might be incorrectly configured.");\r
}\r
- Option::Instance()->Get("MessageDownloadMaxDaysBackward",tempval);\r
- StringFunctions::Convert(tempval,m_maxdaysbackward);\r
+\r
+ m_maxdaysbackward=0;\r
+ Option::Instance()->GetInt("MessageDownloadMaxDaysBackward",m_maxdaysbackward);\r
if(m_maxdaysbackward<0)\r
{\r
m_maxdaysbackward=0;\r
{\r
m_log->warning("Option MessageDownloadMaxDaysBackward is currently set at "+tempval+". This value might be incorrectly configured.");\r
}\r
- Option::Instance()->Get("MaxPeerMessagesPerDay",tempval);\r
- StringFunctions::Convert(tempval,m_maxpeermessages);\r
+\r
+ m_maxpeermessages=0;\r
+ Option::Instance()->GetInt("MaxPeerMessagesPerDay",m_maxpeermessages);\r
if(m_maxpeermessages<1)\r
{\r
m_maxpeermessages=1;\r
{\r
m_log->warning("Option MaxPeerMessagesPerDay is currently set at "+tempval+". This value might be incorrectly configured. The suggested value is 200.");\r
}\r
- Option::Instance()->Get("MaxBoardsPerMessage",tempval);\r
- StringFunctions::Convert(tempval,m_maxboardspermessage);\r
+\r
+ m_maxboardspermessage=0;\r
+ Option::Instance()->GetInt("MaxBoardsPerMessage",m_maxboardspermessage);\r
if(m_maxboardspermessage<1)\r
{\r
m_maxboardspermessage=1;\r
{\r
std::string tempval="";\r
m_fcpuniquename="TrustListRequester";\r
- Option::Instance()->Get("MaxIdentityRequests",tempval);\r
- StringFunctions::Convert(tempval,m_maxrequests);\r
+\r
+ m_maxrequests=0;\r
+ Option::Instance()->GetInt("MaxIdentityRequests",m_maxrequests);\r
if(m_maxrequests<1)\r
{\r
m_maxrequests=1;\r
m_log->error("NNTPConnection::run select returned -1 : "+GetSocketErrorMessage()); \r
}\r
\r
+ //process all remaining commands in buffer\r
+ std::vector<char>::size_type rbs=0;\r
+ while(rbs!=m_receivebuffer.size())\r
+ {\r
+ rbs=m_receivebuffer.size();\r
+ HandleReceivedData();\r
+ }\r
+\r
}while(!Disconnected() && !IsCancelled());\r
\r
Disconnect();\r
return false;\r
}\r
}\r
+\r
+const bool Option::GetInt(const std::string &option, int &value)\r
+{\r
+ std::string valstr="";\r
+ if(Get(option,valstr))\r
+ {\r
+ std::istringstream istr(valstr);\r
+ if(istr >> value)\r
+ {\r
+ return true;\r
+ }\r
+ else\r
+ {\r
+ return false;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ return false;\r
+ }\r
+}\r