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 7274 by michael, Sat Feb 6 20:55:49 2016 UTC vs.
Revision 7687 by michael, Thu Aug 18 17:32:22 2016 UTC

# Line 33 | Line 33
33   #include "ircd.h"
34   #include "ircd_defs.h"
35   #include "s_bsd.h"
36 #include "numeric.h"
36   #include "packet.h"
37   #include "conf.h"
38   #include "server.h"
39   #include "log.h"
41 #include "user.h"
40   #include "send.h"
41   #include "memory.h"
44 #include "channel.h"
42   #include "parse.h"
43  
44  
# Line 255 | Line 252 | try_connections(void *unused)
252    if (GlobalSetOptions.autoconn == 0)
253      return;
254  
255 <  DLINK_FOREACH(node, server_items.head)
255 >  DLINK_FOREACH(node, connect_items.head)
256    {
257      struct MaskItem *conf = node->data;
258  
# Line 291 | Line 288 | try_connections(void *unused)
288        /* Move this entry to the end of the list, if not already last */
289        if (node->next)
290        {
291 <        dlinkDelete(node, &server_items);
292 <        dlinkAddTail(conf, &conf->node, &server_items);
291 >        dlinkDelete(node, &connect_items);
292 >        dlinkAddTail(conf, &conf->node, &connect_items);
293        }
294  
295        if (find_servconn_in_progress(conf->name))
# Line 345 | Line 342 | int
342   check_server(const char *name, struct Client *client_p)
343   {
344    dlink_node *node = NULL;
348  struct MaskItem *conf        = NULL;
345    struct MaskItem *server_conf = NULL;
346    int error = -1;
347  
348    assert(client_p);
349  
350    /* Loop through looking for all possible connect items that might work */
351 <  DLINK_FOREACH(node, server_items.head)
351 >  DLINK_FOREACH(node, connect_items.head)
352    {
353 <    conf = node->data;
353 >    struct MaskItem *conf = node->data;
354  
355 <    if (match(name, conf->name))
355 >    if (irccmp(name, conf->name))
356        continue;
357  
358      error = -3;
359  
360 <    if (!match(conf->host, client_p->host) ||
361 <        !match(conf->host, client_p->sockhost))
360 >    if (!irccmp(conf->host, client_p->host) ||
361 >        !irccmp(conf->host, client_p->sockhost))
362      {
363        error = -2;
364  
# Line 405 | Line 401 | check_server(const char *name, struct Cl
401    return 0;
402   }
403  
404 + /* server_capab_init()
405 + *
406 + * inputs       - none
407 + * output       - none
408 + */
409 + void
410 + server_capab_init(void)
411 + {
412 +  add_capability("QS", CAPAB_QS);
413 +  add_capability("EOB", CAPAB_EOB);
414 +  add_capability("CLUSTER", CAPAB_CLUSTER);
415 +  add_capability("SVS", CAPAB_SVS);
416 +  add_capability("CHW", CAPAB_CHW);
417 +  add_capability("HOPS", CAPAB_HOPS);
418 + }
419 +
420   /* add_capability()
421   *
422   * inputs       - string name of CAPAB
# Line 458 | Line 470 | delete_capability(const char *name)
470   unsigned int
471   find_capability(const char *name)
472   {
473 <  const dlink_node *node = NULL;
473 >  dlink_node *node;
474  
475    DLINK_FOREACH(node, server_capabilities_list.head)
476    {
# Line 471 | Line 483 | find_capability(const char *name)
483    return 0;
484   }
485  
474 /* send_capabilities()
475 *
476 * inputs       - Client pointer to send to
477 *              - int flag of capabilities that this server can send
478 * output       - NONE
479 * side effects - send the CAPAB line to a server  -orabidoo
480 *
481 */
482 void
483 send_capabilities(struct Client *client_p)
484 {
485  char buf[IRCD_BUFSIZE] = "";
486  const dlink_node *node = NULL;
487
488  DLINK_FOREACH(node, server_capabilities_list.head)
489  {
490    const struct Capability *cap = node->data;
491
492    strlcat(buf, cap->name, sizeof(buf));
493
494    if (node->next)
495      strlcat(buf, " ", sizeof(buf));
496  }
497
498  sendto_one(client_p, "CAPAB :%s", buf);
499 }
500
486   /*
487   * show_capabilities - show current server capabilities
488   *
# Line 506 | Line 491 | send_capabilities(struct Client *client_
491   * side effects - build up string representing capabilities of server listed
492   */
493   const char *
494 < show_capabilities(const struct Client *target_p)
494 > get_capabilities(const struct Client *client_p)
495   {
496 <  static char msgbuf[IRCD_BUFSIZE] = "";
497 <  const dlink_node *node = NULL;
496 >  static char buf[IRCD_BUFSIZE] = "";
497 >  dlink_node *node;
498  
499 <  strlcpy(msgbuf, "TS", sizeof(msgbuf));
499 >  buf[0] = '\0';
500  
501    DLINK_FOREACH(node, server_capabilities_list.head)
502    {
503      const struct Capability *cap = node->data;
504  
505 <    if (!IsCapable(target_p, cap->cap))
505 >    if (client_p && !IsCapable(client_p, cap->cap))
506        continue;
507  
508 <    strlcat(msgbuf,       " ", sizeof(msgbuf));
509 <    strlcat(msgbuf, cap->name, sizeof(msgbuf));
508 >    strlcat(buf, cap->name, sizeof(buf));
509 >
510 >    if (node->next)
511 >      strlcat(buf, " ", sizeof(buf));
512    }
513  
514 <  return msgbuf;
514 >  return buf;
515   }
516  
517   /* make_server()
# Line 757 | Line 744 | serv_connect(struct MaskItem *conf, stru
744   static void
745   finish_ssl_server_handshake(struct Client *client_p)
746   {
747 <  struct MaskItem *conf = NULL;
748 <
749 <  conf = find_conf_name(&client_p->connection->confs,
763 <                        client_p->name, CONF_SERVER);
764 <  if (conf == NULL)
747 >  const struct MaskItem *conf = find_conf_name(&client_p->connection->confs,
748 >                                                client_p->name, CONF_SERVER);
749 >  if (!conf)
750    {
751      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
752                           "Lost connect{} block for %s", get_client_name(client_p, SHOW_IP));
# Line 772 | Line 757 | finish_ssl_server_handshake(struct Clien
757      return;
758    }
759  
760 <  sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id);
760 >  sendto_one(client_p, "PASS %s TS %u %s", conf->spasswd, TS_CURRENT, me.id);
761  
762 <  send_capabilities(client_p);
762 >  sendto_one(client_p, "CAPAB :%s", get_capabilities(NULL));
763  
764    sendto_one(client_p, "SERVER %s 1 :%s%s",
765               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 871 | Line 856 | static void
856   serv_connect_callback(fde_t *fd, int status, void *data)
857   {
858    struct Client *const client_p = data;
874  const struct MaskItem *conf = NULL;
859  
860    /* First, make sure it's a real client! */
861    assert(client_p);
862    assert(&client_p->connection->fd == fd);
863  
864    /* Next, for backward purposes, record the ip of the server */
865 <  memcpy(&client_p->connection->ip, &fd->connect.hostaddr,
882 <         sizeof(struct irc_ssaddr));
865 >  memcpy(&client_p->connection->ip, &fd->connect.hostaddr, sizeof(struct irc_ssaddr));
866  
867    /* Check the status */
868    if (status != COMM_OK)
# Line 901 | Line 884 | serv_connect_callback(fde_t *fd, int sta
884    }
885  
886    /* COMM_OK, so continue the connection procedure */
887 <  /* Get the C/N lines */
888 <  conf = find_conf_name(&client_p->connection->confs,
889 <                        client_p->name, CONF_SERVER);
890 <  if (conf == NULL)
887 >  /* Get the connect {} block */
888 >  const struct MaskItem *conf = find_conf_name(&client_p->connection->confs,
889 >                                                client_p->name, CONF_SERVER);
890 >  if (!conf)
891    {
892      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
893                           "Lost connect{} block for %s", get_client_name(client_p, SHOW_IP));
# Line 924 | Line 907 | serv_connect_callback(fde_t *fd, int sta
907      return;
908    }
909  
910 <  sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id);
910 >  sendto_one(client_p, "PASS %s TS %u %s", conf->spasswd, TS_CURRENT, me.id);
911  
912 <  send_capabilities(client_p);
912 >  sendto_one(client_p, "CAPAB :%s", get_capabilities(NULL));
913  
914    sendto_one(client_p, "SERVER %s 1 :%s%s", me.name,
915               ConfigServerHide.hidden ? "(H) " : "", me.info);
# Line 953 | Line 936 | struct Client *
936   find_servconn_in_progress(const char *name)
937   {
938    dlink_node *ptr;
956  struct Client *cptr;
939  
940    DLINK_FOREACH(ptr, unknown_list.head)
941    {
942 <    cptr = ptr->data;
942 >    struct Client *cptr = ptr->data;
943  
944 <    if (cptr && cptr->name[0])
945 <      if (!match(name, cptr->name))
944 >    if (cptr->name[0])
945 >      if (!irccmp(name, cptr->name))
946          return cptr;
947    }
948  

Comparing ircd-hybrid/trunk/src/server.c (property svn:keywords):
Revision 7274 by michael, Sat Feb 6 20:55:49 2016 UTC vs.
Revision 7687 by michael, Thu Aug 18 17:32:22 2016 UTC

# Line 1 | Line 1
1 < Id Revision
1 > Id

Diff Legend

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