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/s_serv.c (file contents), Revision 3320 by michael, Tue Apr 15 15:58:33 2014 UTC vs.
ircd-hybrid/trunk/src/server.c (file contents), Revision 4113 by michael, Tue Jul 1 16:02:52 2014 UTC

# Line 40 | Line 40
40   #include "numeric.h"
41   #include "packet.h"
42   #include "conf.h"
43 < #include "s_serv.h"
43 > #include "server.h"
44   #include "log.h"
45 < #include "s_user.h"
45 > #include "user.h"
46   #include "send.h"
47   #include "memory.h"
48   #include "channel.h"
# Line 159 | Line 159 | hunt_server(struct Client *source_p, con
159    struct Client *target_p = NULL;
160    struct Client *target_tmp = NULL;
161    dlink_node *ptr;
162  int wilds;
162  
163    /* Assume it's me, if no server */
164    if (parc <= server || EmptyString(parv[server]))
# Line 185 | Line 184 | hunt_server(struct Client *source_p, con
184      if (target_p->from == source_p->from && !MyConnect(target_p))
185        target_p = NULL;
186  
188  wilds = has_wildcards(parv[server]);
189
187    /* Again, if there are no wild cards involved in the server
188     * name, use the hash lookup
189     */
190    if (target_p == NULL)
191    {
192 <    if (!wilds)
192 >    if (!has_wildcards(parv[server]))
193      {
194        if (!(target_p = hash_find_server(parv[server])))
195        {
# Line 258 | Line 255 | void
255   try_connections(void *unused)
256   {
257    dlink_node *ptr = NULL;
258 <  struct MaskItem *conf;
262 <  int confrq;
258 >  int confrq = 0;
259  
260    /* TODO: change this to set active flag to 0 when added to event! --Habeeb */
261    if (GlobalSetOptions.autoconn == 0)
# Line 267 | Line 263 | try_connections(void *unused)
263  
264    DLINK_FOREACH(ptr, server_items.head)
265    {
266 <    conf = ptr->data;
266 >    struct MaskItem *conf = ptr->data;
267  
268      assert(conf->type == CONF_SERVER);
269  
# Line 286 | Line 282 | try_connections(void *unused)
282      if (conf->until > CurrentTime)
283        continue;
284  
285 <    if (conf->class == NULL)
286 <      confrq = DEFAULT_CONNECTFREQUENCY;
287 <    else
288 <    {
289 <      confrq = conf->class->con_freq;
294 <      if (confrq < MIN_CONN_FREQ)
295 <        confrq = MIN_CONN_FREQ;
296 <    }
285 >    assert(conf->class);
286 >
287 >    confrq = conf->class->con_freq;
288 >    if (confrq < MIN_CONN_FREQ)
289 >      confrq = MIN_CONN_FREQ;
290  
291      conf->until = CurrentTime + confrq;
292  
# Line 344 | Line 337 | try_connections(void *unused)
337   int
338   valid_servname(const char *name)
339   {
340 <  unsigned int length = 0;
348 <  unsigned int dots   = 0;
340 >  unsigned int dots = 0;
341    const char *p = name;
342  
343    for (; *p; ++p)
# Line 353 | Line 345 | valid_servname(const char *name)
345      if (!IsServChar(*p))
346        return 0;
347  
356    ++length;
357
348      if (*p == '.')
349        ++dots;
350    }
351  
352 <  return dots && length <= HOSTLEN;
352 >  return dots && (p - name) <= HOSTLEN;
353   }
354  
355   int
# Line 446 | Line 436 | check_server(const char *name, struct Cl
436   void
437   add_capability(const char *capab_name, int cap_flag, int add_to_default)
438   {
439 <  struct Capability *cap = MyMalloc(sizeof(*cap));
439 >  struct Capability *cap = MyCalloc(sizeof(*cap));
440  
441    cap->name = xstrdup(capab_name);
442    cap->cap = cap_flag;
# Line 465 | Line 455 | add_capability(const char *capab_name, i
455   int
456   delete_capability(const char *capab_name)
457   {
458 <  dlink_node *ptr;
469 <  dlink_node *next_ptr;
470 <  struct Capability *cap;
458 >  dlink_node *ptr = NULL, *ptr_next = NULL;
459  
460 <  DLINK_FOREACH_SAFE(ptr, next_ptr, cap_list.head)
460 >  DLINK_FOREACH_SAFE(ptr, ptr_next, cap_list.head)
461    {
462 <    cap = ptr->data;
462 >    struct Capability *cap = ptr->data;
463  
464 <    if (cap->cap != 0)
464 >    if (cap->cap)
465      {
466 <      if (irccmp(cap->name, capab_name) == 0)
466 >      if (!irccmp(cap->name, capab_name))
467        {
468          default_server_capabs &= ~(cap->cap);
469          dlinkDelete(ptr, &cap_list);
# Line 522 | Line 510 | find_capability(const char *capab)
510   void
511   send_capabilities(struct Client *client_p, int cap_can_send)
512   {
513 <  char msgbuf[IRCD_BUFSIZE] = "";
514 <  char *t = msgbuf;
527 <  int tl;
528 <  dlink_node *ptr = NULL;
513 >  char buf[IRCD_BUFSIZE] = "";
514 >  const dlink_node *ptr = NULL;
515  
516    DLINK_FOREACH(ptr, cap_list.head)
517    {
518 <    struct Capability *cap = ptr->data;
518 >    const struct Capability *cap = ptr->data;
519  
520      if (cap->cap & (cap_can_send|default_server_capabs))
521      {
522 <      tl = sprintf(t, "%s ", cap->name);
523 <      t += tl;
522 >      strlcat(buf, cap->name, sizeof(buf));
523 >      if (ptr->next)
524 >        strlcat(buf, " ", sizeof(buf));
525      }
526    }
527  
528 <  *(t - 1) = '\0';
542 <  sendto_one(client_p, "CAPAB :%s", msgbuf);
528 >  sendto_one(client_p, "CAPAB :%s", buf);
529   }
530  
531   /*
# Line 582 | Line 568 | struct Server *
568   make_server(struct Client *client_p)
569   {
570    if (client_p->serv == NULL)
571 <    client_p->serv = MyMalloc(sizeof(struct Server));
571 >    client_p->serv = MyCalloc(sizeof(struct Server));
572  
573    return client_p->serv;
574   }
# Line 670 | Line 656 | serv_connect(struct MaskItem *conf, stru
656    strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost));
657  
658    /* create a socket for the server connection */
659 <  if (comm_open(&client_p->localClient->fd, conf->addr.ss.ss_family,
674 <                SOCK_STREAM, 0, NULL) < 0)
659 >  if (comm_open(&client_p->localClient->fd, conf->addr.ss.ss_family, SOCK_STREAM, 0, NULL) < 0)
660    {
661      /* Eek, failure to create the socket */
662 <    report_error(L_ALL, "opening stream socket to %s: %s",
663 <                 conf->name, errno);
662 >    report_error(L_ALL, "opening stream socket to %s: %s", conf->name, errno);
663 >
664      SetDead(client_p);
665      exit_client(client_p, "Connection failed");
666      return 0;
# Line 715 | Line 700 | serv_connect(struct MaskItem *conf, stru
700  
701    SetConnecting(client_p);
702    dlinkAdd(client_p, &client_p->node, &global_client_list);
703 <  /* from def_fam */
703 >
704    client_p->localClient->aftype = conf->aftype;
705  
706    /* Now, initiate the connection */
# Line 878 | Line 863 | ssl_server_handshake(fde_t *fd, struct C
863    if ((cert = SSL_get_peer_certificate(client_p->localClient->fd.ssl)))
864    {
865      int res = SSL_get_verify_result(client_p->localClient->fd.ssl);
866 <    char buf[EVP_MAX_MD_SIZE * 2 + 1] = { '\0' };
867 <    unsigned char md[EVP_MAX_MD_SIZE] = { '\0' };
866 >    char buf[EVP_MAX_MD_SIZE * 2 + 1] = "";
867 >    unsigned char md[EVP_MAX_MD_SIZE] = "";
868  
869      if (res == X509_V_OK || res == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN ||
870          res == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE ||
871          res == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT)
872      {
873 <      unsigned int i = 0, n = 0;
873 >      unsigned int n = 0;
874  
875        if (X509_digest(cert, EVP_sha256(), md, &n))
876        {
877 <        for (; i < n; ++i)
893 <          snprintf(buf + 2 * i, 3, "%02X", md[i]);
877 >        binary_to_hex(md, buf, n);
878          client_p->certfp = xstrdup(buf);
879        }
880      }

Diff Legend

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