Article View: news.software.nn
Article #10014nn-6.6.3 patch: count crossposting via nov newsgroups header
From: G. Paul Ziemba
Date: Tue, 23 Apr 2002 06:09
Date: Tue, 23 Apr 2002 06:09
191 lines
7182 bytes
7182 bytes
One of the newsgroups I read has become infested with cross-posting
gits, and that motivated me to whip up a little hack to NN so I could
kill these posts based on the number of groups crossposted to.
nn-6.6.3 already seems to have the (undocumented?) cross-post-limit
variable, which applies globally. Unfortunately for me, this limit
is applied to newsgroups listed in the Xref header, which reflects
references to this article from other newsgroups only if they are
stored on the news server.
I run a small news server that has mostly the groups I'm interested in
(i.e., much much less than a full feed). Thus, the Xref header usually
didn't match what was in the Newsgroups: header, and cross-post-limit
didn't kick in.
Ultimately I'd like to have the ability to set the limit as part
of a kill-spec, and thus it could be applied per-newsgroup. But I'll
need to learn my way around the nn source better before I can do that.
Meanwhile, here is an enhancement to the cross-post-limit code that
counts entries in the newsgroups header if it is available via NOV.
It does NOT do anything for the non-NOV case (does anyone with nn-6.6.3
run nnmaster anymore? Would I need to add that support to make this a
candidate for inclusion in the baseline nn code?)
I suspect most nntp installations do not serve the newsgroups: header
in their NOV database. I had to modify my INN configuration to add it,
so if you don't control and can't influence your news server configuration
then this patch probably won't do you much good.
Note that I had to tweak the existing db_fixup_cross_postings() to stop
clobbering the nov artp->a_others field. Michael, it'd be cool if you could
incorporate even just those two extra lines in db.c to make the world safe
for any other a_others users later.
I also counted the articles killed due to cross-post count in
killed_articles; I don't know if that's consistent with the intended
use of that variable.
--- articles.c-011003 Wed Oct 3 00:01:08 2001
+++ articles.c Sat Apr 20 01:00:59 2002
@@ -367,8 +367,16 @@
skip_digest = 0;
- if (cross_post_limit && db_hdr.dh_cross_postings >= cross_post_limit)
+ if (cross_post_limit && db_hdr.dh_cross_postings >= cross_post_limit) {
+ ++killed_articles; /* gpz 020419 count these as killed too */
continue;
+ }
+
+ /* gpz 020419 NOV newsgroups: count */
+ if (cross_post_limit && db_hdr.dh_newsgroupcount > cross_post_limit) {
+ ++killed_articles;
+ continue;
+ }
if (db_hdr.dh_cross_postings && !(flags & ACC_ALSO_CROSS_POSTINGS)) {
for (n = 0; n < (int)db_hdr.dh_cross_postings; n++) {
--- db.c-020131 Thu Jan 31 20:10:27 2002
+++ db.c Sat Apr 20 01:00:31 2002
@@ -31,6 +31,9 @@
static void db_fixup_cross_postings __APROTO((data_header *dhp,
data_dynamic_data *ddp,
struct novart *artp));
+static void db_fixup_newsgroupcount __APROTO((data_header *dhp,
+ data_dynamic_data *ddp,
+ struct novart *artp));
static struct novgroup *ngovp;
static struct novart *allarts;
@@ -1377,6 +1380,7 @@
bytes = sizeof(data_header);
#endif /* NETWORK_DATABASE */
+ db_hdr.dh_newsgroupcount = 0; /* unknown - gpz 020419 */
if (db_hdr.dh_number < 0) {
current_digest_article = db_hdr.dh_number = -db_hdr.dh_number;
db_data.dh_type = DH_DIGEST_HEADER;
@@ -1592,6 +1596,7 @@
}
db_fixup_cross_postings(dhp, ddp, artp);
+ db_fixup_newsgroupcount(dhp, ddp, artp); /* gpz 020419 */
if (dhp->dh_number < 0) {
current_digest_article = dhp->dh_number = -dhp->dh_number;
@@ -1634,6 +1639,7 @@
{
char *curg, *tmp;
int numgrps = 0;
+ char savechar;
dhp->dh_cross_postings = 0; /* assume none as default until we can show
otherwise */
@@ -1678,6 +1684,7 @@
break;
}
if (*tmp != ':') break; /* malformed entry, punt. */
+ savechar = *tmp;
*tmp = '\0';
/* Find gh struct for the group. */
@@ -1685,6 +1692,7 @@
/* and add group number to the crosspost list. */
ddp->dh_cross[numgrps++] = gh->group_num;
}
+ *tmp = savechar;
curg = tmp + 1;
while (isdigit(*curg)) ++curg; /* Skip over the article number */
}
@@ -1693,6 +1701,59 @@
at its original value of zero. */
dhp->dh_cross_postings = numgrps;
}
+ return;
+}
+
+/*
+ * gpz 020419
+ * examine NOV optional fields ("other") to see if server provided us
+ * with the newsgroups header. If so, count the newsgroups and save the
+ * count in the data_header dh_newsgroupcount.
+ *
+ * User can then use the number of groups posted to as a way of killing
+ * articles.
+ *
+ * Based on db_fixup_cross_postings()
+ */
+static void
+db_fixup_newsgroupcount(dhp, ddp, artp)
+data_header *dhp;
+data_dynamic_data *ddp;
+struct novart *artp;
+{
+ char *curg, *tmp;
+ int numgrps = 0;
+
+ dhp->dh_newsgroupcount = 0; /* assume none as default until we can show
+ otherwise */
+
+ /* If no "other" header lines are in NOV database, we're out of luck,
+ can only assume no crosspostings, so return. */
+ if ((artp->a_others) == NULL) return;
+
+ /* Scan until we find a Newsgroups: header line. */
+ for (curg = artp->a_others; ; ++curg) {
+ if (strncmp("Newsgroups: ", curg, 12) == 0 ||
+ strncmp("newsgroups: ", curg, 12) == 0)
+ {
+ break;
+ }
+ curg = strchr(curg, '\t'); /* Not this header, skip to the next */
+ if (curg == NULL) return;
+ }
+
+ curg += 12; /* Skip over "Newsgroups: " */
+
+ /*
+ * newsgroups are comma-separated, so count the commas and add 1
+ */
+ while (curg = strchr(curg, ',')) {
+ ++dhp->dh_newsgroupcount;
+ ++curg;
+
+ }
+ ++dhp->dh_newsgroupcount;
+
return;
}
#endif /* NOV */
--- db.h-950428 Fri Apr 28 22:34:27 1995
+++ db.h Fri Apr 19 23:50:38 2002
@@ -78,9 +78,10 @@
int16 dh_lines;
int8 dh_replies;
- int8 dh_cross_postings;
+ int8 dh_cross_postings; /* copies on local server */
int8 dh_subject_length;
int8 dh_sender_length;
+ int16 dh_newsgroupcount; /* groups listed on newsgroup: line */
} data_header;
#define DBUF_SIZE 255
--
G. Paul Ziemba paul+usenetsig@w6yx.stanford.edu
FreeBSD unix:
11:07PM up 28 days, 12:16, 11 users, load averages: 0.06, 0.05, 0.02
Technical Details
Message-ID:
<aa2tqq$714$1@hairball.treehouse.napa.ca.us>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nn.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!hub1.nntpserver.com!telocity-west!TELOCITY!nopics.sjc!directvdsl.comShow Full Headers
Complete Article Headers
Message-ID: <aa2tqq$714$1@hairball.treehouse.napa.ca.us> Subject: nn-6.6.3 patch: count crossposting via nov newsgroups header Date: Tue, 23 Apr 2002 06:09:30 +0000 From: G. Paul Ziemba <paul+usenet@w6yx.stanford.edu> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nn.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!hub1.nntpserver.com!telocity-west!TELOCITY!nopics.sjc!directvdsl.com Newsgroups: news.software.nn Organization: The Treehouse Lines: 190 Reply-To: paul+usenet@w6yx.stanford.edu User-Agent: nn/6.6.3 NNTP-Posting-Host: nopics.sjc