58 |
|
|
59 |
|
#define MIN_CONN_FREQ 300 |
60 |
|
|
61 |
– |
struct Client *uplink = NULL; |
62 |
– |
|
63 |
– |
|
61 |
|
static dlink_list cap_list = { NULL, NULL, 0 }; |
65 |
– |
static unsigned long freeMask; |
62 |
|
static void server_burst(struct Client *); |
63 |
|
static int fork_server(struct Client *); |
64 |
|
static void burst_all(struct Client *); |
69 |
– |
static void cjoin_all(struct Client *); |
65 |
|
static void send_tb(struct Client *client_p, struct Channel *chptr); |
66 |
|
|
67 |
|
static CNCB serv_connect_callback; |
68 |
|
|
69 |
|
static void start_io(struct Client *); |
70 |
|
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 *); |
71 |
|
|
72 |
|
static SlinkRplHnd slink_error; |
73 |
|
static SlinkRplHnd slink_zipstats; |
250 |
|
|
251 |
|
aconf = (struct AccessItem *)map_to_conf(conf); |
252 |
|
if (aconf->fakename != NULL) |
253 |
< |
return(aconf->fakename); |
253 |
> |
return aconf->fakename; |
254 |
|
else |
255 |
< |
return(me.name); |
255 |
> |
return me.name; |
256 |
|
} |
257 |
|
|
258 |
|
/* |
451 |
|
if (!match(target_p->name, parv[server])) |
452 |
|
parv[server] = target_p->name; |
453 |
|
|
461 |
– |
/* Deal with lazylinks */ |
462 |
– |
client_burst_if_needed(target_p, source_p); |
463 |
– |
|
454 |
|
/* This is a little kludgy but should work... */ |
455 |
|
if (IsClient(source_p) && |
456 |
|
((MyConnect(target_p) && IsCapable(target_p, CAP_TS6)) || |
656 |
|
attach_conf(client_p, conf); |
657 |
|
} |
658 |
|
|
659 |
< |
server_aconf = (struct AccessItem *)map_to_conf(server_conf); |
659 |
> |
server_aconf = map_to_conf(server_conf); |
660 |
|
|
671 |
– |
if (!IsConfLazyLink(server_aconf)) |
672 |
– |
ClearCap(client_p, CAP_LL); |
661 |
|
#ifdef HAVE_LIBZ /* otherwise, clear it unconditionally */ |
662 |
|
if (!IsConfCompressed(server_aconf)) |
663 |
|
#endif |
714 |
|
void |
715 |
|
add_capability(const char *capab_name, int cap_flag, int add_to_default) |
716 |
|
{ |
717 |
< |
struct Capability *cap; |
717 |
> |
struct Capability *cap = MyMalloc(sizeof(*cap)); |
718 |
|
|
731 |
– |
cap = (struct Capability *)MyMalloc(sizeof(*cap)); |
719 |
|
DupString(cap->name, capab_name); |
720 |
|
cap->cap = cap_flag; |
721 |
|
dlinkAdd(cap, &cap->node, &cap_list); |
722 |
+ |
|
723 |
|
if (add_to_default) |
724 |
|
default_server_capabs |= cap_flag; |
725 |
|
} |
896 |
|
|
897 |
|
} |
898 |
|
|
911 |
– |
/* client_burst_if_needed() |
912 |
– |
* |
913 |
– |
* inputs - pointer to server |
914 |
– |
* - pointer to client to add |
915 |
– |
* output - NONE |
916 |
– |
* side effects - If this client is not known by this lazyleaf, send it |
917 |
– |
*/ |
918 |
– |
void |
919 |
– |
client_burst_if_needed(struct Client *client_p, struct Client *target_p) |
920 |
– |
{ |
921 |
– |
if (!ServerInfo.hub) |
922 |
– |
return; |
923 |
– |
if (!MyConnect(client_p)) |
924 |
– |
return; |
925 |
– |
if (!IsCapable(client_p,CAP_LL)) |
926 |
– |
return; |
927 |
– |
|
928 |
– |
if ((target_p->lazyLinkClientExists & client_p->localClient->serverMask) == 0) |
929 |
– |
{ |
930 |
– |
sendnick_TS(client_p, target_p); |
931 |
– |
add_lazylinkclient(client_p,target_p); |
932 |
– |
} |
933 |
– |
} |
934 |
– |
|
899 |
|
/* |
900 |
|
* show_capabilities - show current server capabilities |
901 |
|
* |
1025 |
|
|
1026 |
|
/* Pass my info to the new server |
1027 |
|
* |
1064 |
– |
* If trying to negotiate LazyLinks, pass on CAP_LL |
1028 |
|
* If this is a HUB, pass on CAP_HUB |
1029 |
|
* Pass on ZIP if supported |
1030 |
|
* Pass on TB if supported. |
1032 |
|
*/ |
1033 |
|
|
1034 |
|
send_capabilities(client_p, aconf, (ServerInfo.hub ? CAP_HUB : 0) |
1072 |
– |
| (IsConfLazyLink(aconf) ? CAP_LL : 0) |
1035 |
|
| (IsConfCompressed(aconf) ? CAP_ZIP : 0) |
1036 |
|
| (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), 0); |
1037 |
|
|
1225 |
|
IsHidden(target_p) ? "(H) " : "", target_p->info); |
1226 |
|
} |
1227 |
|
|
1266 |
– |
if ((ServerInfo.hub == 0) && MyConnect(client_p)) |
1267 |
– |
uplink = client_p; |
1268 |
– |
|
1228 |
|
server_burst(client_p); |
1229 |
|
} |
1230 |
|
|
1422 |
|
** -orabidoo |
1423 |
|
*/ |
1424 |
|
|
1425 |
< |
/* On a "lazy link" hubs send nothing. |
1467 |
< |
* Leafs always have to send nicks plus channels |
1468 |
< |
*/ |
1469 |
< |
if (IsCapable(client_p, CAP_LL)) |
1470 |
< |
{ |
1471 |
< |
if (!ServerInfo.hub) |
1472 |
< |
{ |
1473 |
< |
/* burst all our info */ |
1474 |
< |
burst_all(client_p); |
1475 |
< |
|
1476 |
< |
/* Now, ask for channel info on all our current channels */ |
1477 |
< |
cjoin_all(client_p); |
1478 |
< |
} |
1479 |
< |
} |
1480 |
< |
else |
1481 |
< |
{ |
1482 |
< |
burst_all(client_p); |
1483 |
< |
} |
1425 |
> |
burst_all(client_p); |
1426 |
|
|
1427 |
|
/* EOB stuff is now in burst_all */ |
1428 |
|
/* Always send a PING after connect burst is done */ |
1528 |
|
} |
1529 |
|
} |
1530 |
|
|
1589 |
– |
/* cjoin_all() |
1590 |
– |
* |
1591 |
– |
* inputs - server to ask for channel info from |
1592 |
– |
* output - NONE |
1593 |
– |
* side effects - CJOINS for all the leafs known channels is sent |
1594 |
– |
*/ |
1595 |
– |
static void |
1596 |
– |
cjoin_all(struct Client *client_p) |
1597 |
– |
{ |
1598 |
– |
const dlink_node *gptr = NULL; |
1599 |
– |
|
1600 |
– |
DLINK_FOREACH(gptr, global_channel_list.head) |
1601 |
– |
{ |
1602 |
– |
const struct Channel *chptr = gptr->data; |
1603 |
– |
sendto_one(client_p, ":%s CBURST %s", |
1604 |
– |
me.name, chptr->chname); |
1605 |
– |
} |
1606 |
– |
} |
1607 |
– |
|
1608 |
– |
/* burst_channel() |
1609 |
– |
* |
1610 |
– |
* inputs - pointer to server to send sjoins to |
1611 |
– |
* - channel pointer |
1612 |
– |
* output - none |
1613 |
– |
* side effects - All sjoins for channel(s) given by chptr are sent |
1614 |
– |
* for all channel members. ONLY called by hub on |
1615 |
– |
* behalf of a lazylink so client_p is always guarunteed |
1616 |
– |
* to be a LL leaf. |
1617 |
– |
*/ |
1618 |
– |
void |
1619 |
– |
burst_channel(struct Client *client_p, struct Channel *chptr) |
1620 |
– |
{ |
1621 |
– |
burst_ll_members(client_p, chptr); |
1622 |
– |
|
1623 |
– |
send_channel_modes(client_p, chptr); |
1624 |
– |
add_lazylinkchannel(client_p,chptr); |
1625 |
– |
|
1626 |
– |
if (chptr->topic != NULL && chptr->topic_info != NULL) |
1627 |
– |
{ |
1628 |
– |
sendto_one(client_p, ":%s TOPIC %s %s %lu :%s", |
1629 |
– |
me.name, chptr->chname, chptr->topic_info, |
1630 |
– |
(unsigned long)chptr->topic_time, chptr->topic); |
1631 |
– |
} |
1632 |
– |
} |
1633 |
– |
|
1634 |
– |
/* add_lazlinkchannel() |
1635 |
– |
* |
1636 |
– |
* inputs - pointer to directly connected leaf server |
1637 |
– |
* being introduced to this hub |
1638 |
– |
* - pointer to channel structure being introduced |
1639 |
– |
* output - NONE |
1640 |
– |
* side effects - The channel pointed to by chptr is now known |
1641 |
– |
* to be on lazyleaf server given by local_server_p. |
1642 |
– |
* mark that in the bit map and add to the list |
1643 |
– |
* of channels to examine after this newly introduced |
1644 |
– |
* server is squit off. |
1645 |
– |
*/ |
1646 |
– |
static void |
1647 |
– |
add_lazylinkchannel(struct Client *local_server_p, struct Channel *chptr) |
1648 |
– |
{ |
1649 |
– |
assert(MyConnect(local_server_p)); |
1650 |
– |
|
1651 |
– |
chptr->lazyLinkChannelExists |= local_server_p->localClient->serverMask; |
1652 |
– |
dlinkAdd(chptr, make_dlink_node(), &lazylink_channels); |
1653 |
– |
} |
1654 |
– |
|
1655 |
– |
/* add_lazylinkclient() |
1656 |
– |
* |
1657 |
– |
* inputs - pointer to directly connected leaf server |
1658 |
– |
* being introduced to this hub |
1659 |
– |
* - pointer to client being introduced |
1660 |
– |
* output - NONE |
1661 |
– |
* side effects - The client pointed to by client_p is now known |
1662 |
– |
* to be on lazyleaf server given by local_server_p. |
1663 |
– |
* mark that in the bit map and add to the list |
1664 |
– |
* of clients to examine after this newly introduced |
1665 |
– |
* server is squit off. |
1666 |
– |
*/ |
1667 |
– |
void |
1668 |
– |
add_lazylinkclient(struct Client *local_server_p, struct Client *client_p) |
1669 |
– |
{ |
1670 |
– |
assert(MyConnect(local_server_p)); |
1671 |
– |
client_p->lazyLinkClientExists |= local_server_p->localClient->serverMask; |
1672 |
– |
} |
1673 |
– |
|
1674 |
– |
/* remove_lazylink_flags() |
1675 |
– |
* |
1676 |
– |
* inputs - pointer to server quitting |
1677 |
– |
* output - NONE |
1678 |
– |
* side effects - All the channels on the lazylink channel list are examined |
1679 |
– |
* If they hold a bit corresponding to the servermask |
1680 |
– |
* attached to client_p, clear that bit. If this bitmask |
1681 |
– |
* goes to 0, then the channel is no longer known to |
1682 |
– |
* be on any lazylink server, and can be removed from the |
1683 |
– |
* link list. |
1684 |
– |
* |
1685 |
– |
* Similar is done for lazylink clients |
1686 |
– |
* |
1687 |
– |
* This function must be run by the HUB on any exiting |
1688 |
– |
* lazylink leaf server, while the pointer is still valid. |
1689 |
– |
* Hence must be run from client.c in exit_one_client() |
1690 |
– |
* |
1691 |
– |
* The old code scanned all channels, this code only |
1692 |
– |
* scans channels/clients on the lazylink_channels |
1693 |
– |
* lazylink_clients lists. |
1694 |
– |
*/ |
1695 |
– |
void |
1696 |
– |
remove_lazylink_flags(unsigned long mask) |
1697 |
– |
{ |
1698 |
– |
dlink_node *ptr; |
1699 |
– |
dlink_node *next_ptr; |
1700 |
– |
struct Channel *chptr; |
1701 |
– |
struct Client *target_p; |
1702 |
– |
unsigned long clear_mask; |
1703 |
– |
|
1704 |
– |
if (!mask) /* On 0 mask, don't do anything */ |
1705 |
– |
return; |
1706 |
– |
|
1707 |
– |
clear_mask = ~mask; |
1708 |
– |
freeMask |= mask; |
1709 |
– |
|
1710 |
– |
DLINK_FOREACH_SAFE(ptr, next_ptr, lazylink_channels.head) |
1711 |
– |
{ |
1712 |
– |
chptr = ptr->data; |
1713 |
– |
|
1714 |
– |
chptr->lazyLinkChannelExists &= clear_mask; |
1715 |
– |
|
1716 |
– |
if (chptr->lazyLinkChannelExists == 0) |
1717 |
– |
{ |
1718 |
– |
dlinkDelete(ptr, &lazylink_channels); |
1719 |
– |
free_dlink_node(ptr); |
1720 |
– |
} |
1721 |
– |
} |
1722 |
– |
|
1723 |
– |
DLINK_FOREACH(ptr, global_client_list.head) |
1724 |
– |
{ |
1725 |
– |
target_p = ptr->data; |
1726 |
– |
target_p->lazyLinkClientExists &= clear_mask; |
1727 |
– |
} |
1728 |
– |
} |
1729 |
– |
|
1531 |
|
/* burst_members() |
1532 |
|
* |
1533 |
|
* inputs - pointer to server to send members to |
1557 |
|
} |
1558 |
|
} |
1559 |
|
|
1759 |
– |
/* burst_ll_members() |
1760 |
– |
* |
1761 |
– |
* inputs - pointer to server to send members to |
1762 |
– |
* - dlink_list pointer to membership list to send |
1763 |
– |
* output - NONE |
1764 |
– |
* side effects - This version also has to check the bitmap for lazylink |
1765 |
– |
*/ |
1766 |
– |
static void |
1767 |
– |
burst_ll_members(struct Client *client_p, struct Channel *chptr) |
1768 |
– |
{ |
1769 |
– |
struct Client *target_p; |
1770 |
– |
struct Membership *ms; |
1771 |
– |
dlink_node *ptr; |
1772 |
– |
|
1773 |
– |
DLINK_FOREACH(ptr, chptr->members.head) |
1774 |
– |
{ |
1775 |
– |
ms = ptr->data; |
1776 |
– |
target_p = ms->client_p; |
1777 |
– |
|
1778 |
– |
if ((target_p->lazyLinkClientExists & client_p->localClient->serverMask) == 0) |
1779 |
– |
{ |
1780 |
– |
if (target_p->from != client_p) |
1781 |
– |
{ |
1782 |
– |
add_lazylinkclient(client_p,target_p); |
1783 |
– |
sendnick_TS(client_p, target_p); |
1784 |
– |
} |
1785 |
– |
} |
1786 |
– |
} |
1787 |
– |
} |
1788 |
– |
|
1560 |
|
/* set_autoconn() |
1561 |
|
* |
1562 |
|
* inputs - struct Client pointer to oper requesting change |
1600 |
|
} |
1601 |
|
} |
1602 |
|
|
1832 |
– |
void |
1833 |
– |
initServerMask(void) |
1834 |
– |
{ |
1835 |
– |
freeMask = 0xFFFFFFFFUL; |
1836 |
– |
} |
1837 |
– |
|
1838 |
– |
/* nextFreeMask() |
1839 |
– |
* |
1840 |
– |
* inputs - NONE |
1841 |
– |
* output - unsigned long next unused mask for use in LL |
1842 |
– |
* side effects - |
1843 |
– |
*/ |
1844 |
– |
unsigned long |
1845 |
– |
nextFreeMask(void) |
1846 |
– |
{ |
1847 |
– |
int i; |
1848 |
– |
unsigned long mask = 1; |
1849 |
– |
|
1850 |
– |
for (i = 0; i < 32; i++) |
1851 |
– |
{ |
1852 |
– |
if (mask & freeMask) |
1853 |
– |
{ |
1854 |
– |
freeMask &= ~mask; |
1855 |
– |
return(mask); |
1856 |
– |
} |
1857 |
– |
|
1858 |
– |
mask <<= 1; |
1859 |
– |
} |
1860 |
– |
|
1861 |
– |
return(0L); /* watch this special case ... */ |
1862 |
– |
} |
1863 |
– |
|
1603 |
|
/* New server connection code |
1604 |
|
* Based upon the stuff floating about in s_bsd.c |
1605 |
|
* -- adrian |
1899 |
|
|
1900 |
|
/* Pass my info to the new server |
1901 |
|
* |
2163 |
– |
* If trying to negotiate LazyLinks, pass on CAP_LL |
1902 |
|
* If this is a HUB, pass on CAP_HUB |
1903 |
|
* Pass on ZIP if supported |
1904 |
|
* Pass on TB if supported. |
1905 |
|
* - Dianora |
1906 |
|
*/ |
1907 |
|
send_capabilities(client_p, aconf, (ServerInfo.hub ? CAP_HUB : 0) |
2170 |
– |
| (IsConfLazyLink(aconf) ? CAP_LL : 0) |
1908 |
|
| (IsConfCompressed(aconf) ? CAP_ZIP : 0) |
1909 |
|
| (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), 0); |
1910 |
|
|
2015 |
|
} |
2016 |
|
|
2017 |
|
send_capabilities(client_p, aconf, (ServerInfo.hub ? CAP_HUB : 0) |
2281 |
– |
| (IsConfLazyLink(aconf) ? CAP_LL : 0) |
2018 |
|
| (IsConfCompressed(aconf) ? CAP_ZIP : 0) |
2019 |
|
| (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), CAP_ENC_MASK); |
2020 |
|
|