Article View: news.software.nntp
Article #24587Re: nntpsend/innxmit & source IP interface
From: Andrew A. Vasilyev
Date: Wed, 24 Dec 1997 00:00
Date: Wed, 24 Dec 1997 00:00
181 lines
5127 bytes
5127 bytes
Paul Gregg <pgregg@blackhole.nyx.net> wrote:
PG> One of these IPs is 'news.tibus.net', but the innxmit/nntpsend connects
PG> to remote machines from sparc.tibus.net.
PG> How can I force innxmit to connect from news.tibus.net when sending its
PG> outgoing spools ?
Try the following patch (add by hands not by patch -p :)),
compile with "-DNNTP_SOURCE" in lib/Makefile.
Usage: innxmit flags -F news.tibus.net host file
I use this one (together with the similar for innfeed) for
about half of a year without any pain. Suggested to inn-workers
without any result. :((
________
ANDY
*** inn-1.7.2/backends/innxmit.c Sat Dec 6 01:42:12 1997
--- inn/backends/innxmit.c Sat Jul 26 06:34:31 1997
***************
*** 1132,1138 ****
Usage()
{
(void)fprintf(stderr,
! "Usage: innxmit [-a] [-c] [-d] [-M] [-N] [-p] [-r] [-s] [-S] [-t#] [-T#] host file\n");
exit(1);
}
--- 1141,1147 ----
Usage()
{
(void)fprintf(stderr,
! "Usage: innxmit [-a] [-c] [-d] [-M] [-N] [-p] [-r] [-s] [-S] [-t#] [-T#] host file\n");
exit(1);
}
***************
*** 1160,1165 ****
--- 1169,1175 ----
unsigned int ConnectTimeout;
unsigned int TotalTimeout;
extern char *nntp_port;
+ extern char *nntp_host;
/* Set defaults. */
ConnectTimeout = 0;
***************
*** 1168,1178 ****
(void)umask(NEWSUMASK);
/* Parse JCL. */
! while ((i = getopt(ac, av, "lA:acdMNprsSt:T:vP:")) != EOF)
switch (i) {
default:
Usage();
/* NOTREACHED */
case 'A':
AltSpool = optarg;
AltPath = NEW(char, SPOOLNAMEBUFF + strlen(AltSpool));
--- 1178,1193 ----
(void)umask(NEWSUMASK);
/* Parse JCL. */
! while ((i = getopt(ac, av, "lA:acdMNprsSt:T:vP:F:")) != EOF)
switch (i) {
default:
Usage();
/* NOTREACHED */
+
+ case 'F': /* Source hostname --Andy */
+ nntp_host = optarg ;
+ break ;
+
case 'A':
AltSpool = optarg;
AltPath = NEW(char, SPOOLNAMEBUFF + strlen(AltSpool));
*** inn-1.7.2/lib/remopen.c Sat Dec 6 01:42:12 1997
--- inn/lib/remopen.c Mon Apr 21 04:39:26 1997
***************
*** 15,20 ****
--- 15,21 ----
#include "nntp.h"
#include "paths.h"
#include "libinn.h"
+ #include "macros.h"
#if !defined(ntohs) && !defined(NETSWAP)
***************
*** 26,31 ****
--- 27,37 ----
#endif /* !defined(ntohs) && !defined(NETSWAP) */
char *nntp_port = NULL;
+ /* To set the outgoing address exactly */
+ #define NNTP_SOURCE
+ #ifdef NNTP_SOURCE
+ char *nntp_host = NULL;
+ #endif
/*
** Open a connection to an NNTP server and create stdio FILE's for talking
***************
*** 52,57 ****
--- 58,77 ----
struct in_addr quadaddr;
struct sockaddr_in server;
+ #ifdef NNTP_SOURCE
+ char *ph_addr;
+ {
+ struct hostent *host;
+
+ if ( nntp_host &&
+ (host = gethostbyname(nntp_host)) != NULL &&
+ (ph_addr = (char *)malloc(host->h_length)) != NULL)
+ memcpy(ph_addr, host->h_addr, host->h_length);
+ else
+ ph_addr = NULL;
+ }
+ #endif
+
buff = errbuff ? errbuff : mybuff;
*buff = '\0';
quadaddr.s_addr = inet_addr(p);
***************
*** 93,98 ****
--- 113,132 ----
/* Make a socket and try to connect. */
if ((i = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0)
break;
+
+ #ifdef NNTP_SOURCE
+ if (ph_addr) {
+ struct sockaddr_in server_a;
+
+ (void)memset((POINTER)&server_a, 0, sizeof server_a);
+ server_a.sin_family = hp->h_addrtype;
+ (void)memcpy(&server_a.sin_addr, ph_addr, sizeof(server_a.sin_addr));
+
+ if(bind(i, (struct sockaddr *)&server_a, sizeof server_a) < 0)
+ /* fprintf(stderr, "bind() = %d\n", errno) */ ;
+ }
+ #endif
+
/* Copy the address via inline memcpy:
* (void)memcpy((POINTER)&server.sin_addr, (POINTER)*ap,
(int)hp->h_length); */
***************
*** 134,142 ****
errno = oerrno;
continue;
}
return 0;
}
!
return -1;
}
--- 168,183 ----
errno = oerrno;
continue;
}
+ #ifdef NNTP_SOURCE
+ if (ph_addr)
+ DISPOSE(ph_addr);
+ #endif
return 0;
}
! #ifdef NNTP_SOURCE
! if (ph_addr)
! DISPOSE(ph_addr);
! #endif
return -1;
}
Technical Details
Message-ID:
<67pk0f$j3s$1@news.demos.su>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-mailReferences:
<882893741.851283@sparc.tibus.net>Show Full Headers
Complete Article Headers
Message-ID: <67pk0f$j3s$1@news.demos.su> Subject: Re: nntpsend/innxmit & source IP interface Date: Wed, 24 Dec 1997 00:00:00 +0000 From: Andrew A. Vasilyev <andy@snm.demos.su> References: <882893741.851283@sparc.tibus.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 X-Deja-AN: 309763096 Distribution: world Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=KOI8-R Organization: Demos Online Service Mime-Version: 1.0 Newsgroups: news.software.nntp