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 1306 by michael, Sat Mar 24 07:43:04 2012 UTC vs.
ircd-hybrid/trunk/src/s_serv.c (file contents), Revision 1649 by michael, Sat Nov 10 19:27:13 2012 UTC

# Line 43 | Line 43
43   #include "numeric.h"
44   #include "packet.h"
45   #include "irc_res.h"
46 < #include "s_conf.h"
46 > #include "conf.h"
47   #include "s_serv.h"
48 < #include "s_log.h"
48 > #include "log.h"
49   #include "s_misc.h"
50   #include "s_user.h"
51   #include "send.h"
# Line 62 | Line 62 | static void send_tb(struct Client *clien
62  
63   static CNCB serv_connect_callback;
64  
65 static void start_io(struct Client *);
65   static void burst_members(struct Client *, struct Channel *);
66  
67   /*
# Line 76 | Line 75 | static void burst_members(struct Client
75   void
76   write_links_file(void* notused)
77   {
78 <  MessageFileLine *next_mptr = 0;
79 <  MessageFileLine *mptr = 0;
80 <  MessageFileLine *currentMessageLine = 0;
81 <  MessageFileLine *newMessageLine = 0;
82 <  MessageFile *MessageFileptr;
83 <  const char *p;
85 <  FBFILE *file;
78 >  MessageFileLine *next_mptr = NULL;
79 >  MessageFileLine *mptr = NULL;
80 >  MessageFileLine *currentMessageLine = NULL;
81 >  MessageFileLine *newMessageLine = NULL;
82 >  MessageFile *MessageFileptr = &ConfigFileEntry.linksfile;
83 >  FILE *file;
84    char buff[512];
85    dlink_node *ptr;
86  
87 <  MessageFileptr = &ConfigFileEntry.linksfile;
90 <
91 <  if ((file = fbopen(MessageFileptr->fileName, "w")) == NULL)
87 >  if ((file = fopen(MessageFileptr->fileName, "w")) == NULL)
88      return;
89  
90    for (mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr)
# Line 98 | Line 94 | write_links_file(void* notused)
94    }
95  
96    MessageFileptr->contentsOfFile = NULL;
101  currentMessageLine             = NULL;
97  
98    DLINK_FOREACH(ptr, global_serv_list.head)
99    {
100 <    size_t nbytes = 0;
106 <    struct Client *target_p = ptr->data;
100 >    const struct Client *target_p = ptr->data;
101  
102      /* skip ourselves, we send ourselves in /links */
103      if (IsMe(target_p))
104        continue;
105  
106      /* skip hidden servers */
107 <    if (IsHidden(target_p) && !ConfigServerHide.disable_hidden)
107 >    if (IsHidden(target_p))
108        continue;
109  
116    if (target_p->info[0])
117      p = target_p->info;
118    else
119      p = "(Unknown Location)";
120
110      newMessageLine = MyMalloc(sizeof(MessageFileLine));
111  
112 <    /* Attempt to format the file in such a way it follows the usual links output
112 >    /*
113 >     * Attempt to format the file in such a way it follows the usual links output
114       * ie  "servername uplink :hops info"
115       * Mostly for aesthetic reasons - makes it look pretty in mIRC ;)
116       * - madmax
117       */
118 <
119 <    /*
130 <     * For now, check this ircsprintf wont overflow - it shouldnt on a
131 <     * default config but it is configurable..
132 <     * This should be changed to an snprintf at some point, but I'm wanting to
133 <     * know if this is a cause of a bug - cryogen
134 <     */
135 <    assert(strlen(target_p->name) + strlen(me.name) + 6 + strlen(p) <=
136 <            MESSAGELINELEN);
137 <    ircsprintf(newMessageLine->line, "%s %s :1 %s",
138 <               target_p->name, me.name, p);
139 <    newMessageLine->next = NULL;
118 >    snprintf(newMessageLine->line, sizeof(newMessageLine->line), "%s %s :1 %s",
119 >             target_p->name, me.name, target_p->info);
120  
121      if (MessageFileptr->contentsOfFile)
122      {
# Line 150 | Line 130 | write_links_file(void* notused)
130        currentMessageLine = newMessageLine;
131      }
132  
133 <    nbytes = ircsprintf(buff, "%s %s :1 %s\n", target_p->name, me.name, p);
134 <    fbputs(buff, file, nbytes);
133 >    snprintf(buff, sizeof(buff), "%s %s :1 %s\n",
134 >             target_p->name, me.name, target_p->info);
135 >    fputs(buff, file);
136    }
137  
138 <  fbclose(file);
138 >  fclose(file);
139   }
140  
141   /* hunt_server()
# Line 185 | Line 166 | hunt_server(struct Client *client_p, str
166    dlink_node *ptr;
167    int wilds;
168  
169 <  /* Assume it's me, if no server
170 <   */
171 <  if (parc <= server || EmptyString(parv[server]) ||
172 <      match(me.name, parv[server]) ||
173 <      match(parv[server], me.name) ||
174 <      !strcmp(parv[server], me.id))
194 <    return(HUNTED_ISME);
169 >  /* Assume it's me, if no server */
170 >  if (parc <= server || EmptyString(parv[server]))
171 >    return HUNTED_ISME;
172 >
173 >  if (!strcmp(parv[server], me.id) || match(parv[server], me.name))
174 >    return HUNTED_ISME;
175  
176    /* These are to pickup matches that would cause the following
177     * message to go in the wrong direction while doing quick fast
# Line 211 | Line 191 | hunt_server(struct Client *client_p, str
191        target_p = NULL;
192  
193    collapse(parv[server]);
194 <  wilds = (strchr(parv[server], '?') || strchr(parv[server], '*'));
194 >  wilds = has_wildcards(parv[server]);
195  
196    /* Again, if there are no wild cards involved in the server
197     * name, use the hash lookup
# Line 291 | Line 271 | hunt_server(struct Client *client_p, str
271   void
272   try_connections(void *unused)
273   {
274 <  dlink_node *ptr;
275 <  struct ConfItem *conf;
296 <  struct AccessItem *aconf;
297 <  struct ClassItem *cltmp;
274 >  dlink_node *ptr = NULL;
275 >  struct MaskItem *conf;
276    int confrq;
277  
278    /* TODO: change this to set active flag to 0 when added to event! --Habeeb */
# Line 304 | Line 282 | try_connections(void *unused)
282    DLINK_FOREACH(ptr, server_items.head)
283    {
284      conf = ptr->data;
285 <    aconf = map_to_conf(conf);
285 >
286 >    assert(conf->type == CONF_SERVER);
287  
288      /* Also when already connecting! (update holdtimes) --SRB
289       */
290 <    if (!(aconf->status & CONF_SERVER) || !aconf->port ||
312 <        !(IsConfAllowAutoConn(aconf)))
290 >    if (!conf->port ||!IsConfAllowAutoConn(conf))
291        continue;
292  
315    cltmp = map_to_conf(aconf->class_ptr);
293  
294      /* Skip this entry if the use of it is still on hold until
295       * future. Otherwise handle this entry (and set it on hold
# Line 320 | Line 297 | try_connections(void *unused)
297       * made one successfull connection... [this algorithm is
298       * a bit fuzzy... -- msa >;) ]
299       */
300 <    if (aconf->hold > CurrentTime)
300 >    if (conf->until > CurrentTime)
301        continue;
302  
303 <    if (cltmp == NULL)
303 >    if (conf->class == NULL)
304        confrq = DEFAULT_CONNECTFREQUENCY;
305      else
306      {
307 <      confrq = ConFreq(cltmp);
308 <      if (confrq < MIN_CONN_FREQ )
307 >      confrq = conf->class->con_freq;
308 >      if (confrq < MIN_CONN_FREQ)
309          confrq = MIN_CONN_FREQ;
310      }
311  
312 <    aconf->hold = CurrentTime + confrq;
312 >    conf->until = CurrentTime + confrq;
313  
314      /* Found a CONNECT config with port specified, scan clients
315       * and see if this server is already connected?
# Line 340 | Line 317 | try_connections(void *unused)
317      if (hash_find_server(conf->name) != NULL)
318        continue;
319  
320 <    if (CurrUserCount(cltmp) < MaxTotal(cltmp))
320 >    if (conf->class->ref_count < conf->class->max_total)
321      {
322        /* Go to the end of the list, if not already last */
323        if (ptr->next != NULL)
# Line 361 | Line 338 | try_connections(void *unused)
338         *   -- adrian
339         */
340        if (ConfigServerHide.hide_server_ips)
341 <        sendto_realops_flags(UMODE_ALL, L_ALL, "Connection to %s activated.",
341 >        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
342 >                             "Connection to %s activated.",
343                               conf->name);
344        else
345 <        sendto_realops_flags(UMODE_ALL, L_ALL, "Connection to %s[%s] activated.",
346 <                             conf->name, aconf->host);
345 >        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
346 >                             "Connection to %s[%s] activated.",
347 >                             conf->name, conf->host);
348  
349 <      serv_connect(aconf, NULL);
349 >      serv_connect(conf, NULL);
350        /* We connect only one at time... */
351        return;
352      }
# Line 399 | Line 378 | int
378   check_server(const char *name, struct Client *client_p)
379   {
380    dlink_node *ptr;
381 <  struct ConfItem *conf           = NULL;
382 <  struct ConfItem *server_conf    = NULL;
404 <  struct AccessItem *server_aconf = NULL;
405 <  struct AccessItem *aconf        = NULL;
381 >  struct MaskItem *conf        = NULL;
382 >  struct MaskItem *server_conf = NULL;
383    int error = -1;
384  
385    assert(client_p != NULL);
386  
410  if (client_p == NULL)
411    return(error);
412
413  if (strlen(name) > HOSTLEN)
414    return(-4);
415
387    /* loop through looking for all possible connect items that might work */
388    DLINK_FOREACH(ptr, server_items.head)
389    {
390      conf = ptr->data;
420    aconf = map_to_conf(conf);
391  
392      if (!match(name, conf->name))
393        continue;
# Line 426 | Line 396 | check_server(const char *name, struct Cl
396  
397      /* XXX: Fix me for IPv6                    */
398      /* XXX sockhost is the IPv4 ip as a string */
399 <    if (match(aconf->host, client_p->host) ||
400 <        match(aconf->host, client_p->sockhost))
399 >    if (match(conf->host, client_p->host) ||
400 >        match(conf->host, client_p->sockhost))
401      {
402        error = -2;
433      {
434        /* A NULL password is as good as a bad one */
435        if (EmptyString(client_p->localClient->passwd))
436          return(-2);
437
438        /* code in s_conf.c should not have allowed this to be NULL */
439        if (aconf->passwd == NULL)
440          return(-2);
403  
404 <        if (IsConfEncrypted(aconf))
405 <        {
406 <          if (strcmp(aconf->passwd,
407 <              (const char *)crypt(client_p->localClient->passwd,
446 <                                  aconf->passwd)) == 0)
447 <            server_conf = conf;
448 <        }
449 <        else
450 <        {
451 <          if (strcmp(aconf->passwd, client_p->localClient->passwd) == 0)
452 <            server_conf = conf;
453 <        }
454 <      }
404 >      if (!match_conf_password(client_p->localClient->passwd, conf))
405 >        return -2;
406 >
407 >      server_conf = conf;
408      }
409    }
410  
# Line 460 | Line 413 | check_server(const char *name, struct Cl
413  
414    attach_conf(client_p, server_conf);
415  
463  /* Now find all leaf or hub config items for this server */
464  DLINK_FOREACH(ptr, hub_items.head)
465  {
466    conf = ptr->data;
467
468    if (!match(name, conf->name))
469      continue;
470    attach_conf(client_p, conf);
471  }
472
473  DLINK_FOREACH(ptr, leaf_items.head)
474  {
475    conf = ptr->data;
476
477    if (!match(name, conf->name))
478      continue;
479    attach_conf(client_p, conf);
480  }
481
482  server_aconf = map_to_conf(server_conf);
416  
417 <  if (!IsConfTopicBurst(server_aconf))
485 <  {
486 <    ClearCap(client_p, CAP_TB);
487 <    ClearCap(client_p, CAP_TBURST);
488 <  }
489 <
490 <  if (aconf != NULL)
417 >  if (server_conf != NULL)
418    {
419      struct sockaddr_in *v4;
420   #ifdef IPV6
421      struct sockaddr_in6 *v6;
422   #endif
423 <    switch (aconf->aftype)
423 >    switch (server_conf->aftype)
424      {
425   #ifdef IPV6
426        case AF_INET6:
427 <        v6 = (struct sockaddr_in6 *)&aconf->ipnum;
427 >        v6 = (struct sockaddr_in6 *)&server_conf->addr;
428  
429          if (IN6_IS_ADDR_UNSPECIFIED(&v6->sin6_addr))
430 <          memcpy(&aconf->ipnum, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
430 >          memcpy(&server_conf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
431          break;
432   #endif
433        case AF_INET:
434 <        v4 = (struct sockaddr_in *)&aconf->ipnum;
434 >        v4 = (struct sockaddr_in *)&server_conf->addr;
435  
436          if (v4->sin_addr.s_addr == INADDR_NONE)
437 <          memcpy(&aconf->ipnum, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
437 >          memcpy(&server_conf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
438          break;
439      }
440    }
# Line 529 | Line 456 | add_capability(const char *capab_name, i
456   {
457    struct Capability *cap = MyMalloc(sizeof(*cap));
458  
459 <  DupString(cap->name, capab_name);
459 >  cap->name = xstrdup(capab_name);
460    cap->cap = cap_flag;
461    dlinkAdd(cap, &cap->node, &cap_list);
462  
# Line 596 | Line 523 | find_capability(const char *capab)
523   /* send_capabilities()
524   *
525   * inputs       - Client pointer to send to
599 *              - Pointer to AccessItem (for crypt)
526   *              - int flag of capabilities that this server can send
527   * output       - NONE
528   * side effects - send the CAPAB line to a server  -orabidoo
529   *
530   */
531   void
532 < send_capabilities(struct Client *client_p, struct AccessItem *aconf,
607 <                  int cap_can_send)
532 > send_capabilities(struct Client *client_p, int cap_can_send)
533   {
534    struct Capability *cap=NULL;
535    char msgbuf[IRCD_BUFSIZE];
# Line 652 | Line 577 | sendnick_TS(struct Client *client_p, str
577      ubuf[1] = '\0';
578    }
579  
655  /* XXX Both of these need to have a :me.name or :mySID!?!?! */
580    if (IsCapable(client_p, CAP_SVS))
581    {
582      if (HasID(target_p) && IsCapable(client_p, CAP_TS6))
583 <      sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %lu :%s",
583 >      sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %s :%s",
584                   target_p->servptr->id,
585                   target_p->name, target_p->hopcount + 1,
586                   (unsigned long) target_p->tsinfo,
587                   ubuf, target_p->username, target_p->host,
588                   (MyClient(target_p) && IsIPSpoof(target_p)) ?
589                   "0" : target_p->sockhost, target_p->id,
590 <                 (unsigned long)target_p->servicestamp, target_p->info);
590 >                 target_p->svid, target_p->info);
591      else
592 <      sendto_one(client_p, "NICK %s %d %lu %s %s %s %s %lu :%s",
592 >      sendto_one(client_p, "NICK %s %d %lu %s %s %s %s %s :%s",
593                   target_p->name, target_p->hopcount + 1,
594                   (unsigned long) target_p->tsinfo,
595                   ubuf, target_p->username, target_p->host,
596 <                 target_p->servptr->name, (unsigned long)target_p->servicestamp,
596 >                 target_p->servptr->name, target_p->svid,
597                   target_p->info);
598    }
599    else
# Line 690 | Line 614 | sendnick_TS(struct Client *client_p, str
614                   target_p->servptr->name, target_p->info);
615    }
616  
617 <  if (IsConfAwayBurst((struct AccessItem *)map_to_conf(client_p->serv->sconf)))
618 <    if (!EmptyString(target_p->away))
619 <      sendto_one(client_p, ":%s AWAY :%s", target_p->name,
696 <                 target_p->away);
617 >  if (target_p->away[0])
618 >    sendto_one(client_p, ":%s AWAY :%s", ID_or_name(target_p, client_p),
619 >               target_p->away);
620  
621   }
622  
# Line 751 | Line 674 | void
674   server_estab(struct Client *client_p)
675   {
676    struct Client *target_p;
677 <  struct ConfItem *conf;
755 <  struct AccessItem *aconf=NULL;
677 >  struct MaskItem *conf = NULL;
678    char *host;
679    const char *inpath;
680    static char inpath_ip[HOSTLEN * 2 + USERLEN + 6];
# Line 768 | Line 690 | server_estab(struct Client *client_p)
690    inpath = get_client_name(client_p, MASK_IP); /* "refresh" inpath with host */
691    host   = client_p->name;
692  
693 <  if ((conf = find_conf_name(&client_p->localClient->confs, host, SERVER_TYPE))
693 >  if ((conf = find_conf_name(&client_p->localClient->confs, host, CONF_SERVER))
694        == NULL)
695    {
696      /* This shouldn't happen, better tell the ops... -A1kmm */
697 <    sendto_realops_flags(UMODE_ALL, L_ALL, "Warning: Lost connect{} block "
697 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
698 >                         "Warning: Lost connect{} block "
699                           "for server %s(this shouldn't happen)!", host);
700      exit_client(client_p, &me, "Lost connect{} block!");
701      return;
# Line 798 | Line 721 | server_estab(struct Client *client_p)
721      }
722    }
723  
801  aconf = map_to_conf(conf);
802
724    if (IsUnknown(client_p))
725    {
726      /* jdc -- 1.  Use EmptyString(), not [0] index reference.
727 <     *        2.  Check aconf->spasswd, not aconf->passwd.
727 >     *        2.  Check conf->spasswd, not conf->passwd.
728       */
729 <    if (!EmptyString(aconf->spasswd))
729 >    if (!EmptyString(conf->spasswd))
730        sendto_one(client_p, "PASS %s TS %d %s",
731 <                 aconf->spasswd, TS_CURRENT, me.id);
731 >                 conf->spasswd, TS_CURRENT, me.id);
732  
733 <    /* Pass my info to the new server
813 <     *
814 <     * Pass on ZIP if supported
815 <     * Pass on TB if supported.
816 <     * - Dianora
817 <     */
818 <
819 <    send_capabilities(client_p, aconf,
820 <      (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
733 >    send_capabilities(client_p, 0);
734  
735      sendto_one(client_p, "SERVER %s 1 :%s%s",
736                 me.name, ConfigServerHide.hidden ? "(H) " : "", me.info);
# Line 831 | Line 744 | server_estab(struct Client *client_p)
744      hash_add_id(client_p);
745  
746    /* XXX Does this ever happen? I don't think so -db */
747 <  detach_conf(client_p, OPER_TYPE);
747 >  detach_conf(client_p, CONF_OPER);
748  
749    /* *WARNING*
750    **    In the following code in place of plain server's
# Line 873 | Line 786 | server_estab(struct Client *client_p)
786    /* fixing eob timings.. -gnp */
787    client_p->localClient->firsttime = CurrentTime;
788  
789 <  if (find_matching_name_conf(SERVICE_TYPE, client_p->name, NULL, NULL, 0))
789 >  if (find_matching_name_conf(CONF_SERVICE, client_p->name, NULL, NULL, 0))
790      AddFlag(client_p, FLAGS_SERVICE);
791  
792    /* Show the real host/IP to admins */
# Line 883 | Line 796 | server_estab(struct Client *client_p)
796      compression = SSL_get_current_compression(client_p->localClient->fd.ssl);
797      expansion   = SSL_get_current_expansion(client_p->localClient->fd.ssl);
798  
799 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
799 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
800                           "Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)",
801                           inpath_ip, ssl_get_cipher(client_p->localClient->fd.ssl),
802                           compression ? SSL_COMP_get_name(compression) : "NONE",
803                           expansion ? SSL_COMP_get_name(expansion) : "NONE",
804                           show_capabilities(client_p));
805      /* Now show the masked hostname/IP to opers */
806 <    sendto_realops_flags(UMODE_ALL, L_OPER,
806 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
807                           "Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)",
808                           inpath, ssl_get_cipher(client_p->localClient->fd.ssl),
809                           compression ? SSL_COMP_get_name(compression) : "NONE",
# Line 905 | Line 818 | server_estab(struct Client *client_p)
818    else
819   #endif
820    {
821 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
821 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
822                           "Link with %s established: (Capabilities: %s)",
823 <                         inpath_ip,show_capabilities(client_p));
823 >                         inpath_ip, show_capabilities(client_p));
824      /* Now show the masked hostname/IP to opers */
825 <    sendto_realops_flags(UMODE_ALL, L_OPER,
825 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
826                           "Link with %s established: (Capabilities: %s)",
827 <                         inpath,show_capabilities(client_p));
827 >                         inpath, show_capabilities(client_p));
828      ilog(LOG_TYPE_IRCD, "Link with %s established: (Capabilities: %s)",
829           inpath_ip, show_capabilities(client_p));
830    }
831  
919  client_p->serv->sconf = conf;
920
832    fd_note(&client_p->localClient->fd, "Server: %s", client_p->name);
833  
834    /* Old sendto_serv_but_one() call removed because we now
# Line 1038 | Line 949 | burst_all(struct Client *client_p)
949        burst_members(client_p, chptr);
950        send_channel_modes(client_p, chptr);
951  
952 <      if (IsCapable(client_p, CAP_TBURST) ||
1042 <          IsCapable(client_p, CAP_TB))
952 >      if (IsCapable(client_p, CAP_TBURST))
953          send_tb(client_p, chptr);
954      }
955    }
# Line 1071 | Line 981 | burst_all(struct Client *client_p)
981   *              - pointer to channel
982   * output       - NONE
983   * side effects - Called on a server burst when
984 < *                server is CAP_TB|CAP_TBURST capable
984 > *                server is CAP_TBURST capable
985   */
986   static void
987   send_tb(struct Client *client_p, struct Channel *chptr)
# Line 1090 | Line 1000 | send_tb(struct Client *client_p, struct
1000     * for further information   -Michael
1001     */
1002    if (chptr->topic_time != 0)
1003 <  {
1004 <    if (IsCapable(client_p, CAP_TBURST))
1005 <      sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1006 <                 me.name, (unsigned long)chptr->channelts, chptr->chname,
1007 <                 (unsigned long)chptr->topic_time,
1008 <                 chptr->topic_info,
1099 <                 chptr->topic);
1100 <    else if (IsCapable(client_p, CAP_TB))
1101 <    {
1102 <      if (ConfigChannel.burst_topicwho)
1103 <      {
1104 <        sendto_one(client_p, ":%s TB %s %lu %s :%s",
1105 <                   me.name, chptr->chname,
1106 <                   (unsigned long)chptr->topic_time,
1107 <                   chptr->topic_info, chptr->topic);
1108 <      }
1109 <      else
1110 <      {
1111 <        sendto_one(client_p, ":%s TB %s %lu :%s",
1112 <                   me.name, chptr->chname,
1113 <                   (unsigned long)chptr->topic_time,
1114 <                   chptr->topic);
1115 <      }
1116 <    }
1117 <  }
1003 >    sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1004 >               ID_or_name(&me, client_p),
1005 >               (unsigned long)chptr->channelts, chptr->chname,
1006 >               (unsigned long)chptr->topic_time,
1007 >               chptr->topic_info,
1008 >               chptr->topic);
1009   }
1010  
1011   /* burst_members()
# Line 1168 | Line 1059 | burst_members(struct Client *client_p, s
1059   * it suceeded or not, and 0 if it fails in here somewhere.
1060   */
1061   int
1062 < serv_connect(struct AccessItem *aconf, struct Client *by)
1062 > serv_connect(struct MaskItem *conf, struct Client *by)
1063   {
1173  struct ConfItem *conf;
1064    struct Client *client_p;
1065 <  char buf[HOSTIPLEN];
1065 >  char buf[HOSTIPLEN + 1];
1066  
1067    /* conversion structs */
1068    struct sockaddr_in *v4;
1069 <  /* Make sure aconf is useful */
1070 <  assert(aconf != NULL);
1181 <
1182 <  if(aconf == NULL)
1183 <    return (0);
1069 >  /* Make sure conf is useful */
1070 >  assert(conf != NULL);
1071  
1185  /* XXX should be passing struct ConfItem in the first place */
1186  conf = unmap_conf_item(aconf);
1072  
1073 <  /* log */
1189 <  getnameinfo((struct sockaddr *)&aconf->ipnum, aconf->ipnum.ss_len,
1073 >  getnameinfo((struct sockaddr *)&conf->addr, conf->addr.ss_len,
1074                buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
1075 <  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", aconf->user, aconf->host,
1075 >  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", conf->name, conf->host,
1076         buf);
1077  
1078    /* Still processing a DNS lookup? -> exit */
1079 <  if (aconf->dns_pending)
1079 >  if (conf->dns_pending)
1080    {
1081 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1081 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1082                           "Error connecting to %s: DNS lookup for connect{} in progress.",
1083                           conf->name);
1084      return (0);
1085    }
1086  
1087 <  if (aconf->dns_failed)
1087 >  if (conf->dns_failed)
1088    {
1089 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1089 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1090                           "Error connecting to %s: DNS lookup for connect{} failed.",
1091                           conf->name);
1092      return (0);
1093    }
1094  
1095    /* Make sure this server isn't already connected
1096 <   * Note: aconf should ALWAYS be a valid C: line
1096 >   * Note: conf should ALWAYS be a valid C: line
1097     */
1098    if ((client_p = hash_find_server(conf->name)) != NULL)
1099    {
1100 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1100 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1101                           "Server %s already present from %s",
1102                           conf->name, get_client_name(client_p, SHOW_IP));
1103 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1103 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1104                           "Server %s already present from %s",
1105                           conf->name, get_client_name(client_p, MASK_IP));
1106      if (by && IsClient(by) && !MyClient(by))
# Line 1231 | Line 1115 | serv_connect(struct AccessItem *aconf, s
1115  
1116    /* Copy in the server, hostname, fd */
1117    strlcpy(client_p->name, conf->name, sizeof(client_p->name));
1118 <  strlcpy(client_p->host, aconf->host, sizeof(client_p->host));
1118 >  strlcpy(client_p->host, conf->host, sizeof(client_p->host));
1119  
1120    /* We already converted the ip once, so lets use it - stu */
1121    strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost));
1122  
1123    /* create a socket for the server connection */
1124 <  if (comm_open(&client_p->localClient->fd, aconf->ipnum.ss.ss_family,
1124 >  if (comm_open(&client_p->localClient->fd, conf->addr.ss.ss_family,
1125                  SOCK_STREAM, 0, NULL) < 0)
1126    {
1127      /* Eek, failure to create the socket */
# Line 1254 | Line 1138 | serv_connect(struct AccessItem *aconf, s
1138    /* Attach config entries to client here rather than in
1139     * serv_connect_callback(). This to avoid null pointer references.
1140     */
1141 <  if (!attach_connect_block(client_p, conf->name, aconf->host))
1141 >  if (!attach_connect_block(client_p, conf->name, conf->host))
1142    {
1143 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1144 <                         "Host %s is not enabled for connecting:no C/N-line",
1143 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1144 >                         "Host %s is not enabled for connecting: no connect{} block",
1145                           conf->name);
1146      if (by && IsClient(by) && !MyClient(by))  
1147        sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.",
# Line 1283 | Line 1167 | serv_connect(struct AccessItem *aconf, s
1167    SetConnecting(client_p);
1168    dlinkAdd(client_p, &client_p->node, &global_client_list);
1169    /* from def_fam */
1170 <  client_p->localClient->aftype = aconf->aftype;
1170 >  client_p->localClient->aftype = conf->aftype;
1171  
1172    /* Now, initiate the connection */
1173    /* XXX assume that a non 0 type means a specific bind address
1174     * for this connect.
1175     */
1176 <  switch (aconf->aftype)
1176 >  switch (conf->aftype)
1177    {
1178      case AF_INET:
1179 <      v4 = (struct sockaddr_in*)&aconf->my_ipnum;
1179 >      v4 = (struct sockaddr_in*)&conf->bind;
1180        if (v4->sin_addr.s_addr != 0)
1181        {
1182          struct irc_ssaddr ipn;
1183          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1184          ipn.ss.ss_family = AF_INET;
1185          ipn.ss_port = 0;
1186 <        memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1187 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1186 >        memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr));
1187 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1188                           (struct sockaddr *)&ipn, ipn.ss_len,
1189 <                         serv_connect_callback, client_p, aconf->aftype,
1189 >                         serv_connect_callback, client_p, conf->aftype,
1190                           CONNECTTIMEOUT);
1191        }
1192        else if (ServerInfo.specific_ipv4_vhost)
# Line 1312 | Line 1196 | serv_connect(struct AccessItem *aconf, s
1196          ipn.ss.ss_family = AF_INET;
1197          ipn.ss_port = 0;
1198          memcpy(&ipn, &ServerInfo.ip, sizeof(struct irc_ssaddr));
1199 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1199 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1200                           (struct sockaddr *)&ipn, ipn.ss_len,
1201 <                         serv_connect_callback, client_p, aconf->aftype,
1201 >                         serv_connect_callback, client_p, conf->aftype,
1202                           CONNECTTIMEOUT);
1203        }
1204        else
1205 <        comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1206 <                         NULL, 0, serv_connect_callback, client_p, aconf->aftype,
1205 >        comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port,
1206 >                         NULL, 0, serv_connect_callback, client_p, conf->aftype,
1207                           CONNECTTIMEOUT);
1208        break;
1209   #ifdef IPV6
# Line 1330 | Line 1214 | serv_connect(struct AccessItem *aconf, s
1214          struct sockaddr_in6 *v6conf;
1215  
1216          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1217 <        v6conf = (struct sockaddr_in6 *)&aconf->my_ipnum;
1217 >        v6conf = (struct sockaddr_in6 *)&conf->bind;
1218          v6 = (struct sockaddr_in6 *)&ipn;
1219  
1220          if (memcmp(&v6conf->sin6_addr, &v6->sin6_addr,
1221                     sizeof(struct in6_addr)) != 0)
1222          {
1223 <          memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1223 >          memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr));
1224            ipn.ss.ss_family = AF_INET6;
1225            ipn.ss_port = 0;
1226            comm_connect_tcp(&client_p->localClient->fd,
1227 <                           aconf->host, aconf->port,
1227 >                           conf->host, conf->port,
1228                             (struct sockaddr *)&ipn, ipn.ss_len,
1229                             serv_connect_callback, client_p,
1230 <                           aconf->aftype, CONNECTTIMEOUT);
1230 >                           conf->aftype, CONNECTTIMEOUT);
1231          }
1232          else if (ServerInfo.specific_ipv6_vhost)
1233          {
# Line 1351 | Line 1235 | serv_connect(struct AccessItem *aconf, s
1235            ipn.ss.ss_family = AF_INET6;
1236            ipn.ss_port = 0;
1237            comm_connect_tcp(&client_p->localClient->fd,
1238 <                           aconf->host, aconf->port,
1238 >                           conf->host, conf->port,
1239                             (struct sockaddr *)&ipn, ipn.ss_len,
1240                             serv_connect_callback, client_p,
1241 <                           aconf->aftype, CONNECTTIMEOUT);
1241 >                           conf->aftype, CONNECTTIMEOUT);
1242          }
1243          else
1244            comm_connect_tcp(&client_p->localClient->fd,
1245 <                           aconf->host, aconf->port,
1245 >                           conf->host, conf->port,
1246                             NULL, 0, serv_connect_callback, client_p,
1247 <                           aconf->aftype, CONNECTTIMEOUT);
1247 >                           conf->aftype, CONNECTTIMEOUT);
1248        }
1249   #endif
1250    }
# Line 1371 | Line 1255 | serv_connect(struct AccessItem *aconf, s
1255   static void
1256   finish_ssl_server_handshake(struct Client *client_p)
1257   {
1258 <  struct ConfItem *conf=NULL;
1375 <  struct AccessItem *aconf=NULL;
1258 >  struct MaskItem *conf = NULL;
1259  
1260    conf = find_conf_name(&client_p->localClient->confs,
1261 <                        client_p->name, SERVER_TYPE);
1261 >                        client_p->name, CONF_SERVER);
1262    if (conf == NULL)
1263    {
1264 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1264 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1265                           "Lost connect{} block for %s", get_client_name(client_p, HIDE_IP));
1266 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1266 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1267                           "Lost connect{} block for %s", get_client_name(client_p, MASK_IP));
1268  
1269      exit_client(client_p, &me, "Lost connect{} block");
1270      return;
1271    }
1272  
1390  aconf = map_to_conf(conf);
1391
1273    /* jdc -- Check and send spasswd, not passwd. */
1274 <  if (!EmptyString(aconf->spasswd))
1274 >  if (!EmptyString(conf->spasswd))
1275      sendto_one(client_p, "PASS %s TS %d %s",
1276 <               aconf->spasswd, TS_CURRENT, me.id);
1276 >               conf->spasswd, TS_CURRENT, me.id);
1277  
1278 <  send_capabilities(client_p, aconf,
1398 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1278 >  send_capabilities(client_p, 0);
1279  
1280    sendto_one(client_p, "SERVER %s 1 :%s%s",
1281               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 1406 | Line 1286 | finish_ssl_server_handshake(struct Clien
1286     */
1287    if (IsDead(client_p))
1288    {
1289 <      sendto_realops_flags(UMODE_ALL, L_ADMIN,
1289 >      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1290                             "%s[%s] went dead during handshake",
1291                             client_p->name,
1292                             client_p->host);
1293 <      sendto_realops_flags(UMODE_ALL, L_OPER,
1293 >      sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1294                             "%s went dead during handshake", client_p->name);
1295        return;
1296    }
# Line 1434 | Line 1314 | ssl_server_handshake(fde_t *fd, struct C
1314      {
1315        case SSL_ERROR_WANT_WRITE:
1316          comm_setselect(&client_p->localClient->fd, COMM_SELECT_WRITE,
1317 <            (PF *) ssl_server_handshake, client_p, 0);
1317 >                       (PF *)ssl_server_handshake, client_p, 0);
1318          return;
1319        case SSL_ERROR_WANT_READ:
1320          comm_setselect(&client_p->localClient->fd, COMM_SELECT_READ,
1321 <            (PF *) ssl_server_handshake, client_p, 0);
1321 >                       (PF *)ssl_server_handshake, client_p, 0);
1322          return;
1323        default:
1324 +      {
1325 +        const char *sslerr = ERR_error_string(ERR_get_error(), NULL);
1326 +        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1327 +                             "Error connecting to %s: %s", client_p->name,
1328 +                             sslerr ? sslerr : "unknown SSL error");
1329          exit_client(client_p, client_p, "Error during SSL handshake");
1330          return;
1331 +      }
1332      }
1333    }
1334  
# Line 1450 | Line 1336 | ssl_server_handshake(fde_t *fd, struct C
1336   }
1337  
1338   static void
1339 < ssl_connect_init(struct Client *client_p, struct AccessItem *aconf, fde_t *fd)
1339 > ssl_connect_init(struct Client *client_p, struct MaskItem *conf, fde_t *fd)
1340   {
1341    if ((client_p->localClient->fd.ssl = SSL_new(ServerInfo.client_ctx)) == NULL)
1342    {
# Line 1463 | Line 1349 | ssl_connect_init(struct Client *client_p
1349  
1350    SSL_set_fd(fd->ssl, fd->fd);
1351  
1352 <  if (!EmptyString(aconf->cipher_list))
1353 <    SSL_set_cipher_list(client_p->localClient->fd.ssl, aconf->cipher_list);
1352 >  if (!EmptyString(conf->cipher_list))
1353 >    SSL_set_cipher_list(client_p->localClient->fd.ssl, conf->cipher_list);
1354  
1355    ssl_server_handshake(NULL, client_p);
1356   }
# Line 1482 | Line 1368 | static void
1368   serv_connect_callback(fde_t *fd, int status, void *data)
1369   {
1370    struct Client *client_p = data;
1371 <  struct ConfItem *conf=NULL;
1486 <  struct AccessItem *aconf=NULL;
1371 >  struct MaskItem *conf = NULL;
1372  
1373    /* First, make sure its a real client! */
1374    assert(client_p != NULL);
# Line 1499 | Line 1384 | serv_connect_callback(fde_t *fd, int sta
1384       * Admins get to see any IP, mere opers don't *sigh*
1385       */
1386       if (ConfigServerHide.hide_server_ips)
1387 <       sendto_realops_flags(UMODE_ALL, L_ADMIN,
1387 >       sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1388                              "Error connecting to %s: %s",
1389                              client_p->name, comm_errstr(status));
1390       else
1391 <       sendto_realops_flags(UMODE_ALL, L_ADMIN,
1391 >       sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1392                              "Error connecting to %s[%s]: %s", client_p->name,
1393                              client_p->host, comm_errstr(status));
1394  
1395 <     sendto_realops_flags(UMODE_ALL, L_OPER,
1395 >     sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1396                            "Error connecting to %s: %s",
1397                            client_p->name, comm_errstr(status));
1398  
# Line 1521 | Line 1406 | serv_connect_callback(fde_t *fd, int sta
1406    /* COMM_OK, so continue the connection procedure */
1407    /* Get the C/N lines */
1408    conf = find_conf_name(&client_p->localClient->confs,
1409 <                        client_p->name, SERVER_TYPE);
1409 >                        client_p->name, CONF_SERVER);
1410    if (conf == NULL)
1411    {
1412 <    sendto_realops_flags(UMODE_ALL, L_ADMIN,
1412 >    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1413                           "Lost connect{} block for %s", get_client_name(client_p, HIDE_IP));
1414 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1414 >    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1415                           "Lost connect{} block for %s", get_client_name(client_p, MASK_IP));
1416  
1417      exit_client(client_p, &me, "Lost connect{} block");
1418      return;
1419    }
1420  
1536  aconf = map_to_conf(conf);
1421    /* Next, send the initial handshake */
1422    SetHandshake(client_p);
1423  
1424   #ifdef HAVE_LIBCRYPTO
1425 <  if (IsConfSSL(aconf))
1425 >  if (IsConfSSL(conf))
1426    {
1427 <    ssl_connect_init(client_p, aconf, fd);
1427 >    ssl_connect_init(client_p, conf, fd);
1428      return;
1429    }
1430   #endif
1431  
1432    /* jdc -- Check and send spasswd, not passwd. */
1433 <  if (!EmptyString(aconf->spasswd))
1433 >  if (!EmptyString(conf->spasswd))
1434      sendto_one(client_p, "PASS %s TS %d %s",
1435 <               aconf->spasswd, TS_CURRENT, me.id);
1435 >               conf->spasswd, TS_CURRENT, me.id);
1436  
1437 <  send_capabilities(client_p, aconf,
1554 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1437 >  send_capabilities(client_p, 0);
1438  
1439    sendto_one(client_p, "SERVER %s 1 :%s%s",
1440               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 1562 | Line 1445 | serv_connect_callback(fde_t *fd, int sta
1445     */
1446    if (IsDead(client_p))
1447    {
1448 <      sendto_realops_flags(UMODE_ALL, L_ADMIN,
1448 >      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1449                             "%s[%s] went dead during handshake",
1450                             client_p->name,
1451                             client_p->host);
1452 <      sendto_realops_flags(UMODE_ALL, L_OPER,
1452 >      sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
1453                             "%s went dead during handshake", client_p->name);
1454        return;
1455    }

Diff Legend

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