From: SomeDude Date: Wed, 9 Jul 2008 13:27:00 +0000 (+0200) Subject: version 0.3.6 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=026dc6b2bc548c945359c4e166eff514f2c47c6a;p=fms.git version 0.3.6 --- diff --git a/include/fmsapp.h b/include/fmsapp.h index ac2ef7d..56b6125 100644 --- a/include/fmsapp.h +++ b/include/fmsapp.h @@ -36,6 +36,7 @@ private: bool m_setoption; std::map m_setoptions; std::string m_logtype; + std::string m_workingdirectory; ThreadedExecutor m_threads; diff --git a/include/freenet/messagelistrequester.h b/include/freenet/messagelistrequester.h index 73bddf2..106c2fe 100644 --- a/include/freenet/messagelistrequester.h +++ b/include/freenet/messagelistrequester.h @@ -3,6 +3,8 @@ #include "iindexrequester.h" +#include + class MessageListRequester:public IIndexRequester { public: @@ -16,8 +18,10 @@ private: void StartRedirectRequest(FCPMessage &message); const bool HandleAllData(FCPMessage &message); const bool HandleGetFailed(FCPMessage &message); + void GetBoardList(std::map &boards); bool m_localtrustoverrides; + bool m_savetonewboards; }; diff --git a/include/global.h b/include/global.h index 13fa70c..204aa45 100644 --- a/include/global.h +++ b/include/global.h @@ -7,7 +7,7 @@ #define VERSION_MAJOR "0" #define VERSION_MINOR "3" -#define VERSION_RELEASE "5" +#define VERSION_RELEASE "6" #define FMS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE typedef Poco::ScopedLock Guard; diff --git a/src/fmsapp.cpp b/src/fmsapp.cpp index 3182443..94443c4 100644 --- a/src/fmsapp.cpp +++ b/src/fmsapp.cpp @@ -24,9 +24,17 @@ #include #endif -FMSApp::FMSApp():m_displayhelp(false),m_showoptions(false),m_setoption(false),m_logtype("file") +FMSApp::FMSApp():m_displayhelp(false),m_showoptions(false),m_setoption(false),m_logtype("file"),m_workingdirectory("") { - + // get current working dir so we can go to it later + char wd[1024]; + char *wdptr=NULL; + memset(wd,0,1024); + wdptr=getcwd(wd,1023); + if(wdptr) + { + m_workingdirectory=wdptr; + } } void FMSApp::defineOptions(Poco::Util::OptionSet &options) @@ -90,8 +98,12 @@ void FMSApp::initialize(Poco::Util::Application &self) { ServerApplication::initialize(self); - // set working directory to program directory - int rval=chdir(config().getString("application.dir").c_str()); + // set working directory - fall back on application.dir if working directory isn't set + if(m_workingdirectory=="") + { + m_workingdirectory=config().getString("application.dir"); + } + int rval=chdir(m_workingdirectory.c_str()); SetupDB(); SetupDefaultOptions(); @@ -145,8 +157,7 @@ int FMSApp::main(const std::vector &args) // running as a daemon would reset the working directory to / before calling main // so we need to set the working directory again - // set working directory to program directory - int rval=chdir(config().getString("application.dir").c_str()); + int rval=chdir(m_workingdirectory.c_str()); if(m_displayhelp) { diff --git a/src/freenet/messagelistrequester.cpp b/src/freenet/messagelistrequester.cpp index ee2dfaf..62d5bb2 100644 --- a/src/freenet/messagelistrequester.cpp +++ b/src/freenet/messagelistrequester.cpp @@ -19,6 +19,30 @@ MessageListRequester::MessageListRequester(FCPv2 *fcp):IIndexRequester(fcp Initialize(); } +void MessageListRequester::GetBoardList(std::map &boards) +{ + SQLite3DB::Statement st=m_db->Prepare("SELECT BoardName, SaveReceivedMessages FROM tblBoard;"); + st.Step(); + while(st.RowReturned()) + { + std::string boardname=""; + std::string tempval=""; + st.ResultText(0,boardname); + st.ResultText(1,tempval); + + if(tempval=="true") + { + boards[boardname]=true; + } + else + { + boards[boardname]=false; + } + + st.Step(); + } +} + const bool MessageListRequester::HandleAllData(FCPMessage &message) { SQLite3DB::Statement st; @@ -29,6 +53,11 @@ const bool MessageListRequester::HandleAllData(FCPMessage &message) MessageListXML xml; long identityid; long index; + std::map boards; // list of boards and if we will save messages for that board or not + bool addmessage=false; + std::string boardsstr=""; + + GetBoardList(boards); StringFunctions::Split(message["Identifier"],"|",idparts); StringFunctions::Convert(message["DataLength"],datalength); @@ -60,19 +89,52 @@ const bool MessageListRequester::HandleAllData(FCPMessage &message) SQLite3DB::Statement mst=m_db->Prepare("INSERT INTO tblMessageRequests(IdentityID,Day,RequestIndex,FromMessageList) VALUES(?,?,?,'true');"); for(long i=0; i messageboards=xml.GetBoards(i); + for(std::vector::iterator j=messageboards.begin(); j!=messageboards.end(); j++) { - mst.Bind(0,identityid); - mst.Bind(1,xml.GetDate(i)); - mst.Bind(2,xml.GetIndex(i)); - mst.Step(); - mst.Reset(); + if(boards.find((*j))!=boards.end()) + { + if(boards[(*j)]==true) + { + addmessage=true; + } + } + else if(m_savetonewboards==true) + { + addmessage=true; + } + if(j!=messageboards.begin()) + { + boardsstr+=", "; + } + boardsstr+=(*j); + } + + if(addmessage==true) + { + st.Bind(0,identityid); + st.Bind(1,xml.GetDate(i)); + st.Bind(2,xml.GetIndex(i)); + st.Step(); + if(st.RowReturned()==false) + { + mst.Bind(0,identityid); + mst.Bind(1,xml.GetDate(i)); + mst.Bind(2,xml.GetIndex(i)); + mst.Step(); + mst.Reset(); + } + st.Reset(); + } + else + { + m_log->trace("MessageListRequester::HandleAllData will not download message posted to "+boardsstr); } - st.Reset(); } // insert external message indexes @@ -80,19 +142,51 @@ const bool MessageListRequester::HandleAllData(FCPMessage &message) { if(xml.GetExternalType(i)=="Keyed") { - spk.Bind(0,xml.GetExternalIdentity(i)); - spk.Step(); - if(spk.RowReturned()) + // go through each board the message was posted to and see if we are saving messages to that board + // if the board isn't found, see if we are saving messages to new boards + boardsstr=""; + addmessage=false; + std::vector messageboards=xml.GetExternalBoards(i); + for(std::vector::iterator j=messageboards.begin(); j!=messageboards.end(); j++) { - int thisidentityid=0; - spk.ResultInt(0,thisidentityid); - mst.Bind(0,thisidentityid); - mst.Bind(1,xml.GetExternalDate(i)); - mst.Bind(2,xml.GetExternalIndex(i)); - mst.Step(); - mst.Reset(); + if(boards.find((*j))!=boards.end()) + { + if(boards[(*j)]==true) + { + addmessage=true; + } + } + else if(m_savetonewboards==true) + { + addmessage=true; + } + if(j!=messageboards.begin()) + { + boardsstr+=", "; + } + boardsstr+=(*j); + } + + if(addmessage==true) + { + spk.Bind(0,xml.GetExternalIdentity(i)); + spk.Step(); + if(spk.RowReturned()) + { + int thisidentityid=0; + spk.ResultInt(0,thisidentityid); + mst.Bind(0,thisidentityid); + mst.Bind(1,xml.GetExternalDate(i)); + mst.Bind(2,xml.GetExternalIndex(i)); + mst.Step(); + mst.Reset(); + } + spk.Reset(); + } + else + { + m_log->trace("MessageListRequester::HandleAllData will not download external message posted to "+boardsstr+" from " + xml.GetExternalIdentity(i)); } - spk.Reset(); } } @@ -178,6 +272,7 @@ void MessageListRequester::Initialize() m_log->warning("Option MaxMessageListRequests is currently set at "+tempval+". This value might be incorrectly configured."); } + tempval=""; Option::Instance()->Get("LocalTrustOverridesPeerTrust",tempval); if(tempval=="true") { @@ -188,6 +283,17 @@ void MessageListRequester::Initialize() m_localtrustoverrides=false; } + tempval=""; + Option::Instance()->Get("SaveMessagesFromNewBoards",tempval); + if(tempval=="true") + { + m_savetonewboards=true; + } + else + { + m_savetonewboards=false; + } + } void MessageListRequester::PopulateIDList() diff --git a/src/http/multipartparser.cpp b/src/http/multipartparser.cpp index 3b91cd2..63247b4 100644 --- a/src/http/multipartparser.cpp +++ b/src/http/multipartparser.cpp @@ -15,8 +15,7 @@ void MultiPartParser::handlePart(const Poco::Net::MessageHeader &header, std::is Poco::Net::MessageHeader::splitParameters(header["Content-Disposition"],disp,nvc); name=nvc.get("name",""); - Poco::StreamCopier sc; - sc.copyToString(stream,data); + Poco::StreamCopier::copyToString(stream,data); vars[name]=data; } diff --git a/src/http/pages/boardspage.cpp b/src/http/pages/boardspage.cpp index 43870ce..8b2866e 100644 --- a/src/http/pages/boardspage.cpp +++ b/src/http/pages/boardspage.cpp @@ -258,7 +258,7 @@ const std::string BoardsPage::GeneratePage(const std::string &method, const std: content+=""; content+=""; content+="

