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/trunk/src/server.c (file contents):
Revision 7997 by michael, Tue Mar 14 13:17:52 2017 UTC vs.
Revision 8512 by michael, Fri Apr 6 19:28:05 2018 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2017 ircd-hybrid development team
4 > *  Copyright (c) 1997-2018 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 19 | Line 19
19   *  USA
20   */
21  
22 < /*! \file s_serv.c
22 > /*! \file server.c
23   * \brief Server related functions.
24   * \version $Id$
25   */
# Line 36 | Line 36
36   #include "packet.h"
37   #include "conf.h"
38   #include "server.h"
39 + #include "server_capab.h"
40   #include "log.h"
41   #include "send.h"
42   #include "memory.h"
# Line 43 | Line 44
44  
45  
46   dlink_list flatten_links;
47 < static dlink_list server_capabilities_list;
47 < static void serv_connect_callback(fde_t *, int, void *);
47 > static void server_connect_callback(fde_t *, int, void *);
48  
49  
50   /*
# Line 186 | Line 186 | server_hunt(struct Client *source_p, con
186      if (h->target_p->from == source_p->from && !MyConnect(h->target_p))
187        h->target_p = NULL;
188  
189 <  if (!h->target_p && has_wildcards(parv[server]))
189 >  if (h->target_p == NULL && has_wildcards(parv[server]))
190    {
191      DLINK_FOREACH(node, global_server_list.head)
192      {
193        struct Client *tmp = node->data;
194  
195        assert(IsMe(tmp) || IsServer(tmp));
196 <      if (!match(parv[server], tmp->name))
196 >      if (match(parv[server], tmp->name) == 0)
197        {
198          if (tmp->from == source_p->from && !MyConnect(tmp))
199            continue;
# Line 203 | Line 203 | server_hunt(struct Client *source_p, con
203        }
204      }
205  
206 <    if (!h->target_p)
206 >    if (h->target_p == NULL)
207      {
208        DLINK_FOREACH(node, global_client_list.head)
209        {
210          struct Client *tmp = node->data;
211  
212          assert(IsClient(tmp));
213 <        if (!match(parv[server], tmp->name))
213 >        if (match(parv[server], tmp->name) == 0)
214          {
215            if (tmp->from == source_p->from && !MyConnect(tmp))
216              continue;
# Line 270 | Line 270 | try_connections(void *unused)
270      assert(conf->class);
271  
272      /* Also when already connecting! (update holdtimes) --SRB */
273 <    if (!conf->port || !IsConfAllowAutoConn(conf))
273 >    if (conf->port == 0 || !IsConfAllowAutoConn(conf))
274        continue;
275  
276      /*
# Line 305 | Line 305 | try_connections(void *unused)
305          return;
306  
307        /*
308 <       * We used to only print this if serv_connect() actually
308 >       * We used to only print this if server_connect() actually
309         * succeeded, but since comm_tcp_connect() can call the callback
310         * immediately if there is an error, we were getting error messages
311         * in the wrong order. SO, we just print out the activated line,
312 <       * and let serv_connect() / serv_connect_callback() print an
312 >       * and let server_connect() / server_connect_callback() print an
313         * error afterwards if it fails.
314         *   -- adrian
315         */
# Line 322 | Line 322 | try_connections(void *unused)
322                               "Connection to %s[%s] activated.",
323                               conf->name, conf->host);
324  
325 <      serv_connect(conf, NULL);
325 >      server_connect(conf, NULL);
326        /* We connect only one at time... */
327        return;
328      }
# Line 330 | Line 330 | try_connections(void *unused)
330   }
331  
332   int
333 < valid_servname(const char *name)
333 > server_valid_name(const char *name)
334   {
335    unsigned int dots = 0;
336    const char *p = name;
# Line 347 | Line 347 | valid_servname(const char *name)
347    return dots && (p - name) <= HOSTLEN;
348   }
349  
350 < /* server_capab_init()
351 < *
352 < * inputs       - none
353 < * output       - none
354 < */
355 < void
356 < server_capab_init(void)
357 < {
358 <  add_capability("QS", CAPAB_QS);
359 <  add_capability("EOB", CAPAB_EOB);
360 <  add_capability("CLUSTER", CAPAB_CLUSTER);
361 <  add_capability("SVS", CAPAB_SVS);
362 <  add_capability("CHW", CAPAB_CHW);
363 <  add_capability("HOPS", CAPAB_HOPS);
364 < }
365 <
366 < /* add_capability()
367 < *
368 < * inputs       - string name of CAPAB
369 < *              - int flag of capability
370 < * output       - NONE
371 < * side effects - Adds given capability name and bit mask to
372 < *                current supported capabilities. This allows
373 < *                modules to dynamically add or subtract their capability.
374 < */
375 < void
376 < add_capability(const char *name, unsigned int flag)
377 < {
378 <  struct Capability *cap = xcalloc(sizeof(*cap));
379 <
380 <  cap->name = xstrdup(name);
381 <  cap->cap = flag;
382 <  dlinkAdd(cap, &cap->node, &server_capabilities_list);
383 < }
384 <
385 < /* delete_capability()
386 < *
387 < * inputs       - string name of CAPAB
388 < * output       - NONE
389 < * side effects - delete given capability from ones known.
390 < */
391 < void
392 < delete_capability(const char *name)
393 < {
394 <  dlink_node *node, *node_next;
395 <
396 <  DLINK_FOREACH_SAFE(node, node_next, server_capabilities_list.head)
397 <  {
398 <    struct Capability *cap = node->data;
399 <
400 <    if (!irccmp(cap->name, name))
401 <    {
402 <      dlinkDelete(node, &server_capabilities_list);
403 <      xfree(cap->name);
404 <      xfree(cap);
405 <    }
406 <  }
407 < }
408 <
409 < /*
410 < * find_capability()
411 < *
412 < * inputs       - string name of capab to find
413 < * output       - 0 if not found CAPAB otherwise
414 < * side effects - none
415 < */
416 < unsigned int
417 < find_capability(const char *name)
418 < {
419 <  dlink_node *node;
420 <
421 <  DLINK_FOREACH(node, server_capabilities_list.head)
422 <  {
423 <    const struct Capability *cap = node->data;
424 <
425 <    if (!irccmp(cap->name, name))
426 <      return cap->cap;
427 <  }
428 <
429 <  return 0;
430 < }
431 <
432 < /*
433 < * show_capabilities - show current server capabilities
434 < *
435 < * inputs       - pointer to a struct Client
436 < * output       - pointer to static string
437 < * side effects - build up string representing capabilities of server listed
438 < */
439 < const char *
440 < get_capabilities(const struct Client *client_p)
441 < {
442 <  static char buf[IRCD_BUFSIZE] = "";
443 <  dlink_node *node;
444 <
445 <  buf[0] = '\0';
446 <
447 <  DLINK_FOREACH(node, server_capabilities_list.head)
448 <  {
449 <    const struct Capability *cap = node->data;
450 <
451 <    if (client_p && !IsCapable(client_p, cap->cap))
452 <      continue;
453 <
454 <    strlcat(buf, cap->name, sizeof(buf));
455 <
456 <    if (node->next)
457 <      strlcat(buf, " ", sizeof(buf));
458 <  }
459 <
460 <  return buf;
461 < }
462 <
463 < /* make_server()
350 > /* server_make()
351   *
352   * inputs       - pointer to client struct
353   * output       - pointer to struct Server
# Line 468 | Line 355 | get_capabilities(const struct Client *cl
355   *                if it was not previously allocated.
356   */
357   struct Server *
358 < make_server(struct Client *client_p)
358 > server_make(struct Client *client_p)
359   {
360    if (client_p->serv == NULL)
361 <    client_p->serv = xcalloc(sizeof(struct Server));
361 >    client_p->serv = xcalloc(sizeof(*client_p->serv));
362  
363    return client_p->serv;
364   }
365  
366 < /* New server connection code
480 < * Based upon the stuff floating about in s_bsd.c
481 < *   -- adrian
482 < */
483 <
484 < /* serv_connect() - initiate a server connection
366 > /* server_connect() - initiate a server connection
367   *
368   * inputs       - pointer to conf
369   *              - pointer to client doing the connect
# Line 498 | Line 380 | make_server(struct Client *client_p)
380   * it suceeded or not, and 0 if it fails in here somewhere.
381   */
382   int
383 < serv_connect(struct MaskItem *conf, struct Client *by)
383 > server_connect(struct MaskItem *conf, struct Client *by)
384   {
503  struct Client *client_p = NULL;
385    char buf[HOSTIPLEN + 1] = "";
386  
387    /* conversion structs */
# Line 508 | Line 389 | serv_connect(struct MaskItem *conf, stru
389  
390    /* Make sure conf is useful */
391    assert(conf);
392 +  assert(conf->type == CONF_SERVER);
393 +  assert(hash_find_server(conf->name) == NULL);  /* This should have been checked by the caller */
394  
395    getnameinfo((const struct sockaddr *)&conf->addr, conf->addr.ss_len,
396                buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
397 <  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", conf->name, conf->host,
515 <       buf);
397 >  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", conf->name, conf->host, buf);
398  
399    /* Still processing a DNS lookup? -> exit */
400    if (conf->dns_pending)
# Line 531 | Line 413 | serv_connect(struct MaskItem *conf, stru
413      return 0;
414    }
415  
416 <  /*
417 <   * Make sure this server isn't already connected.
418 <   * Note: conf should ALWAYS be a valid connect {} block
537 <   */
538 <  if ((client_p = hash_find_server(conf->name)))
416 >  /* Create a socket for the server connection */
417 >  int fd = comm_socket(conf->addr.ss.ss_family, SOCK_STREAM, 0);
418 >  if (fd == -1)
419    {
420 <    sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
421 <                         "Server %s already present from %s",
542 <                         conf->name, client_get_name(client_p, SHOW_IP));
543 <    sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
544 <                         "Server %s already present from %s",
545 <                         conf->name, client_get_name(client_p, MASK_IP));
546 <    if (by && IsClient(by) && !MyClient(by))
547 <      sendto_one_notice(by, &me, ":Server %s already present from %s",
548 <                        conf->name, client_get_name(client_p, MASK_IP));
420 >    /* Eek, failure to create the socket */
421 >    report_error(L_ALL, "opening stream socket to %s: %s", conf->name, errno);
422      return 0;
423    }
424  
425    /* Create a local client */
426 <  client_p = client_make(NULL);
426 >  struct Client *client_p = client_make(NULL);
427  
428    /* Copy in the server, hostname, fd */
429    strlcpy(client_p->name, conf->name, sizeof(client_p->name));
# Line 559 | Line 432 | serv_connect(struct MaskItem *conf, stru
432    /* We already converted the ip once, so lets use it - stu */
433    strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost));
434  
435 <  /* Create a socket for the server connection */
563 <  if (comm_open(&client_p->connection->fd, conf->addr.ss.ss_family, SOCK_STREAM, 0, NULL) < 0)
564 <  {
565 <    /* Eek, failure to create the socket */
566 <    report_error(L_ALL, "opening stream socket to %s: %s", conf->name, errno);
567 <
568 <    SetDead(client_p);
569 <    exit_client(client_p, "Connection failed");
570 <    return 0;
571 <  }
435 >  client_p->connection->fd = fd_open(fd, 1, NULL);
436  
437    /* Server names are always guaranteed under HOSTLEN chars */
438 <  fd_note(&client_p->connection->fd, "Server: %s", client_p->name);
438 >  fd_note(client_p->connection->fd, "Server: %s", client_p->name);
439  
440    /*
441 <   * Attach config entries to client here rather than in serv_connect_callback().
441 >   * Attach config entries to client here rather than in server_connect_callback().
442     * This to avoid null pointer references.
443     */
444 <  if (!attach_connect_block(client_p, conf->name, conf->host))
581 <  {
582 <    sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
583 <                         "Host %s is not enabled for connecting: no connect {} block",
584 <                         conf->name);
585 <    if (by && IsClient(by) && !MyClient(by))
586 <      sendto_one_notice(by, &me, ":Connect to host %s failed: no connect {} block", client_p->name);
444 >  conf_attach(client_p, conf);
445  
446 <    SetDead(client_p);
589 <    exit_client(client_p, "Connection failed");
590 <    return 0;
591 <  }
592 <
593 <  /*
594 <   * At this point we have a connection in progress and a connect {} block
595 <   * attached to the client, the socket info should be saved in the client
596 <   * and it should either be resolved or have a valid address.
597 <   *
598 <   * The socket has been connected or connect is in progress.
599 <   */
600 <  make_server(client_p);
446 >  server_make(client_p);
447  
448    if (by && IsClient(by))
449      strlcpy(client_p->serv->by, by->name, sizeof(client_p->serv->by));
# Line 605 | Line 451 | serv_connect(struct MaskItem *conf, stru
451      strlcpy(client_p->serv->by, "AutoConn.", sizeof(client_p->serv->by));
452  
453    SetConnecting(client_p);
454 <  client_p->connection->aftype = conf->aftype;
454 >  client_p->ip.ss.ss_family = conf->aftype;
455  
456    /* Now, initiate the connection */
457    /* XXX assume that a non 0 type means a specific bind address
# Line 615 | Line 461 | serv_connect(struct MaskItem *conf, stru
461    {
462      case AF_INET:
463        v4 = (struct sockaddr_in*)&conf->bind;
464 +
465        if (v4->sin_addr.s_addr)
466        {
467          struct irc_ssaddr ipn;
468 <        memset(&ipn, 0, sizeof(struct irc_ssaddr));
468 >
469 >        memset(&ipn, 0, sizeof(ipn));
470          ipn.ss.ss_family = AF_INET;
471          ipn.ss_port = 0;
472 <        memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr));
473 <        comm_connect_tcp(&client_p->connection->fd, conf->host, conf->port,
472 >        memcpy(&ipn, &conf->bind, sizeof(ipn));
473 >
474 >        comm_connect_tcp(client_p->connection->fd, conf->host, conf->port,
475                           (struct sockaddr *)&ipn, ipn.ss_len,
476 <                         serv_connect_callback, client_p, conf->aftype,
476 >                         server_connect_callback, client_p, conf->aftype,
477                           CONNECTTIMEOUT);
478        }
479        else if (ConfigServerInfo.specific_ipv4_vhost)
480        {
481          struct irc_ssaddr ipn;
482 <        memset(&ipn, 0, sizeof(struct irc_ssaddr));
482 >
483 >        memset(&ipn, 0, sizeof(ipn));
484          ipn.ss.ss_family = AF_INET;
485          ipn.ss_port = 0;
486 <        memcpy(&ipn, &ConfigServerInfo.ip, sizeof(struct irc_ssaddr));
487 <        comm_connect_tcp(&client_p->connection->fd, conf->host, conf->port,
486 >        memcpy(&ipn, &ConfigServerInfo.ip, sizeof(ipn));
487 >
488 >        comm_connect_tcp(client_p->connection->fd, conf->host, conf->port,
489                           (struct sockaddr *)&ipn, ipn.ss_len,
490 <                         serv_connect_callback, client_p, conf->aftype,
490 >                         server_connect_callback, client_p, conf->aftype,
491                           CONNECTTIMEOUT);
492        }
493        else
494 <        comm_connect_tcp(&client_p->connection->fd, conf->host, conf->port,
495 <                         NULL, 0, serv_connect_callback, client_p, conf->aftype,
494 >        comm_connect_tcp(client_p->connection->fd, conf->host, conf->port,
495 >                         NULL, 0, server_connect_callback, client_p, conf->aftype,
496                           CONNECTTIMEOUT);
497        break;
498      case AF_INET6:
# Line 650 | Line 501 | serv_connect(struct MaskItem *conf, stru
501          struct sockaddr_in6 *v6;
502          struct sockaddr_in6 *v6conf;
503  
504 <        memset(&ipn, 0, sizeof(struct irc_ssaddr));
504 >        memset(&ipn, 0, sizeof(ipn));
505          v6conf = (struct sockaddr_in6 *)&conf->bind;
506          v6 = (struct sockaddr_in6 *)&ipn;
507  
508          if (memcmp(&v6conf->sin6_addr, &v6->sin6_addr, sizeof(struct in6_addr)))
509          {
510 <          memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr));
510 >          memcpy(&ipn, &conf->bind, sizeof(ipn));
511            ipn.ss.ss_family = AF_INET6;
512            ipn.ss_port = 0;
513 <          comm_connect_tcp(&client_p->connection->fd,
513 >
514 >          comm_connect_tcp(client_p->connection->fd,
515                             conf->host, conf->port,
516                             (struct sockaddr *)&ipn, ipn.ss_len,
517 <                           serv_connect_callback, client_p,
517 >                           server_connect_callback, client_p,
518                             conf->aftype, CONNECTTIMEOUT);
519          }
520          else if (ConfigServerInfo.specific_ipv6_vhost)
521          {
522 <          memcpy(&ipn, &ConfigServerInfo.ip6, sizeof(struct irc_ssaddr));
522 >          memcpy(&ipn, &ConfigServerInfo.ip6, sizeof(ipn));
523            ipn.ss.ss_family = AF_INET6;
524            ipn.ss_port = 0;
525 <          comm_connect_tcp(&client_p->connection->fd,
525 >
526 >          comm_connect_tcp(client_p->connection->fd,
527                             conf->host, conf->port,
528                             (struct sockaddr *)&ipn, ipn.ss_len,
529 <                           serv_connect_callback, client_p,
529 >                           server_connect_callback, client_p,
530                             conf->aftype, CONNECTTIMEOUT);
531          }
532          else
533 <          comm_connect_tcp(&client_p->connection->fd,
533 >          comm_connect_tcp(client_p->connection->fd,
534                             conf->host, conf->port,
535 <                           NULL, 0, serv_connect_callback, client_p,
535 >                           NULL, 0, server_connect_callback, client_p,
536                             conf->aftype, CONNECTTIMEOUT);
537        }
538    }
539  
540 +  /*
541 +   * At this point we have a connection in progress and a connect {} block
542 +   * attached to the client, the socket info should be saved in the client
543 +   * and it should either be resolved or have a valid address.
544 +   *
545 +   * The socket has been connected or connect is in progress.
546 +   */
547    return 1;
548   }
549  
550   static void
551 < finish_ssl_server_handshake(struct Client *client_p)
551 > server_finish_tls_handshake(struct Client *client_p)
552   {
553    const struct MaskItem *conf = find_conf_name(&client_p->connection->confs,
554                                                  client_p->name, CONF_SERVER);
# Line 705 | Line 565 | finish_ssl_server_handshake(struct Clien
565  
566    sendto_one(client_p, "PASS %s TS %u %s", conf->spasswd, TS_CURRENT, me.id);
567  
568 <  sendto_one(client_p, "CAPAB :%s", get_capabilities(NULL));
568 >  sendto_one(client_p, "CAPAB :%s", capab_get(NULL));
569  
570    sendto_one(client_p, "SERVER %s 1 :%s%s",
571               me.name, ConfigServerHide.hidden ? "(H) " : "",
572               me.info);
573  
714  /*
715   * If we've been marked dead because a send failed, just exit
716   * here now and save everyone the trouble of us ever existing.
717   */
718  if (IsDead(client_p))
719  {
720    sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
721                         "%s went dead during handshake", client_get_name(client_p, SHOW_IP));
722    sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
723                         "%s went dead during handshake", client_get_name(client_p, MASK_IP));
724    return;
725  }
726
727  /* don't move to serv_list yet -- we haven't sent a burst! */
574    /* If we get here, we're ok, so lets start reading some data */
575 <  comm_setselect(&client_p->connection->fd, COMM_SELECT_READ, read_packet, client_p, 0);
575 >  read_packet(client_p->connection->fd, client_p);
576   }
577  
578   static void
579 < ssl_server_handshake(fde_t *fd, void *data)
579 > server_tls_handshake(fde_t *F, void *data)
580   {
581    struct Client *client_p = data;
582    const char *sslerr = NULL;
583  
584 <  tls_handshake_status_t ret = tls_handshake(&client_p->connection->fd.ssl, TLS_ROLE_CLIENT, &sslerr);
584 >  assert(client_p);
585 >  assert(client_p->connection);
586 >  assert(client_p->connection->fd);
587 >  assert(client_p->connection->fd == F);
588 >
589 >  tls_handshake_status_t ret = tls_handshake(&F->ssl, TLS_ROLE_CLIENT, &sslerr);
590    if (ret != TLS_HANDSHAKE_DONE)
591    {
592      if ((CurrentTime - client_p->connection->firsttime) > CONNECTTIMEOUT)
# Line 747 | Line 598 | ssl_server_handshake(fde_t *fd, void *da
598      switch (ret)
599      {
600        case TLS_HANDSHAKE_WANT_WRITE:
601 <        comm_setselect(&client_p->connection->fd, COMM_SELECT_WRITE,
602 <                       ssl_server_handshake, client_p, CONNECTTIMEOUT);
601 >        comm_setselect(F, COMM_SELECT_WRITE,
602 >                       server_tls_handshake, client_p, CONNECTTIMEOUT);
603          return;
604        case TLS_HANDSHAKE_WANT_READ:
605 <        comm_setselect(&client_p->connection->fd, COMM_SELECT_READ,
606 <                       ssl_server_handshake, client_p, CONNECTTIMEOUT);
605 >        comm_setselect(F, COMM_SELECT_READ,
606 >                       server_tls_handshake, client_p, CONNECTTIMEOUT);
607          return;
608        default:
609        {
# Line 765 | Line 616 | ssl_server_handshake(fde_t *fd, void *da
616      }
617    }
618  
619 <  comm_settimeout(&client_p->connection->fd, 0, NULL, NULL);
619 >  comm_settimeout(F, 0, NULL, NULL);
620  
621 <  if (!tls_verify_cert(&client_p->connection->fd.ssl, ConfigServerInfo.message_digest_algorithm, &client_p->certfp))
621 >  if (!tls_verify_cert(&F->ssl, ConfigServerInfo.message_digest_algorithm, &client_p->certfp))
622      ilog(LOG_TYPE_IRCD, "Server %s!%s@%s gave bad TLS client certificate",
623           client_p->name, client_p->username, client_p->host);
624  
625 <  finish_ssl_server_handshake(client_p);
625 >  server_finish_tls_handshake(client_p);
626   }
627  
628   static void
629 < ssl_connect_init(struct Client *client_p, const struct MaskItem *conf, fde_t *fd)
629 > server_tls_connect_init(struct Client *client_p, const struct MaskItem *conf, fde_t *F)
630   {
631 <  if (!tls_new(&client_p->connection->fd.ssl, fd->fd, TLS_ROLE_CLIENT))
631 >  assert(client_p);
632 >  assert(client_p->connection);
633 >  assert(client_p->connection->fd);
634 >  assert(client_p->connection->fd == F);
635 >
636 >  if (!tls_new(&F->ssl, F->fd, TLS_ROLE_CLIENT))
637    {
638      SetDead(client_p);
639      exit_client(client_p, "TLS context initialization failed");
# Line 785 | Line 641 | ssl_connect_init(struct Client *client_p
641    }
642  
643    if (!EmptyString(conf->cipher_list))
644 <    tls_set_ciphers(&client_p->connection->fd.ssl, conf->cipher_list);
644 >    tls_set_ciphers(&F->ssl, conf->cipher_list);
645  
646 <  ssl_server_handshake(NULL, client_p);
646 >  server_tls_handshake(F, client_p);
647   }
648  
649 < /* serv_connect_callback() - complete a server connection.
649 > /* server_connect_callback() - complete a server connection.
650   *
651   * This routine is called after the server connection attempt has
652   * completed. If unsucessful, an error is sent to ops and the client
# Line 799 | Line 655 | ssl_connect_init(struct Client *client_p
655   * marked for reading.
656   */
657   static void
658 < serv_connect_callback(fde_t *fd, int status, void *data)
658 > server_connect_callback(fde_t *F, int status, void *data)
659   {
660    struct Client *const client_p = data;
661  
662    /* First, make sure it's a real client! */
663    assert(client_p);
664 <  assert(&client_p->connection->fd == fd);
664 >  assert(client_p->connection);
665 >  assert(client_p->connection->fd);
666 >  assert(client_p->connection->fd == F);
667  
668    /* Next, for backward purposes, record the ip of the server */
669 <  memcpy(&client_p->connection->ip, &fd->connect.hostaddr, sizeof(struct irc_ssaddr));
669 >  memcpy(&client_p->ip, &F->connect.hostaddr, sizeof(client_p->ip));
670  
671    /* Check the status */
672    if (status != COMM_OK)
# Line 849 | Line 707 | serv_connect_callback(fde_t *fd, int sta
707  
708    if (IsConfSSL(conf))
709    {
710 <    ssl_connect_init(client_p, conf, fd);
710 >    server_tls_connect_init(client_p, conf, F);
711      return;
712    }
713  
714    sendto_one(client_p, "PASS %s TS %u %s", conf->spasswd, TS_CURRENT, me.id);
715  
716 <  sendto_one(client_p, "CAPAB :%s", get_capabilities(NULL));
716 >  sendto_one(client_p, "CAPAB :%s", capab_get(NULL));
717  
718    sendto_one(client_p, "SERVER %s 1 :%s%s", me.name,
719               ConfigServerHide.hidden ? "(H) " : "", me.info);
720  
863  /*
864   * If we've been marked dead because a send failed, just exit
865   * here now and save everyone the trouble of us ever existing.
866   */
867  if (IsDead(client_p))
868  {
869    sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
870                         "%s went dead during handshake", client_get_name(client_p, SHOW_IP));
871    sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
872                         "%s went dead during handshake", client_get_name(client_p, MASK_IP));
873    return;
874  }
875
876  /* don't move to serv_list yet -- we haven't sent a burst! */
721    /* If we get here, we're ok, so lets start reading some data */
722 <  comm_setselect(fd, COMM_SELECT_READ, read_packet, client_p, 0);
722 >  read_packet(client_p->connection->fd, client_p);
723   }
724  
725   struct Client *

Diff Legend

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