🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #53168

Re: maxconnections question in inn.conf

#53168
From: those who know me have no need o...
Date: Mon, 09 Jul 2001 01:08
75 lines
3607 bytes
<slrn9khafj.kuj.steffie@wodan.balpol.tudelft.nl> divulged:

>now my question is, how can i limit the number of people
>actually connecting and reading and posting to nnrpd ?

depends on the version of inn.  first look at the -H, -T, and -X command
line options, and if those are missing then consider another way.  the
easiest is probably to integrate the decision into your authentication,
which requires using authentication (this can be a problem for some) and
you have to use an external method since the internal one doesn't have any
provisions for doing this.  or, you could add some code, e.g., near the
loadlimit stuff -- you could even add the code that newer innd's use.

note: doing this might open an avenue to a dos, or change the character of
the existing possibilities.  in fact the code i'm about to post certainly
will, it's really just an example.

note2: only innd supports the -H, -T, and -X switches, which is okay as far
as it goes, but when nnrpd is run in daemon mode this functionality is
lost.  integrating the innd code into nnrpd would be much better than the
quickie i'm showing you.

warning: untested.  patch is against 2.3.2.

--- nnrpd.c.old	Thu May  3 13:27:32 2001
+++ nnrpd.c	Sun Jul  8 17:56:31 2001
@@ -727,6 +727,7 @@
 #if	NNRP_LOADLIMIT > 0
     int			load;
 #endif	/* NNRP_LOADLIMIT > 0 */
+	int			numconnections=0;
     CMDENT		*cp;
     char		buff[NNTP_STRLEN];
     char		**av;
@@ -780,9 +781,9 @@
     if (ReadInnConf() < 0) exit(1);
 
 #ifdef HAVE_SSL
-    while ((i = getopt(argc, argv, "b:Di:g:op:Rr:s:tS")) != EOF)
+    while ((i = getopt(argc, argv, "b:Di:I:g:op:Rr:s:tS")) != EOF)
 #else
-    while ((i = getopt(argc, argv, "b:Di:g:op:Rr:s:t")) != EOF)
+    while ((i = getopt(argc, argv, "b:Di:I:g:op:Rr:s:t")) != EOF)
 #endif /* HAVE_SSL */
 	switch (i) {
 	default:
@@ -805,6 +806,9 @@
 	case 'i':			/* Initial command */
 	    PushedBack = COPY(optarg);
 	    break;
+	case 'I':			/* connection limit.  can't use -i as innd does */
+	    innconf->maxconnections = atoi(optarg);
+	    break;
 	case 'o':
 	    Offlinepost = TRUE;		/* Offline posting only */
 	    break;
@@ -1050,6 +1054,15 @@
 	ExitWithStats(1, TRUE);
     }
 #endif	/* NNRP_LOADLIMIT > 0 */
+
+	/* drop new connections when there are too many already connected */
+	if (numconnections < innconf->maxconnections) {
+		numconnections++;
+	} else {
+		syslog(L_NOTICE, "connection limit (%d) reached", innconf->maxconnections);
+		Reply("connection limit (%d) reached, try later\r\n", NNTP_GOODBYE_VAL, innconf->maxconnections);
+		ExitWithStats(1, TRUE);
+	}
 
     strcpy (LogName, "?");

-- 
okay, have a sig then
Technical Details
Message-ID: <9ib06f01t8i@enews1.newsguy.com>
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!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!209.155.233.16!pln-e!spln!dex!extra.newsguy.com!newsp.newsguy.com!enews1
References: <slrn9khafj.kuj.steffie@wodan.balpol.tudelft.nl>

Show Full Headers
Complete Article Headers
Message-ID: <9ib06f01t8i@enews1.newsguy.com>
Subject: Re: maxconnections question in inn.conf
Date: Mon, 09 Jul 2001 01:08:32 +0000
From: those who know me have no need of my name <not-a-real-address@usa.net>
References: <slrn9khafj.kuj.steffie@wodan.balpol.tudelft.nl>
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!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!209.155.233.16!pln-e!spln!dex!extra.newsguy.com!newsp.newsguy.com!enews1
Newsgroups: news.software.nntp
Organization: earthfriends
Lines: 74
NNTP-Posting-Host: p-684.newsdawg.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
User-Agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.1 (Cuyahoga Valley)