[prev in list] [next in list] [prev in thread] [next in thread] 

List:       inn-workers
Subject:    PATCH: innd: pathcluster
From:       list-inn-workers () news ! cistron ! nl ("Miquel van Smoorenburg" )
Date:       2008-03-23 13:25:49
Message-ID: 47e65a5d$0$14343$e4fe514c () news ! xs4all ! nl
[Download RAW message or body]

If you have multiple servers that exchange newsfeeds with the
outside world it can be useful to have the same path-name on
all outgoing articles. Ofcourse you can just set 'path' to
the same value on all servers, but it is then impossible to
see what individual server(s) an article passed through.

This patch adds a setting called 'pathcluster' that adds a
common name to the Path: header on all incoming articles. 'path'
and 'pathalias' (if set) are still appended to the path as
usual, but 'pathcluster' is always appended as the last element
(e.g. on the leftmost side of the Path).

If the last pathname of the incoming article is the same as
'pathcluster' it is stripped from the path.

inn-2.4.3-pathcluster.patch

diff -ruN t/inn-2.4.3/doc/pod/inn.conf.pod inn-2.4.3/doc/pod/inn.conf.pod
--- t/inn-2.4.3/doc/pod/inn.conf.pod	2006-03-20 05:14:57.000000000 +0100
+++ inn-2.4.3/doc/pod/inn.conf.pod	2008-03-13 20:56:12.000000000 +0100
@@ -215,6 +215,15 @@
 a particular organization to add a common identity string to the
 Path: header.  The default value is unset.
 
+=item I<pathcluster>
+
+If set, this value is appended to the Path: header of accepted posts
+(after I<pathhost>) if it isn't already present as the last element
+of the Path: header. The purpose of this parameter is to make several
+newsservers appear as one server. The default value is unset.
+(note: the Path: header reads right to left, so appended means inserted
+at the leftmost side of the Path: header)
+
 =item I<pgpverify>
 
 Whether to enable PGP verification of control messages other than cancel.
diff -ruN t/inn-2.4.3/include/inn/innconf.h inn-2.4.3/include/inn/innconf.h
--- t/inn-2.4.3/include/inn/innconf.h	2006-03-20 05:14:57.000000000 +0100
+++ inn-2.4.3/include/inn/innconf.h	2008-03-13 20:56:12.000000000 +0100
@@ -39,6 +39,7 @@
     long maxartsize;            /* Reject articles bigger than this */
     long maxconnections;        /* Max number of incoming NNTP connections */
     char *pathalias;            /* Prepended Host for the Path line */
+    char *pathcluster;          /* Appended Host for the Path line */
     bool pgpverify;             /* Verify control messages with pgpverify? */
     long port;                  /* Which port innd should listen on */
     bool refusecybercancels;    /* Reject message IDs with "<cancel."? */
diff -ruN t/inn-2.4.3/innd/art.c inn-2.4.3/innd/art.c
--- t/inn-2.4.3/innd/art.c	2006-03-20 05:14:57.000000000 +0100
+++ inn-2.4.3/innd/art.c	2008-03-14 22:35:55.000000000 +0100
@@ -439,11 +439,17 @@
   for (p = Article->data + cp->Start, j = 0 ; j < i ; j++) {
     switch (hp[j].index) {
       case HDR__PATH:
-	if (!data->Hassamepath || data->AddAlias) {
+	if (!data->Hassamepath || data->AddAlias || Pathcluster.used) {
 	  /* write heading data */
 	  iov[iovcnt].iov_base = (char *) p;
 	  iov[iovcnt++].iov_len = HDR(HDR__PATH) - p;
 	  arth.len += HDR(HDR__PATH) - p;
+	  /* append clusterpath */
+	  if (Pathcluster.used) {
+	    iov[iovcnt].iov_base = Pathcluster.data;
+	    iov[iovcnt++].iov_len = Pathcluster.used;
+	    arth.len += Pathcluster.used;
+	  }
 	  /* now append new one */
 	  iov[iovcnt].iov_base = Path.data;
 	  iov[iovcnt++].iov_len = Path.used;
@@ -455,6 +461,8 @@
 	  }
 	  /* next to write */
 	  p = HDR(HDR__PATH);
+	  if (data->Hassamecluster)
+	    p += Pathcluster.used;
 	}
 	break;
       case HDR__XREF:
@@ -1856,10 +1891,18 @@
     return false;
   }
 
-  if (strncmp(Path.data, hops[0], Path.used - 1) == 0)
+  i = strlen(hops[0]);
+  if (i == Path.used - 1 &&
+    strncmp(Path.data, hops[0], Path.used - 1) == 0)
     data->Hassamepath = true;
   else
     data->Hassamepath = false;
+  if (Pathcluster.data != NULL &&
+    i == Pathcluster.used - 1 &&
+    strncmp(Pathcluster.data, hops[0], Pathcluster.used - 1) == 0)
+    data->Hassamecluster = true;
+  else
+    data->Hassamecluster = false;
   if (Pathalias.data != NULL &&
     !ListHas((const char **)hops, (const char *)innconf->pathalias))
     data->AddAlias = true;
diff -ruN t/inn-2.4.3/innd/cc.c inn-2.4.3/innd/cc.c
--- t/inn-2.4.3/innd/cc.c	2006-03-20 05:14:57.000000000 +0100
+++ inn-2.4.3/innd/cc.c	2008-03-13 20:56:12.000000000 +0100
@@ -1389,6 +1389,16 @@
 	    Pathalias.Data = xmalloc(Pathalias.Used + 1);
 	    sprintf(Pathalias.Data, "%s!", innconf->pathalias);
 	}
