Author: Bleep <helveytw@home.com>
authorBleep <twhelvey1@home.com>
Sun, 17 Sep 2000 08:32:40 +0000 (08:32 +0000)
committerBleep <twhelvey1@home.com>
Sun, 17 Sep 2000 08:32:40 +0000 (08:32 +0000)
Log message: Move me config stuff to local conf, fixup affected code,
test changes.

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@293 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/s_bsd.h
include/s_conf.h
ircd/IPcheck.c
ircd/chkconf.c
ircd/ircd.c
ircd/s_bsd.c
ircd/s_conf.c

index 5cdea5330b35d565980f54e49bd039b11e55f728..c008d01c727d521fb9dec8fc499de70e131419b1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2000-09-17  Thomas Helvey <helveytw@home.com>
+       * ircd/s_conf.c: add me to local conf
+       * include/s_conf.h: move CONF_ME macro to chkconf.c
+       * ircd/s_bsd.c: cleanup initialization, allow virtual host
+       to be changed by rehash
+
 2000-09-17  Thomas Helvey <helveytw@home.com>
        * include/class.h: add missing prototype
        * ircd/class.c: make argument to get_conf_class const
index 59dcc5f939f7b7dcc3935437acc27aa1629bb293..dcada222a06cf7cd1f9c507fd898c9899ffd338c 100644 (file)
 #include <sys/types.h>         /* size_t, time_t */
 #define INCLUDED_sys_types_h
 #endif
+#ifndef INCLUDED_netinet_in_h
+#include <netinet/in.h>
+#define INCLUDED_netinet_in_h
+#endif
 
 struct Client;
 struct ConfItem;
@@ -82,8 +86,9 @@ extern int  net_close_unregistered_connections(struct Client* source);
 extern void close_connection(struct Client *cptr);
 extern void add_connection(struct Listener* listener, int fd);
 extern int  read_message(time_t delay);
-extern int  init_server_identity(void);
+extern void init_server_identity(void);
 extern void close_connections(int close_stderr);
 extern int  init_connection_limits(void);
+extern void set_virtual_host(struct in_addr addr);
 
 #endif /* INCLUDED_s_bsd_h */
index 9e676f921ad35e6579c7e31c3fce91a8813eca3f..73d0b9cb37cfc42c63834317a1d22eceaff58fe9 100644 (file)
@@ -21,7 +21,6 @@
 struct Client;
 struct SLink;
 struct TRecord;
