🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #14903

patch to nnrpd

#14903
From: Eilon Gishri
Date: Mon, 10 Feb 1997 00:00
99 lines
3582 bytes
Hi,
  I've made a small patch to nnrpd against one with the following patch
already applied: nnrpd-mmap-shared-active.patch. The idea is to be able to:

A. Block clients from crossposting to more than X groups.
B. To get the amount of data transferred to the clients.

Shoot me if I made a mistake :)

diff -u --recursive --new-file nnrpd.old/nnrpd.c nnrpd/nnrpd.c
--- nnrpd.old/nnrpd.c	Tue Dec 17 16:40:40 1996
+++ nnrpd/nnrpd.c	Mon Feb 10 23:42:38 1997
@@ -150,8 +150,8 @@
     }
 
     GRPreport();
-    syslog(L_NOTICE, "%s exit articles %ld groups %ld",
-	   ClientHost, ARTcount, GRPcount);
+    syslog(L_NOTICE, "%s exit articles %ld groups %ld bytes %ld",
+	   ClientHost, ARTcount, GRPcount, BYTEcount);
     if (POSTreceived ||  POSTrejected)
 	syslog(L_NOTICE, "%s posts received %ld rejected %ld",
 	   ClientHost, POSTreceived, POSTrejected);
@@ -486,7 +486,7 @@
 #endif	/* defined(VAR_VARARGS) */
 
     START_VARARG(fmt, vp, char*);
-    (void)vprintf(fmt, vp);
+    BYTEcount += (int)vprintf(fmt, vp);
     va_end(vp);
 
     if (Tracing) {
diff -u --recursive --new-file nnrpd.old/nnrpd.h nnrpd/nnrpd.h
--- nnrpd.old/nnrpd.h	Thu Feb  6 23:23:02 1997
+++ nnrpd/nnrpd.h	Mon Feb 10 23:42:24 1997
@@ -39,9 +39,9 @@
 **  Some convenient shorthands.
 */
 typedef struct in_addr	INADDR;
-#define Printf		(void)printf
+#define Printf		BYTEcount += (int)printf
 #if	defined(VAR_NONE)
-#define Reply		(void)printf
+#define Reply		BYTEcount += (int)printf
 #endif	/* defined(VAR_NONE) */
 
 
@@ -111,6 +111,7 @@
 EXTERN int	ARTsize;
 extern int	PERMdefault;
 EXTERN long	ARTcount;
+EXTERN long	BYTEcount;
 EXTERN long	GRParticles;
 EXTERN long	GRPcount;
 EXTERN char	GRPlast[SPOOLNAMEBUFF];
diff -u --recursive --new-file nnrpd.old/post.c nnrpd/post.c
--- nnrpd.old/post.c	Thu Feb  6 23:23:02 1997
+++ nnrpd/post.c	Mon Feb 10 23:34:15 1997
@@ -567,6 +567,7 @@
     char      *grplist[2];
     BOOL		IsNewgroup;
     BOOL		FoundOne;
+    int			GroupCount;
 
     p = HDR(_control);
     IsNewgroup = p && EQn(p, "newgroup", 8);
@@ -588,6 +589,7 @@
 	if ((gp = GRPfind(p)) == NULL)
 	    continue;
 	FoundOne = TRUE;
+	GroupCount++;
 	DDcheck(h, p);
 	switch (GPFLAG(gp)) {
 	case NF_FLAG_OK:
@@ -622,6 +624,16 @@
         }
     } while ((p = strtok((char *)NULL, NGSEPS)) != NULL);
     DISPOSE(groups);
+
+    if (Tracing)
+	syslog(L_NOTICE, "%s crossposting article to %d newsgroups",
+		ClientHost, GroupCount);
+#ifdef LOCAL_MAX_CROSSPOST
+    if ( GroupCount > LOCAL_MAX_CROSSPOST )
+        (void)sprintf(Error,
+                "Crossposting to %d newsgroups while the limit is %d!",
+                 GroupCount, LOCAL_MAX_CROSSPOST);
+#endif
 
     if (!FoundOne && !IsNewgroup)
 	(void)sprintf(Error, "No valid newsgroups in \"%s\"", hdr);

-- 
		Eilon Gishri, Tel-Aviv University Computation Center
		Home 03-5078671 /* on a matter of national security */
		E-mail: eilon@aristo.tau.ac.il

Technical Details
Message-ID: <5do758$jqo@news.ibm.net.il>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <5do758$jqo@news.ibm.net.il>
Subject: patch to nnrpd
Date: Mon, 10 Feb 1997 00:00:00 +0000
From: Eilon Gishri <eilon@tau.ac.il>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 217894907
Content-type: text/plain; charset=US-ASCII
Organization: Tel-Aviv University Computation Center
Mime-version: 1.0
Newsgroups: news.software.nntp
Nntp-posting-user: eilon