+	if (Pathcluster.Used > 0)
+	    free(Pathcluster.Data);
+	if (innconf->pathcluster == NULL) {
+	    Pathcluster.Used = 0;
+	    Pathcluster.Data = NULL;
+	} else {
+	    Pathcluster.Used = strlen(innconf->pathcluster) + 1;
+	    Pathcluster.Data = xmalloc(Pathcluster.Used + 1);
+	    sprintf(Pathcluster.Data, "%s!", innconf->pathcluster);
+	}
     }
 #endif
 #if defined(DO_TCL)
diff -ruN t/inn-2.4.3/innd/innd.c inn-2.4.3/innd/innd.c
--- t/inn-2.4.3/innd/innd.c	2006-03-20 05:14:57.000000000 +0100
+++ inn-2.4.3/innd/innd.c	2008-03-13 20:56:12.000000000 +0100
@@ -477,6 +477,15 @@
 	Pathalias.data = xmalloc(Pathalias.size);
 	snprintf(Pathalias.data, Pathalias.size, "%s!", innconf->pathalias);
     }
+    if (innconf->pathcluster == NULL) {
+	Pathcluster.used = 0;
+	Pathcluster.data = NULL;
+    } else {
+	Pathcluster.used = strlen(innconf->pathcluster) + 1;
+	Pathcluster.size = Pathcluster.used + 1;
+	Pathcluster.data = xmalloc(Pathcluster.size);
+	snprintf(Pathcluster.data, Pathcluster.size, "%s!", innconf->pathcluster);
+    }
     /* Trace history ? */
     if (innconf->stathist != NULL) {
         syslog(L_NOTICE, "logging hist stats to %s", innconf->stathist);
diff -ruN t/inn-2.4.3/innd/innd.h inn-2.4.3/innd/innd.h
--- t/inn-2.4.3/innd/innd.h	2006-03-20 05:14:57.000000000 +0100
+++ inn-2.4.3/innd/innd.h	2008-03-13 20:56:12.000000000 +0100
@@ -240,6 +240,8 @@
   bool            AddAlias;             /* Whether Pathalias should be added
                                            to this article */
   bool            Hassamepath;          /* Whether this article matches Path */
+  bool            Hassamecluster;       /* Whether this article matches 
+					   Pathcluster */
 } ARTDATA;
 
 /*
@@ -567,6 +581,7 @@
 extern bool		Tracing;
 EXTERN struct buffer	Path;
 EXTERN struct buffer	Pathalias;
+EXTERN struct buffer	Pathcluster;
 EXTERN char	     *  ModeReason;	/* NNTP reject message   */
 EXTERN char	     *  NNRPReason;	/* NNRP reject message   */
 EXTERN char	     *  Reservation;	/* Reserved lock message */
diff -ruN t/inn-2.4.3/innd/site.c inn-2.4.3/innd/site.c
--- t/inn-2.4.3/innd/site.c	2006-03-20 05:14:57.000000000 +0100
+++ inn-2.4.3/innd/site.c	2008-03-13 20:56:12.000000000 +0100
@@ -390,11 +390,18 @@
 	case FEED_PATH:
 	    if (Dirty)
 		buffer_append(bp, ITEMSEP, strlen(ITEMSEP));
-	    if (!Data->Hassamepath)
+	    if (!Data->Hassamepath || Data->AddAlias || Pathcluster.used) {
+		if (Pathcluster.used)
+		    buffer_append(bp, Pathcluster.data, Pathcluster.used);
 		buffer_append(bp, Path.data, Path.used);
-	    if (Data->AddAlias)
-		buffer_append(bp, Pathalias.data, Pathalias.used);
-	    buffer_append(bp, HDR(HDR__PATH), HDR_LEN(HDR__PATH));
+		if (Data->AddAlias)
+		    buffer_append(bp, Pathalias.data, Pathalias.used);
+	    }
+	    if (Data->Hassamecluster)
+	    	buffer_append(bp, HDR(HDR__PATH) + Pathcluster.used,
+					HDR_LEN(HDR__PATH) - Pathcluster.used);
+	    else
+	    	buffer_append(bp, HDR(HDR__PATH), HDR_LEN(HDR__PATH));
 	    break;
 	case FEED_REPLIC:
 	    if (Dirty)
diff -ruN t/inn-2.4.3/lib/innconf.c inn-2.4.3/lib/innconf.c
--- t/inn-2.4.3/lib/innconf.c	2006-03-20 05:14:57.000000000 +0100
+++ inn-2.4.3/lib/innconf.c	2008-03-13 20:56:12.000000000 +0100
@@ -163,6 +163,7 @@
     { K(nntplinklog),           BOOL    (false) },
     { K(noreader),              BOOL    (false) },
     { K(pathalias),             STRING  (NULL) },
+    { K(pathcluster),           STRING  (NULL) },
     { K(pauseretrytime),        NUMBER  (300) },
     { K(peertimeout),           NUMBER  (3600) },
     { K(port),                  NUMBER  (119) },
-- 
The From: and Reply-To: addresses are internal news2mail gateway addresses.
Reply to the list or to "Miquel van Smoorenburg" <miquels@cistron.nl>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic