Fix setting of FLAG_DOID and buglet from last commit.
authorMichael Poole <mdpoole@troilus.org>
Thu, 6 Oct 2005 00:37:31 +0000 (00:37 +0000)
committerMichael Poole <mdpoole@troilus.org>
Thu, 6 Oct 2005 00:37:31 +0000 (00:37 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1514 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/class.c
ircd/ircd_parser.y
ircd/s_conf.c

index 914677fb2966baca88b949253ee0cbb718789335..8baae4b9a2dc6956916de9950ba94543066438e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-10-05  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/class.c (do_find_class): Fix bug from previous commit.
+
+       * ircd/ircd_parser.y (clientblock): Allow setting Client port.
+
+       * ircd/s_conf.c (check_limit_and_attach): Merge into attach_iline.
+       (attach_iline): Only set FLAG_DOID when we are sure we will attach
+       this Client block to the client. [Credit: Jukka Ollila and others]
+
 2005-10-04  Michael Poole <mdpoole@troilus.org>
        [Based on a patch by Jukka Ollila]
 
index d4ddff9b95c4079e8687dacfd47c99fc28e2a152..216960534d2df75d48bd0e3e55173f4e7a40771a 100644 (file)
@@ -238,7 +238,7 @@ struct ConnectionClass* do_find_class(const char *name, int extras)
   struct ConnectionClass *cltmp;
 
   for (cltmp = connClassList; cltmp; cltmp = cltmp->next) {
-    if (!cltmp->valid || !extras)
+    if (!cltmp->valid && !extras)
       continue;
     if (!ircd_strcmp(ConClass(cltmp), name))
       return cltmp;
index 934f9231b917152a72790d4dd3ec409bf8db5d6e..c8a9048f4b5d5e4a541101298a158caf560091ae 100644 (file)
@@ -665,6 +665,7 @@ porthidden: HIDDEN '=' YES ';'
 clientblock: CLIENT
 {
   maxlinks = 65535;
+  port = 0;
 }
 '{' clientitems '}' ';'
 {
@@ -684,6 +685,7 @@ clientblock: CLIENT
       memcpy(&aconf->address.addr, &addr, sizeof(aconf->address.addr));
     else
       memset(&aconf->address.addr, 0, sizeof(aconf->address.addr));
+    aconf->address.port = port;
     aconf->addrbits = addrbits;
     aconf->name = ip;
     aconf->conn_class = c_class;
@@ -701,9 +703,10 @@ clientblock: CLIENT
   c_class = NULL;
   ip = NULL;
   pass = NULL;
+  port = 0;
 };
 clientitems: clientitem clientitems | clientitem;
-clientitem: clienthost | clientip | clientusername | clientclass | clientpass | clientmaxlinks;
+clientitem: clienthost | clientip | clientusername | clientclass | clientpass | clientmaxlinks | clientport;
 clienthost: HOST '=' QSTRING ';'
 {
   char *sep = strchr($3, '@');
@@ -752,6 +755,10 @@ clientmaxlinks: MAXLINKS '=' expr ';'
 {
   maxlinks = $3;
 };
+clientport: PORT '=' expr ';'
+{
+  port = $3;
+};
 
 killblock: KILL
 {
index cc425ca79c69e01f1a98578b84262a3b8fd16848..bd1704ddcb8f3afb4c61f3a67ff2bdfb6ab482d4 100644 (file)
@@ -345,22 +345,6 @@ void det_confs_butmask(struct Client* cptr, int mask)
   }
 }
 
-/** Check client limits and attach Client block.
- * If there are more connections from the IP than \a aconf->maximum
- * allows, return ACR_TOO_MANY_FROM_IP.  Otherwise, attach \a aconf to
- * \a cptr.
- * @param cptr Client getting \a aconf.
- * @param aconf Configuration item to attach.
- * @return Authorization check result.
- */
-static enum AuthorizationCheckResult
-check_limit_and_attach(struct Client* cptr, struct ConfItem* aconf)
-{
-  if (IPcheck_nr(cptr) > aconf->maximum)
-    return ACR_TOO_MANY_FROM_IP;
-  return attach_conf(cptr, aconf);
-}
-
 /** Find the first (best) Client block to attach.
  * @param cptr Client for whom to check rules.
  * @return Authorization check result.
@@ -379,17 +363,18 @@ enum AuthorizationCheckResult attach_iline(struct Client* cptr)
      */
     if (aconf->address.port && aconf->address.port != cli_listener(cptr)->addr.port)
       continue;
-    if (aconf->username) {
-      SetFlag(cptr, FLAG_DOID);
-      if (match(aconf->username, cli_username(cptr)))
-        continue;
-    }
+    if (aconf->username && match(aconf->username, cli_username(cptr)))
+      continue;
     if (aconf->host && match(aconf->host, cli_sockhost(cptr)))
       continue;
     if ((aconf->addrbits >= 0)
         && !ipmask_check(&cli_ip(cptr), &aconf->address.addr, aconf->addrbits))
       continue;
-    return check_limit_and_attach(cptr, aconf);
+    if (IPcheck_nr(cptr) > aconf->maximum)
+      return ACR_TOO_MANY_FROM_IP;
+    if (aconf->username)
+      SetFlag(cptr, FLAG_DOID);
+    return attach_conf(cptr, aconf);
   }
   return ACR_NO_AUTHORIZATION;
 }