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 1386 by michael, Tue May 1 11:35:46 2012 UTC vs.
ircd-hybrid/trunk/src/s_serv.c (file contents), Revision 1877 by michael, Sat Apr 27 10:26:51 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  
109 <    if (target_p->info[0])
110 <      p = target_p->info;
116 <    else
117 <      p = "(Unknown Location)";
109 >    if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services)
110 >      continue;
111  
112      newMessageLine = MyMalloc(sizeof(MessageFileLine));
113  
114 <    /* Attempt to format the file in such a way it follows the usual links output
114 >    /*
115 >     * Attempt to format the file in such a way it follows the usual links output
116       * ie  "servername uplink :hops info"
117       * Mostly for aesthetic reasons - makes it look pretty in mIRC ;)
118       * - madmax
119       */
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);
120      snprintf(newMessageLine->line, sizeof(newMessageLine->line), "%s %s :1 %s",
121 <             target_p->name, me.name, p);
137 <    newMessageLine->next = NULL;
121 >             target_p->name, me.name, target_p->info);
122  
123      if (MessageFileptr->contentsOfFile)
124      {
# Line 148 | Line 132 | write_links_file(void* notused)
132        currentMessageLine = newMessageLine;
133      }
134  
135 <    snprintf(buff, sizeof(buff), "%s %s :1 %s\n", target_p->name, me.name, p);
135 >    snprintf(buff, sizeof(buff), "%s %s :1 %s\n",
136 >             target_p->name, me.name, target_p->info);
137      fputs(buff, file);
138    }
139  
# Line 176 | Line 161 | write_links_file(void* notused)
161   */
162   int
163   hunt_server(struct Client *client_p, struct Client *source_p, const char *command,
164 <            int server, int parc, char *parv[])
164 >            const int server, const int parc, char *parv[])
165   {
166    struct Client *target_p = NULL;
167    struct Client *target_tmp = NULL;
# Line 187 | Line 172 | hunt_server(struct Client *client_p, str
172    if (parc <= server || EmptyString(parv[server]))
173      return HUNTED_ISME;
174  
175 <  if (!strcmp(parv[server], me.id) || match(parv[server], me.name))
175 >  if (!strcmp(parv[server], me.id) || !match(parv[server], me.name))
176      return HUNTED_ISME;
177  
178    /* These are to pickup matches that would cause the following
# Line 208 | Line 193 | hunt_server(struct Client *client_p, str
193        target_p = NULL;
194  
195    collapse(parv[server]);
196 <  wilds = (strchr(parv[server], '?') || strchr(parv[server], '*'));
196 >  wilds = has_wildcards(parv[server]);
197  
198    /* Again, if there are no wild cards involved in the server
199     * name, use the hash lookup
# Line 230 | Line 215 | hunt_server(struct Client *client_p, str
215        {
216          target_tmp = ptr->data;
217  
218 <        if (match(parv[server], target_tmp->name))
218 >        if (!match(parv[server], target_tmp->name))
219          {
220            if (target_tmp->from == source_p->from && !MyConnect(target_tmp))
221              continue;
# Line 255 | Line 240 | hunt_server(struct Client *client_p, str
240      if (IsMe(target_p) || MyClient(target_p))
241        return HUNTED_ISME;
242  
243 <    if (!match(target_p->name, parv[server]))
243 >    if (match(target_p->name, parv[server]))
244        parv[server] = target_p->name;
245  
246      /* This is a little kludgy but should work... */
# Line 288 | Line 273 | hunt_server(struct Client *client_p, str
273   void
274   try_connections(void *unused)
275   {
276 <  dlink_node *ptr;
277 <  struct ConfItem *conf;
293 <  struct AccessItem *aconf;
294 <  struct ClassItem *cltmp;
276 >  dlink_node *ptr = NULL;
277 >  struct MaskItem *conf;
278    int confrq;
279  
280    /* TODO: change this to set active flag to 0 when added to event! --Habeeb */
# Line 301 | Line 284 | try_connections(void *unused)
284    DLINK_FOREACH(ptr, server_items.head)
285    {
286      conf = ptr->data;
287 <    aconf = map_to_conf(conf);
287 >
288 >    assert(conf->type == CONF_SERVER);
289  
290      /* Also when already connecting! (update holdtimes) --SRB
291       */
292 <    if (!(aconf->status & CONF_SERVER) || !aconf->port ||
309 <        !(IsConfAllowAutoConn(aconf)))
292 >    if (!conf->port ||!IsConfAllowAutoConn(conf))
293        continue;
294  
312    cltmp = map_to_conf(aconf->class_ptr);
295  
296      /* Skip this entry if the use of it is still on hold until
297       * future. Otherwise handle this entry (and set it on hold
# Line 317 | Line 299 | try_connections(void *unused)
299       * made one successfull connection... [this algorithm is
300       * a bit fuzzy... -- msa >;) ]
301       */
302 <    if (aconf->hold > CurrentTime)
302 >    if (conf->until > CurrentTime)
303        continue;
304  
305 <    if (cltmp == NULL)
305 >    if (conf->class == NULL)
306        confrq = DEFAULT_CONNECTFREQUENCY;
307      else
308      {
309 <      confrq = cltmp->con_freq;
309 >      confrq = conf->class->con_freq;
310        if (confrq < MIN_CONN_FREQ)
311          confrq = MIN_CONN_FREQ;
312      }
313  
314 <    aconf->hold = CurrentTime + confrq;
314 >    conf->until = CurrentTime + confrq;
315  
316      /* Found a CONNECT config with port specified, scan clients
317       * and see if this server is already connected?
# Line 337 | Line 319 | try_connections(void *unused)
319      if (hash_find_server(conf->name) != NULL)
320        continue;
321  
322 <    if (cltmp->curr_user_count < cltmp->max_total)
322 >    if (conf->class->ref_count < conf->class->max_total)
323      {
324        /* Go to the end of the list, if not already last */
325        if (ptr->next != NULL)
# Line 358 | Line 340 | try_connections(void *unused)
340         *   -- adrian
341         */
342        if (ConfigServerHide.hide_server_ips)
343 <        sendto_realops_flags(UMODE_ALL, L_ALL, "Connection to %s activated.",
343 >        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
344 >                             "Connection to %s activated.",
345                               conf->name);
346        else
347 <        sendto_realops_flags(UMODE_ALL, L_ALL, "Connection to %s[%s] activated.",
348 <                             conf->name, aconf->host);
347 >        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
348 >                             "Connection to %s[%s] activated.",
349 >                             conf->name, conf->host);
350  
351 <      serv_connect(aconf, NULL);
351 >      serv_connect(conf, NULL);
352        /* We connect only one at time... */
353        return;
354      }
# Line 396 | Line 380 | int
380   check_server(const char *name, struct Client *client_p)
381   {
382    dlink_node *ptr;
383 <  struct ConfItem *conf           = NULL;
384 <  struct ConfItem *server_conf    = NULL;
401 <  struct AccessItem *server_aconf = NULL;
402 <  struct AccessItem *aconf        = NULL;
383 >  struct MaskItem *conf        = NULL;
384 >  struct MaskItem *server_conf = NULL;
385    int error = -1;
386  
387    assert(client_p != NULL);
388  
407  if (client_p == NULL)
408    return(error);
409
410  if (strlen(name) > HOSTLEN)
411    return(-4);
412
389    /* loop through looking for all possible connect items that might work */
390    DLINK_FOREACH(ptr, server_items.head)
391    {
392      conf = ptr->data;
417    aconf = map_to_conf(conf);
393  
394 <    if (!match(name, conf->name))
394 >    if (match(name, conf->name))
395        continue;
396  
397      error = -3;
398  
399      /* XXX: Fix me for IPv6                    */
400      /* XXX sockhost is the IPv4 ip as a string */
401 <    if (match(aconf->host, client_p->host) ||
402 <        match(aconf->host, client_p->sockhost))
401 >    if (!match(conf->host, client_p->host) ||
402 >        !match(conf->host, client_p->sockhost))
403      {
404        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);
405  
406 <        if (IsConfEncrypted(aconf))
407 <        {
408 <          if (strcmp(aconf->passwd,
409 <              (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 <      }
406 >      if (!match_conf_password(client_p->localClient->passwd, conf))
407 >        return -2;
408 >
409 >      server_conf = conf;
410      }
411    }
412  
# Line 457 | Line 415 | check_server(const char *name, struct Cl
415  
416    attach_conf(client_p, server_conf);
417  
460  server_aconf = map_to_conf(server_conf);
418  
419 <  if (!IsConfTopicBurst(server_aconf))
463 <  {
464 <    ClearCap(client_p, CAP_TB);
465 <    ClearCap(client_p, CAP_TBURST);
466 <  }
467 <
468 <  if (aconf != NULL)
419 >  if (server_conf != NULL)
420    {
421      struct sockaddr_in *v4;
422   #ifdef IPV6
423      struct sockaddr_in6 *v6;
424   #endif
425 <    switch (aconf->aftype)
425 >    switch (server_conf->aftype)
426      {
427   #ifdef IPV6
428        case AF_INET6:
429 <        v6 = (struct sockaddr_in6 *)&aconf->ipnum;
429 >        v6 = (struct sockaddr_in6 *)&server_conf->addr;
430  
431          if (IN6_IS_ADDR_UNSPECIFIED(&v6->sin6_addr))
432 <          memcpy(&aconf->ipnum, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
432 >          memcpy(&server_conf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
433          break;
434   #endif
435        case AF_INET:
436 <        v4 = (struct sockaddr_in *)&aconf->ipnum;
436 >        v4 = (struct sockaddr_in *)&server_conf->addr;
437  
438          if (v4->sin_addr.s_addr == INADDR_NONE)
439 <          memcpy(&aconf->ipnum, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
439 >          memcpy(&server_conf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
440          break;
441      }
442    }
# Line 507 | Line 458 | add_capability(const char *capab_name, i
458   {
459    struct Capability *cap = MyMalloc(sizeof(*cap));
460  
461 <  DupString(cap->name, capab_name);
461 >  cap->name = xstrdup(capab_name);
462    cap->cap = cap_flag;
463    dlinkAdd(cap, &cap->node, &cap_list);
464  
# Line 555 | Line 506 | delete_capability(const char *capab_name
506   * output       - 0 if not found CAPAB otherwise
507   * side effects - none
508   */
509 < int
509 > unsigned int
510   find_capability(const char *capab)
511   {
512    const dlink_node *ptr = NULL;
# Line 574 | Line 525 | find_capability(const char *capab)
525   /* send_capabilities()
526   *
527   * inputs       - Client pointer to send to
577 *              - Pointer to AccessItem (for crypt)
528   *              - int flag of capabilities that this server can send
529   * output       - NONE
530   * side effects - send the CAPAB line to a server  -orabidoo
531   *
532   */
533   void
534 < send_capabilities(struct Client *client_p, struct AccessItem *aconf,
585 <                  int cap_can_send)
534 > send_capabilities(struct Client *client_p, int cap_can_send)
535   {
536    struct Capability *cap=NULL;
537    char msgbuf[IRCD_BUFSIZE];
# Line 598 | Line 547 | send_capabilities(struct Client *client_
547  
548      if (cap->cap & (cap_can_send|default_server_capabs))
549      {
550 <      tl = ircsprintf(t, "%s ", cap->name);
550 >      tl = sprintf(t, "%s ", cap->name);
551        t += tl;
552      }
553    }
# Line 630 | Line 579 | sendnick_TS(struct Client *client_p, str
579      ubuf[1] = '\0';
580    }
581  
633  /* XXX Both of these need to have a :me.name or :mySID!?!?! */
582    if (IsCapable(client_p, CAP_SVS))
583    {
584      if (HasID(target_p) && IsCapable(client_p, CAP_TS6))
585 <      sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %lu :%s",
585 >      sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %s :%s",
586                   target_p->servptr->id,
587                   target_p->name, target_p->hopcount + 1,
588                   (unsigned long) target_p->tsinfo,
589                   ubuf, target_p->username, target_p->host,
590                   (MyClient(target_p) && IsIPSpoof(target_p)) ?
591                   "0" : target_p->sockhost, target_p->id,
592 <                 (unsigned long)target_p->servicestamp, target_p->info);
592 >                 target_p->svid, target_p->info);
593      else
594 <      sendto_one(client_p, "NICK %s %d %lu %s %s %s %s %lu :%s",
594 >      sendto_one(client_p, "NICK %s %d %lu %s %s %s %s %s :%s",
595                   target_p->name, target_p->hopcount + 1,
596                   (unsigned long) target_p->tsinfo,
597                   ubuf, target_p->username, target_p->host,
598 <                 target_p->servptr->name, (unsigned long)target_p->servicestamp,
598 >                 target_p->servptr->name, target_p->svid,
599                   target_p->info);
600    }
601    else
# Line 668 | Line 616 | sendnick_TS(struct Client *client_p, str
616                   target_p->servptr->name, target_p->info);
617    }
618  
619 <  if (IsConfAwayBurst((struct AccessItem *)map_to_conf(client_p->localClient->confs.head->data)))
620 <    if (!EmptyString(target_p->away))
621 <      sendto_one(client_p, ":%s AWAY :%s", target_p->name,
674 <                 target_p->away);
619 >  if (target_p->away[0])
620 >    sendto_one(client_p, ":%s AWAY :%s", ID_or_name(target_p, client_p),
621 >               target_p->away);
622  
623   }
624  
# Line 689 | Line 636 | show_capabilities(struct Client *target_
636    char *t = msgbuf;
637    dlink_node *ptr;
638  
639 <  t += ircsprintf(msgbuf, "TS ");
639 >  t += sprintf(msgbuf, "TS ");
640  
641    DLINK_FOREACH(ptr, cap_list.head)
642    {
643      const struct Capability *cap = ptr->data;
644  
645      if (IsCapable(target_p, cap->cap))
646 <      t += ircsprintf(t, "%s ", cap->name);
646 >      t += sprintf(t, "%s ", cap->name);
647    }
648  
649    *(t - 1) = '\0';
# Line 729 | Line 676 | void
676   server_estab(struct Client *client_p)
677   {
678    struct Client *target_p;
679 <  struct ConfItem *conf;
733 <  struct AccessItem *aconf=NULL;
679 >  struct MaskItem *conf = NULL;
680    char *host;
681    const char *inpath;
682    static char inpath_ip[HOSTLEN * 2 + USERLEN + 6];
# Line 746 | Line 692 | server_estab(struct Client *client_p)
692    inpath = get_client_name(client_p, MASK_IP); /* "refresh" inpath with host */
693    host   = client_p->name;
694  
695 <  if ((conf = find_conf_name(&client_p->localClient->confs, host, SERVER_TYPE))
695 >  if ((conf = find_conf_name(&client_p->localClient->confs, host, CONF_SERVER))
696        == NULL)
697    {
698      /* This shouldn't happen, better tell the ops... -A1kmm */
699 <    sendto_realops_flags(UMODE_ALL, L_ALL, "Warning: Lost connect{} block "
699 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
700 >                         "Warning: Lost connect{} block "
701                           "for server %s(this shouldn't happen)!", host);
702      exit_client(client_p, &me, "Lost connect{} block!");
703      return;
# Line 776 | Line 723 | server_estab(struct Client *client_p)
723      }
724    }
725  
779  aconf = map_to_conf(conf);
780
726    if (IsUnknown(client_p))
727    {
728      /* jdc -- 1.  Use EmptyString(), not [0] index reference.
729 <     *        2.  Check aconf->spasswd, not aconf->passwd.
729 >     *        2.  Check conf->spasswd, not conf->passwd.
730       */
731 <    if (!EmptyString(aconf->spasswd))
731 >    if (!EmptyString(conf->spasswd))
732        sendto_one(client_p, "PASS %s TS %d %s",
733 <                 aconf->spasswd, TS_CURRENT, me.id);
733 >                 conf->spasswd, TS_CURRENT, me.id);
734  
735 <    /* Pass my info to the new server
791 <     *
792 <     * Pass on ZIP if supported
793 <     * Pass on TB if supported.
794 <     * - Dianora
795 <     */
796 <
797 <    send_capabilities(client_p, aconf,
798 <      (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
735 >    send_capabilities(client_p, 0);
736  
737      sendto_one(client_p, "SERVER %s 1 :%s%s",
738                 me.name, ConfigServerHide.hidden ? "(H) " : "", me.info);
# Line 809 | Line 746 | server_estab(struct Client *client_p)
746      hash_add_id(client_p);
747  
748    /* XXX Does this ever happen? I don't think so -db */
749 <  detach_conf(client_p, OPER_TYPE);
749 >  detach_conf(client_p, CONF_OPER);
750  
751    /* *WARNING*
752    **    In the following code in place of plain server's
# Line 851 | Line 788 | server_estab(struct Client *client_p)
788    /* fixing eob timings.. -gnp */
789    client_p->localClient->firsttime = CurrentTime;
790  
791 <  if (find_matching_name_conf(SERVICE_TYPE, client_p->name, NULL, NULL, 0))
791 >  if (find_matching_name_conf(CONF_SERVICE, client_p->name, NULL, NULL, 0))
792      AddFlag(client_p, FLAGS_SERVICE);
793  
794    /* Show the real host/IP to admins */
# Line 861 | Line 798 | server_estab(struct Client *client_p)
798      compression = SSL_get_current_compression(client_p->localClient->fd.ssl);
799      expansion   = SSL_get_current_expansion(client_p->localClient->fd.ssl);
800  
801 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
801 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
802                           "Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)",
803                           inpath_ip, ssl_get_cipher(client_p->localClient->fd.ssl),
804                           compression ? SSL_COMP_get_name(compression) : "NONE",
805                           expansion ? SSL_COMP_get_name(expansion) : "NONE",
806                           show_capabilities(client_p));
807      /* Now show the masked hostname/IP to opers */
808 <    sendto_realops_flags(UMODE_ALL, L_OPER,
808 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
809                           "Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)",
810                           inpath, ssl_get_cipher(client_p->localClient->fd.ssl),
811                           compression ? SSL_COMP_get_name(compression) : "NONE",
# Line 883 | Line 820 | server_estab(struct Client *client_p)
820    else
821   #endif
822    {
823 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
823 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
824                           "Link with %s established: (Capabilities: %s)",
825 <                         inpath_ip,show_capabilities(client_p));
825 >                         inpath_ip, show_capabilities(client_p));
826      /* Now show the masked hostname/IP to opers */
827 <    sendto_realops_flags(UMODE_ALL, L_OPER,
827 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
828                           "Link with %s established: (Capabilities: %s)",
829 <                         inpath,show_capabilities(client_p));
829 >                         inpath, show_capabilities(client_p));
830      ilog(LOG_TYPE_IRCD, "Link with %s established: (Capabilities: %s)",
831           inpath_ip, show_capabilities(client_p));
832    }
# Line 1014 | Line 951 | burst_all(struct Client *client_p)
951        burst_members(client_p, chptr);
952        send_channel_modes(client_p, chptr);
953  
954 <      if (IsCapable(client_p, CAP_TBURST) ||
1018 <          IsCapable(client_p, CAP_TB))
954 >      if (IsCapable(client_p, CAP_TBURST))
955          send_tb(client_p, chptr);
956      }
957    }
# Line 1047 | Line 983 | burst_all(struct Client *client_p)
983   *              - pointer to channel
984   * output       - NONE
985   * side effects - Called on a server burst when
986 < *                server is CAP_TB|CAP_TBURST capable
986 > *                server is CAP_TBURST capable
987   */
988   static void
989   send_tb(struct Client *client_p, struct Channel *chptr)
# Line 1066 | Line 1002 | send_tb(struct Client *client_p, struct
1002     * for further information   -Michael
1003     */
1004    if (chptr->topic_time != 0)
1005 <  {
1006 <    if (IsCapable(client_p, CAP_TBURST))
1007 <      sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1008 <                 me.name, (unsigned long)chptr->channelts, chptr->chname,
1009 <                 (unsigned long)chptr->topic_time,
1010 <                 chptr->topic_info,
1075 <                 chptr->topic);
1076 <    else if (IsCapable(client_p, CAP_TB))
1077 <    {
1078 <      if (ConfigChannel.burst_topicwho)
1079 <      {
1080 <        sendto_one(client_p, ":%s TB %s %lu %s :%s",
1081 <                   me.name, chptr->chname,
1082 <                   (unsigned long)chptr->topic_time,
1083 <                   chptr->topic_info, chptr->topic);
1084 <      }
1085 <      else
1086 <      {
1087 <        sendto_one(client_p, ":%s TB %s %lu :%s",
1088 <                   me.name, chptr->chname,
1089 <                   (unsigned long)chptr->topic_time,
1090 <                   chptr->topic);
1091 <      }
1092 <    }
1093 <  }
1005 >    sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1006 >               ID_or_name(&me, client_p),
1007 >               (unsigned long)chptr->channelts, chptr->chname,
1008 >               (unsigned long)chptr->topic_time,
1009 >               chptr->topic_info,
1010 >               chptr->topic);
1011   }
1012  
1013   /* burst_members()
# Line 1144 | Line 1061 | burst_members(struct Client *client_p, s
1061   * it suceeded or not, and 0 if it fails in here somewhere.
1062   */
1063   int
1064 < serv_connect(struct AccessItem *aconf, struct Client *by)
1064 > serv_connect(struct MaskItem *conf, struct Client *by)
1065   {
1149  struct ConfItem *conf;
1066    struct Client *client_p;
1067 <  char buf[HOSTIPLEN];
1067 >  char buf[HOSTIPLEN + 1];
1068  
1069    /* conversion structs */
1070    struct sockaddr_in *v4;
1071 <  /* Make sure aconf is useful */
1072 <  assert(aconf != NULL);
1157 <
1158 <  if(aconf == NULL)
1159 <    return (0);
1071 >  /* Make sure conf is useful */
1072 >  assert(conf != NULL);
1073  
1161  /* XXX should be passing struct ConfItem in the first place */
1162  conf = unmap_conf_item(aconf);
1074  
1075 <  /* log */
1165 <  getnameinfo((struct sockaddr *)&aconf->ipnum, aconf->ipnum.ss_len,
1075 >  getnameinfo((struct sockaddr *)&conf->addr, conf->addr.ss_len,
1076                buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
1077 <  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", aconf->user, aconf->host,
1077 >  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", conf->name, conf->host,
1078         buf);
1079  
1080    /* Still processing a DNS lookup? -> exit */
1081 <  if (aconf->dns_pending)
1081 >  if (conf->dns_pending)
1082    {
1083 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1083 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1084                           "Error connecting to %s: DNS lookup for connect{} in progress.",
1085                           conf->name);
1086      return (0);
1087    }
1088  
1089 <  if (aconf->dns_failed)
1089 >  if (conf->dns_failed)
1090    {
1091 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1091 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1092                           "Error connecting to %s: DNS lookup for connect{} failed.",
1093                           conf->name);
1094      return (0);
1095    }
1096  
1097    /* Make sure this server isn't already connected
1098 <   * Note: aconf should ALWAYS be a valid C: line
1098 >   * Note: conf should ALWAYS be a valid C: line
1099     */
1100    if ((client_p = hash_find_server(conf->name)) != NULL)
1101    {
1102 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1102 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1103                           "Server %s already present from %s",
1104                           conf->name, get_client_name(client_p, SHOW_IP));
1105 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1105 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1106                           "Server %s already present from %s",
1107                           conf->name, get_client_name(client_p, MASK_IP));
1108      if (by && IsClient(by) && !MyClient(by))
# Line 1207 | Line 1117 | serv_connect(struct AccessItem *aconf, s
1117  
1118    /* Copy in the server, hostname, fd */
1119    strlcpy(client_p->name, conf->name, sizeof(client_p->name));
1120 <  strlcpy(client_p->host, aconf->host, sizeof(client_p->host));
1120 >  strlcpy(client_p->host, conf->host, sizeof(client_p->host));
1121  
1122    /* We already converted the ip once, so lets use it - stu */
1123    strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost));
1124  
1125    /* create a socket for the server connection */
1126 <  if (comm_open(&client_p->localClient->fd, aconf->ipnum.ss.ss_family,
1126 >  if (comm_open(&client_p->localClient->fd, conf->addr.ss.ss_family,
1127                  SOCK_STREAM, 0, NULL) < 0)
1128    {
1129      /* Eek, failure to create the socket */
# Line 1230 | Line 1140 | serv_connect(struct AccessItem *aconf, s
1140    /* Attach config entries to client here rather than in
1141     * serv_connect_callback(). This to avoid null pointer references.
1142     */
1143 <  if (!attach_connect_block(client_p, conf->name, aconf->host))
1143 >  if (!attach_connect_block(client_p, conf->name, conf->host))
1144    {
1145 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1146 <                         "Host %s is not enabled for connecting:no C/N-line",
1145 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1146 >                         "Host %s is not enabled for connecting: no connect{} block",
1147                           conf->name);
1148      if (by && IsClient(by) && !MyClient(by))  
1149        sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.",
# Line 1259 | Line 1169 | serv_connect(struct AccessItem *aconf, s
1169    SetConnecting(client_p);
1170    dlinkAdd(client_p, &client_p->node, &global_client_list);
1171    /* from def_fam */
1172 <  client_p->localClient->aftype = aconf->aftype;
1172 >  client_p->localClient->aftype = conf->aftype;
1173  
1174    /* Now, initiate the connection */
1175    /* XXX assume that a non 0 type means a specific bind address
1176     * for this connect.
1177     */
1178 <  switch (aconf->aftype)
1178 >  switch (conf->aftype)
1179    {
1180      case AF_INET:
1181 <      v4 = (struct sockaddr_in*)&aconf->my_ipnum;
1181 >      v4 = (struct sockaddr_in*)&conf->bind;
1182        if (v4->sin_addr.s_addr != 0)
1183        {
1184          struct irc_ssaddr ipn;
1185          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1186          ipn.ss.ss_family = AF_INET;
1187          ipn.ss_port = 0;
1188 <        memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1189 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1188 >        memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr));
1189 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1190                           (struct sockaddr *)&ipn, ipn.ss_len,
1191 <                         serv_connect_callback, client_p, aconf->aftype,
1191 >                         serv_connect_callback, client_p, conf->aftype,
1192                           CONNECTTIMEOUT);
1193        }
1194        else if (ServerInfo.specific_ipv4_vhost)
# Line 1288 | Line 1198 | serv_connect(struct AccessItem *aconf, s
1198          ipn.ss.ss_family = AF_INET;
1199          ipn.ss_port = 0;
1200          memcpy(&ipn, &ServerInfo.ip, sizeof(struct irc_ssaddr));
1201 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1201 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1202                           (struct sockaddr *)&ipn, ipn.ss_len,
1203 <                         serv_connect_callback, client_p, aconf->aftype,
1203 >                         serv_connect_callback, client_p, conf->aftype,
1204                           CONNECTTIMEOUT);
1205        }
1206        else
1207 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1208 <                         NULL, 0, serv_connect_callback, client_p, aconf->aftype,
1207 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1208 >                         NULL, 0, serv_connect_callback, client_p, conf->aftype,
1209                           CONNECTTIMEOUT);
1210        break;
1211   #ifdef IPV6
# Line 1306 | Line 1216 | serv_connect(struct AccessItem *aconf, s
1216          struct sockaddr_in6 *v6conf;
1217  
1218          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1219 <        v6conf = (struct sockaddr_in6 *)&aconf->my_ipnum;
1219 >        v6conf = (struct sockaddr_in6 *)&conf->bind;
1220          v6 = (struct sockaddr_in6 *)&ipn;
1221  
1222          if (memcmp(&v6conf->sin6_addr, &v6->sin6_addr,
1223                     sizeof(struct in6_addr)) != 0)
1224          {
1225 <          memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1225 >          memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr));
1226            ipn.ss.ss_family = AF_INET6;
1227            ipn.ss_port = 0;
1228            comm_connect_tcp(&client_p->localClient->fd,
1229 <                           aconf->host, aconf->port,
1229 >                           conf->host, conf->port,
1230                             (struct sockaddr *)&ipn, ipn.ss_len,
1231                             serv_connect_callback, client_p,
1232 <                           aconf->aftype, CONNECTTIMEOUT);
1232 >                           conf->aftype, CONNECTTIMEOUT);
1233          }
1234          else if (ServerInfo.specific_ipv6_vhost)
1235          {
# Line 1327 | Line 1237 | serv_connect(struct AccessItem *aconf, s
1237            ipn.ss.ss_family = AF_INET6;
1238            ipn.ss_port = 0;
1239            comm_connect_tcp(&client_p->localClient->fd,
1240 <                           aconf->host, aconf->port,
1240 >                           conf->host, conf->port,
1241                             (struct sockaddr *)&ipn, ipn.ss_len,
1242                             serv_connect_callback, client_p,
1243 <                           aconf->aftype, CONNECTTIMEOUT);
1243 >                           conf->aftype, CONNECTTIMEOUT);
1244          }
1245          else
1246            comm_connect_tcp(&client_p->localClient->fd,
1247 <                           aconf->host, aconf->port,
1247 >                           conf->host, conf->port,
1248                             NULL, 0, serv_connect_callback, client_p,
1249 <                           aconf->aftype, CONNECTTIMEOUT);
1249 >                           conf->aftype, CONNECTTIMEOUT);
1250        }
1251   #endif
1252    }
# Line 1347 | Line 1257 | serv_connect(struct AccessItem *aconf, s
1257   static void
1258   finish_ssl_server_handshake(struct Client *client_p)
1259   {
1260 <  struct ConfItem *conf=NULL;
1351 <  struct AccessItem *aconf=NULL;
1260 >  struct MaskItem *conf = NULL;
1261  
1262    conf = find_conf_name(&client_p->localClient->confs,
1263 <                        client_p->name, SERVER_TYPE);
1263 >                        client_p->name, CONF_SERVER);
1264    if (conf == NULL)
1265    {
1266 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1266 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1267                           "Lost connect{} block for %s", get_client_name(client_p, HIDE_IP));
1268 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1268 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1269                           "Lost connect{} block for %s", get_client_name(client_p, MASK_IP));
1270  
1271      exit_client(client_p, &me, "Lost connect{} block");
1272      return;
1273    }
1274  
1366  aconf = map_to_conf(conf);
1367
1275    /* jdc -- Check and send spasswd, not passwd. */
1276 <  if (!EmptyString(aconf->spasswd))
1276 >  if (!EmptyString(conf->spasswd))
1277      sendto_one(client_p, "PASS %s TS %d %s",
1278 <               aconf->spasswd, TS_CURRENT, me.id);
1278 >               conf->spasswd, TS_CURRENT, me.id);
1279  
1280 <  send_capabilities(client_p, aconf,
1374 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1280 >  send_capabilities(client_p, 0);
1281  
1282    sendto_one(client_p, "SERVER %s 1 :%s%s",
1283               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 1382 | Line 1288 | finish_ssl_server_handshake(struct Clien
1288     */
1289    if (IsDead(client_p))
1290    {
1291 <      sendto_realops_flags(UMODE_ALL, L_ADMIN,
1291 >      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1292                             "%s[%s] went dead during handshake",
1293                             client_p->name,
1294                             client_p->host);
1295 <      sendto_realops_flags(UMODE_ALL, L_OPER,
1295 >      sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1296                             "%s went dead during handshake", client_p->name);
1297        return;
1298    }
# Line 1419 | Line 1325 | ssl_server_handshake(fde_t *fd, struct C
1325        default:
1326        {
1327          const char *sslerr = ERR_error_string(ERR_get_error(), NULL);
1328 <        sendto_realops_flags(UMODE_ALL, L_ALL,
1328 >        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1329                               "Error connecting to %s: %s", client_p->name,
1330                               sslerr ? sslerr : "unknown SSL error");
1331          exit_client(client_p, client_p, "Error during SSL handshake");
# Line 1432 | Line 1338 | ssl_server_handshake(fde_t *fd, struct C
1338   }
1339  
1340   static void
1341 < ssl_connect_init(struct Client *client_p, struct AccessItem *aconf, fde_t *fd)
1341 > ssl_connect_init(struct Client *client_p, struct MaskItem *conf, fde_t *fd)
1342   {
1343    if ((client_p->localClient->fd.ssl = SSL_new(ServerInfo.client_ctx)) == NULL)
1344    {
# Line 1445 | Line 1351 | ssl_connect_init(struct Client *client_p
1351  
1352    SSL_set_fd(fd->ssl, fd->fd);
1353  
1354 <  if (!EmptyString(aconf->cipher_list))
1355 <    SSL_set_cipher_list(client_p->localClient->fd.ssl, aconf->cipher_list);
1354 >  if (!EmptyString(conf->cipher_list))
1355 >    SSL_set_cipher_list(client_p->localClient->fd.ssl, conf->cipher_list);
1356  
1357    ssl_server_handshake(NULL, client_p);
1358   }
# Line 1464 | Line 1370 | static void
1370   serv_connect_callback(fde_t *fd, int status, void *data)
1371   {
1372    struct Client *client_p = data;
1373 <  struct ConfItem *conf=NULL;
1468 <  struct AccessItem *aconf=NULL;
1373 >  struct MaskItem *conf = NULL;
1374  
1375    /* First, make sure its a real client! */
1376    assert(client_p != NULL);
# Line 1481 | Line 1386 | serv_connect_callback(fde_t *fd, int sta
1386       * Admins get to see any IP, mere opers don't *sigh*
1387       */
1388       if (ConfigServerHide.hide_server_ips)
1389 <       sendto_realops_flags(UMODE_ALL, L_ADMIN,
1389 >       sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1390                              "Error connecting to %s: %s",
1391                              client_p->name, comm_errstr(status));
1392       else
1393 <       sendto_realops_flags(UMODE_ALL, L_ADMIN,
1393 >       sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1394                              "Error connecting to %s[%s]: %s", client_p->name,
1395                              client_p->host, comm_errstr(status));
1396  
1397 <     sendto_realops_flags(UMODE_ALL, L_OPER,
1397 >     sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1398                            "Error connecting to %s: %s",
1399                            client_p->name, comm_errstr(status));
1400  
# Line 1503 | Line 1408 | serv_connect_callback(fde_t *fd, int sta
1408    /* COMM_OK, so continue the connection procedure */
1409    /* Get the C/N lines */
1410    conf = find_conf_name(&client_p->localClient->confs,
1411 <                        client_p->name, SERVER_TYPE);
1411 >                        client_p->name, CONF_SERVER);
1412    if (conf == NULL)
1413    {
1414 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1414 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1415                           "Lost connect{} block for %s", get_client_name(client_p, HIDE_IP));
1416 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1416 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1417                           "Lost connect{} block for %s", get_client_name(client_p, MASK_IP));
1418  
1419      exit_client(client_p, &me, "Lost connect{} block");
1420      return;
1421    }
1422  
1518  aconf = map_to_conf(conf);
1423    /* Next, send the initial handshake */
1424    SetHandshake(client_p);
1425  
1426   #ifdef HAVE_LIBCRYPTO
1427 <  if (IsConfSSL(aconf))
1427 >  if (IsConfSSL(conf))
1428    {
1429 <    ssl_connect_init(client_p, aconf, fd);
1429 >    ssl_connect_init(client_p, conf, fd);
1430      return;
1431    }
1432   #endif
1433  
1434    /* jdc -- Check and send spasswd, not passwd. */
1435 <  if (!EmptyString(aconf->spasswd))
1435 >  if (!EmptyString(conf->spasswd))
1436      sendto_one(client_p, "PASS %s TS %d %s",
1437 <               aconf->spasswd, TS_CURRENT, me.id);
1437 >               conf->spasswd, TS_CURRENT, me.id);
1438  
1439 <  send_capabilities(client_p, aconf,
1536 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1439 >  send_capabilities(client_p, 0);
1440  
1441    sendto_one(client_p, "SERVER %s 1 :%s%s",
1442               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 1544 | Line 1447 | serv_connect_callback(fde_t *fd, int sta
1447     */
1448    if (IsDead(client_p))
1449    {
1450 <      sendto_realops_flags(UMODE_ALL, L_ADMIN,
1450 >      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1451                             "%s[%s] went dead during handshake",
1452                             client_p->name,
1453                             client_p->host);
1454 <      sendto_realops_flags(UMODE_ALL, L_OPER,
1454 >      sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1455                             "%s went dead during handshake", client_p->name);
1456        return;
1457    }
# Line 1569 | Line 1472 | find_servconn_in_progress(const char *na
1472      cptr = ptr->data;
1473  
1474      if (cptr && cptr->name[0])
1475 <      if (match(name, cptr->name))
1475 >      if (!match(name, cptr->name))
1476          return cptr;
1477    }
1478    

Diff Legend

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