nnrpd rate limiting via readers.conf

Jeffrey M. Vinocur jeff at litech.org
Fri Apr 27 16:07:46 UTC 2001


As per discussion on inn-workers, a reader.conf parameter for access to
the rate-limiting code.  Against CURRENT 20010425.


-- 
Jeffrey M. Vinocur
jeff at litech.org


-- Attached file included as plaintext by Listar --
-- File: nnrpd-maxrate

diff -u -r inn-CURRENT-20010425/doc/man/readers.conf.5 inn-CURRENT-20010425-modified/doc/man/readers.conf.5
--- inn-CURRENT-20010425/doc/man/readers.conf.5	Wed Apr 25 05:00:39 2001
+++ inn-CURRENT-20010425-modified/doc/man/readers.conf.5	Fri Apr 27 11:56:25 2001
@@ -463,6 +463,12 @@
 disconnected with a \*(L"Permission denied\*(R" message containing the contents
 (a \*(L"reason\*(R") of this parameter.  Some newsreaders will then display the 
 reason to the user.
+.Ip "\fBmax_rate:\fR" 4
+.IX Item "max_rate:"
+If this parameter is present (and nonzero) it is used for nnrpd's 
+rate-limiting code.  The client will only be able to download at this 
+speed (in bytes/second).  Note that at present these limits are 
+ignored if compiled with \s-1SSL\s0 support.
 .Ip "\fBlocaltime:\fR" 4
 .IX Item "localtime:"
 If a Date: header is not included in a posted article, \fInnrpd\fR\|(8) normally
diff -u -r inn-CURRENT-20010425/doc/pod/readers.conf.pod inn-CURRENT-20010425-modified/doc/pod/readers.conf.pod
--- inn-CURRENT-20010425/doc/pod/readers.conf.pod	Wed Apr 25 05:00:44 2001
+++ inn-CURRENT-20010425-modified/doc/pod/readers.conf.pod	Fri Apr 27 11:56:04 2001
@@ -342,6 +342,13 @@
 (a "reason") of this parameter.  Some newsreaders will then display the 
 reason to the user.
 
+=item B<max_rate:>
+
+If this parameter is present (and nonzero) it is used for nnrpd's 
+rate-limiting code.  The client will only be able to download at this 
+speed (in bytes/second).  Note that at present these limits are 
+ignored if compiled with SSL support.
+
 =item B<localtime:>
 
 If a Date: header is not included in a posted article, nnrpd(8) normally
diff -u -r inn-CURRENT-20010425/nnrpd/nnrpd.h inn-CURRENT-20010425-modified/nnrpd/nnrpd.h
--- inn-CURRENT-20010425/nnrpd/nnrpd.h	Wed Apr 25 05:01:18 2001
+++ inn-CURRENT-20010425-modified/nnrpd/nnrpd.h	Wed Apr 25 17:13:43 2001
@@ -89,6 +89,7 @@
     int nnrpdauthsender;
     int virtualhost;
     char *newsmaster;
+    long maxbytespersecond;
 } ACCESSGROUP;
 
 /*
diff -u -r inn-CURRENT-20010425/nnrpd/perm.c inn-CURRENT-20010425-modified/nnrpd/perm.c
--- inn-CURRENT-20010425/nnrpd/perm.c	Wed Apr 25 05:01:18 2001
+++ inn-CURRENT-20010425-modified/nnrpd/perm.c	Fri Apr 27 11:40:54 2001
@@ -142,11 +142,12 @@
 #define PERMnewsmaster		52
 #define PERMlocaladdress	53
 #define PERMrejectwith		54
+#define PERMmaxbytespersecond	55
 #ifdef HAVE_SSL
-#define PERMrequire_ssl		55
-#define PERMMAX			56
+#define PERMrequire_ssl		56
+#define PERMMAX			57
 #else
-#define PERMMAX			55
+#define PERMMAX			56
 #endif
 
 #define TEST_CONFIG(a, b) \
@@ -226,6 +227,7 @@
   { PERMnewsmaster, "newsmaster:" },
   { PERMlocaladdress, "localaddress:" },
   { PERMrejectwith, "reject_with:" },
+  { PERMmaxbytespersecond, "max_rate:" },
 #ifdef HAVE_SSL
   { PERMrequire_ssl, "require_ssl:" },
 #endif
@@ -458,6 +460,7 @@
     curaccess->nnrpdauthsender = innconf->nnrpdauthsender;
     curaccess->virtualhost = FALSE;
     curaccess->newsmaster = NULL;
+    curaccess->maxbytespersecond = 0;
 }
 
 static void free_authgroup(AUTHGROUP *del)
@@ -930,6 +933,10 @@
 	curaccess->newsmaster = COPY(tok->name);
 	SET_CONFIG(oldtype);
 	break;
+      case PERMmaxbytespersecond:
+	curaccess->maxbytespersecond = atol(tok->name);
+	SET_CONFIG(oldtype);
+	break;
       default:
 	ReportError(f, "Unexpected token.");
 	break;
@@ -1460,6 +1467,7 @@
 	    PERMcanpost = FALSE;
 	}
 	PERMaccessconf = access_realms[i];
+	MaxBytesPerSecond = PERMaccessconf->maxbytespersecond;
 	if (PERMaccessconf->virtualhost) {
 	    if (PERMaccessconf->domain == NULL) {
 		syslog(L_ERROR, "%s virtualhost needs domain parameter(%s)",



More information about the inn-patches mailing list