diff --git a/src/sbbs3/qwk.cpp b/src/sbbs3/qwk.cpp index b0d00dd2765fcf8a6c4eedfe9ec1183e2cbbf5a2..ec5d3885a4c7cbf08d94f88643154cae240b6906 100644 --- a/src/sbbs3/qwk.cpp +++ b/src/sbbs3/qwk.cpp @@ -1259,3 +1259,46 @@ bool sbbs_t::qwk_vote(str_list_t ini, const char* section, smb_net_type_t net_ty smb_freemsgmem(&msg); return result == SMB_SUCCESS; } + +bool sbbs_t::qwk_msg_filtered(smbmsg_t* msg, str_list_t ip_can, str_list_t host_can, str_list_t subject_can, str_list_t twit_list) +{ + uint32_t now = time32(NULL); + + if(cfg.max_qwkmsgage && msg->hdr.when_written.time < now + && (now-msg->hdr.when_written.time)/(24*60*60) > cfg.max_qwkmsgage) { + lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to age: %u days" + ,msg->from + ,(unsigned int)(now-msg->hdr.when_written.time)/(24*60*60)); + return true; + } + + if(findstr_in_list(msg->from_ip,ip_can)) { + lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to blocked IP: %s" + ,msg->from + ,msg->from_ip); + return true; + } + + const char* hostname=getHostNameByAddr(msg->from_host); + if(findstr_in_list(hostname,host_can)) { + lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to blocked hostname: %s" + ,msg->from + ,hostname); + return true; + } + + if(findstr_in_list(msg->subj,subject_can)) { + lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to filtered subject: %s" + ,msg->from + ,msg->subj); + return true; + } + + if(findstr_in_list(msg->from,twit_list) || findstr_in_list(msg->to,twit_list)) { + lprintf(LOG_NOTICE,"!Filtering QWK message from '%s' to '%s'" + ,msg->from + ,msg->to); + return true; + } + return false; +} diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index bb7a44c4c50e9cb202cc5d3d913b64c363cad455..ecd4e8ecf1ba7b2d0a452a7488fff1ce19c3af31 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -1055,6 +1055,7 @@ public: bool qwk_vote(str_list_t ini, const char* section, smb_net_type_t, const char* qnet_id, uint confnum, int hubnum); bool qwk_voting(str_list_t* ini, long offset, smb_net_type_t, const char* qnet_id, uint confnum, int hubnum = -1); void qwk_handle_remaining_votes(str_list_t* ini, smb_net_type_t, const char* qnet_id, int hubnum = -1); + bool qwk_msg_filtered(smbmsg_t* msg, str_list_t ip_can, str_list_t host_can, str_list_t subject_can, str_list_t twit_list=NULL); /* pack_qwk.cpp */ bool pack_qwk(char *packet, ulong *msgcnt, bool prepack); diff --git a/src/sbbs3/un_qwk.cpp b/src/sbbs3/un_qwk.cpp index 8f4d4e64d65d3b6992868e3b7649bb618df17a1a..a263156250cf197ac3d31b4504f129557be000c5 100644 --- a/src/sbbs3/un_qwk.cpp +++ b/src/sbbs3/un_qwk.cpp @@ -79,7 +79,6 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum) str_list_t subject_can=NULL; str_list_t twit_list=NULL; link_list_t user_list={0}; - const char* hostname; memset(&msg,0,sizeof(msg)); @@ -159,6 +158,8 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum) n=(uint)block[123]|(((uint)block[124])<<8); /* conference number */ if(blocks<2) { if(block[0] == 'V' && blocks == 1 && voting != NULL) { /* VOTING DATA */ + if(qwk_msg_filtered(&msg, ip_can, host_can, subject_can, twit_list)) + continue; if(!qwk_voting(&voting, l, NET_QWK, cfg.qhub[hubnum]->id, n, hubnum)) { lprintf(LOG_WARNING, "QWK vote failure, offset %lu in %s", l, packet); errors++; @@ -177,35 +178,8 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum) continue; } - if(cfg.max_qwkmsgage && msg.hdr.when_written.time < (uint32_t)now - && (now-msg.hdr.when_written.time)/(24*60*60) > cfg.max_qwkmsgage) { - lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to age: %u days" - ,msg.from - ,(unsigned int)(now-msg.hdr.when_written.time)/(24*60*60)); + if(qwk_msg_filtered(&msg, ip_can, host_can, subject_can)) continue; - } - - if(findstr_in_list(msg.from_ip,ip_can)) { - lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to blocked IP: %s" - ,msg.from - ,msg.from_ip); - continue; - } - - hostname=getHostNameByAddr(msg.from_host); - if(findstr_in_list(hostname,host_can)) { - lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to blocked hostname: %s" - ,msg.from - ,hostname); - continue; - } - - if(findstr_in_list(msg.subj,subject_can)) { - lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to filtered subject: %s" - ,msg.from - ,msg.subj); - continue; - } if(!n) { /* NETMAIL */ lprintf(LOG_INFO,"QWK NetMail from %s to %s", cfg.qhub[hubnum]->id, msg.to); @@ -301,13 +275,8 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum) } /* TWIT FILTER */ - if(findstr_in_list(msg.from,twit_list) || findstr_in_list(msg.to,twit_list)) { - lprintf(LOG_NOTICE,"!Filtering QWK post from '%s' to '%s' on %s %s" - ,msg.from - ,msg.to - ,cfg.grp[cfg.sub[j]->grp]->sname,cfg.sub[j]->lname); + if(qwk_msg_filtered(&msg, /* ip_can: */NULL, /* host_can: */NULL, /* subject_can: */NULL, twit_list)) continue; - } if(j!=lastsub) { diff --git a/src/sbbs3/un_rep.cpp b/src/sbbs3/un_rep.cpp index 847d2a5d8119ded98c77cb46b4bd8d214a04b9df..cd157aa32e1c43ec34b5be2a76fb86b30a1bd095 100644 --- a/src/sbbs3/un_rep.cpp +++ b/src/sbbs3/un_rep.cpp @@ -70,7 +70,6 @@ bool sbbs_t::unpack_rep(char* repfile) str_list_t subject_can=NULL; str_list_t twit_list=NULL; link_list_t user_list={0}; - const char* hostname; const char* AttemptedToUploadREPpacket="Attempted to upload REP packet"; memset(&msg,0,sizeof(msg)); @@ -197,6 +196,8 @@ bool sbbs_t::unpack_rep(char* repfile) long confnum = atol((char *)block+1); if(blocks<2) { if(block[0] == 'V' && blocks == 1 && voting != NULL) { /* VOTING DATA */ + if(qwk_msg_filtered(&msg, ip_can, host_can, subject_can, twit_list)) + continue; if(!qwk_voting(&voting, l, (useron.rest&FLAG('Q')) ? NET_QWK : NET_NONE, /* QWKnet ID : */useron.alias, confnum)) { lprintf(LOG_WARNING, "QWK vote failure, offset %ld of %s", l, getfname(msg_fname)); errors++; @@ -217,39 +218,8 @@ bool sbbs_t::unpack_rep(char* repfile) continue; } - if(cfg.max_qwkmsgage && msg.hdr.when_written.time < (uint32_t)now - && (now-msg.hdr.when_written.time)/(24*60*60) > cfg.max_qwkmsgage) { - SAFEPRINTF2(str,"!Filtering QWK message from %s due to age: %" PRIu64 " days" - ,msg.from - ,(uint64_t)((now-msg.hdr.when_written.time)/(24*60*60))); - logline(LOG_NOTICE,"P!",str); - continue; - } - - if(findstr_in_list(msg.from_ip,ip_can)) { - SAFEPRINTF2(str,"!Filtering QWK message from %s due to blocked IP: %s" - ,msg.from - ,msg.from_ip); - logline(LOG_NOTICE,"P!",str); - continue; - } - - hostname = getHostNameByAddr(msg.from_host); - if(findstr_in_list(hostname,host_can)) { - SAFEPRINTF2(str,"!Filtering QWK message from %s due to blocked hostname: %s" - ,msg.from - ,hostname); - logline(LOG_NOTICE,"P!",str); - continue; - } - - if(findstr_in_list(msg.subj,subject_can)) { - SAFEPRINTF2(str,"!Filtering QWK message from %s due to filtered subject: %s" - ,msg.from - ,msg.subj); - logline(LOG_NOTICE,"P!",str); + if(qwk_msg_filtered(&msg, ip_can, host_can, subject_can)) continue; - } if(confnum == 0) { /* E-mail */ if(msg.from == NULL) @@ -491,14 +461,8 @@ bool sbbs_t::unpack_rep(char* repfile) #endif /* TWIT FILTER */ - if(findstr_in_list(msg.from,twit_list) || findstr_in_list(msg.to,twit_list)) { - SAFEPRINTF4(str,"!Filtering QWK post from %s to %s on %s %s" - ,msg.from - ,msg.to - ,cfg.grp[cfg.sub[n]->grp]->sname,cfg.sub[n]->lname); - logline(LOG_NOTICE,"P!",str); - continue; - } + if(qwk_msg_filtered(&msg, /* ip_can: */NULL, /* host_can: */NULL, /* subject_can: */NULL, twit_list)) + continue; if(n!=lastsub) { if(lastsub!=INVALID_SUB)