Commit 9c91d32a authored by rswindell's avatar rswindell

Move all the QWK import-msg-filtering logic into a single method and use it to

filter incoming messages, including vote/poll messages. This should address Nightfox's bug report that polls posted by twit-listed users were still imported/posted on his BBS.
parent 792188b2
......@@ -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;
}
......@@ -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);
......
......@@ -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) {
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment