INN commit: trunk (4 files)

INN Commit Russ_Allbery at isc.org
Sat Nov 22 19:09:58 UTC 2008


    Date: Saturday, November 22, 2008 @ 11:09:57
  Author: iulius
Revision: 8185

Add a new ignore: parameter in incoming.conf.  It compels innd to answer
435 and 438 to IHAVE/CHECK commands from the remote peer so that it does not
send any articles.

Modified:
  trunk/innd/innd.h
  trunk/innd/nc.c
  trunk/innd/rc.c
  trunk/samples/incoming.conf

-----------------------+
 innd/innd.h           |    1 
 innd/nc.c             |    4 -
 innd/rc.c             |   50 ++++++++++++++++
 samples/incoming.conf |  147 ++++++++++++++++++++++++++----------------------
 4 files changed, 133 insertions(+), 69 deletions(-)

Modified: innd/innd.h
===================================================================
--- innd/innd.h	2008-11-22 18:15:01 UTC (rev 8184)
+++ innd/innd.h	2008-11-22 19:09:57 UTC (rev 8185)
@@ -320,6 +320,7 @@
   enum channel_state   State;
   int		       fd;
   bool		       Skip;
+  bool                 Ignore;
   bool		       Streaming;
   bool		       NoResendId;
   bool		       privileged;

Modified: innd/nc.c
===================================================================
--- innd/nc.c	2008-11-22 18:15:01 UTC (rev 8184)
+++ innd/nc.c	2008-11-22 19:09:57 UTC (rev 8185)
@@ -524,7 +524,7 @@
     }
 #endif
 