"; - content+="* If you uncheck this box, any new messages you download that are posted to this board will be discarded."; + content+="* If you uncheck this box, any new messages you download that are posted to this board will be discarded. When multiple local identities are used, it is best not to discard messages from any boards, as identifying which identities are the same person is much easier when their message lists are missing messages from the same boards."; content+="

"; return StringFunctions::Replace(m_template,"[CONTENT]",content); diff --git a/src/http/pages/execquerypage.cpp b/src/http/pages/execquerypage.cpp index b09b32e..8d46c46 100644 --- a/src/http/pages/execquerypage.cpp +++ b/src/http/pages/execquerypage.cpp @@ -51,7 +51,7 @@ const std::string ExecQueryPage::GeneratePage(const std::string &method, const s content+="

Execute Query

"; content+="
"; content+=""; - content+=""; + content+=""; content+=""; content+="
"; diff --git a/src/ipaddressacl.cpp b/src/ipaddressacl.cpp index 64ca979..2f62955 100644 --- a/src/ipaddressacl.cpp +++ b/src/ipaddressacl.cpp @@ -12,7 +12,7 @@ IPAddressACL::IPAddressACL():m_allowbydefault(true) const bool IPAddressACL::Add(const std::string &aclentry) { bool allow=m_allowbydefault; - int maskbits=0; + int maskbits=32; std::string::size_type strpos=std::string::npos; std::string entrystr=aclentry; @@ -63,21 +63,11 @@ const bool IPAddressACL::Add(const std::string &aclentry) const std::string IPAddressACL::CreateMask(const int maskbits) { +/* int bitsleft=maskbits; - //int parts[4]={255,255,255,255}; int parts[4]={0,0,0,0}; std::ostringstream ipstr; - /* - for(int i=3; i>=0; i--) - { - for(int b=0; b<8 && bitsleft>0; b++) - { - parts[i]-=pow((float)2,b); - bitsleft--; - } - } - */ for(int i=0; i<4; i++) { for(int b=7; b>=0 && bitsleft>0; b--) @@ -86,6 +76,19 @@ const std::string IPAddressACL::CreateMask(const int maskbits) bitsleft--; } } +*/ + int bits=maskbits; + bits>32 ? bits=32 : false; + bits<0 ? bits=0 : false; + int parts[4]={0,0,0,0}; + std::ostringstream ipstr; + + unsigned long maskval=(((unsigned long)pow((float)2,bits)-1) << (32-bits)); + + parts[0]=((maskval >> 24) & 0xff); + parts[1]=((maskval >> 16) & 0xff); + parts[2]=((maskval >> 8) & 0xff); + parts[3]=(maskval & 0xff); ipstr << parts[0] << "." << parts[1] << "." << parts[2] << "." << parts[3]; @@ -105,8 +108,11 @@ const bool IPAddressACL::IsAllowed(const Poco::Net::IPAddress &addr) //ip1.mask((*i).m_mask); //ip2.mask((*i).m_mask); - ip1=MaskAddress(ip1,(*i).m_mask); - ip2=MaskAddress(ip2,(*i).m_mask); + if(ip1.family()==Poco::Net::IPAddress::IPv4 && ip2.family()==Poco::Net::IPAddress::IPv4) + { + ip1=MaskAddress(ip1,(*i).m_mask); + ip2=MaskAddress(ip2,(*i).m_mask); + } if(ip1==ip2) { diff --git a/src/optionssetup.cpp b/src/optionssetup.cpp index 25de886..9395454 100644 --- a/src/optionssetup.cpp +++ b/src/optionssetup.cpp @@ -68,7 +68,7 @@ void SetupDefaultOptions() upd.Reset(); st.Bind(0,"FMSVersionEdition"); - st.Bind(1,"3"); + st.Bind(1,"7"); st.Step(); st.Reset(); upd.Bind(0,"Program");