🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #24106

Re: inn cidr slash patch

#24106
From: Dale Ghent
Date: Sat, 06 Dec 1997 00:00
125 lines
4551 bytes
This is a multi-part message in MIME format.

--------------FF6ABD31DF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Rob Monz wrote:
> 
> Where can I get the inn cidr slash patch ?  Thanks

Here it is

		-Dale G.

-- 
Dale Ghent                        daleg @ digex.net
NetworkNews Administrator             DIGEX, Inc.
http://www.digex.net                Beltsville, MD
                    I speak for myself

--------------FF6ABD31DF
Content-Type: text/plain; charset=us-ascii; name="nnrpd-cidr.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="nnrpd-cidr.patch"

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], "+")) {

--------------FF6ABD31DF--


Technical Details
Message-ID: <3488AEEA.3F54@digex.net>
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: <01bd01e7$6b24f820$4f016281@vodka.aecom.yu.edu>

Show Full Headers
Complete Article Headers
Message-ID: <3488AEEA.3F54@digex.net>
Subject: Re: inn cidr slash patch
Date: Sat, 06 Dec 1997 00:00:00 +0000
From: Dale Ghent <daleg@digex.net>
References: <01bd01e7$6b24f820$4f016281@vodka.aecom.yu.edu>
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: 295639974
To: Rob Monz <rob@miracle.net>
Organization: DIGEX Inc.
Newsgroups: news.software.nntp