Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2004-09-10 16:40:16 UTC

Modified files:
     ChangeLog include/s_conf.h ircd/ircd_parser.y ircd/s_bsd.c
     ircd/s_conf.c

Log message:

Similar to Kev's patch dated 2004-08-26, allow specification of local
IPs for each Connect block in the config file.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.450 ircu2.10/ChangeLog:1.451
--- ircu2.10/ChangeLog:1.450    Fri Sep 10 09:07:35 2004
+++ ircu2.10/ChangeLog  Fri Sep 10 09:40:04 2004
@@ -1,3 +1,19 @@
+2004-09-10  Michael Poole <[EMAIL PROTECTED]>
+
+       * include/s_conf.h (struct ConfItem): Add origin and origin_name
+       fields.
+
+       * ircd/ircd_parser.y: Add new global variable "origin."  Add a new
+       "connectionvhost" production that accepts vhost = "IP" inside a
+       Connect block and assigns the IP to origin_name.
+
+       * ircd/s_bsd (connect_inet): If aconf has a valid origin, use it
+       as the local address.  Otherwise, fall back to the old logic (if
+       VIRTUAL_HOST="TRUE", use the virtual host setting).
+
+       * ircd/s_conf.c (lookup_confhost): If the ConfItem has an
+       origin_name, try to parse it as an IP address.
+
 2004-04-17  Isomer <[EMAIL PROTECTED]>
        * ircd/parse.c: Don't rate limit /gline messages
 
Index: ircu2.10/include/s_conf.h
diff -u ircu2.10/include/s_conf.h:1.22 ircu2.10/include/s_conf.h:1.23
--- ircu2.10/include/s_conf.h:1.22      Wed Aug 18 21:00:47 2004
+++ ircu2.10/include/s_conf.h   Fri Sep 10 09:40:05 2004
@@ -1,7 +1,7 @@
 /*
  * s_conf.h
  *
- * $Id: s_conf.h,v 1.22 2004/08/19 04:00:47 entrope Exp $ 
+ * $Id: s_conf.h,v 1.23 2004/09/10 16:40:05 entrope Exp $ 
  */
 #ifndef INCLUDED_s_conf_h
 #define INCLUDED_s_conf_h
@@ -52,8 +52,10 @@
   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 irc_sockaddr origin;  /* local address */
   struct irc_sockaddr address; /* ip and port */
   char *host;
+  char *origin_name;
   char *passwd;
   char *name;
   time_t hold; /* Hold until this time (calendar time) */
Index: ircu2.10/ircd/ircd_parser.y
diff -u ircu2.10/ircd/ircd_parser.y:1.22 ircu2.10/ircd/ircd_parser.y:1.23
--- ircu2.10/ircd/ircd_parser.y:1.22    Fri Sep 10 08:48:45 2004
+++ ircu2.10/ircd/ircd_parser.y Fri Sep 10 09:40:05 2004
@@ -17,7 +17,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  *  USA.
- * $Id: ircd_parser.y,v 1.22 2004/09/10 15:48:45 entrope Exp $
+ * $Id: ircd_parser.y,v 1.23 2004/09/10 16:40:05 entrope Exp $
  */
 %{
 
@@ -72,7 +72,7 @@
   /* Now all the globals we need :/... */
   int tping, tconn, maxlinks, sendq, port, invert;
   int stringno;
-  char *name, *pass, *host;
+  char *name, *pass, *host, *origin;
   char *stringlist[MAX_STRINGS];
   struct ConnectionClass *c_class;
   struct ConfItem *aconf;
@@ -382,7 +382,7 @@
 
 connectblock: CONNECT
 {
- name = pass = host = NULL;
+ name = pass = host = origin = NULL;
  c_class = NULL;
  port = 0;
 } '{' connectitems '}'
@@ -393,6 +393,7 @@
    aconf = make_conf();
    aconf->status = CONF_SERVER;
    aconf->name = name;
+   aconf->origin_name = origin;
    aconf->passwd = pass;
    aconf->conn_class = c_class;
    aconf->address.port = port;
@@ -407,13 +408,14 @@
    MyFree(name);
    MyFree(pass);
    MyFree(host);
-   name = pass = host = NULL;
+   MyFree(origin);
    parse_error("Bad connect block");
  }
+ name = pass = host = origin = NULL;
 }';';
 connectitems: connectitem connectitems | connectitem;
 connectitem: connectname | connectpass | connectclass | connecthost
-              | connectport | error;
+              | connectport | connectvhost | error;
 connectname: NAME '=' QSTRING ';'
 {
  MyFree(name);
@@ -437,6 +439,11 @@
 {
  port = $3;
 };
+connectvhost: VHOST '=' QSTRING ';'
+{
+ MyFree(origin);
+ DupString(origin, $3);
+};
 
 serverblock: SERVER
 {
Index: ircu2.10/ircd/s_bsd.c
diff -u ircu2.10/ircd/s_bsd.c:1.60 ircu2.10/ircd/s_bsd.c:1.61
--- ircu2.10/ircd/s_bsd.c:1.60  Wed Aug 18 21:00:53 2004
+++ ircu2.10/ircd/s_bsd.c       Fri Sep 10 09:40:05 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.60 2004/08/19 04:00:53 entrope Exp $
+ * $Id: s_bsd.c,v 1.61 2004/09/10 16:40:05 entrope Exp $
  */
 #include "config.h"
 
@@ -226,6 +226,7 @@
  */
 static int connect_inet(struct ConfItem* aconf, struct Client* cptr)
 {
+  const struct irc_sockaddr *local;
   IOResult result;
   assert(0 != aconf);
   assert(0 != cptr);
@@ -233,7 +234,13 @@
    * Might as well get sockhost from here, the connection is attempted
    * with it so if it fails its useless.
    */
-  cli_fd(cptr) = os_socket((feature_bool(FEAT_VIRTUAL_HOST) ? &VirtualHost : NULL), 
SOCK_STREAM, cli_name(cptr));
+  if (irc_in_addr_valid(&aconf->origin.addr))
+    local = &aconf->origin;
+  else if (feature_bool(FEAT_VIRTUAL_HOST))
+    local = &VirtualHost;
+  else
+    local = NULL;
+  cli_fd(cptr) = os_socket(local, SOCK_STREAM, cli_name(cptr));
   if (cli_fd(cptr) < 0)
     return 0;
 
Index: ircu2.10/ircd/s_conf.c
diff -u ircu2.10/ircd/s_conf.c:1.59 ircu2.10/ircd/s_conf.c:1.60
--- ircu2.10/ircd/s_conf.c:1.59 Sun Aug 22 16:45:52 2004
+++ ircu2.10/ircd/s_conf.c      Fri Sep 10 09:40:06 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.59 2004/08/22 23:45:52 entrope Exp $
+ * $Id: s_conf.c,v 1.60 2004/09/10 16:40:06 entrope Exp $
  */
 #include "config.h"
 
@@ -245,6 +245,11 @@
            aconf->host, aconf->name));
     return;
   }
+  if (aconf->origin_name
+      && !ircd_aton(&aconf->origin.addr, aconf->origin_name)) {
+    Debug((DEBUG_ERROR, "Origin name error: (%s) (%s)",
+        aconf->origin_name, aconf->name));
+  }
   /*
    * Do name lookup now on hostnames given and store the
    * ip numbers in conf structure.
----------------------- End of diff -----------------------

Reply via email to