Committer : klmitch CVSROOT : /cvsroot/undernet-ircu Module : ircu2.10 Branch tags: u2_10_11_07 Commit time: 2004-08-27 04:01:38 UTC
Modified files: Tag: u2_10_11_07 ChangeLog include/s_conf.h ircd/s_bsd.c ircd/s_conf.c Log message: Author: Kev <[EMAIL PROTECTED]> Log message: Quick hack to allow C-lines to originate connects from specific local IPs, rather than from INADDR_ANY or the VirtualHost setting. To use, set the first field of your C-line to <local ip address>/<remote host/ip>--i.e.: C:10.1.0.5/10.1.0.6:passwd:localnet.net:4400:5 A "/connect localnet.net" would result in a TCP connection originating from 10.1.0.5 to 10.1.0.6 port 4400. If you don't need the feature, just omit the '/' and anything before it. ---------------------- diff included ---------------------- Index: ircu2.10/ChangeLog diff -u ircu2.10/ChangeLog:1.290.2.130.2.11 ircu2.10/ChangeLog:1.290.2.130.2.12 --- ircu2.10/ChangeLog:1.290.2.130.2.11 Sun Jun 20 12:20:31 2004 +++ ircu2.10/ChangeLog Thu Aug 26 21:01:21 2004 @@ -1,3 +1,15 @@ +2004-08-26 Kevin L Mitchell <[EMAIL PROTECTED]> + + * ircd/s_conf.c (lookup_confhost): if field 1 of a C-line contains + a '/', interpret the text before the '/' as an IP address to bind + to locally, and use the text after the '/' as the host to connect + to + + * ircd/s_bsd.c (connect_inet): if origin field in struct ConfItem + is set, bind to the identified address + + * include/s_conf.h: add origin field to struct ConfItem + 2004-06-20 Alex Badea <[EMAIL PROTECTED]> * ircd/m_account.c: login-on-connect extensions, part 1: Index: ircu2.10/include/s_conf.h diff -u ircu2.10/include/s_conf.h:1.15.2.1 ircu2.10/include/s_conf.h:1.15.2.1.16.1 --- ircu2.10/include/s_conf.h:1.15.2.1 Fri May 17 09:42:19 2002 +++ ircu2.10/include/s_conf.h Thu Aug 26 21:01:25 2004 @@ -1,7 +1,7 @@ /* * s_conf.h * - * $Id: s_conf.h,v 1.15.2.1 2002/05/17 16:42:19 kev Exp $ + * $Id: s_conf.h,v 1.15.2.1.16.1 2004/08/27 04:01:25 klmitch Exp $ */ #ifndef INCLUDED_s_conf_h #define INCLUDED_s_conf_h @@ -55,6 +55,7 @@ unsigned int status; /* If CONF_ILLEGAL, delete when no clients */ unsigned int clients; /* Number of *LOCAL* clients using this */ struct ConnectionClass* conn_class; /* Class of connection */ + struct in_addr origin; /* ip number of connect origin */ struct in_addr ipnum; /* ip number of host field */ char* host; char* passwd; Index: ircu2.10/ircd/s_bsd.c diff -u ircu2.10/ircd/s_bsd.c:1.45.2.13 ircu2.10/ircd/s_bsd.c:1.45.2.13.4.1 --- ircu2.10/ircd/s_bsd.c:1.45.2.13 Sat Nov 1 02:19:12 2003 +++ ircu2.10/ircd/s_bsd.c Thu Aug 26 21:01:26 2004 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: s_bsd.c,v 1.45.2.13 2003/11/01 10:19:12 isomer Exp $ + * $Id: s_bsd.c,v 1.45.2.13.4.1 2004/08/27 04:01:26 klmitch Exp $ */ #include "config.h" @@ -229,7 +229,7 @@ */ static int connect_inet(struct ConfItem* aconf, struct Client* cptr) { - static struct sockaddr_in sin; + static struct sockaddr_in sin, *locaddr = 0; IOResult result; assert(0 != aconf); assert(0 != cptr); @@ -265,9 +265,17 @@ * explicitly bind it, it will default to IN_ADDR_ANY and we lose * due to the other server not allowing our base IP --smg */ - if (feature_bool(FEAT_VIRTUAL_HOST) && - bind(cli_fd(cptr), (struct sockaddr*) &VirtualHost, - sizeof(VirtualHost))) { + if (aconf->origin.s_addr != INADDR_NONE) { + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = aconf->origin.s_addr; + locaddr = &sin; + } else if (feature_bool(FEAT_VIRTUAL_HOST)) + locaddr = &VirtualHost; + + if (locaddr && + bind(cli_fd(cptr), (struct sockaddr*) locaddr, + sizeof(struct sockaddr_in))) { report_error(BIND_ERROR_MSG, cli_name(cptr), errno); close(cli_fd(cptr)); cli_fd(cptr) = -1; Index: ircu2.10/ircd/s_conf.c diff -u ircu2.10/ircd/s_conf.c:1.44.2.5.4.1 ircu2.10/ircd/s_conf.c:1.44.2.5.4.2 --- ircu2.10/ircd/s_conf.c:1.44.2.5.4.1 Fri Jun 18 06:41:44 2004 +++ ircu2.10/ircd/s_conf.c Thu Aug 26 21:01:28 2004 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: s_conf.c,v 1.44.2.5.4.1 2004/06/18 13:41:44 decampos Exp $ + * $Id: s_conf.c,v 1.44.2.5.4.2 2004/08/27 04:01:28 klmitch Exp $ */ #include "config.h" @@ -238,6 +238,7 @@ */ static void lookup_confhost(struct ConfItem *aconf) { + char *tmp, *tmp2; struct DNSReply* reply; if (EmptyString(aconf->host) || EmptyString(aconf->name)) { @@ -249,6 +250,15 @@ * Do name lookup now on hostnames given and store the * ip numbers in conf structure. */ + if ((tmp = strchr(aconf->host, '/'))) { + *(tmp++) = '\0'; + aconf->origin.s_addr = inet_addr(aconf->host); + tmp2 = aconf->host; + DupString(aconf->host, tmp); + free(tmp2); + } else + aconf->origin.s_addr = INADDR_NONE; + if (IsDigit(*aconf->host)) { /* * rfc 1035 sez host names may not start with a digit ----------------------- End of diff -----------------------