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 1321 by michael, Fri Mar 30 11:23:16 2012 UTC vs.
Revision 1514 by michael, Sun Aug 26 09:11:17 2012 UTC

# Line 81 | 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 101 | Line 101 | write_links_file(void* notused)
101  
102    DLINK_FOREACH(ptr, global_serv_list.head)
103    {
104 <    size_t nbytes = 0;
105 <    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))
108        continue;
109  
110      /* skip hidden servers */
111 <    if (IsHidden(target_p) && !ConfigServerHide.disable_hidden)
111 >    if (IsHidden(target_p))
112        continue;
113  
114      if (target_p->info[0])
# Line 133 | 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 149 | 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 184 | 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))
193 <    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 210 | 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 326 | 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 339 | 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 406 | Line 404 | check_server(const char *name, struct Cl
404  
405    assert(client_p != NULL);
406  
409  if (client_p == NULL)
410    return(error);
411
412  if (strlen(name) > HOSTLEN)
413    return(-4);
414
407    /* loop through looking for all possible connect items that might work */
408    DLINK_FOREACH(ptr, server_items.head)
409    {
# Line 429 | Line 421 | check_server(const char *name, struct Cl
421          match(aconf->host, client_p->sockhost))
422      {
423        error = -2;
432      {
433        /* A NULL password is as good as a bad one */
434        if (EmptyString(client_p->localClient->passwd))
435          return(-2);
436
437        /* code in s_conf.c should not have allowed this to be NULL */
438        if (aconf->passwd == NULL)
439          return(-2);
424  
425 <        if (IsConfEncrypted(aconf))
426 <        {
427 <          if (strcmp(aconf->passwd,
428 <              (const char *)crypt(client_p->localClient->passwd,
445 <                                  aconf->passwd)) == 0)
446 <            server_conf = conf;
447 <        }
448 <        else
449 <        {
450 <          if (strcmp(aconf->passwd, client_p->localClient->passwd) == 0)
451 <            server_conf = conf;
452 <        }
453 <      }
425 >      if (!match_conf_password(client_p->localClient->passwd, aconf))
426 >        return -2;
427 >
428 >      server_conf = conf;
429      }
430    }
431  
# Line 459 | Line 434 | check_server(const char *name, struct Cl
434  
435    attach_conf(client_p, server_conf);
436  
462  /* Now find all leaf or hub config items for this server */
463  DLINK_FOREACH(ptr, hub_items.head)
464  {
465    conf = ptr->data;
466
467    if (!match(name, conf->name))
468      continue;
469    attach_conf(client_p, conf);
470  }
471
472  DLINK_FOREACH(ptr, leaf_items.head)
473  {
474    conf = ptr->data;
475
476    if (!match(name, conf->name))
477      continue;
478    attach_conf(client_p, conf);
479  }
480
437    server_aconf = map_to_conf(server_conf);
438  
439    if (!IsConfTopicBurst(server_aconf))
484  {
485    ClearCap(client_p, CAP_TB);
440      ClearCap(client_p, CAP_TBURST);
487  }
441  
442    if (aconf != NULL)
443    {
# Line 496 | 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 651 | Line 604 | sendnick_TS(struct Client *client_p, str
604      ubuf[1] = '\0';
605    }
606  
654  /* XXX Both of these need to have a :me.name or :mySID!?!?! */
607    if (IsCapable(client_p, CAP_SVS))
608    {
609      if (HasID(target_p) && IsCapable(client_p, CAP_TS6))
# Line 689 | Line 641 | sendnick_TS(struct Client *client_p, str
641                   target_p->servptr->name, target_p->info);
642    }
643  
644 <  if (IsConfAwayBurst((struct AccessItem *)map_to_conf(client_p->serv->sconf)))
645 <    if (!EmptyString(target_p->away))
646 <      sendto_one(client_p, ":%s AWAY :%s", target_p->name,
644 >  if (IsConfAwayBurst((struct AccessItem *)map_to_conf(client_p->localClient->confs.head->data)))
645 >    if (target_p->away[0])
646 >      sendto_one(client_p, ":%s AWAY :%s", ID_or_name(target_p, client_p),
647                   target_p->away);
648  
649   }
# Line 816 | Line 768 | server_estab(struct Client *client_p)
768       */
769  
770      send_capabilities(client_p, aconf,
771 <      (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
771 >      (IsConfTopicBurst(aconf) ? CAP_TBURST : 0));
772  
773      sendto_one(client_p, "SERVER %s 1 :%s%s",
774                 me.name, ConfigServerHide.hidden ? "(H) " : "", me.info);
# Line 915 | Line 867 | server_estab(struct Client *client_p)
867           inpath_ip, show_capabilities(client_p));
868    }
869  
918  client_p->serv->sconf = conf;
919
870    fd_note(&client_p->localClient->fd, "Server: %s", client_p->name);
871  
872    /* Old sendto_serv_but_one() call removed because we now
# Line 1037 | Line 987 | burst_all(struct Client *client_p)
987        burst_members(client_p, chptr);
988        send_channel_modes(client_p, chptr);
989  
990 <      if (IsCapable(client_p, CAP_TBURST) ||
1041 <          IsCapable(client_p, CAP_TB))
990 >      if (IsCapable(client_p, CAP_TBURST))
991          send_tb(client_p, chptr);
992      }
993    }
# Line 1070 | Line 1019 | burst_all(struct Client *client_p)
1019   *              - pointer to channel
1020   * output       - NONE
1021   * side effects - Called on a server burst when
1022 < *                server is CAP_TB|CAP_TBURST capable
1022 > *                server is CAP_TBURST capable
1023   */
1024   static void
1025   send_tb(struct Client *client_p, struct Channel *chptr)
# Line 1089 | Line 1038 | send_tb(struct Client *client_p, struct
1038     * for further information   -Michael
1039     */
1040    if (chptr->topic_time != 0)
1041 <  {
1042 <    if (IsCapable(client_p, CAP_TBURST))
1043 <      sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1044 <                 me.name, (unsigned long)chptr->channelts, chptr->chname,
1045 <                 (unsigned long)chptr->topic_time,
1046 <                 chptr->topic_info,
1098 <                 chptr->topic);
1099 <    else if (IsCapable(client_p, CAP_TB))
1100 <    {
1101 <      if (ConfigChannel.burst_topicwho)
1102 <      {
1103 <        sendto_one(client_p, ":%s TB %s %lu %s :%s",
1104 <                   me.name, chptr->chname,
1105 <                   (unsigned long)chptr->topic_time,
1106 <                   chptr->topic_info, chptr->topic);
1107 <      }
1108 <      else
1109 <      {
1110 <        sendto_one(client_p, ":%s TB %s %lu :%s",
1111 <                   me.name, chptr->chname,
1112 <                   (unsigned long)chptr->topic_time,
1113 <                   chptr->topic);
1114 <      }
1115 <    }
1116 <  }
1041 >    sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1042 >               ID_or_name(&me, client_p),
1043 >               (unsigned long)chptr->channelts, chptr->chname,
1044 >               (unsigned long)chptr->topic_time,
1045 >               chptr->topic_info,
1046 >               chptr->topic);
1047   }
1048  
1049   /* burst_members()
# Line 1171 | Line 1101 | serv_connect(struct AccessItem *aconf, s
1101   {
1102    struct ConfItem *conf;
1103    struct Client *client_p;
1104 <  char buf[HOSTIPLEN];
1104 >  char buf[HOSTIPLEN + 1];
1105  
1106    /* conversion structs */
1107    struct sockaddr_in *v4;
1108    /* Make sure aconf is useful */
1109    assert(aconf != NULL);
1110  
1181  if(aconf == NULL)
1182    return (0);
1183
1111    /* XXX should be passing struct ConfItem in the first place */
1112    conf = unmap_conf_item(aconf);
1113  
1114    /* log */
1115 <  getnameinfo((struct sockaddr *)&aconf->ipnum, aconf->ipnum.ss_len,
1115 >  getnameinfo((struct sockaddr *)&aconf->addr, aconf->addr.ss_len,
1116                buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
1117 <  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", aconf->user, aconf->host,
1117 >  ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", conf->name, aconf->host,
1118         buf);
1119  
1120    /* Still processing a DNS lookup? -> exit */
# Line 1236 | Line 1163 | serv_connect(struct AccessItem *aconf, s
1163    strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost));
1164  
1165    /* create a socket for the server connection */
1166 <  if (comm_open(&client_p->localClient->fd, aconf->ipnum.ss.ss_family,
1166 >  if (comm_open(&client_p->localClient->fd, aconf->addr.ss.ss_family,
1167                  SOCK_STREAM, 0, NULL) < 0)
1168    {
1169      /* Eek, failure to create the socket */
# Line 1291 | Line 1218 | serv_connect(struct AccessItem *aconf, s
1218    switch (aconf->aftype)
1219    {
1220      case AF_INET:
1221 <      v4 = (struct sockaddr_in*)&aconf->my_ipnum;
1221 >      v4 = (struct sockaddr_in*)&aconf->bind;
1222        if (v4->sin_addr.s_addr != 0)
1223        {
1224          struct irc_ssaddr ipn;
1225          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1226          ipn.ss.ss_family = AF_INET;
1227          ipn.ss_port = 0;
1228 <        memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1228 >        memcpy(&ipn, &aconf->bind, sizeof(struct irc_ssaddr));
1229          comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port,
1230                           (struct sockaddr *)&ipn, ipn.ss_len,
1231                           serv_connect_callback, client_p, aconf->aftype,
# Line 1329 | Line 1256 | serv_connect(struct AccessItem *aconf, s
1256          struct sockaddr_in6 *v6conf;
1257  
1258          memset(&ipn, 0, sizeof(struct irc_ssaddr));
1259 <        v6conf = (struct sockaddr_in6 *)&aconf->my_ipnum;
1259 >        v6conf = (struct sockaddr_in6 *)&aconf->bind;
1260          v6 = (struct sockaddr_in6 *)&ipn;
1261  
1262          if (memcmp(&v6conf->sin6_addr, &v6->sin6_addr,
1263                     sizeof(struct in6_addr)) != 0)
1264          {
1265 <          memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr));
1265 >          memcpy(&ipn, &aconf->bind, sizeof(struct irc_ssaddr));
1266            ipn.ss.ss_family = AF_INET6;
1267            ipn.ss_port = 0;
1268            comm_connect_tcp(&client_p->localClient->fd,
# Line 1394 | Line 1321 | finish_ssl_server_handshake(struct Clien
1321                 aconf->spasswd, TS_CURRENT, me.id);
1322  
1323    send_capabilities(client_p, aconf,
1324 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1324 >                   (IsConfTopicBurst(aconf) ? CAP_TBURST : 0));
1325  
1326    sendto_one(client_p, "SERVER %s 1 :%s%s",
1327               me.name, ConfigServerHide.hidden ? "(H) " : "",
# Line 1556 | Line 1483 | serv_connect_callback(fde_t *fd, int sta
1483                 aconf->spasswd, TS_CURRENT, me.id);
1484  
1485    send_capabilities(client_p, aconf,
1486 <                   (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0));
1486 >                   (IsConfTopicBurst(aconf) ? CAP_TBURST : 0));
1487  
1488    sendto_one(client_p, "SERVER %s 1 :%s%s",
1489               me.name, ConfigServerHide.hidden ? "(H) " : "",

Diff Legend

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