Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit ec9e6712 authored by rswindell's avatar rswindell

Don't save QWK or REP packets with rejected duplicate mesages as a ".BAD" packet

parent 643d3edb
......@@ -235,7 +235,7 @@ bool sbbs_t::qwk_new_msg(ulong confnum, smbmsg_t* msg, char* hdrblk, long offset
/****************************************************************************/
bool sbbs_t::qwk_import_msg(FILE *qwk_fp, char *hdrblk, ulong blocks
,char fromhub, smb_t* smb
,uint touser, smbmsg_t* msg)
,uint touser, smbmsg_t* msg, bool* dupe)
{
char* body;
char* tail;
......@@ -251,6 +251,7 @@ bool sbbs_t::qwk_import_msg(FILE *qwk_fp, char *hdrblk, ulong blocks
str_list_t kludges;
uint subnum = smb->subnum;
*dupe = false;
if(subnum!=INVALID_SUB
&& (hdrblk[0]=='*' || hdrblk[0]=='+' || cfg.sub[subnum]->misc&SUB_PONLY))
msg->hdr.attr|=MSG_PRIVATE;
......@@ -503,6 +504,7 @@ bool sbbs_t::qwk_import_msg(FILE *qwk_fp, char *hdrblk, ulong blocks
logline(LOG_NOTICE,"P!",str);
}
}
*dupe=true;
}
else
errormsg(WHERE,ERR_WRITE,smb->file,i,smb->last_error);
......
......@@ -1019,7 +1019,7 @@ public:
/* qwktomsg.cpp */
bool qwk_new_msg(ulong confnum, smbmsg_t* msg, char* hdrblk, long offset, str_list_t headers, bool parse_sender_hfields);
bool qwk_import_msg(FILE *qwk_fp, char *hdrblk, ulong blocks, char fromhub, smb_t*
,uint touser, smbmsg_t* msg);
,uint touser, smbmsg_t* msg, bool* dupe);
/* fido.cpp */
bool netmail(const char *into, const char *subj = NULL, long mode = WM_NONE, smb_t* resmb = NULL, smbmsg_t* remsg = NULL);
......
......@@ -63,6 +63,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
ulong t;
ulong msgs=0;
ulong tmsgs=0;
ulong dupes=0;
ulong errors=0;
time_t start;
time_t startsub;
......@@ -269,13 +270,18 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
continue;
}
smb_unlocksmbhdr(&smb);
if(qwk_import_msg(qwk, (char *)block, blocks, hubnum+1, &smb, usernum, &msg)) {
bool dupe=false;
if(qwk_import_msg(qwk, (char *)block, blocks, hubnum+1, &smb, usernum, &msg, &dupe)) {
eprintf(LOG_INFO,"Imported QWK mail message from %s to %s #%u", msg.from, msg.to, usernum);
SAFEPRINTF(str,text[UserSentYouMail],msg.from);
putsmsg(&cfg,usernum,str);
tmsgs++;
} else
} else {
if(dupe)
dupes++;
else
errors++;
}
smb_close(&smb);
smb_stack(&smb,SMB_STACK_POP);
continue;
......@@ -349,13 +355,18 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
lastsub=j;
}
if(qwk_import_msg(qwk, (char *)block, blocks, hubnum+1, &smb, /*touser: */0, &msg)) {
bool dupe = false;
if(qwk_import_msg(qwk, (char *)block, blocks, hubnum+1, &smb, /*touser: */0, &msg, &dupe)) {
signal_sub_sem(&cfg,j);
msgs++;
tmsgs++;
} else
} else {
if(dupe)
dupes++;
else
errors++;
}
}
if(lastsub != INVALID_SUB) {
log_qwk_import_stats(msgs, startsub);
smb_close(&smb);
......@@ -414,12 +425,12 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
closedir(dir);
t=(ulong)(time(NULL)-start);
if(tmsgs) {
if(tmsgs || errors || dupes) {
if(t<1)
t=1;
eprintf(LOG_INFO,"Finished Importing QWK Network Packet from %s: "
"(%lu msgs) in %lu seconds (%lu msgs/sec), %lu errors"
,cfg.qhub[hubnum]->id, tmsgs, t, tmsgs/t, errors);
"(%lu msgs) in %lu seconds (%lu msgs/sec), %lu errors, %lu dupes"
,cfg.qhub[hubnum]->id, tmsgs, t, tmsgs/t, errors, dupes);
/* trigger timed event with internal code of 'qnet-qwk' to run */
sprintf(str,"%sqnet-qwk.now",cfg.data_dir);
ftouch(str);
......
......@@ -56,6 +56,7 @@ bool sbbs_t::unpack_rep(char* repfile)
ulong n;
ulong ex;
ulong tmsgs = 0;
ulong dupes = 0;
ulong errors = 0;
node_t node;
FILE* rep;
......@@ -346,8 +347,9 @@ bool sbbs_t::unpack_rep(char* repfile)
smb_unlocksmbhdr(&smb);
bool dupe = false;
if(qwk_import_msg(rep, block, blocks
,/* fromhub: */0, &smb, /* touser: */usernum, &msg)) {
,/* fromhub: */0, &smb, /* touser: */usernum, &msg, &dupe)) {
if(usernum==1) {
useron.fbacks++;
logon_fbacks++;
......@@ -386,8 +388,12 @@ bool sbbs_t::unpack_rep(char* repfile)
putsmsg(&cfg,usernum,str);
}
tmsgs++;
} else
} else {
if(dupe)
dupes++;
else
errors++;
}
smb_close(&smb);
} /* end of email */
......@@ -536,8 +542,9 @@ bool sbbs_t::unpack_rep(char* repfile)
lastsub=n;
}
bool dupe = false;
if(qwk_import_msg(rep, block, blocks
,/* fromhub: */0, &smb, /* touser: */0, &msg)) {
,/* fromhub: */0, &smb, /* touser: */0, &msg, &dupe)) {
logon_posts++;
user_posted_msg(&cfg, &useron, 1);
if(online == ON_REMOTE)
......@@ -550,8 +557,12 @@ bool sbbs_t::unpack_rep(char* repfile)
if(!(useron.rest&FLAG('Q')))
user_event(EVENT_POST);
tmsgs++;
} else
} else {
if(dupe)
dupes++;
else
errors++;
}
} /* end of public message */
}
......@@ -666,7 +677,7 @@ bool sbbs_t::unpack_rep(char* repfile)
/**********************************************/
autohangup();
} else
lprintf(LOG_INFO, "Unpacking completed: %s (%lu msgs, %lu errors)", rep_fname, tmsgs, errors);
lprintf(LOG_INFO, "Unpacking completed: %s (%lu msgs, %lu errors, %lu dupes)", rep_fname, tmsgs, errors, dupes);
return errors == 0;
}
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