X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnntp%2Fnntpconnection.cpp;h=431c1e6153e8347f2fc0d78cbe8805c5a07b1935;hb=59a5414ec47a2932a7802fcd1d98c4d80166564f;hp=3fffad7d312c4e12194da23d85e0a94949227c25;hpb=b9c3763a932cebaa015a27fe111017f6f34dfbaa;p=fms.git diff --git a/src/nntp/nntpconnection.cpp b/src/nntp/nntpconnection.cpp index 3fffad7..431c1e6 100644 --- a/src/nntp/nntpconnection.cpp +++ b/src/nntp/nntpconnection.cpp @@ -1,26 +1,25 @@ #include "../../include/nntp/nntpconnection.h" #include "../../include/nntp/uwildmat.h" #include "../../include/stringfunctions.h" -#include "../../include/datetime.h" #include "../../include/boardlist.h" #include "../../include/message.h" #include "../../include/messagelist.h" #include "../../include/option.h" +#include "../../include/nntp/extensiontrust.h" +#include "../../include/threadwrapper/cancelablethread.h" #include - -//#include -#include "../../include/pthreadwrapper/thread.h" +#include +#include +#include #ifdef XMEM #include #endif -NNTPConnection::NNTPConnection(SOCKET sock) +NNTPConnection::NNTPConnection(SOCKET sock):m_socket(sock),m_status(0) { - std::string tempval; - m_socket=sock; m_tempbuffer.resize(32768); m_status.m_isposting=false; @@ -28,12 +27,7 @@ NNTPConnection::NNTPConnection(SOCKET sock) m_status.m_boardid=-1; m_status.m_messageid=-1; m_status.m_mode=MODE_NONE; - - Option::Instance()->Get("NNTPAllowPost",tempval); - if(tempval=="true") - { - m_status.m_allowpost=true; - } + m_status.m_authenticated=false; } @@ -68,6 +62,58 @@ const bool NNTPConnection::HandleArticleCommand(const NNTPCommand &command) return true; } +const bool NNTPConnection::HandleAuthInfoCommand(const NNTPCommand &command) +{ + if(command.m_arguments.size()<2) + { + SendBufferedLine("501 Syntax error"); + } + else if(m_status.m_authenticated==true) + { + SendBufferedLine("502 Command unavailable"); // not available when already authenticated + } + else + { + std::string arg=command.m_arguments[0]; + StringFunctions::UpperCase(arg,arg); + std::string name=""; + // get remaining args as part of the name since a name might have a space and the args are split on spaces + for(std::vector::const_iterator i=command.m_arguments.begin()+1; i!=command.m_arguments.end(); i++) + { + // we split on the space, so add it back + if(i!=command.m_arguments.begin()+1) + { + name+=" "; + } + name+=(*i); + } + if(arg=="USER") + { + LocalIdentity localid(m_db); + if(localid.Load(name)) + { + m_status.m_authuser=localid; + m_status.m_authenticated=true; + SendBufferedLine("281 Authentication accepted"); + } + else + { + SendBufferedLine("481 Authentication failed"); + } + } + else if(arg=="PASS") + { + SendBufferedLine("482 Authentication commands issued out of sequence"); // only require username + } + else + { + SendBufferedLine("501 Syntax error"); + } + } + + return true; +} + const bool NNTPConnection::HandleBodyCommand(const NNTPCommand &command) { SendArticleParts(command); @@ -80,7 +126,10 @@ const bool NNTPConnection::HandleCapabilitiesCommand(const NNTPCommand &command) SendBufferedLine("101 Capability list :"); SendBufferedLine("VERSION 2"); - SendBufferedLine("MODE-READER"); + if(m_status.m_authenticated==false) // RFC 4643 2.2 0 - don't advertise MODE-READER after authentication + { + SendBufferedLine("MODE-READER"); + } SendBufferedLine("READER"); SendBufferedLine("LIST OVERVIEW.FMT"); SendBufferedLine("OVER MSGID"); @@ -88,6 +137,11 @@ const bool NNTPConnection::HandleCapabilitiesCommand(const NNTPCommand &command) { SendBufferedLine("POST"); } + if(m_status.m_authenticated==false) + { + SendBufferedLine("AUTHINFO USER"); + } + SendBufferedLine("XFMSTRUST"); SendBufferedLine("."); return true; @@ -163,15 +217,185 @@ const bool NNTPConnection::HandleCommand(const NNTPCommand &command) { return HandleOverCommand(command); } + if(command.m_command=="AUTHINFO") + { + return HandleAuthInfoCommand(command); + } + if(command.m_command=="XGETTRUST") + { + return HandleGetTrustCommand(command); + } + if(command.m_command=="XSETTRUST") + { + return HandleSetTrustCommand(command); + } + if(command.m_command=="XGETTRUSTLIST") + { + return HandleGetTrustListCommand(command); + } return false; } const bool NNTPConnection::HandleDateCommand(const NNTPCommand &command) { - DateTime now; - now.SetToGMTime(); - SendBufferedLine("111 "+now.Format("%Y%m%d%H%M%S")); + Poco::DateTime now; + SendBufferedLine("111 "+Poco::DateTimeFormatter::format(now,"%Y%m%d%H%M%S")); + return true; +} + +const bool NNTPConnection::HandleGetTrustCommand(const NNTPCommand &command) +{ + if(command.m_arguments.size()>=2) + { + std::string type=command.m_arguments[0]; + StringFunctions::UpperCase(type,type); + if(type=="MESSAGE" || type=="TRUSTLIST" || type=="PEERMESSAGE" || type=="PEERTRUSTLIST") + { + if(m_status.m_authenticated) + { + bool found=false; + int trust=-1; + std::string nntpname=""; + for(int i=1; i=0 && found) + { + std::string truststr=""; + StringFunctions::Convert(trust,truststr); + SendBufferedLine("280 "+truststr); + } + else if(found) + { + SendBufferedLine("281 null"); + } + else + { + SendBufferedLine("480 Identity not found"); + } + + } + else + { + SendBufferedLine("480 User not authenticated"); + } + } + else + { + SendBufferedLine("501 Syntax error"); + } + } + else + { + SendBufferedLine("501 Syntax error"); + } + return true; +} + +const bool NNTPConnection::HandleGetTrustListCommand(const NNTPCommand &command) +{ + if(m_status.m_authenticated) + { + TrustExtension tr(m_db,m_status.m_authuser.GetID()); + std::map trustlist; + if(tr.GetTrustList(trustlist)) + { + SendBufferedLine("280 Trust list follows"); + for(std::map::iterator i=trustlist.begin(); i!=trustlist.end(); i++) + { + std::ostringstream tempstr; + tempstr << (*i).first << "\t"; + if((*i).second.m_localmessagetrust>-1) + { + tempstr << (*i).second.m_localmessagetrust; + } + else + { + tempstr << "null"; + } + tempstr << "\t"; + if((*i).second.m_localtrustlisttrust>-1) + { + tempstr << (*i).second.m_localtrustlisttrust; + } + else + { + tempstr << "null"; + } + tempstr << "\t"; + if((*i).second.m_peermessagetrust>-1) + { + tempstr << (*i).second.m_peermessagetrust; + } + else + { + tempstr << "null"; + } + tempstr << "\t"; + if((*i).second.m_peertrustlisttrust>-1) + { + tempstr << (*i).second.m_peertrustlisttrust; + } + else + { + tempstr << "null"; + } + tempstr << "\t"; + tempstr << (*i).second.m_messagetrustcomment; + tempstr << "\t"; + tempstr << (*i).second.m_trustlisttrustcomment; + + SendBufferedLine(tempstr.str()); + } + SendBufferedLine("."); + } + else + { + SendBufferedLine("501 Syntax error"); + } + } + else + { + SendBufferedLine("480 User not authenticated"); + } return true; } @@ -179,7 +403,7 @@ const bool NNTPConnection::HandleGroupCommand(const NNTPCommand &command) { if(command.m_arguments.size()==1) { - Board board; + Board board(m_db); if(board.Load(command.m_arguments[0])==true) { std::ostringstream tempstr; @@ -202,7 +426,7 @@ const bool NNTPConnection::HandleGroupCommand(const NNTPCommand &command) else { SendBufferedLine("501 Syntax error"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"NNTPConnection::HandleGroupCommand syntax error"); + m_log->debug("NNTPConnection::HandleGroupCommand syntax error"); } return true; @@ -231,7 +455,7 @@ const bool NNTPConnection::HandleLastCommand(const NNTPCommand &command) { if(m_status.m_messageid!=-1) { - Message mess; + Message mess(m_db); if(mess.LoadPrevious(m_status.m_messageid,m_status.m_boardid)) { @@ -301,7 +525,7 @@ const bool NNTPConnection::HandleListCommand(const NNTPCommand &command) { bool show; std::ostringstream tempstr; - BoardList bl; + BoardList bl(m_db); bl.Load(); SendBufferedLine("215 list of newsgroups follows"); @@ -317,7 +541,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() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << (m_status.m_allowpost ? "y" : "n"); SendBufferedLine(tempstr.str()); @@ -332,7 +556,7 @@ const bool NNTPConnection::HandleListCommand(const NNTPCommand &command) { bool show; std::ostringstream tempstr; - BoardList bl; + BoardList bl(m_db); bl.Load(); SendBufferedLine("215 list of newsgroups follows"); @@ -348,7 +572,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()); @@ -375,7 +599,7 @@ const bool NNTPConnection::HandleListCommand(const NNTPCommand &command) { // unknown arg SendBufferedLine("501 Syntax error"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"NNTPConnection::HandleListCommand unhandled LIST variant"); + m_log->debug("NNTPConnection::HandleListCommand unhandled LIST variant"); } return true; @@ -385,7 +609,7 @@ const bool NNTPConnection::HandleListGroupCommand(const NNTPCommand &command) { std::ostringstream tempstr; - Board board; + Board board(m_db); bool validgroup=false; int lownum=-1; int highnum=-1; @@ -432,7 +656,7 @@ const bool NNTPConnection::HandleListGroupCommand(const NNTPCommand &command) { // unknown arg SendBufferedLine("501 Syntax error"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"NNTPConnection::HandleListGroupCommand unknown arguments"); + m_log->debug("NNTPConnection::HandleListGroupCommand unknown arguments"); } if(validgroup) @@ -454,7 +678,7 @@ const bool NNTPConnection::HandleListGroupCommand(const NNTPCommand &command) tempstr << "211 " << board.GetMessageCount() << " " << board.GetLowMessageID() << " " << board.GetHighMessageID() << " " << board.GetBoardName(); SendBufferedLine(tempstr.str()); - MessageList ml; + MessageList ml(m_db); ml.LoadRange(lownum,highnum,board.GetBoardID()); for(std::vector::iterator i=ml.begin(); i!=ml.end(); i++) @@ -491,18 +715,18 @@ const bool NNTPConnection::HandleModeCommand(const NNTPCommand &command) SendBufferedLine("201 Posting prohibited"); } - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"NNTPConnection::HandleModeCommand set mode to reader"); + m_log->debug("NNTPConnection::HandleModeCommand set mode to reader"); } else { SendBufferedLine("501 Syntax error"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"NNTPConnection::HandleModeCommand unknown MODE argument : "+arg); + m_log->debug("NNTPConnection::HandleModeCommand unknown MODE argument : "+arg); } } else { SendBufferedLine("501 Syntax error"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"NNTPConnection::HandleModeCommand no argument supplied for MODE"); + m_log->debug("NNTPConnection::HandleModeCommand no argument supplied for MODE"); } return true; @@ -512,16 +736,23 @@ const bool NNTPConnection::HandleNewGroupsCommand(const NNTPCommand &command) { if(command.m_arguments.size()>=2) { - DateTime date; - int tempint; + Poco::DateTime date; + int tempyear=0; + int tempmonth=0; + int tempday=0; if(command.m_arguments[0].size()==8) { - StringFunctions::Convert(command.m_arguments[0].substr(0,4),tempint); - date.SetYear(tempint); - StringFunctions::Convert(command.m_arguments[0].substr(4,2),tempint); - date.SetMonth(tempint); - StringFunctions::Convert(command.m_arguments[0].substr(6,2),tempint); - date.SetDay(tempint); + StringFunctions::Convert(command.m_arguments[0].substr(0,4),tempyear); + StringFunctions::Convert(command.m_arguments[0].substr(4,2),tempmonth); + StringFunctions::Convert(command.m_arguments[0].substr(6,2),tempday); + try + { + date.assign(tempyear,tempmonth,tempday,date.hour(),date.minute(),date.second()); + } + catch(...) + { + m_log->fatal("NNTPConnection::HandleNewGroupsCommand error assigning date"); + } } else { @@ -533,35 +764,40 @@ const bool NNTPConnection::HandleNewGroupsCommand(const NNTPCommand &command) the current year, and the previous century otherwise. */ int century; - DateTime now; - now.SetToGMTime(); - century=now.GetYear()-(now.GetYear()%100); + Poco::DateTime now; + century=now.year()-(now.year()%100); - StringFunctions::Convert(command.m_arguments[0].substr(0,2),tempint); - tempint<=now.GetYear()-century ? tempint+=century : tempint+=(century-100); + StringFunctions::Convert(command.m_arguments[0].substr(0,2),tempyear); + tempyear<=now.year()-century ? tempyear+=century : tempyear+=(century-100); //tempint > 50 ? tempint+=1900 : tempint+=2000; - date.SetYear(tempint); - StringFunctions::Convert(command.m_arguments[0].substr(2,2),tempint); - date.SetMonth(tempint); - StringFunctions::Convert(command.m_arguments[0].substr(4,2),tempint); - date.SetDay(tempint); + StringFunctions::Convert(command.m_arguments[0].substr(2,2),tempmonth); + StringFunctions::Convert(command.m_arguments[0].substr(4,2),tempday); + try + { + date.assign(tempyear,tempmonth,tempday); + } + catch(...) + { + m_log->fatal("NNTPConnection::HandleNewGroupsCommand error assigning date"); + } } - date.Normalize(); + BoardList bl(m_db); - BoardList bl; - - bl.LoadNew(date.Format("%Y-%m-%d %H:%M:%S")); + bl.LoadNew(Poco::DateTimeFormatter::format(date,"%Y-%m-%d %H:%M:%S")); SendBufferedLine("231 List of new newsgroups follows"); 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("."); @@ -570,7 +806,7 @@ const bool NNTPConnection::HandleNewGroupsCommand(const NNTPCommand &command) else { SendBufferedLine("501 Syntax error"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"NNTPConnection::HandleNewGroupsCommand syntax error"); + m_log->debug("NNTPConnection::HandleNewGroupsCommand syntax error"); } return true; @@ -583,7 +819,7 @@ const bool NNTPConnection::HandleNextCommand(const NNTPCommand &command) { if(m_status.m_messageid!=-1) { - Message mess; + Message mess(m_db); if(mess.LoadNext(m_status.m_messageid,m_status.m_boardid)) { @@ -635,11 +871,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 @@ -671,7 +909,7 @@ const bool NNTPConnection::HandleOverCommand(const NNTPCommand &command) if(messageuuid!="") { - Message mess; + Message mess(m_db); if(mess.Load(messageuuid)) { SendBufferedLine("224 Overview information follows"); @@ -685,13 +923,13 @@ const bool NNTPConnection::HandleOverCommand(const NNTPCommand &command) } else { - Board bd; + Board bd(m_db); if(m_status.m_boardid!=-1 && bd.Load(m_status.m_boardid)) { // single message if(highmessageid==-2) { - Message mess; + Message mess(m_db); if(mess.Load(lowmessageid,m_status.m_boardid)) { SendBufferedLine("224 Overview information follows"); @@ -706,7 +944,7 @@ const bool NNTPConnection::HandleOverCommand(const NNTPCommand &command) // range with no upper bound else if(highmessageid==-1) { - MessageList ml; + MessageList ml(m_db); ml.LoadRange(lowmessageid,bd.GetHighMessageID(),m_status.m_boardid); if(ml.size()>0) { @@ -725,7 +963,7 @@ const bool NNTPConnection::HandleOverCommand(const NNTPCommand &command) // range with upper and lower bound else if(highmessageid>=lowmessageid) { - MessageList ml; + MessageList ml(m_db); ml.LoadRange(lowmessageid,highmessageid,m_status.m_boardid); if(ml.size()>0) { @@ -774,19 +1012,28 @@ const bool NNTPConnection::HandlePostCommand(const NNTPCommand &command) void NNTPConnection::HandlePostedMessage(const std::string &message) { - Message mess; + Message mess(m_db); if(mess.ParseNNTPMessage(message)) { + // if we authenticated, set the username to the authenticated user + if(m_status.m_authenticated) + { + mess.SetFromName(m_status.m_authuser.GetName()); + } + // handle a messages posted to an adminboard if(mess.PostedToAdministrationBoard()==true) { mess.HandleAdministrationMessage(); } + if(mess.StartFreenetInsert()) + { + SendBufferedLine("240 Article received OK"); + } else { - mess.StartFreenetInsert(); + SendBufferedLine("441 Posting failed. Make sure the identity you are sending with exists!"); } - SendBufferedLine("240 Article received OK"); } else { @@ -830,7 +1077,7 @@ void NNTPConnection::HandleReceivedData() { SendBufferedLine("500 Unknown command"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"NNTPConnection::HandleReceivedData received unhandled NNTP command : "+commandline); + m_log->debug("NNTPConnection::HandleReceivedData received unhandled NNTP command : "+commandline); } } @@ -860,6 +1107,147 @@ void NNTPConnection::HandleReceivedData() } } +const bool NNTPConnection::HandleSetTrustCommand(const NNTPCommand &command) +{ + if(command.m_arguments.size()>=3) + { + std::string type=command.m_arguments[0]; + StringFunctions::UpperCase(type,type); + if(type=="MESSAGE" || type=="TRUSTLIST" || type=="MESSAGECOMMENT" || type=="TRUSTLISTCOMMENT") + { + if(m_status.m_authenticated) + { + bool found=false; + bool valid=false; + int trust=-1; + std::string comment=""; + std::string nntpname=""; + + if(type=="MESSAGE" || type=="TRUSTLIST") + { + for(int i=1; i=-1 && trust<=100) + { + valid=true; + } + } + else + { + int startpos=-1; + // get nntpname + for(int i=1; i0 && command.m_arguments[i][0]!='\"') + { + if(i!=1) + { + nntpname+=" "; + } + nntpname+=command.m_arguments[i]; + } + else + { + startpos=i; + } + } + + // get comment + for(int i=startpos; i0 && comment[0]=='\"') + { + comment.erase(0,1); + } + if(comment.size()>0 && comment[comment.size()-1]=='\"') + { + comment.erase(comment.size()-1); + } + + valid=true; + } + + TrustExtension tr(m_db,m_status.m_authuser.GetID()); + + if(type=="MESSAGE") + { + if(tr.SetMessageTrust(nntpname,trust)) + { + found=true; + } + } + if(type=="TRUSTLIST") + { + if(tr.SetTrustListTrust(nntpname,trust)) + { + found=true; + } + } + if(type=="MESSAGECOMMENT") + { + if(tr.SetMessageTrustComment(nntpname,comment)) + { + found=true; + } + } + if(type=="TRUSTLISTCOMMENT") + { + if(tr.SetTrustListTrustComment(nntpname,comment)) + { + found=true; + } + } + + if(found && valid) + { + SendBufferedLine("280 Trust Set"); + } + else if(found==false) + { + SendBufferedLine("480 Identity not found"); + } + else + { + SendBufferedLine("501 Syntax error"); + } + + } + else + { + SendBufferedLine("480 User not authenticated"); + } + } + else + { + SendBufferedLine("501 Syntax error"); + } + } + else + { + SendBufferedLine("501 Syntax error"); + } + return true; +} + const bool NNTPConnection::HandleStatCommand(const NNTPCommand &command) { SendArticleParts(command); @@ -872,15 +1260,26 @@ const bool NNTPConnection::HandleQuitCommand(const NNTPCommand &command) SendBufferedLine("205 Connection Closing"); SocketSend(); Disconnect(); - m_log->WriteLog(LogFile::LOGLEVEL_INFO,"NNTPConnection::HandleQuitCommand client closed connection"); + m_log->information("NNTPConnection::HandleQuitCommand client closed connection"); return true; } -void NNTPConnection::Run() +void NNTPConnection::run() { struct timeval tv; fd_set writefs,readfs; int rval; + std::string tempval(""); + + LoadDatabase(); + + m_status.m_authuser.SetDB(m_db); + Option option(m_db); + option.Get("NNTPAllowPost",tempval); + if(tempval=="true") + { + m_status.m_allowpost=true; + } // seed random number generater for this thread srand(time(NULL)); @@ -924,10 +1323,17 @@ void NNTPConnection::Run() } else if(rval==SOCKET_ERROR) { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::run select returned -1 : "+GetSocketErrorMessage()); + m_log->error("NNTPConnection::run select returned -1 : "+GetSocketErrorMessage()); + } + + //process all remaining commands in buffer + std::vector::size_type rbs=0; + while(rbs!=m_receivebuffer.size()) + { + rbs=m_receivebuffer.size(); + HandleReceivedData(); } -// }while(!Disconnected() && !ZThread::Thread::interrupted()); }while(!Disconnected() && !IsCancelled()); Disconnect(); @@ -944,7 +1350,7 @@ void NNTPConnection::SendArticleOverInfo(Message &message) line=tempval+"\t"; line+=message.GetSubject()+"\t"; line+=message.GetFromName()+"\t"; - line+=message.GetDateTime().Format("%a, %d %b %y %H:%M:%S -0000")+"\t"; + line+=Poco::DateTimeFormatter::format(message.GetDateTime(),"%w, %d %b %y %H:%M:%S -0000")+"\t"; line+=message.GetNNTPArticleID()+"\t"; references=message.GetInReplyTo(); if(references.size()>0) @@ -955,7 +1361,7 @@ void NNTPConnection::SendArticleOverInfo(Message &message) { line+=" "; } - line+="<"+(*i).second+"@freenetproject.org>"; + line+="<"+(*i).second+">"; //+"@freenetproject.org>"; } line+="\t"; } @@ -998,7 +1404,7 @@ void NNTPConnection::SendArticleParts(const NNTPConnection::NNTPCommand &command successcode="223"; } - Message message; + Message message(m_db); int messageid=m_status.m_messageid; std::string articleid=""; int type=0; // default to current messageid, 1=messageid, 2=articleid @@ -1015,6 +1421,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; } @@ -1174,7 +1595,7 @@ void NNTPConnection::SocketReceive() else if(rval==0) { Disconnect(); - m_log->WriteLog(LogFile::LOGLEVEL_INFO,"NNTPConnection::SocketReceive remote host closed connection"); + m_log->information("NNTPConnection::SocketReceive remote host closed connection"); } else if(rval==-1) { @@ -1182,7 +1603,7 @@ void NNTPConnection::SocketReceive() StringFunctions::Convert(GetSocketErrorNumber(),errnostr); // error on receive - close the connection Disconnect(); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::SocketReceive recv returned -1 : "+errnostr+" - "+GetSocketErrorMessage()); + m_log->error("NNTPConnection::SocketReceive recv returned -1 : "+errnostr+" - "+GetSocketErrorMessage()); } } @@ -1199,7 +1620,7 @@ void NNTPConnection::SocketSend() { std::string errnostr; StringFunctions::Convert(GetSocketErrorNumber(),errnostr); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::SocketSend returned -1 : "+errnostr+" - "+GetSocketErrorMessage()); + m_log->error("NNTPConnection::SocketSend returned -1 : "+errnostr+" - "+GetSocketErrorMessage()); } } }