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

Comparing:
ircd-hybrid-8/src/s_serv.c (file contents), Revision 1377 by michael, Mon Apr 30 19:35:16 2012 UTC vs.
ircd-hybrid/trunk/src/s_serv.c (file contents), Revision 1972 by michael, Wed May 8 18:41:37 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  /* Now find all leaf or hub config items for this server */
461  DLINK_FOREACH(ptr, hub_items.head)
462  {
463    conf = ptr->data;
464
465    if (!match(name, conf->name))
466      continue;
467    attach_conf(client_p, conf);
468  }
469
470  DLINK_FOREACH(ptr, leaf_items.head)
471  {
472    conf = ptr->data;
473
474    if (!match(name, conf->name))
475      continue;
476    attach_conf(client_p, conf);
477  }
478
479  server_aconf = map_to_conf(server_conf);
480
481  if (!IsConfTopicBurst(server_aconf))
482  {
483    ClearCap(client_p, CAP_TB);
484    ClearCap(client_p, CAP_TBURST);
485  }
418  
419 <  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 526 | 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 574 | 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 593 | Line 525 | find_capability(const char *capab)
525   /* send_capabilities()
526   *
527   * inputs       - Client pointer to send to
596 *              - 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,
604 <                  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 617 | 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 649 | Line 579 | sendnick_TS(struct Client *client_p, str
579      ubuf[1] = '\0';
580    }
581  
652  /* 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 687 | 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->serv->sconf)))
620 <    if (!EmptyString(target_p->away))
621 <      sendto_one(client_p, ":%s AWAY :%s", target_p->name,
693 <                 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 708 | 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 748 | Line 676 | void
676   server_estab(struct Client *client_p)
677   {
678    struct Client *target_p;
679 <  struct ConfItem *conf;
752 <  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 765 | 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 795 | Line 723 | server_estab(struct Client *client_p)
723      }
724    }
725  
798  aconf = map_to_conf(conf);
799
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);
808 <
809 <    /* Pass my info to the new server
810 <     *
811 <     * Pass on ZIP if supported
812 <     * Pass on TB if supported.
813 <     * - Dianora
814 <     */
733 >                 conf->spasswd, TS_CURRENT, me.id);
734  
735 <    send_capabilities(client_p, aconf,
817 <      (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 828 | 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 870 | 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 880 | 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 902 | 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    }
833  
916  client_p->serv->sconf = conf;
917
834    fd_note(&client_p->localClient->fd, "Server: %s", client_p->name);
835  
836    /* Old sendto_serv_but_one() call removed because we now
# Line 982 | Line 898 | server_estab(struct Client *client_p)
898        sendto_one(client_p, ":%s SERVER %s %d :%s%s",
899                   target_p->servptr->name, target_p->name, target_p->hopcount+1,
900                   IsHidden(target_p) ? "(H) " : "", target_p->info);
901 +
902 +    if (HasFlag(target_p, FLAGS_EOB))
903 +      sendto_one(client_p, ":%s EOB", ID_or_name(client_p, target_p));
904    }
905  
906    server_burst(client_p);
# Line 1035 | Line 954 | burst_all(struct Client *client_p)
954        burst_members(client_p, chptr);
955        send_channel_modes(client_p, chptr);
956  
957 <      if (IsCapable(client_p, CAP_TBURST) ||
1039 <          IsCapable(client_p, CAP_TB))
957 >      if (IsCapable(client_p, CAP_TBURST))
958          send_tb(client_p, chptr);
959      }
960    }
# Line 1053 | Line 971 | burst_all(struct Client *client_p)
971      DelFlag(target_p, FLAGS_BURSTED);
972    }
973  
1056  /* We send the time we started the burst, and let the remote host determine an EOB time,
1057  ** as otherwise we end up sending a EOB of 0   Sending here means it gets sent last -- fl
1058  */
1059  /* Its simpler to just send EOB and use the time its been connected.. --fl_ */
974    if (IsCapable(client_p, CAP_EOB))
975      sendto_one(client_p, ":%s EOB", ID_or_name(&me, client_p));
976   }
# Line 1068 | Line 982 | burst_all(struct Client *client_p)
982   *              - pointer to channel
983   * output       - NONE
984   * side effects - Called on a server burst when
985 < *                server is CAP_TB|CAP_TBURST capable
985 > *                server is CAP_TBURST capable
986   */
987   static void
988   send_tb(struct Client *client_p, struct Channel *chptr)
# Line 1087 | Line 1001 | send_tb(struct Client *client_p, struct
1001     * for further information   -Michael
1002     */
1003    if (chptr->topic_time != 0)
1004 <  {
1005 <    if (IsCapable(client_p, CAP_TBURST))
1006 <      sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1007 <                 me.name, (unsigned long)chptr->channelts, chptr->chname,
1008 <                 (unsigned long)chptr->topic_time,
1009 <                 chptr->topic_info,
1096 <                 chptr->topic);
1097 <    else if (IsCapable(client_p, CAP_TB))
1098 <    {
1099 <      if (ConfigChannel.burst_topicwho)
1100 <      {
1101 <        sendto_one(client_p, ":%s TB %s %lu %s :%s",
1102 <                   me.name, chptr->chname,
1103 <                   (unsigned long)chptr->topic_time,
1104 <                   chptr->topic_info, chptr->topic);
1105 <      }
1106 <      else
1107 <      {
1108 <        sendto_one(client_p, ":%s TB %s %lu :%s",
1109 <                   me.name, chptr->chname,
1110 <                   (unsigned long)chptr->topic_time,
1111 <                   chptr->topic);
1112 <      }
1113 <    }
1114 <  }
1004 >    sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1005 >               ID_or_name(&me, client_p),
1006 >               (unsigned long)chptr->channelts, chptr->chname,
1007 >               (unsigned long)chptr->topic_time,
1008 >               chptr->topic_info,
1009 >               chptr->topic);
1010   }
1011  
1012   /* burst_members()
# Line 1165 | Line 1060 | burst_members(struct Client *client_p, s
1060   * it suceeded or not, and 0 if it fails in here somewhere.
1061   */
1062   int
1063 < serv_connect(struct AccessItem *aconf, struct Client *by)
1063 > serv_connect(struct MaskItem *conf, struct Client *by)
1064   {
1170  struct ConfItem *conf;
1065    struct Client *client_p;
1066 <  char buf[HOSTIPLEN];
1066 >  char buf[HOSTIPLEN + 1];
1067  
1068    /* conversion structs */
1069    struct sockaddr_in *v4;
1070 <  /* Make sure aconf is useful */
1071 <  assert(aconf != NULL);
1070 >  /* Make sure conf is useful */
1071 >  assert(conf != NULL);
1072  
1179  if(aconf == NULL)
1180    return (0);
1181
1182  /* XXX should be passing struct ConfItem in the first place */
1183  conf = unmap_conf_item(aconf);
1073  
1074 <  /* log */
1186 <  getnameinfo((struct sockaddr *)&aconf->ipnum, aconf->ipnum.ss_len,
1074 >  getnameinfo((struct sockaddr *)&conf->addr, conf->addr.ss_len,
1075                buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
1076 <  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", aconf->user, aconf->host,
1076 >  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", conf->name, conf->host,
1077         buf);
1078  
1079    /* Still processing a DNS lookup? -> exit */
1080 <  if (aconf->dns_pending)
1080 >  if (conf->dns_pending)
1081    {
1082 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1082 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1083                           "Error connecting to %s: DNS lookup for connect{} in progress.",
1084                           conf->name);
1085      return (0);
1086    }
1087  
1088 <  if (aconf->dns_failed)
1088 >  if (conf->dns_failed)
1089    {
1090 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1090 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1091                           "Error connecting to %s: DNS lookup for connect{} failed.",
1092                           conf->name);
1093      return (0);
1094    }
1095  
1096    /* Make sure this server isn't already connected
1097 <   * Note: aconf should ALWAYS be a valid C: line
1097 >   * Note: conf should ALWAYS be a valid C: line
1098     */
1099    if ((client_p = hash_find_server(conf->name)) != NULL)
1100    {
1101 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1101 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1102                           "Server %s already present from %s",
1103                           conf->name, get_client_name(client_p, SHOW_IP));
1104 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1104 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1105                           "Server %s already present from %s",
1106                           conf->name, get_client_name(client_p, MASK_IP));
1107      if (by && IsClient(by) && !MyClient(by))
# Line 1228 | Line 1116 | serv_connect(struct AccessItem *aconf, s
1116  
1117    /* Copy in the server, hostname, fd */
1118    strlcpy(client_p->name, conf->name, sizeof(client_p->name));
1119 <  strlcpy(client_p->host, aconf->host, sizeof(client_p->host));
1119 >  strlcpy(client_p->host, conf->host, sizeof(client_p->host));
1120  
1121    /* We already converted the ip once, so lets use it - stu */
1122    strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost));
1123  
1124    /* create a socket for the server connection */
1125 <  if (comm_open(&client_p->localClient->fd, aconf->ipnum.ss.ss_family,
1125 >  if (comm_open(&client_p->localClient->fd, conf->addr.ss.ss_family,
1126                  SOCK_STREAM, 0, NULL) < 0)
1127    {
1128      /* Eek, failure to create the socket */
# Line 1251 | Line 1139 | serv_connect(struct AccessItem *aconf, s
1139    /* Attach config entries to client here rather than in
1140     * serv_connect_callback(). This to avoid null pointer references.
1141     */
1142 <  if (!attach_connect_block(client_p, conf->name, aconf->host))
1142 >  if (!attach_connect_block(client_p, conf->name, conf->host))
1143    {
1144 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1145 <                         "Host %s is not enabled for connecting:no C/N-line",
1144 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1145 >                         "Host %s is not enabled for connecting: no connect{} block",
1146                           conf->name);
1147      if (by && IsClient(by) && !MyClient(by))  
1148        sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.",
# Line 1280 | Line 1168 | serv_connect(struct AccessItem *aconf, s
1168    SetConnecting(client_p);
1169    dlinkAdd(client_p, &client_p->node, &global_client_list);
1170    /* from def_fam */
1171 <  client_p->localClient->aftype = aconf->aftype;
1171 >  client_p->localClient->aftype = conf->aftype;
1172  
1173    /* Now, initiate the connection */
1174    /* XXX assume that a non 0 type means a specific bind address
1175     * for this connect.
1176     */
1177 <  switch (aconf->aftype)
1177 >  switch (conf->aftype)
1178    {
1179      case AF_INET:
1180 <      v4 = (struct sockaddr_in*)&aconf->my_ipnum;
1180 >      v4 = (struct sockaddr_in*)&conf->bind;
1181        if (v4->sin_addr.s_addr != 0)
1182        {
1183          struct irc_ssaddr ipn;
1184          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1185          ipn.ss.ss_family = AF_INET;
1186          ipn.ss_port = 0;
1187 <        memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1188 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1187 >        memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr));
1188 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1189                           (struct sockaddr *)&ipn, ipn.ss_len,
1190 <                         serv_connect_callback, client_p, aconf->aftype,
1190 >                         serv_connect_callback, client_p, conf->aftype,
1191                           CONNECTTIMEOUT);
1192        }
1193        else if (ServerInfo.specific_ipv4_vhost)
# Line 1309 | Line 1197 | serv_connect(struct AccessItem *aconf, s
1197          ipn.ss.ss_family = AF_INET;
1198          ipn.ss_port = 0;
1199          memcpy(&ipn, &ServerInfo.ip, sizeof(struct irc_ssaddr));
1200 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1200 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1201                           (struct sockaddr *)&ipn, ipn.ss_len,
1202 <                         serv_connect_callback, client_p, aconf->aftype,
1202 >                         serv_connect_callback, client_p, conf->aftype,
1203                           CONNECTTIMEOUT);
1204        }
1205        else
1206 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1207 <                         NULL, 0, serv_connect_callback, client_p, aconf->aftype,
1206 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1207 >                         NULL, 0, serv_connect_callback, client_p, conf->aftype,
1208                           CONNECTTIMEOUT);
1209        break;
1210   #ifdef IPV6
# Line 1327 | Line 1215 | serv_connect(struct AccessItem *aconf, s
1215          struct sockaddr_in6 *v6conf;
1216  
1217          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1218 <        v6conf = (struct sockaddr_in6 *)&aconf->my_ipnum;
1218 >        v6conf = (struct sockaddr_in6 *)&conf->bind;
1219          v6 = (struct sockaddr_in6 *)&ipn;
1220  
1221          if (memcmp(&v6conf->sin6_addr, &v6->sin6_addr,
1222                     sizeof(struct in6_addr)) != 0)
1223          {
1224 <          memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1224 >          memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr));
1225            ipn.ss.ss_family = AF_INET6;
1226            ipn.ss_port = 0;
1227            comm_connect_tcp(&client_p->localClient->fd,
1228 <                           aconf->host, aconf->port,
1228 >                           conf->host, conf->port,
1229                             (struct sockaddr *)&ipn, ipn.ss_len,
1230                             serv_connect_callback, client_p,
1231 <                           aconf->aftype, CONNECTTIMEOUT);
1231 >                           conf->aftype, CONNECTTIMEOUT);
1232          }
1233          else if (ServerInfo.specific_ipv6_vhost)
1234          {
# Line 1348 | Line 1236 | serv_connect(struct AccessItem *aconf, s
1236            ipn.ss.ss_family = AF_INET6;
1237            ipn.ss_port = 0;
1238            comm_connect_tcp(&client_p->localClient->fd,
1239 <                           aconf->host, aconf->port,
1239 >                           conf->host, conf->port,
1240                             (struct sockaddr *)&ipn, ipn.ss_len,
1241                             serv_connect_callback, client_p,
1242 <                           aconf->aftype, CONNECTTIMEOUT);
1242 >                           conf->aftype, CONNECTTIMEOUT);
1243          }
1244          else
1245            comm_connect_tcp(&client_p->localClient->fd,
1246 <                           aconf->host, aconf->port,
1246 >                           conf->host, conf->port,
1247                             NULL, 0, serv_connect_callback, client_p,
1248 <                           aconf->aftype, CONNECTTIMEOUT);
1248 >                           conf->aftype, CONNECTTIMEOUT);
1249        }
1250   #endif
1251    }
# Line 1368 | Line 1256 | serv_connect(struct AccessItem *aconf, s
1256   static void
1257   finish_ssl_server_handshake(struct Client *client_p)
1258   {
1259 <  struct ConfItem *conf=NULL;
1372 <  struct AccessItem *aconf=NULL;
1259 >  struct MaskItem *conf = NULL;
1260  
1261    conf = find_conf_name(&client_p->localClient->confs,
1262 <                        client_p->name, SERVER_TYPE);
1262 >                        client_p->name, CONF_SERVER);
1263    if (conf == NULL)
1264    {
1265 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1265 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1266                           "Lost connect{} block for %s", get_client_name(client_p, HIDE_IP));
1267 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1267 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1268                           "Lost connect{} block for %s", get_client_name(client_p, MASK_IP));
1269  
1270      exit_client(client_p, &me, "Lost connect{} block");
1271      return;
1272    }
1273  
1387  aconf = map_to_conf(conf);
1388
1274    /* jdc -- Check and send spasswd, not passwd. */
1275 <  if (!EmptyString(aconf->spasswd))
1275 >  if (!EmptyString(conf->spasswd))
1276      sendto_one(client_p, "PASS %s TS %d %s",
1277 <               aconf->spasswd, TS_CURRENT, me.id);
1277 >               conf->spasswd, TS_CURRENT, me.id);
1278  
1279 <  send_capabilities(client_p, aconf,
1395 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1279 >  send_capabilities(client_p, 0);
1280  
1281    sendto_one(client_p, "SERVER %s 1 :%s%s",
1282               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 1403 | Line 1287 | finish_ssl_server_handshake(struct Clien
1287     */
1288    if (IsDead(client_p))
1289    {
1290 <      sendto_realops_flags(UMODE_ALL, L_ADMIN,
1290 >      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1291                             "%s[%s] went dead during handshake",
1292                             client_p->name,
1293                             client_p->host);
1294 <      sendto_realops_flags(UMODE_ALL, L_OPER,
1294 >      sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1295                             "%s went dead during handshake", client_p->name);
1296        return;
1297    }
# Line 1440 | Line 1324 | ssl_server_handshake(fde_t *fd, struct C
1324        default:
1325        {
1326          const char *sslerr = ERR_error_string(ERR_get_error(), NULL);
1327 <        sendto_realops_flags(UMODE_ALL, L_ALL,
1327 >        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1328                               "Error connecting to %s: %s", client_p->name,
1329                               sslerr ? sslerr : "unknown SSL error");
1330          exit_client(client_p, client_p, "Error during SSL handshake");
# Line 1453 | Line 1337 | ssl_server_handshake(fde_t *fd, struct C
1337   }
1338  
1339   static void
1340 < ssl_connect_init(struct Client *client_p, struct AccessItem *aconf, fde_t *fd)
1340 > ssl_connect_init(struct Client *client_p, struct MaskItem *conf, fde_t *fd)
1341   {
1342    if ((client_p->localClient->fd.ssl = SSL_new(ServerInfo.client_ctx)) == NULL)
1343    {
# Line 1466 | Line 1350 | ssl_connect_init(struct Client *client_p
1350  
1351    SSL_set_fd(fd->ssl, fd->fd);
1352  
1353 <  if (!EmptyString(aconf->cipher_list))
1354 <    SSL_set_cipher_list(client_p->localClient->fd.ssl, aconf->cipher_list);
1353 >  if (!EmptyString(conf->cipher_list))
1354 >    SSL_set_cipher_list(client_p->localClient->fd.ssl, conf->cipher_list);
1355  
1356    ssl_server_handshake(NULL, client_p);
1357   }
# Line 1485 | Line 1369 | static void
1369   serv_connect_callback(fde_t *fd, int status, void *data)
1370   {
1371    struct Client *client_p = data;
1372 <  struct ConfItem *conf=NULL;
1489 <  struct AccessItem *aconf=NULL;
1372 >  struct MaskItem *conf = NULL;
1373  
1374    /* First, make sure its a real client! */
1375    assert(client_p != NULL);
# Line 1502 | Line 1385 | serv_connect_callback(fde_t *fd, int sta
1385       * Admins get to see any IP, mere opers don't *sigh*
1386       */
1387       if (ConfigServerHide.hide_server_ips)
1388 <       sendto_realops_flags(UMODE_ALL, L_ADMIN,
1388 >       sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1389                              "Error connecting to %s: %s",
1390                              client_p->name, comm_errstr(status));
1391       else
1392 <       sendto_realops_flags(UMODE_ALL, L_ADMIN,
1392 >       sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1393                              "Error connecting to %s[%s]: %s", client_p->name,
1394                              client_p->host, comm_errstr(status));
1395  
1396 <     sendto_realops_flags(UMODE_ALL, L_OPER,
1396 >     sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1397                            "Error connecting to %s: %s",
1398                            client_p->name, comm_errstr(status));
1399  
# Line 1524 | Line 1407 | serv_connect_callback(fde_t *fd, int sta
1407    /* COMM_OK, so continue the connection procedure */
1408    /* Get the C/N lines */
1409    conf = find_conf_name(&client_p->localClient->confs,
1410 <                        client_p->name, SERVER_TYPE);
1410 >                        client_p->name, CONF_SERVER);
1411    if (conf == NULL)
1412    {
1413 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1413 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1414                           "Lost connect{} block for %s", get_client_name(client_p, HIDE_IP));
1415 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1415 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1416                           "Lost connect{} block for %s", get_client_name(client_p, MASK_IP));
1417  
1418      exit_client(client_p, &me, "Lost connect{} block");
1419      return;
1420    }
1421  
1539  aconf = map_to_conf(conf);
1422    /* Next, send the initial handshake */
1423    SetHandshake(client_p);
1424  
1425   #ifdef HAVE_LIBCRYPTO
1426 <  if (IsConfSSL(aconf))
1426 >  if (IsConfSSL(conf))
1427    {
1428 <    ssl_connect_init(client_p, aconf, fd);
1428 >    ssl_connect_init(client_p, conf, fd);
1429      return;
1430    }
1431   #endif
1432  
1433    /* jdc -- Check and send spasswd, not passwd. */
1434 <  if (!EmptyString(aconf->spasswd))
1434 >  if (!EmptyString(conf->spasswd))
1435      sendto_one(client_p, "PASS %s TS %d %s",
1436 <               aconf->spasswd, TS_CURRENT, me.id);
1436 >               conf->spasswd, TS_CURRENT, me.id);
1437  
1438 <  send_capabilities(client_p, aconf,
1557 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1438 >  send_capabilities(client_p, 0);
1439  
1440    sendto_one(client_p, "SERVER %s 1 :%s%s",
1441               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 1565 | Line 1446 | serv_connect_callback(fde_t *fd, int sta
1446     */
1447    if (IsDead(client_p))
1448    {
1449 <      sendto_realops_flags(UMODE_ALL, L_ADMIN,
1449 >      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1450                             "%s[%s] went dead during handshake",
1451                             client_p->name,
1452                             client_p->host);
1453 <      sendto_realops_flags(UMODE_ALL, L_OPER,
1453 >      sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1454                             "%s went dead during handshake", client_p->name);
1455        return;
1456    }
# Line 1590 | Line 1471 | find_servconn_in_progress(const char *na
1471      cptr = ptr->data;
1472  
1473      if (cptr && cptr->name[0])
1474 <      if (match(name, cptr->name))
1474 >      if (!match(name, cptr->name))
1475          return cptr;
1476    }
1477    

Diff Legend

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