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-7.2/src/s_serv.c (file contents):
Revision 34 by lusky, Sun Oct 2 21:05:51 2005 UTC vs.
Revision 1011 by michael, Fri Sep 18 10:14:09 2009 UTC

# Line 27 | Line 27
27   #include <openssl/rsa.h>
28   #include "rsa.h"
29   #endif
30 < #include "tools.h"
30 > #include "list.h"
31   #include "channel.h"
32   #include "channel_mode.h"
33   #include "client.h"
# Line 43 | Line 43
43   #include "ircd_defs.h"
44   #include "s_bsd.h"
45   #include "irc_getnameinfo.h"
46 #include "list.h"
46   #include "numeric.h"
47   #include "packet.h"
48   #include "irc_res.h"
49   #include "s_conf.h"
50   #include "s_serv.h"
51   #include "s_log.h"
53 #include "s_stats.h"
52   #include "s_user.h"
53   #include "send.h"
54   #include "memory.h"
# Line 58 | Line 56
56  
57   #define MIN_CONN_FREQ 300
58  
61 struct Client *uplink  = NULL;
62
63
59   static dlink_list cap_list = { NULL, NULL, 0 };
65 static unsigned long freeMask;
60   static void server_burst(struct Client *);
61   static int fork_server(struct Client *);
62   static void burst_all(struct Client *);
69 static void cjoin_all(struct Client *);
63   static void send_tb(struct Client *client_p, struct Channel *chptr);
64  
65   static CNCB serv_connect_callback;
66  
67   static void start_io(struct Client *);
68   static void burst_members(struct Client *, struct Channel *);
76 static void burst_ll_members(struct Client *, struct Channel *);
77 static void add_lazylinkchannel(struct Client *, struct Channel *);
69  
70   static SlinkRplHnd slink_error;
71   static SlinkRplHnd slink_zipstats;
# Line 135 | Line 126 | slink_zipstats(unsigned int rpl, unsigne
126                 struct Client *server_p)
127   {
128    struct ZipStats zipstats;
129 <  unsigned long in = 0, in_wire = 0, out = 0, out_wire = 0;
129 >  uint64_t in = 0, in_wire = 0, out = 0, out_wire = 0;
130    int i = 0;
131  
132    assert(rpl == SLINKRPL_ZIPSTATS);
# Line 195 | Line 186 | slink_zipstats(unsigned int rpl, unsigne
186    else
187      zipstats.out_ratio = 0;
188  
189 <  memcpy(&server_p->localClient->zipstats, &zipstats, sizeof (struct ZipStats));
189 >  memcpy(&server_p->localClient->zipstats, &zipstats, sizeof(struct ZipStats));
190   }
191  
192   void
193   collect_zipstats(void *unused)
194   {
195 <  dlink_node *ptr;
205 <  struct Client *target_p;
195 >  dlink_node *ptr = NULL;
196  
197    DLINK_FOREACH(ptr, serv_list.head)
198    {
199 <    target_p = ptr->data;
199 >    struct Client *target_p = ptr->data;
200  
201      if (IsCapable(target_p, CAP_ZIP))
202      {
# Line 227 | Line 217 | collect_zipstats(void *unused)
217   struct EncCapability *
218   check_cipher(struct Client *client_p, struct AccessItem *aconf)
219   {
220 <  struct EncCapability *epref;
220 >  struct EncCapability *epref = NULL;
221  
222    /* Use connect{} specific info if available */
223    if (aconf->cipher_preference)
224      epref = aconf->cipher_preference;
225 <  else
225 >  else if (ConfigFileEntry.default_cipher_preference)
226      epref = ConfigFileEntry.default_cipher_preference;
227  
228 <  /* If the server supports the capability in hand, return the matching
228 >  /*
229 >   * If the server supports the capability in hand, return the matching
230     * conf struct.  Otherwise, return NULL (an error).
231     */
232 <  if (IsCapableEnc(client_p, epref->cap))
233 <    return(epref);
232 >  if (epref && IsCapableEnc(client_p, epref->cap))
233 >    return epref;
234  
235 <  return(NULL);
235 >  return NULL;
236   }
237   #endif /* HAVE_LIBCRYPTO */
238  
# Line 256 | Line 247 | my_name_for_link(struct ConfItem *conf)
247  
248    aconf = (struct AccessItem *)map_to_conf(conf);
249    if (aconf->fakename != NULL)
250 <    return(aconf->fakename);
250 >    return aconf->fakename;
251    else
252 <    return(me.name);
252 >    return me.name;
253   }
254  
255   /*
# Line 457 | Line 448 | hunt_server(struct Client *client_p, str
448      if (!match(target_p->name, parv[server]))
449        parv[server] = target_p->name;
450  
460    /* Deal with lazylinks */
461    client_burst_if_needed(target_p, source_p);
462
451      /* This is a little kludgy but should work... */
452      if (IsClient(source_p) &&
453          ((MyConnect(target_p) && IsCapable(target_p, CAP_TS6)) ||
# Line 665 | Line 653 | check_server(const char *name, struct Cl
653      attach_conf(client_p, conf);
654    }
655  
656 <  server_aconf = (struct AccessItem *)map_to_conf(server_conf);
656 >  server_aconf = map_to_conf(server_conf);
657  
670  if (!IsConfLazyLink(server_aconf))
671    ClearCap(client_p, CAP_LL);
658   #ifdef HAVE_LIBZ /* otherwise, clear it unconditionally */
659    if (!IsConfCompressed(server_aconf))
660   #endif
# Line 676 | Line 662 | check_server(const char *name, struct Cl
662    if (!IsConfCryptLink(server_aconf))
663      ClearCap(client_p, CAP_ENC);
664    if (!IsConfTopicBurst(server_aconf))
665 +  {
666      ClearCap(client_p, CAP_TB);
667 +    ClearCap(client_p, CAP_TBURST);
668 +  }
669  
670    /* Don't unset CAP_HUB here even if the server isn't a hub,
671     * it only indicates if the server thinks it's lazylinks are
# Line 722 | Line 711 | check_server(const char *name, struct Cl
711   void
712   add_capability(const char *capab_name, int cap_flag, int add_to_default)
713   {
714 <  struct Capability *cap;
714 >  struct Capability *cap = MyMalloc(sizeof(*cap));
715  
727  cap = (struct Capability *)MyMalloc(sizeof(*cap));
716    DupString(cap->name, capab_name);
717    cap->cap = cap_flag;
718    dlinkAdd(cap, &cap->node, &cap_list);
719 +
720    if (add_to_default)
721      default_server_capabs |= cap_flag;
722   }
# Line 762 | Line 751 | delete_capability(const char *capab_name
751      }
752    }
753  
754 <  return(0);
754 >  return 0;
755   }
756  
757   /*
# Line 775 | Line 764 | delete_capability(const char *capab_name
764   int
765   find_capability(const char *capab)
766   {
767 <  dlink_node *ptr;
779 <  struct Capability *cap;
767 >  const dlink_node *ptr = NULL;
768  
769    DLINK_FOREACH(ptr, cap_list.head)
770    {
771 <    cap = ptr->data;
771 >    const struct Capability *cap = ptr->data;
772  
773 <    if (cap->cap != 0)
774 <    {
787 <      if (irccmp(cap->name, capab) == 0)
788 <        return(cap->cap);
789 <    }
773 >    if (cap->cap && !irccmp(cap->name, capab))
774 >      return cap->cap;
775    }
776 <  return(0);
776 >
777 >  return 0;
778   }
779  
780   /* send_capabilities()
# Line 811 | Line 797 | send_capabilities(struct Client *client_
797    int tl;
798    dlink_node *ptr;
799   #ifdef HAVE_LIBCRYPTO
800 <  struct EncCapability *epref;
800 >  const struct EncCapability *epref = NULL;
801    char *capend;
802    int sent_cipher = 0;
803   #endif
# Line 838 | Line 824 | send_capabilities(struct Client *client_
824      /* use connect{} specific info if available */
825      if (aconf->cipher_preference)
826        epref = aconf->cipher_preference;
827 <    else
827 >    else if (ConfigFileEntry.default_cipher_preference)
828        epref = ConfigFileEntry.default_cipher_preference;
829  
830 <    if ((epref->cap & enc_can_send))
830 >    if (epref && (epref->cap & enc_can_send))
831      {
832        /* Leave the space -- it is removed later. */
833        tl = ircsprintf(t, "%s ", epref->name);
# Line 853 | Line 839 | send_capabilities(struct Client *client_
839        t = capend; /* truncate string before ENC:, below */
840    }
841   #endif
842 <  *(t-1) = '\0';
842 >  *(t - 1) = '\0';
843    sendto_one(client_p, "CAPAB :%s", msgbuf);
844   }
845  
846   /* sendnick_TS()
847   *
848   * inputs       - client (server) to send nick towards
849 < *              - client to send nick for
849 > *          - client to send nick for
850   * output       - NONE
851   * side effects - NICK message is sent towards given client_p
852   */
# Line 885 | Line 871 | sendnick_TS(struct Client *client_p, str
871    if (HasID(target_p) && IsCapable(client_p, CAP_TS6))
872      sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s :%s",
873                 target_p->servptr->id,
874 <               target_p->name, target_p->hopcount + 1,
875 <               (unsigned long) target_p->tsinfo,
876 <               ubuf, target_p->username, target_p->host,
877 <           ((MyClient(target_p)&&!IsIPSpoof(target_p))?target_p->sockhost:"0"),
878 <           target_p->id, target_p->info);
874 >               target_p->name, target_p->hopcount + 1,
875 >               (unsigned long) target_p->tsinfo,
876 >               ubuf, target_p->username, target_p->host,
877 >               (MyClient(target_p) && IsIPSpoof(target_p)) ?
878 >               "0" : target_p->sockhost, target_p->id, target_p->info);
879    else
880      sendto_one(client_p, "NICK %s %d %lu %s %s %s %s :%s",
881                 target_p->name, target_p->hopcount + 1,
882                 (unsigned long) target_p->tsinfo,
883                 ubuf, target_p->username, target_p->host,
884                 target_p->servptr->name, target_p->info);
885 +
886    if (IsConfAwayBurst((struct AccessItem *)map_to_conf(client_p->serv->sconf)))
887      if (!EmptyString(target_p->away))
888        sendto_one(client_p, ":%s AWAY :%s", target_p->name,
# Line 903 | Line 890 | sendnick_TS(struct Client *client_p, str
890  
891   }
892  
906 /* client_burst_if_needed()
907 *
908 * inputs       - pointer to server
909 *              - pointer to client to add
910 * output       - NONE
911 * side effects - If this client is not known by this lazyleaf, send it
912 */
913 void
914 client_burst_if_needed(struct Client *client_p, struct Client *target_p)
915 {
916  if (!ServerInfo.hub)
917    return;
918  if (!MyConnect(client_p))
919    return;
920  if (!IsCapable(client_p,CAP_LL))
921    return;
922
923  if ((target_p->lazyLinkClientExists & client_p->localClient->serverMask) == 0)
924  {
925    sendnick_TS(client_p, target_p);
926    add_lazylinkclient(client_p,target_p);
927  }
928 }
929
893   /*
894   * show_capabilities - show current server capabilities
895   *
# Line 973 | Line 936 | struct Server *
936   make_server(struct Client *client_p)
937   {
938    if (client_p->serv == NULL)
976  {
939      client_p->serv = MyMalloc(sizeof(struct Server));
978    client_p->serv->dep_servers = 1;
979  }
940  
941    return client_p->serv;
942   }
# Line 1029 | Line 989 | server_estab(struct Client *client_p)
989    {
990      if (client_p != serv_list.head->data || serv_list.head->next)
991      {
992 <      ServerStats->is_ref++;
992 >      ++ServerStats.is_ref;
993        sendto_one(client_p, "ERROR :I'm a leaf not a hub");
994        exit_client(client_p, &me, "I'm a leaf");
995        return;
# Line 1056 | Line 1016 | server_estab(struct Client *client_p)
1016  
1017      /* Pass my info to the new server
1018       *
1059     * If trying to negotiate LazyLinks, pass on CAP_LL
1019       * If this is a HUB, pass on CAP_HUB
1020       * Pass on ZIP if supported
1021       * Pass on TB if supported.
1022       * - Dianora
1023       */
1024  
1025 <     send_capabilities(client_p, aconf,
1026 <       (IsConfLazyLink(aconf) ? find_capability("LL") : 0)
1027 <       | (IsConfCompressed(aconf) ? find_capability("ZIP") : 0)
1069 <       | (IsConfTopicBurst(aconf) ? find_capability("TB") : 0)
1070 <       , 0);
1025 >    send_capabilities(client_p, aconf, (ServerInfo.hub ? CAP_HUB : 0)
1026 >      | (IsConfCompressed(aconf) ? CAP_ZIP : 0)
1027 >      | (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), 0);
1028  
1029      /* SERVER is the last command sent before switching to ziplinks.
1030       * We set TCPNODELAY on the socket to make sure it gets sent out
# Line 1140 | Line 1097 | server_estab(struct Client *client_p)
1097    set_chcap_usage_counts(client_p);
1098  
1099    /* Some day, all these lists will be consolidated *sigh* */
1100 <  dlinkAdd(client_p, &client_p->lnode, &me.serv->servers);
1100 >  dlinkAdd(client_p, &client_p->lnode, &me.serv->server_list);
1101  
1102    m = dlinkFind(&unknown_list, client_p);
1103    assert(NULL != m);
# Line 1259 | Line 1216 | server_estab(struct Client *client_p)
1216                   IsHidden(target_p) ? "(H) " : "", target_p->info);
1217    }
1218  
1262  if ((ServerInfo.hub == 0) && MyConnect(client_p))
1263    uplink = client_p;
1264
1219    server_burst(client_p);
1220   }
1221  
# Line 1339 | Line 1293 | start_io(struct Client *server)
1293      memcpy(buf, &block->data[0], block->size);
1294      buf += block->size;
1295    }
1296 +
1297    dbuf_clear(&lserver->buf_recvq);
1298  
1299    /* pass the whole sendq to servlink */
# Line 1351 | Line 1306 | start_io(struct Client *server)
1306      memcpy(buf, &block->data[0], block->size);
1307      buf += block->size;
1308    }
1309 +
1310    dbuf_clear(&lserver->buf_sendq);
1311  
1312    /* start io */
# Line 1457 | Line 1413 | server_burst(struct Client *client_p)
1413    ** -orabidoo
1414    */
1415  
1416 <  /* On a "lazy link" hubs send nothing.
1461 <   * Leafs always have to send nicks plus channels
1462 <   */
1463 <  if (IsCapable(client_p, CAP_LL))
1464 <  {
1465 <    if (!ServerInfo.hub)
1466 <    {
1467 <      /* burst all our info */
1468 <      burst_all(client_p);
1469 <
1470 <      /* Now, ask for channel info on all our current channels */
1471 <      cjoin_all(client_p);
1472 <    }
1473 <  }
1474 <  else
1475 <  {
1476 <    burst_all(client_p);
1477 <  }
1416 >  burst_all(client_p);
1417  
1418    /* EOB stuff is now in burst_all */
1419    /* Always send a PING after connect burst is done */
# Line 1490 | Line 1429 | server_burst(struct Client *client_p)
1429   static void
1430   burst_all(struct Client *client_p)
1431   {
1432 <  struct Client *target_p;
1494 <  struct Channel *chptr;
1495 <  dlink_node *gptr;
1496 <  dlink_node *ptr;
1432 >  dlink_node *ptr = NULL;
1433  
1434 <  DLINK_FOREACH(gptr, global_channel_list.head)
1434 >  DLINK_FOREACH(ptr, global_channel_list.head)
1435    {
1436 <    chptr = gptr->data;
1436 >    struct Channel *chptr = ptr->data;
1437  
1438      if (dlink_list_length(&chptr->members) != 0)
1439      {
1440        burst_members(client_p, chptr);
1441        send_channel_modes(client_p, chptr);
1442 <      if (IsCapable(client_p, CAP_TB))
1442 >
1443 >      if (IsCapable(client_p, CAP_TBURST) ||
1444 >          IsCapable(client_p, CAP_TB))
1445          send_tb(client_p, chptr);
1446      }
1447    }
# Line 1512 | Line 1450 | burst_all(struct Client *client_p)
1450     */
1451    DLINK_FOREACH(ptr, global_client_list.head)
1452    {
1453 <    target_p = ptr->data;
1453 >    struct Client *target_p = ptr->data;
1454  
1455      if (!IsBursted(target_p) && target_p->from != client_p)
1456        sendnick_TS(client_p, target_p);
# Line 1531 | Line 1469 | burst_all(struct Client *client_p)
1469   /*
1470   * send_tb
1471   *
1472 < * inputs       - pointer to Client
1473 < *              - pointer to channel
1536 < * output       - NONE
1537 < * side effects - Called on a server burst when
1538 < *                server is CAP_TB capable
1539 < */
1540 < static void
1541 < send_tb(struct Client *client_p, struct Channel *chptr)
1542 < {
1543 <  if (chptr->topic != NULL && IsCapable(client_p, CAP_TB))
1544 <  {
1545 <    if (ConfigChannel.burst_topicwho)
1546 <    {
1547 <      sendto_one(client_p, ":%s TB %s %lu %s :%s",
1548 <                 me.name, chptr->chname,
1549 <                 (unsigned long)chptr->topic_time,
1550 <                 chptr->topic_info, chptr->topic);
1551 <    }
1552 <    else
1553 <    {
1554 <      sendto_one(client_p, ":%s TB %s %lu :%s",
1555 <                 me.name, chptr->chname,
1556 <                 (unsigned long)chptr->topic_time, chptr->topic);
1557 <    }
1558 <  }
1559 < }
1560 <
1561 < /* cjoin_all()
1562 < *
1563 < * inputs       - server to ask for channel info from
1472 > * inputs       - pointer to Client
1473 > *              - pointer to channel
1474   * output       - NONE
1475 < * side effects - CJOINS for all the leafs known channels is sent
1476 < */
1567 < static void
1568 < cjoin_all(struct Client *client_p)
1569 < {
1570 <  const dlink_node *gptr = NULL;
1571 <
1572 <  DLINK_FOREACH(gptr, global_channel_list.head)
1573 <  {
1574 <    const struct Channel *chptr = gptr->data;
1575 <    sendto_one(client_p, ":%s CBURST %s",
1576 <               me.name, chptr->chname);
1577 <  }
1578 < }
1579 <
1580 < /* burst_channel()
1581 < *
1582 < * inputs       - pointer to server to send sjoins to
1583 < *              - channel pointer
1584 < * output       - none
1585 < * side effects - All sjoins for channel(s) given by chptr are sent
1586 < *                for all channel members. ONLY called by hub on
1587 < *                behalf of a lazylink so client_p is always guarunteed
1588 < *                to be a LL leaf.
1589 < */
1590 < void
1591 < burst_channel(struct Client *client_p, struct Channel *chptr)
1592 < {
1593 <  burst_ll_members(client_p, chptr);
1594 <
1595 <  send_channel_modes(client_p, chptr);
1596 <  add_lazylinkchannel(client_p,chptr);
1597 <
1598 <  if (chptr->topic != NULL && chptr->topic_info != NULL)
1599 <  {
1600 <    sendto_one(client_p, ":%s TOPIC %s %s %lu :%s",
1601 <               me.name, chptr->chname, chptr->topic_info,
1602 <               (unsigned long)chptr->topic_time, chptr->topic);
1603 <  }
1604 < }
1605 <
1606 < /* add_lazlinkchannel()
1607 < *
1608 < * inputs       - pointer to directly connected leaf server
1609 < *                being introduced to this hub
1610 < *              - pointer to channel structure being introduced
1611 < * output       - NONE
1612 < * side effects - The channel pointed to by chptr is now known
1613 < *                to be on lazyleaf server given by local_server_p.
1614 < *                mark that in the bit map and add to the list
1615 < *                of channels to examine after this newly introduced
1616 < *                server is squit off.
1475 > * side effects - Called on a server burst when
1476 > *                server is CAP_TB|CAP_TBURST capable
1477   */
1478   static void
1479 < add_lazylinkchannel(struct Client *local_server_p, struct Channel *chptr)
1620 < {
1621 <  assert(MyConnect(local_server_p));
1622 <
1623 <  chptr->lazyLinkChannelExists |= local_server_p->localClient->serverMask;
1624 <  dlinkAdd(chptr, make_dlink_node(), &lazylink_channels);
1625 < }
1626 <
1627 < /* add_lazylinkclient()
1628 < *
1629 < * inputs       - pointer to directly connected leaf server
1630 < *                being introduced to this hub
1631 < *              - pointer to client being introduced
1632 < * output       - NONE
1633 < * side effects - The client pointed to by client_p is now known
1634 < *                to be on lazyleaf server given by local_server_p.
1635 < *                mark that in the bit map and add to the list
1636 < *                of clients to examine after this newly introduced
1637 < *                server is squit off.
1638 < */
1639 < void
1640 < add_lazylinkclient(struct Client *local_server_p, struct Client *client_p)
1641 < {
1642 <  assert(MyConnect(local_server_p));
1643 <  client_p->lazyLinkClientExists |= local_server_p->localClient->serverMask;
1644 < }
1645 <
1646 < /* remove_lazylink_flags()
1647 < *
1648 < * inputs       - pointer to server quitting
1649 < * output       - NONE
1650 < * side effects - All the channels on the lazylink channel list are examined
1651 < *                If they hold a bit corresponding to the servermask
1652 < *                attached to client_p, clear that bit. If this bitmask
1653 < *                goes to 0, then the channel is no longer known to
1654 < *                be on any lazylink server, and can be removed from the
1655 < *                link list.
1656 < *
1657 < *                Similar is done for lazylink clients
1658 < *
1659 < *                This function must be run by the HUB on any exiting
1660 < *                lazylink leaf server, while the pointer is still valid.
1661 < *                Hence must be run from client.c in exit_one_client()
1662 < *
1663 < *                The old code scanned all channels, this code only
1664 < *                scans channels/clients on the lazylink_channels
1665 < *                lazylink_clients lists.
1666 < */
1667 < void
1668 < remove_lazylink_flags(unsigned long mask)
1479 > send_tb(struct Client *client_p, struct Channel *chptr)
1480   {
1481 <  dlink_node *ptr;
1482 <  dlink_node *next_ptr;
1483 <  struct Channel *chptr;
1484 <  struct Client *target_p;
1485 <  unsigned long clear_mask;
1486 <
1487 <  if (!mask) /* On 0 mask, don't do anything */
1488 <   return;
1489 <
1490 <  clear_mask = ~mask;
1491 <  freeMask |= mask;
1492 <
1493 <  DLINK_FOREACH_SAFE(ptr, next_ptr, lazylink_channels.head)
1481 >  /*
1482 >   * We may also send an empty topic here, but only if topic_time isn't 0,
1483 >   * i.e. if we had a topic that got unset.  This is required for syncing
1484 >   * topics properly.
1485 >   *
1486 >   * Imagine the following scenario: Our downlink introduces a channel
1487 >   * to us with a TS that is equal to ours, but the channel topic on
1488 >   * their side got unset while the servers were in splitmode, which means
1489 >   * their 'topic' is newer.  They simply wanted to unset it, so we have to
1490 >   * deal with it in a more sophisticated fashion instead of just resetting
1491 >   * it to their old topic they had before.  Read m_tburst.c:ms_tburst
1492 >   * for further information   -Michael
1493 >   */
1494 >  if (chptr->topic_time != 0)
1495    {
1496 <    chptr = ptr->data;
1497 <
1498 <    chptr->lazyLinkChannelExists &= clear_mask;
1499 <
1500 <    if (chptr->lazyLinkChannelExists == 0)
1496 >    if (IsCapable(client_p, CAP_TBURST))
1497 >      sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s",
1498 >                 me.name, (unsigned long)chptr->channelts, chptr->chname,
1499 >                 (unsigned long)chptr->topic_time,
1500 >                 chptr->topic_info ? chptr->topic_info : "",
1501 >                 chptr->topic ? chptr->topic : "");
1502 >    else if (IsCapable(client_p, CAP_TB))
1503      {
1504 <      dlinkDelete(ptr, &lazylink_channels);
1505 <      free_dlink_node(ptr);
1504 >      if (ConfigChannel.burst_topicwho)
1505 >      {
1506 >        sendto_one(client_p, ":%s TB %s %lu %s :%s",
1507 >                   me.name, chptr->chname,
1508 >                   (unsigned long)chptr->topic_time,
1509 >                   chptr->topic_info, chptr->topic ? chptr->topic : "");
1510 >      }
1511 >      else
1512 >      {
1513 >        sendto_one(client_p, ":%s TB %s %lu :%s",
1514 >                   me.name, chptr->chname,
1515 >                   (unsigned long)chptr->topic_time,
1516 >                   chptr->topic ? chptr->topic : "");
1517 >      }
1518      }
1519    }
1694
1695  DLINK_FOREACH(ptr, global_client_list.head)
1696  {
1697    target_p = ptr->data;
1698    target_p->lazyLinkClientExists &= clear_mask;
1699  }
1520   }
1521  
1522   /* burst_members()
# Line 1728 | Line 1548 | burst_members(struct Client *client_p, s
1548    }
1549   }
1550  
1731 /* burst_ll_members()
1732 *
1733 * inputs       - pointer to server to send members to
1734 *              - dlink_list pointer to membership list to send
1735 * output       - NONE
1736 * side effects - This version also has to check the bitmap for lazylink
1737 */
1738 static void
1739 burst_ll_members(struct Client *client_p, struct Channel *chptr)
1740 {
1741  struct Client *target_p;
1742  struct Membership *ms;
1743  dlink_node *ptr;
1744
1745  DLINK_FOREACH(ptr, chptr->members.head)
1746  {
1747    ms       = ptr->data;
1748    target_p = ms->client_p;
1749
1750    if ((target_p->lazyLinkClientExists & client_p->localClient->serverMask) == 0)
1751    {
1752      if (target_p->from != client_p)
1753      {
1754        add_lazylinkclient(client_p,target_p);
1755        sendnick_TS(client_p, target_p);
1756      }
1757    }
1758  }
1759 }
1760
1761 /* set_autoconn()
1762 *
1763 * inputs       - struct Client pointer to oper requesting change
1764 * output       - none
1765 * side effects - set autoconnect mode
1766 */
1767 void
1768 set_autoconn(struct Client *source_p, const char *name, int newval)
1769 {
1770  struct ConfItem *conf;
1771  struct AccessItem *aconf;
1772
1773  if (name != NULL)
1774  {
1775    conf = find_exact_name_conf(SERVER_TYPE, name, NULL, NULL);
1776    if (conf != NULL)
1777    {
1778      aconf = (struct AccessItem *)map_to_conf(conf);
1779      if (newval)
1780        SetConfAllowAutoConn(aconf);
1781      else
1782        ClearConfAllowAutoConn(aconf);
1783
1784      sendto_realops_flags(UMODE_ALL, L_ALL,
1785                           "%s has changed AUTOCONN for %s to %i",
1786                           source_p->name, name, newval);
1787      sendto_one(source_p,
1788                 ":%s NOTICE %s :AUTOCONN for %s is now set to %i",
1789                 me.name, source_p->name, name, newval);
1790    }
1791    else
1792    {
1793      sendto_one(source_p, ":%s NOTICE %s :Can't find %s",
1794                 me.name, source_p->name, name);
1795    }
1796  }
1797  else
1798  {
1799    sendto_one(source_p, ":%s NOTICE %s :Please specify a server name!",
1800               me.name, source_p->name);
1801  }
1802 }
1803
1804 void
1805 initServerMask(void)
1806 {
1807  freeMask = 0xFFFFFFFFUL;
1808 }
1809
1810 /* nextFreeMask()
1811 *
1812 * inputs       - NONE
1813 * output       - unsigned long next unused mask for use in LL
1814 * side effects -
1815 */
1816 unsigned long
1817 nextFreeMask(void)
1818 {
1819  int i;
1820  unsigned long mask = 1;
1821
1822  for (i = 0; i < 32; i++)
1823  {
1824    if (mask & freeMask)
1825    {
1826      freeMask &= ~mask;
1827      return(mask);
1828    }
1829
1830    mask <<= 1;
1831  }
1832
1833  return(0L); /* watch this special case ... */
1834 }
1835
1551   /* New server connection code
1552   * Based upon the stuff floating about in s_bsd.c
1553   *   -- adrian
# Line 1879 | Line 1594 | serv_connect(struct AccessItem *aconf, s
1594         buf);
1595  
1596    /* Still processing a DNS lookup? -> exit */
1597 <  if (aconf->dns_query != NULL)
1597 >  if (aconf->dns_pending)
1598    {
1599 <    sendto_realops_flags(UMODE_ALL, L_OPER,
1600 <                         "Error connecting to %s: Error during DNS lookup", conf->name);
1599 >    sendto_realops_flags(UMODE_ALL, L_ALL,
1600 >                         "Error connecting to %s: DNS lookup for connect{} in progress.",
1601 >                         conf->name);
1602 >    return (0);
1603 >  }
1604 >
1605 >  if (aconf->dns_failed)
1606 >  {
1607 >    sendto_realops_flags(UMODE_ALL, L_ALL,
1608 >                         "Error connecting to %s: DNS lookup for connect{} failed.",
1609 >                         conf->name);
1610      return (0);
1611    }
1612  
# Line 2132 | Line 1856 | serv_connect_callback(fde_t *fd, int sta
1856  
1857    /* Pass my info to the new server
1858     *
2135   * If trying to negotiate LazyLinks, pass on CAP_LL
1859     * If this is a HUB, pass on CAP_HUB
1860     * Pass on ZIP if supported
1861     * Pass on TB if supported.
1862     * - Dianora
1863     */
1864 <  send_capabilities(client_p, aconf,
1865 <                    (IsConfLazyLink(aconf) ? find_capability("LL") : 0)
1866 <                    | (IsConfCompressed(aconf) ? find_capability("ZIP") : 0)
2144 <                    | (IsConfTopicBurst(aconf) ? find_capability("TB") : 0)
2145 <                    , 0);
1864 >  send_capabilities(client_p, aconf, (ServerInfo.hub ? CAP_HUB : 0)
1865 >                    | (IsConfCompressed(aconf) ? CAP_ZIP : 0)
1866 >                    | (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), 0);
1867  
1868    sendto_one(client_p, "SERVER %s 1 :%s%s",
1869               my_name_for_link(conf),
# Line 2250 | Line 1971 | cryptlink_init(struct Client *client_p,
1971      return;
1972    }
1973  
1974 <  send_capabilities(client_p, aconf,
1975 <                    (IsConfLazyLink(aconf) ? find_capability("LL") : 0)
1976 <                    | (IsConfCompressed(aconf) ? find_capability("ZIP") : 0)
1977 <                    | (IsConfTopicBurst(aconf) ? find_capability("TB") : 0)
1978 <                    , CAP_ENC_MASK);
1974 >  send_capabilities(client_p, aconf, (ServerInfo.hub ? CAP_HUB : 0)
1975 >                    | (IsConfCompressed(aconf) ? CAP_ZIP : 0)
1976 >                    | (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), CAP_ENC_MASK);
1977 >
1978 >  if (me.id[0])
1979 >    sendto_one(client_p, "PASS . TS %d %s", TS_CURRENT, me.id);
1980  
1981    sendto_one(client_p, "CRYPTLINK SERV %s %s :%s%s",
1982               my_name_for_link(conf), key_to_send,

Diff Legend

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