-struct hostent;
 
 
 /*
@@ -38,7 +37,6 @@ struct hostent;
 #define CONF_SERVER             0x0004
 #define CONF_LOCOP              0x0010
 #define CONF_OPERATOR           0x0020
-#define CONF_ME                 0x0040
 #define CONF_KILL               0x0080
 #define CONF_LEAF               0x1000
 #define CONF_HUB                0x4000
@@ -87,13 +85,13 @@ struct ServerConf {
  * A line: A:<line 1>:<line 2>:<line 3>
  */
 struct LocalConf {
-  char* server_alias;
-  char* vhost_address;
-  char* description;
-  char* numeric_id;
-  char* location1;
-  char* location2;
-  char* contact;
+  char*          name;
+  char*          description;
+  struct in_addr vhost_address;
+  unsigned int   numeric;
+  char*          location1;
+  char*          location2;
+  char*          contact;
 };
 
 struct MotdItem {
@@ -153,33 +151,31 @@ extern struct TRecord*  tdata;
  * Proto types
  */
 
+extern int init_conf(void);
+
 extern const struct LocalConf* conf_get_local(void);
 extern const struct MotdConf*  conf_get_motd_list(void);
 extern const struct CRuleConf* conf_get_crule_list(void);
 
-extern const char* conf_crule_eval(const char* host, int mask);
+extern const char* conf_eval_crule(const char* name, int mask);
 
 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
 extern struct ConfItem* conf_find_server(const char* name);
-const char* conf_eval_crule(const char* name, int mask);
 
 extern void det_confs_butmask(struct Client *cptr, int mask);
 extern int detach_conf(struct Client *cptr, struct ConfItem *aconf);
 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
-extern struct ConfItem* find_me(void);
 extern struct ConfItem* find_conf_exact(const char* name, const char* user,
                                         const char* host, int statmask);
 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
 extern int  conf_check_server(struct Client *cptr);
 extern struct ConfItem* find_conf_name(const char* name, int statmask);
 extern int rehash(struct Client *cptr, int sig);
-extern int init_conf(void);
 extern void read_tlines(void);
 extern int find_kill(struct Client *cptr);
 extern int find_restrict(struct Client *cptr);
-extern int m_killcomment(struct Client *sptr, char *parv, char *filename);
 extern struct MotdItem* read_motd(const char* motdfile);
 
 #endif /* INCLUDED_s_conf_h */
index 6c58f462c5534be83dc0bd552ba7e4a28d03b5cd..57865fc5da570893bcb3c1a4c5bfe70b7bceb66f 100644 (file)
@@ -27,7 +27,6 @@
 #include "ircd.h"
 #include "numnicks.h"       /* NumNick, NumServ (GODMODE) */
 #include "ircd_alloc.h"
-#include "s_bsd.h"          /* SetIPChecked */
 #include "s_debug.h"        /* Debug */
 #include "s_user.h"         /* TARGET_DELAY */
 #include "send.h"
index 35383670e85495bd4b2cf8b76c6a4575e0e813dc..2b5fd4d4a6c1e4ad827131294bb5a1d0cfc7f4a2 100644 (file)
@@ -42,6 +42,7 @@
 /*
  * stuff that isn't used by s_conf.c anymore
  */
+#define CONF_ME                 0x0040
 #define CONF_ADMIN              0x0100
 #define CONF_CLASS              0x0400
 #define CONF_LISTEN_PORT        0x2000
index fc451592d0d185cad43ff09cf75d8d534747e69c..414eadf3ef32f182827a8b903d97884b311ef122 100644 (file)
@@ -658,10 +658,7 @@ int main(int argc, char **argv) {
     return 7;
   }
 
-  if (!init_server_identity()) {
-    ircd_log(L_CRIT, "Failed to initialize server identity");
-    return 8;
-  }
+  init_server_identity();
 
   uping_init();
 
index cda4eb7ebf5f0ad6b52dfe47433147646251b226..613af93f974ac538d2a82eca7600ae07a6f5ecc0 100644 (file)
@@ -1432,20 +1432,11 @@ int connect_server(struct ConfItem* aconf, struct Client* by,
 /*
  * Setup local socket structure to use for binding to.
  */
-void init_virtual_host(const struct ConfItem* conf)
+void set_virtual_host(struct in_addr addr)
 {
-  assert(0 != conf);
-
   memset(&VirtualHost, 0, sizeof(VirtualHost));
   VirtualHost.sin_family = AF_INET;
-  VirtualHost.sin_addr.s_addr = INADDR_ANY;
-
-  if (EmptyString(conf->passwd) || 0 == strcmp(conf->passwd, "*"))
-    return;
-  VirtualHost.sin_addr.s_addr = inet_addr(conf->passwd);
-
-  if (INADDR_NONE == VirtualHost.sin_addr.s_addr)
-    VirtualHost.sin_addr.s_addr = INADDR_ANY;
+  VirtualHost.sin_addr.s_addr = addr.s_addr;
 }  
 
 /*
@@ -1453,17 +1444,13 @@ void init_virtual_host(const struct ConfItem* conf)
  * matches the server's name) and its primary IP#.  Hostname is stored
  * in the client structure passed as a pointer.
  */
-int init_server_identity()
+void init_server_identity(void)
 {
-  struct ConfItem* conf = find_me();
-
-  if (!conf || EmptyString(conf->host))
-    return 0;
-
-  ircd_strncpy(me.name, conf->host, HOSTLEN);
+  const struct LocalConf* conf = conf_get_local();
+  assert(0 != conf);
 
-  init_virtual_host(conf);
-  return 1;
+  ircd_strncpy(me.name, conf->name, HOSTLEN);
+  SetYXXServerName(&me, conf->numeric);
 }
 
 
index 8385689d7fdd3513ed23d6b83ec77384f133ecc6..da60842be84dc62f7aefc8f93cd078ab0232d160 100644 (file)
@@ -472,16 +472,6 @@ const struct LocalConf* conf_get_local(void)
   return &localConf;
 }
 
-struct ConfItem* find_me(void)
-{
-  struct ConfItem* aconf;
-  for (aconf = GlobalConfList; aconf; aconf = aconf->next) {
-    if (aconf->status & CONF_ME)
-      break;
-  }
-  return aconf;
-}
-
 /*
  * attach_confs_byname
  *
@@ -717,15 +707,48 @@ void conf_add_listener(const char* const* fields, int count)
   add_listener(atoi(fields[4]), fields[2], fields[1], is_server, is_hidden);
 }
 
+void conf_add_local(const char* const* fields, int count)
+{
+  if (count < 6 || EmptyString(fields[1]) || EmptyString(fields[5])) {
+    ircd_log(L_CRIT, "Your M: line must have 6 fields!\n");
+    return;
+  }
+  /*
+   * these two can only be set the first time
+   */
+  if (0 == localConf.name) {
+    if (string_is_hostname(fields[1]))
+      DupString(localConf.name, fields[1]);
+  }
+  if (0 == localConf.numeric) {
+    localConf.numeric = atoi(fields[5]);
+    if (0 == localConf.numeric)
+      ircd_log(L_WARNING, "Your M: line must have a Numeric value greater than 0\n");
+  }
+  /*
+   * these two can be changed while the server is running
+   */
+  if (string_is_address(fields[2])) {
+    if (INADDR_NONE == (localConf.vhost_address.s_addr = inet_addr(fields[2])))
+      localConf.vhost_address.s_addr = INADDR_ANY;
+  }
+  MyFree(localConf.description);
+  DupString(localConf.description, fields[3]);
+  /*
+   * XXX - shouldn't be setting these directly here
+   */
+  ircd_strncpy(me.info, fields[3], REALLEN);
+  set_virtual_host(localConf.vhost_address);
+}
+
 void conf_add_admin(const char* const* fields, int count)
 {
   /*
    * if you have one, it MUST have 3 lines
    */
   if (count < 4) {
-    Debug((DEBUG_FATAL, "Your A: line must have 4 fields!\n"));
     ircd_log(L_CRIT, "Your A: line must have 4 fields!\n");
-    exit(-1);
+    return;
   }
   MyFree(localConf.location1);
   DupString(localConf.location1, fields[1]);
@@ -1040,8 +1063,9 @@ int read_configuration_file(void)
       /* Me. Host field is name used for this host */
       /* and port number is the number of the port */
     case 'M':
-    case 'm':
-      aconf->status = CONF_ME;
+    case 'm':        /* CONF_ME */
+      conf_add_local(field_vector, field_count);
+      aconf->status = CONF_ILLEGAL;
       break;
     case 'O':
       aconf->status = CONF_OPERATOR;
@@ -1090,20 +1114,9 @@ int read_configuration_file(void)
     if (field_count > 4 && !EmptyString(field_vector[4]))
         aconf->port = atoi(field_vector[4]); 
 
-    if (field_count > 5 && !EmptyString(field_vector[5])) {
-      int n = atoi(field_vector[5]);
-      if (CONF_ME == (aconf->status & CONF_ME))
-        SetYXXServerName(&me, n);        /* Our Numeric Nick */
-      else
-        aconf->confClass = find_class(n);
-    }
-    else if (CONF_ME == (aconf->status & CONF_ME)) {
-      Debug((DEBUG_FATAL, "Your M: line must have the Numeric, "
-             "assigned to you by routing-com!\n"));
-      ircd_log(L_WARNING, "Your M: line must have the Numeric, "
-              "assigned to you by routing-com!\n");
-      exit(-1);
-    }
+    if (field_count > 5 && !EmptyString(field_vector[5]))
+      aconf->confClass = find_class(atoi(field_vector[5]));
+
     /*
      * Associate each conf line with a class by using a pointer
      * to the correct class record. -avalon
@@ -1158,17 +1171,6 @@ int read_configuration_file(void)
         continue;
       lookup_confhost(aconf);
     }
-    /*
-     * Own port and name cannot be changed after the startup.
-     * (or could be allowed, but only if all links are closed first).
-     * Configuration info does not override the name and port
-     * if previously defined. Note, that "info"-field can be
-     * changed by "/rehash".
-     */
-    if (aconf->status == CONF_ME) {
-      ircd_strncpy(me.info, aconf->name, REALLEN);
-    }
-    
     if (aconf->status == CONF_IPKILL) {
       /* 
        * Here we use the same kludge as in listener.c to parse
@@ -1365,6 +1367,9 @@ int init_conf(void)
      * XXX - should any of these abort the server?
      * TODO: add warning messages
      */
+    if (0 == localConf.name || 0 == localConf.numeric)
+      return 0;
+
     if (0 == localConf.location1)
       DupString(localConf.location1, "");
     if (0 == localConf.location2)