ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/server.c
(Generate patch)

Comparing:
ircd-hybrid-8/src/s_serv.c (file contents), Revision 1383 by michael, Tue May 1 11:18:22 2012 UTC vs.
ircd-hybrid/trunk/src/s_serv.c (file contents), Revision 1793 by michael, Sun Mar 31 14:06:08 2013 UTC

# Line 36 | Line 36
36   #include "fdlist.h"
37   #include "hash.h"
38   #include "irc_string.h"
39 #include "sprintf_irc.h"
39   #include "ircd.h"
40   #include "ircd_defs.h"
41   #include "s_bsd.h"
# Line 75 | Line 74 | static void burst_members(struct Client
74   void
75   write_links_file(void* notused)
76   {
77 <  MessageFileLine *next_mptr = 0;
78 <  MessageFileLine *mptr = 0;
79 <  MessageFileLine *currentMessageLine = 0;
80 <  MessageFileLine *newMessageLine = 0;
81 <  MessageFile *MessageFileptr;
83 <  const char *p;
77 >  MessageFileLine *next_mptr = NULL;
78 >  MessageFileLine *mptr = NULL;
79 >  MessageFileLine *currentMessageLine = NULL;
80 >  MessageFileLine *newMessageLine = NULL;
81 >  MessageFile *MessageFileptr = &ConfigFileEntry.linksfile;
82    FILE *file;
83    char buff[512];
84    dlink_node *ptr;
85  
88  MessageFileptr = &ConfigFileEntry.linksfile;
89
86    if ((file = fopen(MessageFileptr->fileName, "w")) == NULL)
87      return;
88  
# Line 97 | Line 93 | write_links_file(void* notused)
93    }
94  
95    MessageFileptr->contentsOfFile = NULL;
100  currentMessageLine             = NULL;
96  
97    DLINK_FOREACH(ptr, global_serv_list.head)
98    {
# Line 108 | Line 103 | write_links_file(void* notused)
103        continue;
104  
105      /* skip hidden servers */
106 <    if (IsHidden(target_p) && !ConfigServerHide.disable_hidden)
106 >    if (IsHidden(target_p))
107        continue;
108  
114    if (target_p->info[0])
115      p = target_p->info;
116    else
117      p = "(Unknown Location)";
118
109      newMessageLine = MyMalloc(sizeof(MessageFileLine));
110  
111 <    /* Attempt to format the file in such a way it follows the usual links output
111 >    /*
112 >     * Attempt to format the file in such a way it follows the usual links output
113       * ie  "servername uplink :hops info"
114       * Mostly for aesthetic reasons - makes it look pretty in mIRC ;)
115       * - madmax
116       */
126
127    /*
128     * For now, check this ircsprintf wont overflow - it shouldnt on a
129     * default config but it is configurable..
130     * This should be changed to an snprintf at some point, but I'm wanting to
131     * know if this is a cause of a bug - cryogen
132     */
133    assert(strlen(target_p->name) + strlen(me.name) + 6 + strlen(p) <=
134            MESSAGELINELEN);
117      snprintf(newMessageLine->line, sizeof(newMessageLine->line), "%s %s :1 %s",
118 <             target_p->name, me.name, p);
137 <    newMessageLine->next = NULL;
118 >             target_p->name, me.name, target_p->info);
119  
120      if (MessageFileptr->contentsOfFile)
121      {
# Line 148 | Line 129 | write_links_file(void* notused)
129        currentMessageLine = newMessageLine;
130      }
131  
132 <    snprintf(buff, sizeof(buff), "%s %s :1 %s\n", target_p->name, me.name, p);
132 >    snprintf(buff, sizeof(buff), "%s %s :1 %s\n",
133 >             target_p->name, me.name, target_p->info);
134      fputs(buff, file);
135    }
136  
# Line 187 | Line 169 | hunt_server(struct Client *client_p, str
169    if (parc <= server || EmptyString(parv[server]))
170      return HUNTED_ISME;
171  
172 <  if (!strcmp(parv[server], me.id) || match(parv[server], me.name))
172 >  if (!strcmp(parv[server], me.id) || !match(parv[server], me.name))
173      return HUNTED_ISME;
174  
175    /* These are to pickup matches that would cause the following
# Line 208 | Line 190 | hunt_server(struct Client *client_p, str
190        target_p = NULL;
191  
192    collapse(parv[server]);
193 <  wilds = (strchr(parv[server], '?') || strchr(parv[server], '*'));
193 >  wilds = has_wildcards(parv[server]);
194  
195    /* Again, if there are no wild cards involved in the server
196     * name, use the hash lookup
# Line 230 | Line 212 | hunt_server(struct Client *client_p, str
212        {
213          target_tmp = ptr->data;
214  
215 <        if (match(parv[server], target_tmp->name))
215 >        if (!match(parv[server], target_tmp->name))
216          {
217            if (target_tmp->from == source_p->from && !MyConnect(target_tmp))
218              continue;
# Line 255 | Line 237 | hunt_server(struct Client *client_p, str
237      if (IsMe(target_p) || MyClient(target_p))
238        return HUNTED_ISME;
239  
240 <    if (!match(target_p->name, parv[server]))
240 >    if (match(target_p->name, parv[server]))
241        parv[server] = target_p->name;
242  
243      /* This is a little kludgy but should work... */
# Line 288 | Line 270 | hunt_server(struct Client *client_p, str
270   void
271   try_connections(void *unused)
272   {
273 <  dlink_node *ptr;
274 <  struct ConfItem *conf;
293 <  struct AccessItem *aconf;
294 <  struct ClassItem *cltmp;
273 >  dlink_node *ptr = NULL;
274 >  struct MaskItem *conf;
275    int confrq;
276  
277    /* TODO: change this to set active flag to 0 when added to event! --Habeeb */
# Line 301 | Line 281 | try_connections(void *unused)
281    DLINK_FOREACH(ptr, server_items.head)
282    {
283      conf = ptr->data;
284 <    aconf = map_to_conf(conf);
284 >
285 >    assert(conf->type == CONF_SERVER);
286  
287      /* Also when already connecting! (update holdtimes) --SRB
288       */
289 <    if (!(aconf->status & CONF_SERVER) || !aconf->port ||
309 <        !(IsConfAllowAutoConn(aconf)))
289 >    if (!conf->port ||!IsConfAllowAutoConn(conf))
290        continue;
291  
312    cltmp = map_to_conf(aconf->class_ptr);
292  
293      /* Skip this entry if the use of it is still on hold until
294       * future. Otherwise handle this entry (and set it on hold
# Line 317 | Line 296 | try_connections(void *unused)
296       * made one successfull connection... [this algorithm is
297       * a bit fuzzy... -- msa >;) ]
298       */
299 <    if (aconf->hold > CurrentTime)
299 >    if (conf->until > CurrentTime)
300        continue;
301  
302 <    if (cltmp == NULL)
302 >    if (conf->class == NULL)
303        confrq = DEFAULT_CONNECTFREQUENCY;
304      else
305      {
306 <      confrq = cltmp->con_freq;
306 >      confrq = conf->class->con_freq;
307        if (confrq < MIN_CONN_FREQ)
308          confrq = MIN_CONN_FREQ;
309      }
310  
311 <    aconf->hold = CurrentTime + confrq;
311 >    conf->until = CurrentTime + confrq;
312  
313      /* Found a CONNECT config with port specified, scan clients
314       * and see if this server is already connected?
# Line 337 | Line 316 | try_connections(void *unused)
316      if (hash_find_server(conf->name) != NULL)
317        continue;
318  
319 <    if (cltmp->curr_user_count < cltmp->max_total)
319 >    if (conf->class->ref_count < conf->class->max_total)
320      {
321        /* Go to the end of the list, if not already last */
322        if (ptr->next != NULL)
# Line 358 | Line 337 | try_connections(void *unused)
337         *   -- adrian
338         */
339        if (ConfigServerHide.hide_server_ips)
340 <        sendto_realops_flags(UMODE_ALL, L_ALL, "Connection to %s activated.",
340 >        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
341 >                             "Connection to %s activated.",
342                               conf->name);
343        else
344 <        sendto_realops_flags(UMODE_ALL, L_ALL, "Connection to %s[%s] activated.",
345 <                             conf->name, aconf->host);
344 >        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
345 >                             "Connection to %s[%s] activated.",
346 >                             conf->name, conf->host);
347  
348 <      serv_connect(aconf, NULL);
348 >      serv_connect(conf, NULL);
349        /* We connect only one at time... */
350        return;
351      }
# Line 396 | Line 377 | int
377   check_server(const char *name, struct Client *client_p)
378   {
379    dlink_node *ptr;
380 <  struct ConfItem *conf           = NULL;
381 <  struct ConfItem *server_conf    = NULL;
401 <  struct AccessItem *server_aconf = NULL;
402 <  struct AccessItem *aconf        = NULL;
380 >  struct MaskItem *conf        = NULL;
381 >  struct MaskItem *server_conf = NULL;
382    int error = -1;
383  
384    assert(client_p != NULL);
385  
407  if (client_p == NULL)
408    return(error);
409
410  if (strlen(name) > HOSTLEN)
411    return(-4);
412
386    /* loop through looking for all possible connect items that might work */
387    DLINK_FOREACH(ptr, server_items.head)
388    {
389      conf = ptr->data;
417    aconf = map_to_conf(conf);
390  
391 <    if (!match(name, conf->name))
391 >    if (match(name, conf->name))
392        continue;
393  
394      error = -3;
395  
396      /* XXX: Fix me for IPv6                    */
397      /* XXX sockhost is the IPv4 ip as a string */
398 <    if (match(aconf->host, client_p->host) ||
399 <        match(aconf->host, client_p->sockhost))
398 >    if (!match(conf->host, client_p->host) ||
399 >        !match(conf->host, client_p->sockhost))
400      {
401        error = -2;
430      {
431        /* A NULL password is as good as a bad one */
432        if (EmptyString(client_p->localClient->passwd))
433          return(-2);
434
435        /* code in s_conf.c should not have allowed this to be NULL */
436        if (aconf->passwd == NULL)
437          return(-2);
402  
403 <        if (IsConfEncrypted(aconf))
404 <        {
405 <          if (strcmp(aconf->passwd,
406 <              (const char *)crypt(client_p->localClient->passwd,
443 <                                  aconf->passwd)) == 0)
444 <            server_conf = conf;
445 <        }
446 <        else
447 <        {
448 <          if (strcmp(aconf->passwd, client_p->localClient->passwd) == 0)
449 <            server_conf = conf;
450 <        }
451 <      }
403 >      if (!match_conf_password(client_p->localClient->passwd, conf))
404 >        return -2;
405 >
406 >      server_conf = conf;
407      }
408    }
409  
# Line 457 | Line 412 | check_server(const char *name, struct Cl
412  
413    attach_conf(client_p, server_conf);
414  
460  server_aconf = map_to_conf(server_conf);
415  
416 <  if (!IsConfTopicBurst(server_aconf))
463 <  {
464 <    ClearCap(client_p, CAP_TB);
465 <    ClearCap(client_p, CAP_TBURST);
466 <  }
467 <
468 <  if (aconf != NULL)
416 >  if (server_conf != NULL)
417    {
418      struct sockaddr_in *v4;
419   #ifdef IPV6
420      struct sockaddr_in6 *v6;
421   #endif
422 <    switch (aconf->aftype)
422 >    switch (server_conf->aftype)
423      {
424   #ifdef IPV6
425        case AF_INET6:
426 <        v6 = (struct sockaddr_in6 *)&aconf->ipnum;
426 >        v6 = (struct sockaddr_in6 *)&server_conf->addr;
427  
428          if (IN6_IS_ADDR_UNSPECIFIED(&v6->sin6_addr))
429 <          memcpy(&aconf->ipnum, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
429 >          memcpy(&server_conf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
430          break;
431   #endif
432        case AF_INET:
433 <        v4 = (struct sockaddr_in *)&aconf->ipnum;
433 >        v4 = (struct sockaddr_in *)&server_conf->addr;
434  
435          if (v4->sin_addr.s_addr == INADDR_NONE)
436 <          memcpy(&aconf->ipnum, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
436 >          memcpy(&server_conf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
437          break;
438      }
439    }
# Line 507 | Line 455 | add_capability(const char *capab_name, i
455   {
456    struct Capability *cap = MyMalloc(sizeof(*cap));
457  
458 <  DupString(cap->name, capab_name);
458 >  cap->name = xstrdup(capab_name);
459    cap->cap = cap_flag;
460    dlinkAdd(cap, &cap->node, &cap_list);
461  
# Line 574 | Line 522 | find_capability(const char *capab)
522   /* send_capabilities()
523   *
524   * inputs       - Client pointer to send to
577 *              - Pointer to AccessItem (for crypt)
525   *              - int flag of capabilities that this server can send
526   * output       - NONE
527   * side effects - send the CAPAB line to a server  -orabidoo
528   *
529   */
530   void
531 < send_capabilities(struct Client *client_p, struct AccessItem *aconf,
585 <                  int cap_can_send)
531 > send_capabilities(struct Client *client_p, int cap_can_send)
532   {
533    struct Capability *cap=NULL;
534    char msgbuf[IRCD_BUFSIZE];
# Line 598 | Line 544 | send_capabilities(struct Client *client_
544  
545      if (cap->cap & (cap_can_send|default_server_capabs))
546      {
547 <      tl = ircsprintf(t, "%s ", cap->name);
547 >      tl = sprintf(t, "%s ", cap->name);
548        t += tl;
549      }
550    }
# Line 630 | Line 576 | sendnick_TS(struct Client *client_p, str
576      ubuf[1] = '\0';
577    }
578  
633  /* XXX Both of these need to have a :me.name or :mySID!?!?! */
579    if (IsCapable(client_p, CAP_SVS))
580    {
581      if (HasID(target_p) && IsCapable(client_p, CAP_TS6))
582 <      sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %lu :%s",
582 >      sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %s :%s",
583                   target_p->servptr->id,
584                   target_p->name, target_p->hopcount + 1,
585                   (unsigned long) target_p->tsinfo,
586                   ubuf, target_p->username, target_p->host,
587                   (MyClient(target_p) && IsIPSpoof(target_p)) ?
588                   "0" : target_p->sockhost, target_p->id,
589 <                 (unsigned long)target_p->servicestamp, target_p->info);
589 >                 target_p->svid, target_p->info);
590      else
591 <      sendto_one(client_p, "NICK %s %d %lu %s %s %s %s %lu :%s",
591 >      sendto_one(client_p, "NICK %s %d %lu %s %s %s %s %s :%s",
592                   target_p->name, target_p->hopcount + 1,
593                   (unsigned long) target_p->tsinfo,
594                   ubuf, target_p->username, target_p->host,
595 <                 target_p->servptr->name, (unsigned long)target_p->servicestamp,
595 >                 target_p->servptr->name, target_p->svid,
596                   target_p->info);
597    }
598    else
# Line 668 | Line 613 | sendnick_TS(struct Client *client_p, str
613                   target_p->servptr->name, target_p->info);
614    }
615  
616 <  if (IsConfAwayBurst((struct AccessItem *)map_to_conf(client_p->serv->sconf)))
617 <    if (!EmptyString(target_p->away))
618 <      sendto_one(client_p, ":%s AWAY :%s", target_p->name,
674 <                 target_p->away);
616 >  if (target_p->away[0])
617 >    sendto_one(client_p, ":%s AWAY :%s", ID_or_name(target_p, client_p),
618 >               target_p->away);
619  
620   }
621  
# Line 689 | Line 633 | show_capabilities(struct Client *target_
633    char *t = msgbuf;
634    dlink_node *ptr;
635  
636 <  t += ircsprintf(msgbuf, "TS ");
636 >  t += sprintf(msgbuf, "TS ");
637  
638    DLINK_FOREACH(ptr, cap_list.head)
639    {
640      const struct Capability *cap = ptr->data;
641  
642      if (IsCapable(target_p, cap->cap))
643 <      t += ircsprintf(t, "%s ", cap->name);
643 >      t += sprintf(t, "%s ", cap->name);
644    }
645  
646    *(t - 1) = '\0';
# Line 729 | Line 673 | void
673   server_estab(struct Client *client_p)
674   {
675    struct Client *target_p;
676 <  struct ConfItem *conf;
733 <  struct AccessItem *aconf=NULL;
676 >  struct MaskItem *conf = NULL;
677    char *host;
678    const char *inpath;
679    static char inpath_ip[HOSTLEN * 2 + USERLEN + 6];
# Line 746 | Line 689 | server_estab(struct Client *client_p)
689    inpath = get_client_name(client_p, MASK_IP); /* "refresh" inpath with host */
690    host   = client_p->name;
691  
692 <  if ((conf = find_conf_name(&client_p->localClient->confs, host, SERVER_TYPE))
692 >  if ((conf = find_conf_name(&client_p->localClient->confs, host, CONF_SERVER))
693        == NULL)
694    {
695      /* This shouldn't happen, better tell the ops... -A1kmm */
696 <    sendto_realops_flags(UMODE_ALL, L_ALL, "Warning: Lost connect{} block "
696 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
697 >                         "Warning: Lost connect{} block "
698                           "for server %s(this shouldn't happen)!", host);
699      exit_client(client_p, &me, "Lost connect{} block!");
700      return;
# Line 776 | Line 720 | server_estab(struct Client *client_p)
720      }
721    }
722  
779  aconf = map_to_conf(conf);
780
723    if (IsUnknown(client_p))
724    {
725      /* jdc -- 1.  Use EmptyString(), not [0] index reference.
726 <     *        2.  Check aconf->spasswd, not aconf->passwd.
726 >     *        2.  Check conf->spasswd, not conf->passwd.
727       */
728 <    if (!EmptyString(aconf->spasswd))
728 >    if (!EmptyString(conf->spasswd))
729        sendto_one(client_p, "PASS %s TS %d %s",
730 <                 aconf->spasswd, TS_CURRENT, me.id);
789 <
790 <    /* Pass my info to the new server
791 <     *
792 <     * Pass on ZIP if supported
793 <     * Pass on TB if supported.
794 <     * - Dianora
795 <     */
730 >                 conf->spasswd, TS_CURRENT, me.id);
731  
732 <    send_capabilities(client_p, aconf,
798 <      (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
732 >    send_capabilities(client_p, 0);
733  
734      sendto_one(client_p, "SERVER %s 1 :%s%s",
735                 me.name, ConfigServerHide.hidden ? "(H) " : "", me.info);
# Line 809 | Line 743 | server_estab(struct Client *client_p)
743      hash_add_id(client_p);
744  
745    /* XXX Does this ever happen? I don't think so -db */
746 <  detach_conf(client_p, OPER_TYPE);
746 >  detach_conf(client_p, CONF_OPER);
747  
748    /* *WARNING*
749    **    In the following code in place of plain server's
# Line 851 | Line 785 | server_estab(struct Client *client_p)
785    /* fixing eob timings.. -gnp */
786    client_p->localClient->firsttime = CurrentTime;
787  
788 <  if (find_matching_name_conf(SERVICE_TYPE, client_p->name, NULL, NULL, 0))
788 >  if (find_matching_name_conf(CONF_SERVICE, client_p->name, NULL, NULL, 0))
789      AddFlag(client_p, FLAGS_SERVICE);
790  
791    /* Show the real host/IP to admins */
# Line 861 | Line 795 | server_estab(struct Client *client_p)
795      compression = SSL_get_current_compression(client_p->localClient->fd.ssl);
796      expansion   = SSL_get_current_expansion(client_p->localClient->fd.ssl);
797  
798 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
798 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
799                           "Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)",
800                           inpath_ip, ssl_get_cipher(client_p->localClient->fd.ssl),
801                           compression ? SSL_COMP_get_name(compression) : "NONE",
802                           expansion ? SSL_COMP_get_name(expansion) : "NONE",
803                           show_capabilities(client_p));
804      /* Now show the masked hostname/IP to opers */
805 <    sendto_realops_flags(UMODE_ALL, L_OPER,
805 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
806                           "Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)",
807                           inpath, ssl_get_cipher(client_p->localClient->fd.ssl),
808                           compression ? SSL_COMP_get_name(compression) : "NONE",
# Line 883 | Line 817 | server_estab(struct Client *client_p)
817    else
818   #endif
819    {
820 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
820 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
821                           "Link with %s established: (Capabilities: %s)",
822 <                         inpath_ip,show_capabilities(client_p));
822 >                         inpath_ip, show_capabilities(client_p));
823      /* Now show the masked hostname/IP to opers */
824 <    sendto_realops_flags(UMODE_ALL, L_OPER,
824 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
825                           "Link with %s established: (Capabilities: %s)",
826 <                         inpath,show_capabilities(client_p));
826 >                         inpath, show_capabilities(client_p));
827      ilog(LOG_TYPE_IRCD, "Link with %s established: (Capabilities: %s)",
828           inpath_ip, show_capabilities(client_p));
829    }
830  
897  client_p->serv->sconf = conf;
898
831    fd_note(&client_p->localClient->fd, "Server: %s", client_p->name);
832  
833    /* Old sendto_serv_but_one() call removed because we now
# Line 1016 | Line 948 | burst_all(struct Client *client_p)
948        burst_members(client_p, chptr);
949        send_channel_modes(client_p, chptr);
950  
951 <      if (IsCapable(client_p, CAP_TBURST) ||
1020 <          IsCapable(client_p, CAP_TB))
951 >      if (IsCapable(client_p, CAP_TBURST))
952          send_tb(client_p, chptr);
953      }
954    }
# Line 1049 | Line 980 | burst_all(struct Client *client_p)
980   *              - pointer to channel
981   * output       - NONE
982   * side effects - Called on a server burst when
983 < *                server is CAP_TB|CAP_TBURST capable
983 > *                server is CAP_TBURST capable
984   */
985   static void
986   send_tb(struct Client *client_p, struct Channel *chptr)
# Line 1068 | Line 999 | send_tb(struct Client *client_p, struct
999     * for further information   -Michael
1000     */
1001    if (chptr->topic_time != 0)
1002 <  {
1003 <    if (IsCapable(client_p, CAP_TBURST))
1004 <      sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1005 <                 me.name, (unsigned long)chptr->channelts, chptr->chname,
1006 <                 (unsigned long)chptr->topic_time,
1007 <                 chptr->topic_info,
1077 <                 chptr->topic);
1078 <    else if (IsCapable(client_p, CAP_TB))
1079 <    {
1080 <      if (ConfigChannel.burst_topicwho)
1081 <      {
1082 <        sendto_one(client_p, ":%s TB %s %lu %s :%s",
1083 <                   me.name, chptr->chname,
1084 <                   (unsigned long)chptr->topic_time,
1085 <                   chptr->topic_info, chptr->topic);
1086 <      }
1087 <      else
1088 <      {
1089 <        sendto_one(client_p, ":%s TB %s %lu :%s",
1090 <                   me.name, chptr->chname,
1091 <                   (unsigned long)chptr->topic_time,
1092 <                   chptr->topic);
1093 <      }
1094 <    }
1095 <  }
1002 >    sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1003 >               ID_or_name(&me, client_p),
1004 >               (unsigned long)chptr->channelts, chptr->chname,
1005 >               (unsigned long)chptr->topic_time,
1006 >               chptr->topic_info,
1007 >               chptr->topic);
1008   }
1009  
1010   /* burst_members()
# Line 1146 | Line 1058 | burst_members(struct Client *client_p, s
1058   * it suceeded or not, and 0 if it fails in here somewhere.
1059   */
1060   int
1061 < serv_connect(struct AccessItem *aconf, struct Client *by)
1061 > serv_connect(struct MaskItem *conf, struct Client *by)
1062   {
1151  struct ConfItem *conf;
1063    struct Client *client_p;
1064 <  char buf[HOSTIPLEN];
1064 >  char buf[HOSTIPLEN + 1];
1065  
1066    /* conversion structs */
1067    struct sockaddr_in *v4;
1068 <  /* Make sure aconf is useful */
1069 <  assert(aconf != NULL);
1159 <
1160 <  if(aconf == NULL)
1161 <    return (0);
1068 >  /* Make sure conf is useful */
1069 >  assert(conf != NULL);
1070  
1163  /* XXX should be passing struct ConfItem in the first place */
1164  conf = unmap_conf_item(aconf);
1071  
1072 <  /* log */
1167 <  getnameinfo((struct sockaddr *)&aconf->ipnum, aconf->ipnum.ss_len,
1072 >  getnameinfo((struct sockaddr *)&conf->addr, conf->addr.ss_len,
1073                buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
1074 <  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", aconf->user, aconf->host,
1074 >  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", conf->name, conf->host,
1075         buf);
1076  
1077    /* Still processing a DNS lookup? -> exit */
1078 <  if (aconf->dns_pending)
1078 >  if (conf->dns_pending)
1079    {
1080 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1080 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1081                           "Error connecting to %s: DNS lookup for connect{} in progress.",
1082                           conf->name);
1083      return (0);
1084    }
1085  
1086 <  if (aconf->dns_failed)
1086 >  if (conf->dns_failed)
1087    {
1088 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1088 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1089                           "Error connecting to %s: DNS lookup for connect{} failed.",
1090                           conf->name);
1091      return (0);
1092    }
1093  
1094    /* Make sure this server isn't already connected
1095 <   * Note: aconf should ALWAYS be a valid C: line
1095 >   * Note: conf should ALWAYS be a valid C: line
1096     */
1097    if ((client_p = hash_find_server(conf->name)) != NULL)
1098    {
1099 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1099 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1100                           "Server %s already present from %s",
1101                           conf->name, get_client_name(client_p, SHOW_IP));
1102 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1102 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1103                           "Server %s already present from %s",
1104                           conf->name, get_client_name(client_p, MASK_IP));
1105      if (by && IsClient(by) && !MyClient(by))
# Line 1209 | Line 1114 | serv_connect(struct AccessItem *aconf, s
1114  
1115    /* Copy in the server, hostname, fd */
1116    strlcpy(client_p->name, conf->name, sizeof(client_p->name));
1117 <  strlcpy(client_p->host, aconf->host, sizeof(client_p->host));
1117 >  strlcpy(client_p->host, conf->host, sizeof(client_p->host));
1118  
1119    /* We already converted the ip once, so lets use it - stu */
1120    strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost));
1121  
1122    /* create a socket for the server connection */
1123 <  if (comm_open(&client_p->localClient->fd, aconf->ipnum.ss.ss_family,
1123 >  if (comm_open(&client_p->localClient->fd, conf->addr.ss.ss_family,
1124                  SOCK_STREAM, 0, NULL) < 0)
1125    {
1126      /* Eek, failure to create the socket */
# Line 1232 | Line 1137 | serv_connect(struct AccessItem *aconf, s
1137    /* Attach config entries to client here rather than in
1138     * serv_connect_callback(). This to avoid null pointer references.
1139     */
1140 <  if (!attach_connect_block(client_p, conf->name, aconf->host))
1140 >  if (!attach_connect_block(client_p, conf->name, conf->host))
1141    {
1142 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1143 <                         "Host %s is not enabled for connecting:no C/N-line",
1142 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1143 >                         "Host %s is not enabled for connecting: no connect{} block",
1144                           conf->name);
1145      if (by && IsClient(by) && !MyClient(by))  
1146        sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.",
# Line 1261 | Line 1166 | serv_connect(struct AccessItem *aconf, s
1166    SetConnecting(client_p);
1167    dlinkAdd(client_p, &client_p->node, &global_client_list);
1168    /* from def_fam */
1169 <  client_p->localClient->aftype = aconf->aftype;
1169 >  client_p->localClient->aftype = conf->aftype;
1170  
1171    /* Now, initiate the connection */
1172    /* XXX assume that a non 0 type means a specific bind address
1173     * for this connect.
1174     */
1175 <  switch (aconf->aftype)
1175 >  switch (conf->aftype)
1176    {
1177      case AF_INET:
1178 <      v4 = (struct sockaddr_in*)&aconf->my_ipnum;
1178 >      v4 = (struct sockaddr_in*)&conf->bind;
1179        if (v4->sin_addr.s_addr != 0)
1180        {
1181          struct irc_ssaddr ipn;
1182          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1183          ipn.ss.ss_family = AF_INET;
1184          ipn.ss_port = 0;
1185 <        memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1186 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1185 >        memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr));
1186 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1187                           (struct sockaddr *)&ipn, ipn.ss_len,
1188 <                         serv_connect_callback, client_p, aconf->aftype,
1188 >                         serv_connect_callback, client_p, conf->aftype,
1189                           CONNECTTIMEOUT);
1190        }
1191        else if (ServerInfo.specific_ipv4_vhost)
# Line 1290 | Line 1195 | serv_connect(struct AccessItem *aconf, s
1195          ipn.ss.ss_family = AF_INET;
1196          ipn.ss_port = 0;
1197          memcpy(&ipn, &ServerInfo.ip, sizeof(struct irc_ssaddr));
1198 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1198 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1199                           (struct sockaddr *)&ipn, ipn.ss_len,
1200 <                         serv_connect_callback, client_p, aconf->aftype,
1200 >                         serv_connect_callback, client_p, conf->aftype,
1201                           CONNECTTIMEOUT);
1202        }
1203        else
1204 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1205 <                         NULL, 0, serv_connect_callback, client_p, aconf->aftype,
1204 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1205 >                         NULL, 0, serv_connect_callback, client_p, conf->aftype,
1206                           CONNECTTIMEOUT);
1207        break;
1208   #ifdef IPV6
# Line 1308 | Line 1213 | serv_connect(struct AccessItem *aconf, s
1213          struct sockaddr_in6 *v6conf;
1214  
1215          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1216 <        v6conf = (struct sockaddr_in6 *)&aconf->my_ipnum;
1216 >        v6conf = (struct sockaddr_in6 *)&conf->bind;
1217          v6 = (struct sockaddr_in6 *)&ipn;
1218  
1219          if (memcmp(&v6conf->sin6_addr, &v6->sin6_addr,
1220                     sizeof(struct in6_addr)) != 0)
1221          {
1222 <          memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1222 >          memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr));
1223            ipn.ss.ss_family = AF_INET6;
1224            ipn.ss_port = 0;
1225            comm_connect_tcp(&client_p->localClient->fd,
1226 <                           aconf->host, aconf->port,
1226 >                           conf->host, conf->port,
1227                             (struct sockaddr *)&ipn, ipn.ss_len,
1228                             serv_connect_callback, client_p,
1229 <                           aconf->aftype, CONNECTTIMEOUT);
1229 >                           conf->aftype, CONNECTTIMEOUT);
1230          }
1231          else if (ServerInfo.specific_ipv6_vhost)
1232          {
# Line 1329 | Line 1234 | serv_connect(struct AccessItem *aconf, s
1234            ipn.ss.ss_family = AF_INET6;
1235            ipn.ss_port = 0;
1236            comm_connect_tcp(&client_p->localClient->fd,
1237 <                           aconf->host, aconf->port,
1237 >                           conf->host, conf->port,
1238                             (struct sockaddr *)&ipn, ipn.ss_len,
1239                             serv_connect_callback, client_p,
1240 <                           aconf->aftype, CONNECTTIMEOUT);
1240 >                           conf->aftype, CONNECTTIMEOUT);
1241          }
1242          else
1243            comm_connect_tcp(&client_p->localClient->fd,
1244 <                           aconf->host, aconf->port,
1244 >                           conf->host, conf->port,
1245                             NULL, 0, serv_connect_callback, client_p,
1246 <                           aconf->aftype, CONNECTTIMEOUT);
1246 >                           conf->aftype, CONNECTTIMEOUT);
1247        }
1248   #endif
1249    }
# Line 1349 | Line 1254 | serv_connect(struct AccessItem *aconf, s
1254   static void
1255   finish_ssl_server_handshake(struct Client *client_p)
1256   {
1257 <  struct ConfItem *conf=NULL;
1353 <  struct AccessItem *aconf=NULL;
1257 >  struct MaskItem *conf = NULL;
1258  
1259    conf = find_conf_name(&client_p->localClient->confs,
1260 <                        client_p->name, SERVER_TYPE);
1260 >                        client_p->name, CONF_SERVER);
1261    if (conf == NULL)
1262    {
1263 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1263 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1264                           "Lost connect{} block for %s", get_client_name(client_p, HIDE_IP));
1265 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1265 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1266                           "Lost connect{} block for %s", get_client_name(client_p, MASK_IP));
1267  
1268      exit_client(client_p, &me, "Lost connect{} block");
1269      return;
1270    }
1271  
1368  aconf = map_to_conf(conf);
1369
1272    /* jdc -- Check and send spasswd, not passwd. */
1273 <  if (!EmptyString(aconf->spasswd))
1273 >  if (!EmptyString(conf->spasswd))
1274      sendto_one(client_p, "PASS %s TS %d %s",
1275 <               aconf->spasswd, TS_CURRENT, me.id);
1275 >               conf->spasswd, TS_CURRENT, me.id);
1276  
1277 <  send_capabilities(client_p, aconf,
1376 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1277 >  send_capabilities(client_p, 0);
1278  
1279    sendto_one(client_p, "SERVER %s 1 :%s%s",
1280               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 1384 | Line 1285 | finish_ssl_server_handshake(struct Clien
1285     */
1286    if (IsDead(client_p))
1287    {
1288 <      sendto_realops_flags(UMODE_ALL, L_ADMIN,
1288 >      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1289                             "%s[%s] went dead during handshake",
1290                             client_p->name,
1291                             client_p->host);
1292 <      sendto_realops_flags(UMODE_ALL, L_OPER,
1292 >      sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1293                             "%s went dead during handshake", client_p->name);
1294        return;
1295    }
# Line 1421 | Line 1322 | ssl_server_handshake(fde_t *fd, struct C
1322        default:
1323        {
1324          const char *sslerr = ERR_error_string(ERR_get_error(), NULL);
1325 <        sendto_realops_flags(UMODE_ALL, L_ALL,
1325 >        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1326                               "Error connecting to %s: %s", client_p->name,
1327                               sslerr ? sslerr : "unknown SSL error");
1328          exit_client(client_p, client_p, "Error during SSL handshake");
# Line 1434 | Line 1335 | ssl_server_handshake(fde_t *fd, struct C
1335   }
1336  
1337   static void
1338 < ssl_connect_init(struct Client *client_p, struct AccessItem *aconf, fde_t *fd)
1338 > ssl_connect_init(struct Client *client_p, struct MaskItem *conf, fde_t *fd)
1339   {
1340    if ((client_p->localClient->fd.ssl = SSL_new(ServerInfo.client_ctx)) == NULL)
1341    {
# Line 1447 | Line 1348 | ssl_connect_init(struct Client *client_p
1348  
1349    SSL_set_fd(fd->ssl, fd->fd);
1350  
1351 <  if (!EmptyString(aconf->cipher_list))
1352 <    SSL_set_cipher_list(client_p->localClient->fd.ssl, aconf->cipher_list);
1351 >  if (!EmptyString(conf->cipher_list))
1352 >    SSL_set_cipher_list(client_p->localClient->fd.ssl, conf->cipher_list);
1353  
1354    ssl_server_handshake(NULL, client_p);
1355   }
# Line 1466 | Line 1367 | static void
1367   serv_connect_callback(fde_t *fd, int status, void *data)
1368   {
1369    struct Client *client_p = data;
1370 <  struct ConfItem *conf=NULL;
1470 <  struct AccessItem *aconf=NULL;
1370 >  struct MaskItem *conf = NULL;
1371  
1372    /* First, make sure its a real client! */
1373    assert(client_p != NULL);
# Line 1483 | Line 1383 | serv_connect_callback(fde_t *fd, int sta
1383       * Admins get to see any IP, mere opers don't *sigh*
1384       */
1385       if (ConfigServerHide.hide_server_ips)
1386 <       sendto_realops_flags(UMODE_ALL, L_ADMIN,
1386 >       sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1387                              "Error connecting to %s: %s",
1388                              client_p->name, comm_errstr(status));
1389       else
1390 <       sendto_realops_flags(UMODE_ALL, L_ADMIN,
1390 >       sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1391                              "Error connecting to %s[%s]: %s", client_p->name,
1392                              client_p->host, comm_errstr(status));
1393  
1394 <     sendto_realops_flags(UMODE_ALL, L_OPER,
1394 >     sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1395                            "Error connecting to %s: %s",
1396                            client_p->name, comm_errstr(status));
1397  
# Line 1505 | Line 1405 | serv_connect_callback(fde_t *fd, int sta
1405    /* COMM_OK, so continue the connection procedure */
1406    /* Get the C/N lines */
1407    conf = find_conf_name(&client_p->localClient->confs,
1408 <                        client_p->name, SERVER_TYPE);
1408 >                        client_p->name, CONF_SERVER);
1409    if (conf == NULL)
1410    {
1411 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1411 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1412                           "Lost connect{} block for %s", get_client_name(client_p, HIDE_IP));
1413 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1413 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1414                           "Lost connect{} block for %s", get_client_name(client_p, MASK_IP));
1415  
1416      exit_client(client_p, &me, "Lost connect{} block");
1417      return;
1418    }
1419  
1520  aconf = map_to_conf(conf);
1420    /* Next, send the initial handshake */
1421    SetHandshake(client_p);
1422  
1423   #ifdef HAVE_LIBCRYPTO
1424 <  if (IsConfSSL(aconf))
1424 >  if (IsConfSSL(conf))
1425    {
1426 <    ssl_connect_init(client_p, aconf, fd);
1426 >    ssl_connect_init(client_p, conf, fd);
1427      return;
1428    }
1429   #endif
1430  
1431    /* jdc -- Check and send spasswd, not passwd. */
1432 <  if (!EmptyString(aconf->spasswd))
1432 >  if (!EmptyString(conf->spasswd))
1433      sendto_one(client_p, "PASS %s TS %d %s",
1434 <               aconf->spasswd, TS_CURRENT, me.id);
1434 >               conf->spasswd, TS_CURRENT, me.id);
1435  
1436 <  send_capabilities(client_p, aconf,
1538 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1436 >  send_capabilities(client_p, 0);
1437  
1438    sendto_one(client_p, "SERVER %s 1 :%s%s",
1439               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 1546 | Line 1444 | serv_connect_callback(fde_t *fd, int sta
1444     */
1445    if (IsDead(client_p))
1446    {
1447 <      sendto_realops_flags(UMODE_ALL, L_ADMIN,
1447 >      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1448                             "%s[%s] went dead during handshake",
1449                             client_p->name,
1450                             client_p->host);
1451 <      sendto_realops_flags(UMODE_ALL, L_OPER,
1451 >      sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1452                             "%s went dead during handshake", client_p->name);
1453        return;
1454    }
# Line 1571 | Line 1469 | find_servconn_in_progress(const char *na
1469      cptr = ptr->data;
1470  
1471      if (cptr && cptr->name[0])
1472 <      if (match(name, cptr->name))
1472 >      if (!match(name, cptr->name))
1473          return cptr;
1474    }
1475    

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)