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-8/src/s_serv.c (file contents):
Revision 1309 by michael, Sun Mar 25 11:24:18 2012 UTC vs.
Revision 1472 by michael, Sun Jul 22 12:03:18 2012 UTC

# 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 82 | Line 81 | write_links_file(void* notused)
81    MessageFileLine *newMessageLine = 0;
82    MessageFile *MessageFileptr;
83    const char *p;
84 <  FBFILE *file;
84 >  FILE *file;
85    char buff[512];
86    dlink_node *ptr;
87  
88    MessageFileptr = &ConfigFileEntry.linksfile;
89  
90 <  if ((file = fbopen(MessageFileptr->fileName, "w")) == NULL)
90 >  if ((file = fopen(MessageFileptr->fileName, "w")) == NULL)
91      return;
92  
93    for (mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr)
# Line 102 | Line 101 | write_links_file(void* notused)
101  
102    DLINK_FOREACH(ptr, global_serv_list.head)
103    {
104 <    size_t nbytes = 0;
106 <    struct Client *target_p = ptr->data;
104 >    const struct Client *target_p = ptr->data;
105  
106      /* skip ourselves, we send ourselves in /links */
107      if (IsMe(target_p))
# Line 134 | Line 132 | write_links_file(void* notused)
132       */
133      assert(strlen(target_p->name) + strlen(me.name) + 6 + strlen(p) <=
134              MESSAGELINELEN);
135 <    ircsprintf(newMessageLine->line, "%s %s :1 %s",
136 <               target_p->name, me.name, p);
135 >    snprintf(newMessageLine->line, sizeof(newMessageLine->line), "%s %s :1 %s",
136 >             target_p->name, me.name, p);
137      newMessageLine->next = NULL;
138  
139      if (MessageFileptr->contentsOfFile)
# Line 150 | Line 148 | write_links_file(void* notused)
148        currentMessageLine = newMessageLine;
149      }
150  
151 <    nbytes = ircsprintf(buff, "%s %s :1 %s\n", target_p->name, me.name, p);
152 <    fbputs(buff, file, nbytes);
151 >    snprintf(buff, sizeof(buff), "%s %s :1 %s\n", target_p->name, me.name, p);
152 >    fputs(buff, file);
153    }
154  
155 <  fbclose(file);
155 >  fclose(file);
156   }
157  
158   /* hunt_server()
# Line 185 | Line 183 | hunt_server(struct Client *client_p, str
183    dlink_node *ptr;
184    int wilds;
185  
186 <  /* Assume it's me, if no server
187 <   */
188 <  if (parc <= server || EmptyString(parv[server]) ||
189 <      match(me.name, parv[server]) ||
190 <      match(parv[server], me.name) ||
191 <      !strcmp(parv[server], me.id))
194 <    return(HUNTED_ISME);
186 >  /* Assume it's me, if no server */
187 >  if (parc <= server || EmptyString(parv[server]))
188 >    return HUNTED_ISME;
189 >
190 >  if (!strcmp(parv[server], me.id) || match(parv[server], me.name))
191 >    return HUNTED_ISME;
192  
193    /* These are to pickup matches that would cause the following
194     * message to go in the wrong direction while doing quick fast
# Line 211 | Line 208 | hunt_server(struct Client *client_p, str
208        target_p = NULL;
209  
210    collapse(parv[server]);
211 <  wilds = (strchr(parv[server], '?') || strchr(parv[server], '*'));
211 >  wilds = has_wildcards(parv[server]);
212  
213    /* Again, if there are no wild cards involved in the server
214     * name, use the hash lookup
# Line 327 | Line 324 | try_connections(void *unused)
324        confrq = DEFAULT_CONNECTFREQUENCY;
325      else
326      {
327 <      confrq = ConFreq(cltmp);
328 <      if (confrq < MIN_CONN_FREQ )
327 >      confrq = cltmp->con_freq;
328 >      if (confrq < MIN_CONN_FREQ)
329          confrq = MIN_CONN_FREQ;
330      }
331  
# Line 340 | Line 337 | try_connections(void *unused)
337      if (hash_find_server(conf->name) != NULL)
338        continue;
339  
340 <    if (CurrUserCount(cltmp) < MaxTotal(cltmp))
340 >    if (cltmp->curr_user_count < cltmp->max_total)
341      {
342        /* Go to the end of the list, if not already last */
343        if (ptr->next != NULL)
# Line 407 | Line 404 | check_server(const char *name, struct Cl
404  
405    assert(client_p != NULL);
406  
410  if (client_p == NULL)
411    return(error);
412
413  if (strlen(name) > HOSTLEN)
414    return(-4);
415
407    /* loop through looking for all possible connect items that might work */
408    DLINK_FOREACH(ptr, server_items.head)
409    {
# Line 430 | Line 421 | check_server(const char *name, struct Cl
421          match(aconf->host, client_p->sockhost))
422      {
423        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);
424  
425 <        if (IsConfEncrypted(aconf))
426 <        {
427 <          if (strcmp(aconf->passwd,
428 <              (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 <      }
425 >      if (!match_conf_password(client_p->localClient->passwd, aconf))
426 >        return -2;
427 >
428 >      server_conf = conf;
429      }
430    }
431  
# Line 460 | Line 434 | check_server(const char *name, struct Cl
434  
435    attach_conf(client_p, server_conf);
436  
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
437    server_aconf = map_to_conf(server_conf);
438  
439    if (!IsConfTopicBurst(server_aconf))
485  {
486    ClearCap(client_p, CAP_TB);
440      ClearCap(client_p, CAP_TBURST);
488  }
441  
442    if (aconf != NULL)
443    {
# Line 497 | Line 449 | check_server(const char *name, struct Cl
449      {
450   #ifdef IPV6
451        case AF_INET6:
452 <        v6 = (struct sockaddr_in6 *)&aconf->ipnum;
452 >        v6 = (struct sockaddr_in6 *)&aconf->addr;
453  
454          if (IN6_IS_ADDR_UNSPECIFIED(&v6->sin6_addr))
455 <          memcpy(&aconf->ipnum, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
455 >          memcpy(&aconf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
456          break;
457   #endif
458        case AF_INET:
459 <        v4 = (struct sockaddr_in *)&aconf->ipnum;
459 >        v4 = (struct sockaddr_in *)&aconf->addr;
460  
461          if (v4->sin_addr.s_addr == INADDR_NONE)
462 <          memcpy(&aconf->ipnum, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
462 >          memcpy(&aconf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr));
463          break;
464      }
465    }
# Line 690 | Line 642 | sendnick_TS(struct Client *client_p, str
642                   target_p->servptr->name, target_p->info);
643    }
644  
645 <  if (IsConfAwayBurst((struct AccessItem *)map_to_conf(client_p->serv->sconf)))
645 >  if (IsConfAwayBurst((struct AccessItem *)map_to_conf(client_p->localClient->confs.head->data)))
646      if (!EmptyString(target_p->away))
647 <      sendto_one(client_p, ":%s AWAY :%s", target_p->name,
647 >      sendto_one(client_p, ":%s AWAY :%s", ID_or_name(target_p, client_p),
648                   target_p->away);
649  
650   }
# Line 817 | Line 769 | server_estab(struct Client *client_p)
769       */
770  
771      send_capabilities(client_p, aconf,
772 <      (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
772 >      (IsConfTopicBurst(aconf) ? CAP_TBURST : 0));
773  
774      sendto_one(client_p, "SERVER %s 1 :%s%s",
775                 me.name, ConfigServerHide.hidden ? "(H) " : "", me.info);
# Line 916 | Line 868 | server_estab(struct Client *client_p)
868           inpath_ip, show_capabilities(client_p));
869    }
870  
919  client_p->serv->sconf = conf;
920
871    fd_note(&client_p->localClient->fd, "Server: %s", client_p->name);
872  
873    /* Old sendto_serv_but_one() call removed because we now
# Line 1038 | Line 988 | burst_all(struct Client *client_p)
988        burst_members(client_p, chptr);
989        send_channel_modes(client_p, chptr);
990  
991 <      if (IsCapable(client_p, CAP_TBURST) ||
1042 <          IsCapable(client_p, CAP_TB))
991 >      if (IsCapable(client_p, CAP_TBURST))
992          send_tb(client_p, chptr);
993      }
994    }
# Line 1071 | Line 1020 | burst_all(struct Client *client_p)
1020   *              - pointer to channel
1021   * output       - NONE
1022   * side effects - Called on a server burst when
1023 < *                server is CAP_TB|CAP_TBURST capable
1023 > *                server is CAP_TBURST capable
1024   */
1025   static void
1026   send_tb(struct Client *client_p, struct Channel *chptr)
# Line 1090 | Line 1039 | send_tb(struct Client *client_p, struct
1039     * for further information   -Michael
1040     */
1041    if (chptr->topic_time != 0)
1042 <  {
1043 <    if (IsCapable(client_p, CAP_TBURST))
1044 <      sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1045 <                 me.name, (unsigned long)chptr->channelts, chptr->chname,
1046 <                 (unsigned long)chptr->topic_time,
1047 <                 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 <  }
1042 >    sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1043 >               ID_or_name(&me, client_p),
1044 >               (unsigned long)chptr->channelts, chptr->chname,
1045 >               (unsigned long)chptr->topic_time,
1046 >               chptr->topic_info,
1047 >               chptr->topic);
1048   }
1049  
1050   /* burst_members()
# Line 1172 | Line 1102 | serv_connect(struct AccessItem *aconf, s
1102   {
1103    struct ConfItem *conf;
1104    struct Client *client_p;
1105 <  char buf[HOSTIPLEN];
1105 >  char buf[HOSTIPLEN + 1];
1106  
1107    /* conversion structs */
1108    struct sockaddr_in *v4;
1109    /* Make sure aconf is useful */
1110    assert(aconf != NULL);
1111  
1182  if(aconf == NULL)
1183    return (0);
1184
1112    /* XXX should be passing struct ConfItem in the first place */
1113    conf = unmap_conf_item(aconf);
1114  
1115    /* log */
1116 <  getnameinfo((struct sockaddr *)&aconf->ipnum, aconf->ipnum.ss_len,
1116 >  getnameinfo((struct sockaddr *)&aconf->addr, aconf->addr.ss_len,
1117                buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
1118 <  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", aconf->user, aconf->host,
1118 >  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", conf->name, aconf->host,
1119         buf);
1120  
1121    /* Still processing a DNS lookup? -> exit */
# Line 1237 | Line 1164 | serv_connect(struct AccessItem *aconf, s
1164    strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost));
1165  
1166    /* create a socket for the server connection */
1167 <  if (comm_open(&client_p->localClient->fd, aconf->ipnum.ss.ss_family,
1167 >  if (comm_open(&client_p->localClient->fd, aconf->addr.ss.ss_family,
1168                  SOCK_STREAM, 0, NULL) < 0)
1169    {
1170      /* Eek, failure to create the socket */
# Line 1292 | Line 1219 | serv_connect(struct AccessItem *aconf, s
1219    switch (aconf->aftype)
1220    {
1221      case AF_INET:
1222 <      v4 = (struct sockaddr_in*)&aconf->my_ipnum;
1222 >      v4 = (struct sockaddr_in*)&aconf->bind;
1223        if (v4->sin_addr.s_addr != 0)
1224        {
1225          struct irc_ssaddr ipn;
1226          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1227          ipn.ss.ss_family = AF_INET;
1228          ipn.ss_port = 0;
1229 <        memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1229 >        memcpy(&ipn, &aconf->bind, sizeof(struct irc_ssaddr));
1230          comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1231                           (struct sockaddr *)&ipn, ipn.ss_len,
1232                           serv_connect_callback, client_p, aconf->aftype,
# Line 1330 | Line 1257 | serv_connect(struct AccessItem *aconf, s
1257          struct sockaddr_in6 *v6conf;
1258  
1259          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1260 <        v6conf = (struct sockaddr_in6 *)&aconf->my_ipnum;
1260 >        v6conf = (struct sockaddr_in6 *)&aconf->bind;
1261          v6 = (struct sockaddr_in6 *)&ipn;
1262  
1263          if (memcmp(&v6conf->sin6_addr, &v6->sin6_addr,
1264                     sizeof(struct in6_addr)) != 0)
1265          {
1266 <          memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1266 >          memcpy(&ipn, &aconf->bind, sizeof(struct irc_ssaddr));
1267            ipn.ss.ss_family = AF_INET6;
1268            ipn.ss_port = 0;
1269            comm_connect_tcp(&client_p->localClient->fd,
# Line 1395 | Line 1322 | finish_ssl_server_handshake(struct Clien
1322                 aconf->spasswd, TS_CURRENT, me.id);
1323  
1324    send_capabilities(client_p, aconf,
1325 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1325 >                   (IsConfTopicBurst(aconf) ? CAP_TBURST : 0));
1326  
1327    sendto_one(client_p, "SERVER %s 1 :%s%s",
1328               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 1557 | Line 1484 | serv_connect_callback(fde_t *fd, int sta
1484                 aconf->spasswd, TS_CURRENT, me.id);
1485  
1486    send_capabilities(client_p, aconf,
1487 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1487 >                   (IsConfTopicBurst(aconf) ? CAP_TBURST : 0));
1488  
1489    sendto_one(client_p, "SERVER %s 1 :%s%s",
1490               me.name, ConfigServerHide.hidden ? "(H) " : "",

Diff Legend

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