Add autoconnect option for Connect block.
authorMichael Poole <mdpoole@troilus.org>
Mon, 25 Apr 2005 03:35:54 +0000 (03:35 +0000)
committerMichael Poole <mdpoole@troilus.org>
Mon, 25 Apr 2005 03:35:54 +0000 (03:35 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1383 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
doc/example.conf
include/s_conf.h
ircd/ircd.c
ircd/ircd_lexer.l
ircd/ircd_parser.y
ircd/m_invite.c
ircd/s_user.c

index bfe5003f6acefbdd3fc7d4728c504d3dc8b72c38..189441fb7f7358474c21a373eca898af8493c954 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2005-04-24  Michael Poole <mdpoole@troilus.org>
+
+       * doc/example.conf: Document new autoconnect field of Connect.
+
+       * include/s_conf.h: Add CONF_AUTOCONNECT and field for it.
+
+       * ircd/ircd.c (try_connections): Skip non-autoconnect servers.
+
+       * ircd/ircd_lexer.l: Recognize autoconnect token.
+
+       * ircd/ircd_parser.y: Add autoconnect= option to Connect block.
+
+       * ircd/m_invite.c (m_invite): Avoid sending channel timestamp to
+       user being invited.
+       (ms_invite): Likewise.
+
+       * ircd/s_user.c (register_user): Show class name rather than
+       pointer-as-integer.
+
 2005-04-24  Michael Poole <mdpoole@troilus.org>
 
        * ircd/ircd_parser.y: Rewrite so each error condition gets its own
index 930fe43c2946093461a95cac2f7bfa6a7e75220b..6407f1dead2488c692f0155e03133b77966481f7 100644 (file)
@@ -520,12 +520,15 @@ Kill
 #  class = "classname";
 #  maxhops = 2;
 #  hub = "*.eu.undernet.org";
+#  autoconnect = no;
 # };
 #
 # The "port" field defines the default port the server tries to connect
 # to if an operator uses /connect without specifying a port. This is also
 # the port used when the server attempts to auto-connect to the remote
 # server. (See Class blocks for more informationa about auto-connects).
+# You may tell ircu to not automatically connect to a server by adding
+# "autoconnect = no;"; the default is to autoconnect.
 #
 # The maxhops field causes an SQUIT if a hub tries to introduce
 # servers farther away than that; the element 'leaf;' is an alias for
index 8860e0b46a7ffd8b106b15fdd830a993e6f96a6d..0907f9b5343b9fc1a536c32d854c8d77f2ee6697 100644 (file)
@@ -32,6 +32,8 @@ struct Message;
 #define CONF_OPERATOR           0x0020     /**< ConfItem describes an Operator block */
 #define CONF_UWORLD             0x8000     /**< ConfItem describes a Uworld server */
 
+#define CONF_AUTOCONNECT        0x0001     /**< Autoconnect to a server */
+
 /** Indicates ConfItem types that count associated clients. */
 #define CONF_CLIENT_MASK        (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER)
 
@@ -63,6 +65,7 @@ struct ConfItem
   time_t hold;        /**< Earliest time to attempt an outbound
                          connect on this ConfItem. */
   int dns_pending;    /**< A dns request is pending. */
+  int flags;          /**< Additional modifiers for item. */
   int addrbits;       /**< Number of bits valid in ConfItem::address. */
   struct Privs privs; /**< Privileges for opers. */
   /** Used to detect if a privilege has been set by this ConfItem. */
index bf82c8cfbaf3cb3cb641e6fff33e3001eb4b950f..f2903003fdc476ef3068d3068aa80b51cc0b3bdd 100644 (file)
@@ -265,6 +265,7 @@ static void try_connections(struct Event* ev) {
      */
     if (!(aconf->status & CONF_SERVER)
         || aconf->address.port == 0
+        || !(aconf->flags & CONF_AUTOCONNECT)
         || ((ajupe = jupe_find(aconf->name)) && JupeIsActive(ajupe)))
       continue;
 
index 590e3bcfa8153c5b71dc0ab150a59252df0393e0..930d3e6c1eefdcdd1dacb9f2781a7eb95a9dd52c 100644 (file)
@@ -100,9 +100,11 @@ static struct lexer_token {
   TOKEN(PREPEND),
   TOKEN(USERMODE),
   TOKEN(FAST),
+  TOKEN(AUTOCONNECT),
 #undef TOKEN
   { "administrator", ADMIN },
   { "apass_opmode", TPRIV_APASS_OPMODE },
+  { "auto", AUTOCONNECT },
   { "b", BYTES },
   { "badchan", TPRIV_BADCHAN },
   { "chan_limit", TPRIV_CHAN_LIMIT },
index e02f4ba8a65bee44d3b1f68251f3ca9e79079f27..c7d726dca9747375740641dfbd9d6b9c8b4c458f 100644 (file)
@@ -68,7 +68,7 @@
 
   int yylex(void);
   /* Now all the globals we need :/... */
-  int tping, tconn, maxlinks, sendq, port, invert, stringno;
+  int tping, tconn, maxlinks, sendq, port, invert, stringno, flags;
   char *name, *pass, *host, *ip, *username, *origin, *hub_limit;
   char *stringlist[MAX_STRINGS];
   struct ConnectionClass *c_class;
@@ -155,6 +155,7 @@ static void parse_error(char *pattern,...) {
 %token IAUTH
 %token TIMEOUT
 %token FAST
+%token AUTOCONNECT
 /* and now a lot of privileges... */
 %token TPRIV_CHAN_LIMIT TPRIV_MODE_LCHAN TPRIV_DEOP_LCHAN TPRIV_WALK_LCHAN
 %token TPRIV_LOCAL_KILL TPRIV_REHASH TPRIV_RESTART TPRIV_DIE
@@ -395,6 +396,7 @@ classusermode: USERMODE '=' QSTRING ';'
 connectblock: CONNECT
 {
  maxlinks = 65535;
+ flags = CONF_AUTOCONNECT;
 } '{' connectitems '}'
 {
  struct ConfItem *aconf = NULL;
@@ -418,6 +420,7 @@ connectblock: CONNECT
    aconf->host = host;
    aconf->maximum = maxlinks;
    aconf->hub_limit = hub_limit;
+   aconf->flags = flags;
    lookup_confhost(aconf);
  }
  if (!aconf) {
@@ -429,12 +432,12 @@ connectblock: CONNECT
  }
  name = pass = host = origin = hub_limit = NULL;
  c_class = NULL;
- port = 0;
+ port = flags = 0;
 }';';
 connectitems: connectitem connectitems | connectitem;
 connectitem: connectname | connectpass | connectclass | connecthost
               | connectport | connectvhost | connectleaf | connecthub
-              | connecthublimit | connectmaxhops | error;
+              | connecthublimit | connectmaxhops | connectauto | error;
 connectname: NAME '=' QSTRING ';'
 {
  MyFree(name);
@@ -482,6 +485,8 @@ connectmaxhops: MAXHOPS '=' expr ';'
 {
   maxlinks = $3;
 };
+connectauto: AUTOCONNECT '=' YES ';' { flags |= CONF_AUTOCONNECT; }
+ | AUTOCONNECT '=' NO ';' { flags &= ~CONF_AUTOCONNECT; };
 
 uworldblock: UWORLD '{' uworlditems '}' ';';
 uworlditems: uworlditem uworlditems | uworlditem;
index e068e487e119487a655d8e7dac103ee9927652a9..478ff5b0ca016abfd24df5c07ba68540d53bc9c7 100644 (file)
@@ -177,24 +177,23 @@ int m_invite(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (cli_user(acptr)->away)
     send_reply(sptr, RPL_AWAY, cli_name(acptr), cli_user(acptr)->away);
 
-  if (MyConnect(acptr))
+  if (MyConnect(acptr)) {
     add_invite(acptr, chptr);
+    sendcmdto_one(sptr, CMD_INVITE, acptr, "%s %H", cli_name(acptr), chptr);
+  }
 
   if (!IsLocalChannel(chptr->chname) || MyConnect(acptr)) {
     if (feature_bool(FEAT_ANNOUNCE_INVITES)) {
       /* Announce to channel operators. */
       sendcmdto_channel_butserv_butone(&me, get_error_numeric(RPL_ISSUEDINVITE)->str,
-                                       NULL, chptr, sptr, SKIP_NONOPS, 
+                                       NULL, chptr, sptr, SKIP_NONOPS,
                                        "%H %C %C :%C has been invited by %C",
                                        chptr, acptr, sptr, acptr, sptr);
-      /* Announce to servers with channel operators, but skip acptr,
-       * since they will be notified below. */
-      sendcmdto_channel_servers_butone(sptr, NULL, TOK_INVITE, chptr, acptr, SKIP_NONOPS,
+      /* Announce to servers with channel operators. */
+      sendcmdto_channel_servers_butone(sptr, NULL, TOK_INVITE, chptr, NULL, SKIP_NONOPS,
                                        "%s %H %Tu", cli_name(acptr),
                                        chptr, chptr->creationtime);
     }
-    sendcmdto_one(sptr, CMD_INVITE, acptr, "%s %H %Tu", cli_name(acptr),
-                  chptr, chptr->creationtime);
   }
 
   return 0;
@@ -280,8 +279,10 @@ int ms_invite(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (is_silenced(sptr, acptr))
     return 0;
 
-  if (MyConnect(acptr))
+  if (MyConnect(acptr)) {
       add_invite(acptr, chptr);
+      sendcmdto_one(sptr, CMD_INVITE, acptr, "%s %H", cli_name(acptr), chptr);
+  }
 
   if (feature_bool(FEAT_ANNOUNCE_INVITES)) {
     /* Announce to channel operators. */
@@ -289,16 +290,12 @@ int ms_invite(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
                                      NULL, chptr, sptr, SKIP_NONOPS,
                                      "%H %C %C :%C has been invited by %C",
                                      chptr, acptr, sptr, acptr, sptr);
-    /* Announce to servers with channel operators, but skip acptr,
-     * since they will be notified below. */
-    sendcmdto_channel_servers_butone(sptr, NULL, TOK_INVITE, chptr, acptr, SKIP_NONOPS,
+    /* Announce to servers with channel operators. */
+    sendcmdto_channel_servers_butone(sptr, NULL, TOK_INVITE, chptr, NULL, SKIP_NONOPS,
                                      "%s %H %Tu", cli_name(acptr), chptr,
                                      chptr->creationtime);
   }
 
-  sendcmdto_one(sptr, CMD_INVITE, acptr,
-                "%s %H %Tu",
-                cli_name(acptr), chptr, chptr->creationtime);
   return 0;
 }
 
index af7b93b7e5bf8c320ec267faaef44fd8b378c041..f69acdf2b0e35741589035f2cdc140e1d55c00fd 100644 (file)
@@ -430,7 +430,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
         {
           last_too_many1 = CurrentTime;
           sendto_opmask_butone(0, SNO_TOOMANY, "Too many connections in "
-                               "class %i for %s.", get_client_class(sptr),
+                               "class %s for %s.", get_client_class(sptr),
                                get_client_name(sptr, SHOW_IP));
         }
         ++ServerStats->is_ref;