🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #28271

Re: CIDR aware addresses in nnrp.access

#28271
From: stare master
Date: Wed, 20 May 1998 00:00
120 lines
4912 bytes
In article <6jue7q$c7s$1@escape.rtsnet.ru>,
Igor Vinokurov  <igor@zynaps.ru> wrote:
>How I can use CIDR addresses in nnrp.access for innd?

=====
From: mskucher@vertex.tor.hookup.net (Murray S. Kucherawy)
Subject: Patch to nnrpd to allow netmasks in nnrp.access
Date: 1996/12/11
Message-ID: <58lljp$92c@vertex.tor.hookup.net>#1/1
Organization: HookUp Communication Corporation, Oakville, Ontario, CANADA
Newsgroups: news.software.nntp

The following patch will allow you to do a netmask in your nnrp.access
file so that you can offer news access to pieces of what are commonly
known as subnetted class Cs.  For example, you can currently do this:

165.154.*:RP:::*,!clari*

...or this:

165.154.1.*:RP:::*,!clari*

...but you can't get any more specific than that with wildcards in any
reasonable fashion.  If you split this network at a bit boundary beyond
24 bits, you start to require multiple lines to do the trick.  With
this patch, you can do this:

165.154.1.0/255.255.255.224:RP:::*,!clari*

...or this:

165.154.1.0/27:RP:::*,!clari*

It's worked for me so far.  Let me know if you have any problems with it.

*** nnrpd.c	1996/11/19 19:59:00	1.2
--- nnrpd.c	1996/12/11 01:03:29
***************
*** 347,357 ****
  	    /* Malformed line. */
  	    continue;
  
! 	if (hp)
  	    /* Got an address; try to match either the IP address or as
  	     * a text hostname. */
  	    if (!(ip && wildmat(ip, fields[0])) && !wildmat(hp, fields[0]))
  		continue;
  
  	/* See if we should lookup a specific user in the passwd file */
  	if (user && pass && EQ(fields[2], "+")) {
--- 347,401 ----
  	    /* Malformed line. */
  	    continue;
  
! 	if (hp) {
  	    /* Got an address; try to match either the IP address or as
  	     * a text hostname. */
+ #if defined(HOOKUP)
+             int ipmatch = FALSE;
+             int hostmatch = FALSE;
+             int netmatch = FALSE;
+ 
+             /* compare IP number and first field */
+             if (ip && wildmat(ip, fields[0]))
+                 ipmatch = TRUE;
+ 
+             /* compare hostname and first field */
+             if (hp && wildmat(hp, fields[0]))
+                 hostmatch = TRUE;
+ 
+             /* try a netmask match */
+             if (ip && (p = strchr(fields[0],'/')) != (char *)NULL) {
+                 int bits;
+                 int c;
+                 struct in_addr ia;
+                 unsigned int mask;
+                 struct in_addr net;
+                 char *q;
+ 
+                 *p = '\0';
+                 mask = inet_addr(p+1);
+                 if (mask == (unsigned int)INADDR_NONE) {
+                     bits = strtoul(p+1,&q,10);
+                     for (c = 0; c <= bits; c++)
+                         mask |= (1 << (32-c));
+                     mask = htonl(mask);
+                 }
+                 ia.s_addr = inet_addr(ip);
+                 net.s_addr = inet_addr(fields[0]);
+                 if (ia.s_addr != (unsigned int)INADDR_NONE &&
+                     net.s_addr != (unsigned int)INADDR_NONE &&
+                     bits > 0 &&
+                     *q == '\0' &&
+                     (ia.s_addr & mask) == (net.s_addr & mask))
+                     netmatch = TRUE;
+             }
+ 	    if (!ipmatch && !hostmatch && !netmatch)
+ 		continue;
+ #else
  	    if (!(ip && wildmat(ip, fields[0])) && !wildmat(hp, fields[0]))
  		continue;
+ #endif
+ 	}
  
  	/* See if we should lookup a specific user in the passwd file */
  	if (user && pass && EQ(fields[2], "+")) {
-- 
Murray S. Kucherawy ====================================== mskucher@hookup.net
Vice-President, Software Services             HookUp Communication Corporation
(905) 847-8000                NIC Handle "MSK"       Oakville, Ontario, CANADA
--        No matter who you vote for, the government always gets in.        --
=====
-- 
fuck, i'm so fucking full of angst i think i'll go read generation x so many
times i have it memorized and it just oozes out of my pores like so much of
the empty pseudophilosphy and religion i willingly embrace and espouse to my
peers and mentors.	- Patrick J. Finerty <zinc@zifi.genetics.utah.edu>

Technical Details
Message-ID: <rone.WedMay20112158PDT1998.24167@ennui.org>
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
References: <6jue7q$c7s$1@escape.rtsnet.ru>

Show Full Headers
Complete Article Headers
Message-ID: <rone.WedMay20112158PDT1998.24167@ennui.org>
Subject: Re: CIDR aware addresses in nnrp.access
Date: Wed, 20 May 1998 00:00:00 +0000
From: rone+usenet@ennui.org (stare master)
References: <6jue7q$c7s$1@escape.rtsnet.ru>
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: 355031261
X-URL: http://www.ennui.org/~rone/
X-Trace: 895688620 28012 rone 206.184.139.132
Organization: H�mper D� Boys Choir
Newsgroups: news.software.nntp