X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnntp%2Fnntpconnection.cpp;h=cc5cffe6fb99dc31b412e9eeb030c0b790fcd44e;hb=4430e7762844c66428b6f822288beb71b7f82b95;hp=ac75d4d310ffb0f931252a23b4f71ba3a950345a;hpb=868c533e84b3c81b6604b45b84efa32073aa20b4;p=fms.git diff --git a/src/nntp/nntpconnection.cpp b/src/nntp/nntpconnection.cpp index ac75d4d..cc5cffe 100644 --- a/src/nntp/nntpconnection.cpp +++ b/src/nntp/nntpconnection.cpp @@ -7,7 +7,10 @@ #include "../../include/messagelist.h" #include "../../include/option.h" -#include +#include + +//#include +#include "../../include/pthreadwrapper/thread.h" #ifdef XMEM #include @@ -26,7 +29,7 @@ NNTPConnection::NNTPConnection(SOCKET sock) m_status.m_messageid=-1; m_status.m_mode=MODE_NONE; - Option::instance()->Get("NNTPAllowPost",tempval); + Option::Instance()->Get("NNTPAllowPost",tempval); if(tempval=="true") { m_status.m_allowpost=true; @@ -230,7 +233,7 @@ const bool NNTPConnection::HandleLastCommand(const NNTPCommand &command) { Message mess; - if(mess.Load(m_status.m_messageid,m_status.m_boardid)) + if(mess.LoadPrevious(m_status.m_messageid,m_status.m_boardid)) { std::ostringstream tempstr; @@ -314,9 +317,9 @@ const bool NNTPConnection::HandleListCommand(const NNTPCommand &command) show=uwildmat((*i).GetBoardName().c_str(),arg2.c_str()); } - if(show==true) + if(show==true && (*i).GetSaveReceivedMessages()==true) { - tempstr << (*i).GetBoardName() << "\t" << (*i).GetHighMessageID() << "\t" << (*i).GetLowMessageID() << "\t" << (m_status.m_allowpost ? "y" : "n"); + tempstr << (*i).GetBoardName() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << (m_status.m_allowpost ? "y" : "n"); SendBufferedLine(tempstr.str()); } } @@ -345,7 +348,7 @@ const bool NNTPConnection::HandleListCommand(const NNTPCommand &command) show=uwildmat((*i).GetBoardName().c_str(),arg2.c_str()); } - if(show==true) + if(show==true && (*i).GetSaveReceivedMessages()==true) { tempstr << (*i).GetBoardName() << "\t" << (*i).GetBoardDescription(); SendBufferedLine(tempstr.str()); @@ -384,7 +387,6 @@ const bool NNTPConnection::HandleListGroupCommand(const NNTPCommand &command) std::ostringstream tempstr; Board board; bool validgroup=false; - int tempint; int lownum=-1; int highnum=-1; @@ -557,9 +559,12 @@ const bool NNTPConnection::HandleNewGroupsCommand(const NNTPCommand &command) for(BoardList::iterator i=bl.begin(); i!=bl.end(); i++) { - std::ostringstream tempstr; - tempstr << (*i).GetBoardName() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << m_status.m_allowpost ? "y" : "n"; - SendBufferedLine(tempstr.str()); + if((*i).GetSaveReceivedMessages()==true) + { + std::ostringstream tempstr; + tempstr << (*i).GetBoardName() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << m_status.m_allowpost ? "y" : "n"; + SendBufferedLine(tempstr.str()); + } } SendBufferedLine("."); @@ -583,7 +588,7 @@ const bool NNTPConnection::HandleNextCommand(const NNTPCommand &command) { Message mess; - if(mess.Load(m_status.m_messageid,m_status.m_boardid)) + if(mess.LoadNext(m_status.m_messageid,m_status.m_boardid)) { std::ostringstream tempstr; @@ -633,6 +638,13 @@ const bool NNTPConnection::HandleOverCommand(const NNTPCommand &command) messageuuid=command.m_arguments[0]; messageuuid=StringFunctions::Replace(messageuuid,"<",""); messageuuid=StringFunctions::Replace(messageuuid,">",""); + /* + // get rid of @ and everything after + if(messageuuid.find("@")!=std::string::npos) + { + messageuuid.erase(messageuuid.find("@")); + } + */ } // single article or range else @@ -771,8 +783,18 @@ void NNTPConnection::HandlePostedMessage(const std::string &message) if(mess.ParseNNTPMessage(message)) { - mess.StartFreenetInsert(); - SendBufferedLine("240 Article received OK"); + if(mess.PostedToAdministrationBoard()==true) + { + mess.HandleAdministrationMessage(); + } + if(mess.StartFreenetInsert()) + { + SendBufferedLine("240 Article received OK"); + } + else + { + SendBufferedLine("441 Posting failed. Make sure the identity you are sending with exists!"); + } } else { @@ -862,7 +884,7 @@ const bool NNTPConnection::HandleQuitCommand(const NNTPCommand &command) return true; } -void NNTPConnection::run() +void NNTPConnection::Run() { struct timeval tv; fd_set writefs,readfs; @@ -908,15 +930,16 @@ void NNTPConnection::run() SocketSend(); } } - else if(rval==-1) + else if(rval==SOCKET_ERROR) { m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::run select returned -1 : "+GetSocketErrorMessage()); } - }while(!Disconnected() && !ZThread::Thread::interrupted()); - +// }while(!Disconnected() && !ZThread::Thread::interrupted()); + }while(!Disconnected() && !IsCancelled()); + Disconnect(); - + } void NNTPConnection::SendArticleOverInfo(Message &message) @@ -940,7 +963,7 @@ void NNTPConnection::SendArticleOverInfo(Message &message) { line+=" "; } - line+="<"+(*i).second+">"; + line+="<"+(*i).second+">"; //+"@freenetproject.org>"; } line+="\t"; } @@ -1000,6 +1023,21 @@ void NNTPConnection::SendArticleParts(const NNTPConnection::NNTPCommand &command else { articleid=command.m_arguments[0]; + //strip off < and > and everthing after @ + if(articleid.size()>0 && articleid[0]=='<') + { + articleid.erase(0,1); + } + if(articleid.size()>0 && articleid[articleid.size()-1]=='>') + { + articleid.erase(articleid.size()-1); + } + /* + if(articleid.size()>0 && articleid.find('@')!=std::string::npos) + { + articleid.erase(articleid.find('@')); + } + */ message.Load(articleid); type=2; } @@ -1163,9 +1201,11 @@ void NNTPConnection::SocketReceive() } else if(rval==-1) { + std::string errnostr; + StringFunctions::Convert(GetSocketErrorNumber(),errnostr); // error on receive - close the connection Disconnect(); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::SocketReceive recv returned -1 : "+GetSocketErrorMessage()); + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::SocketReceive recv returned -1 : "+errnostr+" - "+GetSocketErrorMessage()); } } @@ -1180,7 +1220,9 @@ void NNTPConnection::SocketSend() } else if(rval==-1) { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::SocketSend returned -1 : "+GetSocketErrorMessage()); + std::string errnostr; + StringFunctions::Convert(GetSocketErrorNumber(),errnostr); + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::SocketSend returned -1 : "+errnostr+" - "+GetSocketErrorMessage()); } } }