-    if (HIScheck(History, p)) {
+    if (HIScheck(History, p) || cp->Ignore) {
 	cp->Refused++;
 	cp->Ihave_Duplicate++;
 	NCwritereply(cp, NNTP_HAVEIT);
@@ -1367,7 +1367,7 @@
     }
 #endif /* defined(DO_PYTHON) */
 
-    if (HIScheck(History, p)) {
+    if (HIScheck(History, p) || cp->Ignore) {
 	cp->Refused++;
 	cp->Check_got++;
 	snprintf(cp->Sendid.data, cp->Sendid.size, "%d %s",

Modified: innd/rc.c
===================================================================
--- innd/rc.c	2008-11-22 18:15:01 UTC (rev 8184)
+++ innd/rc.c	2008-11-22 19:09:57 UTC (rev 8185)
@@ -37,6 +37,7 @@
     char 	*Identd;	/* Optional identd */
     bool	Streaming;      /* Streaming allowed ? */
     bool	Skip;	        /* Skip this peer ? */
+    bool        Ignore;        /* Ignore articles sent by this peer? */
     bool	NoResendId;	/* Don't send RESEND responses ? */
     bool	Nolist;		/* no list command allowed */
     int		MaxCnx;		/* Max connections (per peer) */
@@ -80,13 +81,14 @@
 #define EMAIL	        "email:"
 #define COMMENT	        "comment:"
 #define SKIP		"skip:"
+#define IGNORE          "ignore:"
 #define NORESENDID	"noresendid:"
 #define HOLD_TIME	"hold-time:"
 #define NOLIST		"nolist:"
 
 typedef enum {K_END, K_BEGIN_PEER, K_BEGIN_GROUP, K_END_PEER, K_END_GROUP,
 	      K_STREAM, K_HOSTNAME, K_MAX_CONN, K_PASSWORD, K_IDENTD,
-	      K_EMAIL, K_PATTERNS, K_COMMENT, K_SKIP, K_NORESENDID,
+	      K_EMAIL, K_PATTERNS, K_COMMENT, K_SKIP, K_IGNORE, K_NORESENDID,
 	      K_HOLD_TIME, K_NOLIST
 	     } _Keywords;
 
@@ -602,6 +604,7 @@
 	if ((new = NCcreate(fd, rp->Password[0] != '\0', false)) != NULL) {
             new->Streaming = rp->Streaming;
             new->Skip = rp->Skip;
+            new->Ignore = rp->Ignore;
             new->NoResendId = rp->NoResendId;
             new->Nolist = rp->Nolist;
             new->CanAuthenticate = true; /* Can use AUTHINFO. */
@@ -860,6 +863,7 @@
     rp->MaxCnx = 0;
     rp->Streaming = true;
     rp->Skip = false;
+    rp->Ignore = false;
     rp->NoResendId = false;
     rp->Nolist = false;
     rp->HoldTime = 0;
@@ -874,6 +878,7 @@
     peer_params.Label = NULL;
     default_params.Streaming = true;
     default_params.Skip = false;
+    default_params.Ignore = false;
     default_params.NoResendId = false;
     default_params.Nolist = false;
     default_params.MaxCnx = 0;
@@ -915,6 +920,8 @@
 	group_params->Label = word;
 	group_params->Skip = groupcount > 1 ?
 	  groups[groupcount - 2].Skip : default_params.Skip;
+        group_params->Ignore = groupcount > 1 ?
+            groups[groupcount - 2].Ignore : default_params.Ignore;
 	group_params->Streaming = groupcount > 1 ?
 	  groups[groupcount - 2].Streaming : default_params.Streaming;
 	group_params->NoResendId = groupcount > 1 ?
@@ -972,6 +979,8 @@
 	peer_params.Name = NULL;
 	peer_params.Skip = groupcount > 0 ?
 	  group_params->Skip : default_params.Skip;
+        peer_params.Ignore = groupcount > 0 ?
+            group_params->Ignore : default_params.Ignore;
 	peer_params.Streaming = groupcount > 0 ?
 	  group_params->Streaming : default_params.Streaming;
 	peer_params.NoResendId = groupcount > 0 ?
@@ -1061,6 +1070,7 @@
 		rp->Comment = xstrdup(peer_params.Comment);
 		rp->Streaming = peer_params.Streaming;
 		rp->Skip = peer_params.Skip;
+                rp->Ignore = peer_params.Ignore;
 		rp->NoResendId = peer_params.NoResendId;
 		rp->Nolist = peer_params.Nolist;
 		rp->Password = xstrdup(peer_params.Password);
@@ -1159,6 +1169,38 @@
 	continue;
       }
 
+      /* ignore */
+      if (!strncmp (word, IGNORE, sizeof IGNORE)) {
+          free(word);
+          TEST_CONFIG(K_IGNORE, bit);
+          if (bit) {
+              syslog(L_ERROR, DUPLICATE_KEY, LogName, filename, linecount);
+              break;
+          }
+          if ((word = RCreaddata (&linecount, F, &toolong)) == NULL) {
+              break;
+          }
+          if (!strcmp (word, "true"))
+              flag = true;
+          else
+              if (!strcmp (word, "false"))
+                  flag = false;
+              else {
+                  syslog(L_ERROR, MUST_BE_BOOL, LogName, filename, linecount);
+                  break;
+              }
+          RCadddata(data, &infocount, K_IGNORE, T_STRING, word);
+          if (peer_params.Label != NULL)
+              peer_params.Ignore = flag;
+          else
+              if (groupcount > 0 && group_params->Label != NULL)
+                  group_params->Ignore = flag;
+              else
+                  default_params.Ignore = flag;
+          SET_CONFIG(K_IGNORE);
+          continue;
+      }
+
       /* noresendid */
       if (!strncmp (word, NORESENDID, sizeof NORESENDID)) {
 	free(word);
@@ -1543,6 +1585,12 @@
 	    RCwritelistvalue (F, RCpeerlistfile[i].value);
 	    fputc ('\n', F);
 	    break;
+          case K_IGNORE:
+            RCwritelistindent (F, inc);
+            fprintf(F, "%s\t", IGNORE);
+            RCwritelistvalue (F, RCpeerlistfile[i].value);
+            fputc ('\n', F);
+            break;
 	  case K_NORESENDID:
 	    RCwritelistindent (F, inc);
 	    fprintf(F, "%s\t", NORESENDID);

Modified: samples/incoming.conf
===================================================================
--- samples/incoming.conf	2008-11-22 18:15:01 UTC (rev 8184)
+++ samples/incoming.conf	2008-11-22 19:09:57 UTC (rev 8185)
@@ -1,141 +1,156 @@
-##  $Revision$
-##  incoming.conf - names and addresses that feed us news
-##      
-##  This file consists of three types of entries: key/value, peer and group.
-##  Comments are taken from the hash character ``#'' to the end of the line.
+##  $Id$
+##
+##  incoming.conf -- names and addresses that feed us news
+##
+##  This file consists of three types of entries:  key/value, peer and group.
+##  Comments are taken from the hash character "#" to the end of the line.
 ##  Blank lines are ignored.
 ##
-##  Key/value entries are a keyword immediatly followed by a colon, at least
-##  one blank and a value. For example:
-## 
+##  Key/value entries are a keyword immediately followed by a colon, at least
+##  one blank and a value.  For example:
+##
 ##         max-connections: 10
-## 
-##  A legal key contains nor blanks, nor colon, nor ``#''.
-##  There are 5 different type of  values:  integers,  booleans, and strings.
-##  Integers are as to be expected. A boolean value is either ``true'' or
-##  ``false'' (case is significant). A string value is any other sequence of
-##  characters. If the string needs to contain whitespace, then it must be
+##
+##  A legal key contains neither blanks, nor colon, nor "#".
+##  There are three different types of  values:  integers,  booleans, and strings.
+##  Integers are as to be expected.  A boolean value is either "true" or
+##  "false" (case is significant).  A string value is any other sequence of
+##  characters.  If the string needs to contain whitespace, then it must be
 ##  quoted with double quotes.
 ##
 ##  Peer entries look like:
-## 
+##
 ##          peer <name> {
 ##               # body
 ##          }
-## 
-##  The word ``peer'' is required. <name> is a label for this peer. It is
-##  any string valid as a key. The body of a peer entry contains some number
+##
+##  The word "peer" is required.  <name> is a label for this peer.  It is
+##  any string valid as a key.  The body of a peer entry contains some number
 ##  of key/value entries.
 ##
 ##  Group entries look like:
-## 
+##
 ##          group <name> {
 ##               # body
 ##          }
 ##
-##  The word ``group'' is required. The ``<name>'' is any string valid as a
-##  key. The body of a group entry contains any number of the three types of
-##  entries. So key/value pairs can be defined inside a group, and peers can
+##  The word "group" is required.  <name> is any string valid as a key.
+##  The body of a group entry contains any number of the three types of
+##  entries.  So key/value pairs can be defined inside a group, and peers can
 ##  be nested inside a group, and other groups can be nested inside a group.
 ##
 ##  Key/value entries that are defined outside of all peer and group entries
-##  are said to be at ``global scope''. Global key/value entries act as
-##  defaults for peers. When innd looks for a specific value in a peer entry
+##  are said to be at "global scope".  Global key/value entries act as
+##  defaults for peers.  When innd looks for a specific value in a peer entry
 ##  (for example, the maximum number of connections to allow), if the value
 ##  is not defined in the peer entry, then the enclosing groups are examined
-##  for the entry (starting at the closest enclosing group). If there are no
+##  for the entry (starting at the closest enclosing group).  If there are no
 ##  enclosing groups, or the enclosing groups don't define the key/value,
 ##  then the value at global scope is used.
 ##
 ##  A small example could be:
-## 
+##
 ##      # Global value applied to all peers that have no value of their own.
 ##      max-connections: 5
-## 
+##
 ##      # A peer definition.
 ##      peer uunet {
 ##           hostname: usenet1.uu.net
 ##      }
-## 
+##
 ##      peer vixie {
 ##              hostname: gw.home.vix.com
-##              max-connections: 10      # override global value.
+##              max-connections: 10      # Override global value.
 ##      }
-## 
-##      # A group of two peers who can open more connections than normal
+##
+##      # A group of two peers who can open more connections than normal.
 ##      group fast-sites {
 ##           max-connections: 15
-## 
-##           # Another peer. The ``max-connections'' value from the
-##           # ``fast-sites'' group scope is used.
+##
+##           # Another peer.  The max-connections: value from the
+##           # fast-sites group scope is used.
 ##           peer data.ramona.vix.com {
 ##                hostname: data.ramona.vix.com
 ##           }
-## 
+##
 ##           peer bb.home.vix.com {
 ##                hostname: bb.home.vix.com
-##                max-connections: 20 # he can really cook.
+##                max-connections: 20    # He can really cook.
 ##           }
 ##      }
-## 
+##
 ##  Given the above configuration file, the defined peers would have the
-##  following values for the ``max-connections'' key.
+##  following values for the max-connections: key.
 ##
 ##          uunet                  5
 ##          vixie                 10
 ##          data.ramona.vix.com   15
 ##          bb.home.vix.com       20
 ##
-##  Height keys are allowed:
+##  The following keys are allowed:
 ##
 ##  hostname:
-##   This key is mandatory in a peer block. The value is a string representing
-##   a list of hostnames separated by a comma. A hostname is the host's FQDN,
+##   This key is mandatory in a peer block.  The value is a string representing
+##   a list of hostnames separated by a comma.  A hostname is the host's FQDN,
 ##   or the dotted quad ip-address of the peer.
 ##
 ##  streaming:
-##   This key requires a boolean value. It defines whether streaming commands
-##   are allowed from this peer. (default=true)
+##   This key requires a boolean value.  It defines whether streaming commands
+##   are allowed from this peer.  (default=true)
 ##
 ##  max-connections:
-##   This key requires positive integer value. It defines the maximum number
-##   of connections allowed. A value of zero specifies an unlimited number
-##   of maximum connections (``unlimited'' or ``none'' can be used as synonym).
+##   This key requires a positive integer value.  It defines the maximum number
+##   of connections allowed.  A value of zero specifies an unlimited number
+##   of maximum connections ("unlimited" or "none" can be used as synonyms).
 ##   (default=0)
-## 
+##
 ##  hold-time:
-##   This key requires positive integer value. It defines the hold time before
-##   close, if the connection is over max-connections. A value of zero
-##   specifies immediate close. (default=0)
+##   This key requires a positive integer value.  It defines the hold time before
+##   close, if the connection is over the max-connections: value.  A value of zero
+##   specifies immediate close.  (default=0)
 ##
+##  identd:
+##   This key requires a string value.  It is used if you wish to require a
+##   peer's user name retrieved through identd match the specified string.
+##   (unset by default, that is to say no identd)
+##
 ##  password:
-##   This key requires a string value. It is used if you wish to require a peer
-##   to supply a password. (default=no password)
+##   This key requires a string value.  It is used if you wish to require a peer
+##   to supply a password.  (unset by default, that is to say no password)
 ##
 ##  patterns:
-##   This key requires a string value. It is a list of newsfeeds(5)-style list
-##   of newsgroups which are to be accepted from this host. (default="*")
+##   This key requires a string value.  It is a list of newsfeeds(5)-style list
+##   of newsgroups which are to be accepted from this host.  (default="*")
 ##
 ##  email:
-##   This key requires a string value. Reserved for future use. (default=empty)
+##   This key requires a string value.  Reserved for future use.  (empty by default)
 ##
 ##  comment:
-##   This key requires a string value. Reserved for future use. (default=empty)
+##   This key requires a string value.  Reserved for future use.  (empty by default)
 ##
 ##  skip:
-##   This key requires a boolean value. Setting this entry causes this peer
-##   to be skipped. Reserved for future use. (default=false)
+##   This key requires a boolean value.  Setting this entry causes this peer
+##   to be skipped.  (default=false)
 ##
-##  noresendid: 
-##   This key requires a boolean value. It defines whether innd should send
-##   "431 RESENDID" (stream mode) or "436 Retry later" (non-stream mode)
-##   responses if a message is offered that is already received from another
-##   peer. This can be useful for peers that resend messages right away,
-##   as innfeed does. (default=false)
+##  ignore:
+##   This key requires a boolean value.  Setting this entry causes innd to
+##   refuse every article sent via CHECK or IHAVE by this peer.  (default=false)
 ##
+##  noresendid:
+##   This key requires a boolean value.  It defines whether innd should send
+##   "431" (response to CHECK, in streaming mode) or "436" (response to IHAVE
+##   in non-streaming mode) responses instead of "438" (response to CHECK)
+##   or "435" (response to IHAVE) if a message is offered that is already
+##   received from another peer.  This can be useful for peers that resend
+##   messages right away, as innfeed does.  (default=false)
+##
+##  nolist:
+##   This key requires a boolean value.  It defines whether a peer is allowed
+##   to issue list command.  (default=false, that is to say it can)
+##
 
-streaming:              true   # streaming allowed by default
-max-connections:        8      # per feed
+streaming:              true   # Streaming allowed by default.
+max-connections:        8      # Per feed.
 
 peer ME {
   hostname:         "localhost, 127.0.0.1, ::1"




More information about the inn-committers mailing list