Article View: news.software.nntp
Article #52253Re: innfeed source address?
From: those who know me have no need o...
Date: Wed, 09 May 2001 01:55
Date: Wed, 09 May 2001 01:55
254 lines
8796 bytes
8796 bytes
<3AF65782.435AF2E3@1012surf.net> divulged:
>Shawn Ramsey schrieb:
>> Is it possible to specify a source address when using innfeed?
>bindaddress: xxx.xxx.xxx.xxx
and if you need per-peer binding you might try the following, completely
untested (you own both halves if it breaks) patch:
--- configfile.h.old Thu May 3 13:27:32 2001
+++ configfile.h Mon May 8 18:24:21 2001
@@ -89,6 +89,7 @@
#define BACKLOG_LIMIT "backlog-limit"
#define INITIAL_CONNECTIONS "initial-connections"
#define IP_NAME "ip-name"
+#define BINDADDRESS "bindaddress"
#define MAX_CONNECTIONS "max-connections"
#define MAX_QUEUE_SIZE "max-queue-size"
#define NO_CHECK_HIGH "no-check-high"
--- connection.h.old Thu May 3 13:27:32 2001
+++ connection.h Mon May 8 18:30:14 2001
@@ -76,6 +76,7 @@
Connection newConnection (Host host,
u_int ident,
const char *ipname,
+ const char *bindname,
u_int artTout,
u_int portNum,
u_int respTimeout,
--- connection.c.old Thu May 3 13:27:32 2001
+++ connection.c Mon May 8 18:27:36 2001
@@ -191,6 +191,7 @@
Buffer respBuffer ; /* buffer all responses are read into */
char *ipName ; /* the ip name (possibly quad) of the remote */
+ char *bindName ; /* the ip name (possibly quad) of the local */
u_int maxCheck ; /* the max number of CHECKs to send */
u_short port ; /* the port number to use */
@@ -406,7 +407,7 @@
iv = INIT_RECON_PER ;
init_reconnect_period = (u_int) iv ;
- if (getString (topScope,"bindaddress",&sv,NO_INHERIT))
+ if (getString (topScope,BINDADDRESS,&sv,NO_INHERIT))
{
bind_addr = inet_addr(sv);
if (bind_addr == INADDR_NONE)
@@ -432,6 +433,7 @@
Connection newConnection (Host host,
u_int id,
const char *ipname,
+ const char *bindname,
u_int articleReceiptTimeout,
u_int portNum,
u_int respTimeout,
@@ -476,6 +478,9 @@
cxn->respBuffer = newBuffer (BUFFER_SIZE) ;
ASSERT (cxn->respBuffer != NULL) ;
+ if (bindname) {
+ cxn->bindName = strdup (bindname) ;
+ } else cxn->bindName = NULL ;
cxn->ipName = strdup (ipname) ;
cxn->port = portNum ;
@@ -582,6 +587,33 @@
}
/* bind to a specified virtual host */
+ if (cxn->bindName)
+ {
+ u_long bind_addr = inet_addr(cxn->bindName);
+ if (bind_addr == INADDR_NONE)
+ {
+ logOrPrint (LOG_ERR,fp,"innfeed unable to determine bind ip for peer %s",cxn->peerName) ;
+ bind_addr = INADDR_ANY;
+ }
+ else
+ {
+ memset (&cxnSelf, 0, sizeof (cxnSelf)) ;
+ cxnSelf.sin_family = AF_INET ;
+ cxnSelf.sin_port = 0 ;
+ cxnSelf.sin_addr.s_addr = bind_addr;
+ if (bind (fd, (struct sockaddr *) &cxnSelf,sizeof (cxnSelf)) < 0)
+ {
+ syslog (LOG_ERR,"bind: %m") ;
+
+ cxnSleepOrDie (cxn) ;
+
+ return false ;
+ }
+ }
+ }
+ else
+
+ /* bind to a specified virtual host */
if (bind_addr != INADDR_ANY)
{
memset (&cxnSelf, 0, sizeof (cxnSelf)) ;
@@ -1163,6 +1195,7 @@
fprintf (fp,"%s endpoint : %p\n",indent,cxn->myEp) ;
fprintf (fp,"%s state : %s\n",indent, stateToString (cxn->state)) ;
fprintf (fp,"%s ident : %d\n",indent,cxn->ident) ;
+ fprintf (fp,"%s bindaddress : %s\n", indent, (cxn->bindName)?cxn->bindName:"ANY") ;
fprintf (fp,"%s ip-name : %s\n", indent, cxn->ipName) ;
fprintf (fp,"%s port-number : %d\n",indent,cxn->port) ;
fprintf (fp,"%s max-checks : %d\n",indent,cxn->maxCheck) ;
@@ -4059,6 +4092,8 @@
cxn->ident = 0 ;
cxn->timeCon = 0 ;
+ if (cxn->bindName)
+ FREE (cxn->bindName) ;
FREE (cxn->ipName) ;
clearTimer (cxn->artReceiptTimerId) ;
--- host.c.old Thu May 3 13:27:32 2001
+++ host.c Mon May 8 18:24:12 2001
@@ -113,6 +113,7 @@
{
char *peerName;
char *ipName;
+ char *bindName;
u_int articleTimeout;
u_int responseTimeout;
u_int initialConnections;
@@ -351,6 +352,7 @@
static u_int gHostCount = 0 ;
+static u_int maxBindNameLen = 0 ;
static u_int maxIpNameLen = 0 ;
static u_int maxPeerNameLen = 0 ;
@@ -507,12 +509,15 @@
params->peerName = strdup(params->peerName);
if (params->ipName)
params->ipName = strdup(params->ipName);
+ if (params->bindName)
+ params->bindName = strdup(params->bindName);
}
else
{
/* Fill in defaults */
params->peerName=NULL;
params->ipName=NULL;
+ params->bindName=NULL;
params->articleTimeout=ARTTOUT;
params->responseTimeout=RESPTOUT;
params->initialConnections=INIT_CXNS;
@@ -548,6 +553,8 @@
FREE (params->peerName) ;
if (params->ipName)
FREE (params->ipName) ;
+ if (params->bindName)
+ FREE (params->bindName) ;
FREE (params) ;
}
@@ -563,6 +570,12 @@
h->nextIpLookup = theTime () ;
}
+ if (strcmp(h->params->bindName, params->bindName) != 0)
+ {
+ FREE (h->params->bindName) ;
+ h->params->bindName = strdup (params->bindName) ;
+ }
+
/* Put in new parameters
Unfortunately we can't blat on top of absMaxConnections
as we need to do some resizing here
@@ -670,10 +683,13 @@
params = newHostParams(defaultParams);
ASSERT(params->peerName == NULL);
ASSERT(params->ipName == NULL);
+ ASSERT(params->bindName == NULL);
ASSERT(h->params->peerName != NULL);
ASSERT(h->params->ipName != NULL);
+ ASSERT(h->params->bindName != NULL);
params->peerName = strdup(h->params->peerName);
params->ipName = strdup(h->params->ipName);
+ params->bindName = strdup(h->params->bindName);
hostReconfigure(h, params);
h->removeOnReload = true;
}
@@ -819,6 +835,7 @@
host->connections [i] =
newConnection (host, i,
host->params->ipName,
+ host->params->bindName,
host->params->articleTimeout,
host->params->portNum,
host->params->responseTimeout,
@@ -945,6 +962,7 @@
/* relies on fact listener and names are null in default*/
p->peerName=strdup(name);
p->ipName=strdup(name);
+ p->bindName=NULL;
h=newHost (listener,p);
if (h==NULL)
@@ -1119,7 +1137,9 @@
strcpy (startTime,ctime (&start)) ;
myPid = getpid() ;
}
-
+
+ if (strlen (nh->params->bindName) > maxBindNameLen)
+ maxBindNameLen = strlen (nh->params-bindName) ;
if (strlen (nh->params->ipName) > maxIpNameLen)
maxIpNameLen = strlen (nh->params->ipName) ;
if (strlen (nh->params->peerName) > maxPeerNameLen)
@@ -1252,6 +1272,7 @@
fprintf (fp,"%s peer-name : %s\n",indent,host->params->peerName) ;
fprintf (fp,"%s ip-name : %s\n",indent,host->params->ipName) ;
+ fprintf (fp,"%s bindaddress : %s\n",indent,(host->params->bindName!=NULL)?host->params->bindName:"ANY") ;
fprintf (fp,"%s abs-max-connections : %d\n",indent,
host->params->absMaxConnections) ;
fprintf (fp,"%s active-connections : %d\n",indent,host->activeCxns) ;
@@ -2521,11 +2542,17 @@
p->peerName=strdup(name);
}
- if (s != NULL)
+ if (s != NULL) {
if (getString (s,IP_NAME,&q,NO_INHERIT))
p->ipName = q ;
else
p->ipName = strdup (name) ;
+
+ if (getString (s,BINDADDRESS,&q,INHERIT))
+ p->bindName = q;
+ else
+ p->bindName = NULL;
+ }
}
@@ -2688,6 +2715,7 @@
FREE (host->cxnSleeping) ;
FREE (host->params->peerName) ;
FREE (host->params->ipName) ;
+ FREE (host->params->bindName) ;
if (host->ipAddrs)
FREE (host->ipAddrs) ;
--
okay, have a sig then
Technical Details
Message-ID:
<tfh8sr8a9ng401@news.supernews.com>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!newsfeed.google.com!newsfeed.stanford.edu!sn-xit-01!sn-post-01!supernews.com!news.supernews.com!not-a-real-addressReferences:
<9csqf8$p04$1@feeder.buzzardnews.com> <3AF65782.435AF2E3@1012surf.net>Show Full Headers
Complete Article Headers
Message-ID: <tfh8sr8a9ng401@news.supernews.com> Subject: Re: innfeed source address? Date: Wed, 09 May 2001 01:55:39 -0000 From: not-a-real-address@usa.net (those who know me have no need of my name) References: <9csqf8$p04$1@feeder.buzzardnews.com> <3AF65782.435AF2E3@1012surf.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!newsfeed.google.com!newsfeed.stanford.edu!sn-xit-01!sn-post-01!supernews.com!news.supernews.com!not-a-real-address Newsgroups: news.software.nntp Organization: earthfriends User-Agent: slrn/0.9.6.3 (Linux) X-Complaints-To: newsabuse@supernews.com Lines: 253