| 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" |
| 37 |
|
#include "fdlist.h" |
| 38 |
|
#include "hash.h" |
| 39 |
|
#include "irc_string.h" |
| 40 |
– |
#include "inet_misc.h" |
| 40 |
|
#include "sprintf_irc.h" |
| 41 |
|
#include "ircd.h" |
| 42 |
|
#include "ircd_defs.h" |
| 43 |
|
#include "s_bsd.h" |
| 45 |
– |
#include "irc_getnameinfo.h" |
| 46 |
– |
#include "list.h" |
| 44 |
|
#include "numeric.h" |
| 45 |
|
#include "packet.h" |
| 46 |
|
#include "irc_res.h" |
| 47 |
|
#include "s_conf.h" |
| 48 |
|
#include "s_serv.h" |
| 49 |
|
#include "s_log.h" |
| 53 |
– |
#include "s_stats.h" |
| 50 |
|
#include "s_user.h" |
| 51 |
|
#include "send.h" |
| 52 |
|
#include "memory.h" |
| 54 |
|
|
| 55 |
|
#define MIN_CONN_FREQ 300 |
| 56 |
|
|
| 61 |
– |
struct Client *uplink = NULL; |
| 62 |
– |
|
| 63 |
– |
|
| 57 |
|
static dlink_list cap_list = { NULL, NULL, 0 }; |
| 65 |
– |
static unsigned long freeMask; |
| 58 |
|
static void server_burst(struct Client *); |
| 59 |
|
static int fork_server(struct Client *); |
| 60 |
|
static void burst_all(struct Client *); |
| 69 |
– |
static void cjoin_all(struct Client *); |
| 61 |
|
static void send_tb(struct Client *client_p, struct Channel *chptr); |
| 62 |
|
|
| 63 |
|
static CNCB serv_connect_callback; |
| 64 |
|
|
| 65 |
|
static void start_io(struct Client *); |
| 66 |
|
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 *); |
| 67 |
|
|
| 68 |
|
static SlinkRplHnd slink_error; |
| 69 |
|
static SlinkRplHnd slink_zipstats; |
| 124 |
|
struct Client *server_p) |
| 125 |
|
{ |
| 126 |
|
struct ZipStats zipstats; |
| 127 |
< |
unsigned long in = 0, in_wire = 0, out = 0, out_wire = 0; |
| 127 |
> |
uint64_t in = 0, in_wire = 0, out = 0, out_wire = 0; |
| 128 |
|
int i = 0; |
| 129 |
|
|
| 130 |
|
assert(rpl == SLINKRPL_ZIPSTATS); |
| 184 |
|
else |
| 185 |
|
zipstats.out_ratio = 0; |
| 186 |
|
|
| 187 |
< |
memcpy(&server_p->localClient->zipstats, &zipstats, sizeof (struct ZipStats)); |
| 187 |
> |
memcpy(&server_p->localClient->zipstats, &zipstats, sizeof(struct ZipStats)); |
| 188 |
|
} |
| 189 |
|
|
| 190 |
|
void |
| 191 |
|
collect_zipstats(void *unused) |
| 192 |
|
{ |
| 193 |
< |
dlink_node *ptr; |
| 205 |
< |
struct Client *target_p; |
| 193 |
> |
dlink_node *ptr = NULL; |
| 194 |
|
|
| 195 |
|
DLINK_FOREACH(ptr, serv_list.head) |
| 196 |
|
{ |
| 197 |
< |
target_p = ptr->data; |
| 197 |
> |
struct Client *target_p = ptr->data; |
| 198 |
|
|
| 199 |
|
if (IsCapable(target_p, CAP_ZIP)) |
| 200 |
|
{ |
| 215 |
|
struct EncCapability * |
| 216 |
|
check_cipher(struct Client *client_p, struct AccessItem *aconf) |
| 217 |
|
{ |
| 218 |
< |
struct EncCapability *epref; |
| 218 |
> |
struct EncCapability *epref = NULL; |
| 219 |
|
|
| 220 |
|
/* Use connect{} specific info if available */ |
| 221 |
|
if (aconf->cipher_preference) |
| 222 |
|
epref = aconf->cipher_preference; |
| 223 |
< |
else |
| 223 |
> |
else if (ConfigFileEntry.default_cipher_preference) |
| 224 |
|
epref = ConfigFileEntry.default_cipher_preference; |
| 225 |
|
|
| 226 |
< |
/* If the server supports the capability in hand, return the matching |
| 226 |
> |
/* |
| 227 |
> |
* If the server supports the capability in hand, return the matching |
| 228 |
|
* conf struct. Otherwise, return NULL (an error). |
| 229 |
|
*/ |
| 230 |
< |
if (IsCapableEnc(client_p, epref->cap)) |
| 231 |
< |
return(epref); |
| 230 |
> |
if (epref && IsCapableEnc(client_p, epref->cap)) |
| 231 |
> |
return epref; |
| 232 |
|
|
| 233 |
< |
return(NULL); |
| 233 |
> |
return NULL; |
| 234 |
|
} |
| 235 |
|
#endif /* HAVE_LIBCRYPTO */ |
| 236 |
|
|
| 248 |
– |
/* my_name_for_link() |
| 249 |
– |
* return wildcard name of my server name |
| 250 |
– |
* according to given config entry --Jto |
| 251 |
– |
*/ |
| 252 |
– |
const char * |
| 253 |
– |
my_name_for_link(struct ConfItem *conf) |
| 254 |
– |
{ |
| 255 |
– |
struct AccessItem *aconf; |
| 256 |
– |
|
| 257 |
– |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 258 |
– |
if (aconf->fakename != NULL) |
| 259 |
– |
return(aconf->fakename); |
| 260 |
– |
else |
| 261 |
– |
return(me.name); |
| 262 |
– |
} |
| 263 |
– |
|
| 237 |
|
/* |
| 238 |
|
* write_links_file |
| 239 |
|
* |
| 367 |
|
* non-matching lookups. |
| 368 |
|
*/ |
| 369 |
|
if (MyClient(source_p)) |
| 370 |
< |
target_p = find_client(parv[server]); |
| 370 |
> |
target_p = hash_find_client(parv[server]); |
| 371 |
|
else |
| 372 |
|
target_p = find_person(client_p, parv[server]); |
| 373 |
|
|
| 375 |
|
if (target_p->from == source_p->from && !MyConnect(target_p)) |
| 376 |
|
target_p = NULL; |
| 377 |
|
|
| 378 |
< |
if (target_p == NULL && (target_p = find_server(parv[server]))) |
| 378 |
> |
if (target_p == NULL && (target_p = hash_find_server(parv[server]))) |
| 379 |
|
if (target_p->from == source_p->from && !MyConnect(target_p)) |
| 380 |
|
target_p = NULL; |
| 381 |
|
|
| 389 |
|
{ |
| 390 |
|
if (!wilds) |
| 391 |
|
{ |
| 392 |
< |
if (!(target_p = find_server(parv[server]))) |
| 392 |
> |
if (!(target_p = hash_find_server(parv[server]))) |
| 393 |
|
{ |
| 394 |
|
sendto_one(source_p, form_str(ERR_NOSUCHSERVER), |
| 395 |
|
me.name, parv[0], parv[server]); |
| 430 |
|
if (!match(target_p->name, parv[server])) |
| 431 |
|
parv[server] = target_p->name; |
| 432 |
|
|
| 460 |
– |
/* Deal with lazylinks */ |
| 461 |
– |
client_burst_if_needed(target_p, source_p); |
| 462 |
– |
|
| 433 |
|
/* This is a little kludgy but should work... */ |
| 434 |
|
if (IsClient(source_p) && |
| 435 |
|
((MyConnect(target_p) && IsCapable(target_p, CAP_TS6)) || |
| 473 |
|
DLINK_FOREACH(ptr, server_items.head) |
| 474 |
|
{ |
| 475 |
|
conf = ptr->data; |
| 476 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 476 |
> |
aconf = map_to_conf(conf); |
| 477 |
|
|
| 478 |
|
/* Also when already connecting! (update holdtimes) --SRB |
| 479 |
|
*/ |
| 480 |
< |
if (!(aconf->status & CONF_SERVER) || aconf->port <= 0 || |
| 480 |
> |
if (!(aconf->status & CONF_SERVER) || !aconf->port || |
| 481 |
|
!(IsConfAllowAutoConn(aconf))) |
| 482 |
|
continue; |
| 483 |
|
|
| 484 |
< |
cltmp = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
| 484 |
> |
cltmp = map_to_conf(aconf->class_ptr); |
| 485 |
|
|
| 486 |
|
/* Skip this entry if the use of it is still on hold until |
| 487 |
|
* future. Otherwise handle this entry (and set it on hold |
| 506 |
|
/* Found a CONNECT config with port specified, scan clients |
| 507 |
|
* and see if this server is already connected? |
| 508 |
|
*/ |
| 509 |
< |
if (find_server(conf->name) != NULL) |
| 509 |
> |
if (hash_find_server(conf->name) != NULL) |
| 510 |
|
continue; |
| 511 |
|
|
| 512 |
|
if (CurrUserCount(cltmp) < MaxTotal(cltmp)) |
| 544 |
|
} |
| 545 |
|
|
| 546 |
|
int |
| 547 |
+ |
valid_servname(const char *name) |
| 548 |
+ |
{ |
| 549 |
+ |
unsigned int length = 0; |
| 550 |
+ |
unsigned int dots = 0; |
| 551 |
+ |
const char *p = name; |
| 552 |
+ |
|
| 553 |
+ |
for (; *p; ++p) |
| 554 |
+ |
{ |
| 555 |
+ |
if (!IsServChar(*p)) |
| 556 |
+ |
return 0; |
| 557 |
+ |
|
| 558 |
+ |
++length; |
| 559 |
+ |
|
| 560 |
+ |
if (*p == '.') |
| 561 |
+ |
++dots; |
| 562 |
+ |
} |
| 563 |
+ |
|
| 564 |
+ |
return dots != 0 && length <= HOSTLEN; |
| 565 |
+ |
} |
| 566 |
+ |
|
| 567 |
+ |
int |
| 568 |
|
check_server(const char *name, struct Client *client_p, int cryptlink) |
| 569 |
|
{ |
| 570 |
|
dlink_node *ptr; |
| 586 |
|
DLINK_FOREACH(ptr, server_items.head) |
| 587 |
|
{ |
| 588 |
|
conf = ptr->data; |
| 589 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 589 |
> |
aconf = map_to_conf(conf); |
| 590 |
|
|
| 591 |
|
if (!match(name, conf->name)) |
| 592 |
|
continue; |
| 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 |
|
|
| 670 |
– |
if (!IsConfLazyLink(server_aconf)) |
| 671 |
– |
ClearCap(client_p, CAP_LL); |
| 661 |
|
#ifdef HAVE_LIBZ /* otherwise, clear it unconditionally */ |
| 662 |
|
if (!IsConfCompressed(server_aconf)) |
| 663 |
|
#endif |
| 665 |
|
if (!IsConfCryptLink(server_aconf)) |
| 666 |
|
ClearCap(client_p, CAP_ENC); |
| 667 |
|
if (!IsConfTopicBurst(server_aconf)) |
| 668 |
+ |
{ |
| 669 |
|
ClearCap(client_p, CAP_TB); |
| 670 |
+ |
ClearCap(client_p, CAP_TBURST); |
| 671 |
+ |
} |
| 672 |
|
|
| 681 |
– |
/* Don't unset CAP_HUB here even if the server isn't a hub, |
| 682 |
– |
* it only indicates if the server thinks it's lazylinks are |
| 683 |
– |
* leafs or not.. if you unset it, bad things will happen |
| 684 |
– |
*/ |
| 673 |
|
if (aconf != NULL) |
| 674 |
|
{ |
| 675 |
|
struct sockaddr_in *v4; |
| 710 |
|
void |
| 711 |
|
add_capability(const char *capab_name, int cap_flag, int add_to_default) |
| 712 |
|
{ |
| 713 |
< |
struct Capability *cap; |
| 713 |
> |
struct Capability *cap = MyMalloc(sizeof(*cap)); |
| 714 |
|
|
| 727 |
– |
cap = (struct Capability *)MyMalloc(sizeof(*cap)); |
| 715 |
|
DupString(cap->name, capab_name); |
| 716 |
|
cap->cap = cap_flag; |
| 717 |
|
dlinkAdd(cap, &cap->node, &cap_list); |
| 718 |
+ |
|
| 719 |
|
if (add_to_default) |
| 720 |
|
default_server_capabs |= cap_flag; |
| 721 |
|
} |
| 750 |
|
} |
| 751 |
|
} |
| 752 |
|
|
| 753 |
< |
return(0); |
| 753 |
> |
return 0; |
| 754 |
|
} |
| 755 |
|
|
| 756 |
|
/* |
| 763 |
|
int |
| 764 |
|
find_capability(const char *capab) |
| 765 |
|
{ |
| 766 |
< |
dlink_node *ptr; |
| 779 |
< |
struct Capability *cap; |
| 766 |
> |
const dlink_node *ptr = NULL; |
| 767 |
|
|
| 768 |
|
DLINK_FOREACH(ptr, cap_list.head) |
| 769 |
|
{ |
| 770 |
< |
cap = ptr->data; |
| 770 |
> |
const struct Capability *cap = ptr->data; |
| 771 |
|
|
| 772 |
< |
if (cap->cap != 0) |
| 773 |
< |
{ |
| 787 |
< |
if (irccmp(cap->name, capab) == 0) |
| 788 |
< |
return(cap->cap); |
| 789 |
< |
} |
| 772 |
> |
if (cap->cap && !irccmp(cap->name, capab)) |
| 773 |
> |
return cap->cap; |
| 774 |
|
} |
| 775 |
< |
return(0); |
| 775 |
> |
|
| 776 |
> |
return 0; |
| 777 |
|
} |
| 778 |
|
|
| 779 |
|
/* send_capabilities() |
| 796 |
|
int tl; |
| 797 |
|
dlink_node *ptr; |
| 798 |
|
#ifdef HAVE_LIBCRYPTO |
| 799 |
< |
struct EncCapability *epref; |
| 799 |
> |
const struct EncCapability *epref = NULL; |
| 800 |
|
char *capend; |
| 801 |
|
int sent_cipher = 0; |
| 802 |
|
#endif |
| 823 |
|
/* use connect{} specific info if available */ |
| 824 |
|
if (aconf->cipher_preference) |
| 825 |
|
epref = aconf->cipher_preference; |
| 826 |
< |
else |
| 826 |
> |
else if (ConfigFileEntry.default_cipher_preference) |
| 827 |
|
epref = ConfigFileEntry.default_cipher_preference; |
| 828 |
|
|
| 829 |
< |
if ((epref->cap & enc_can_send)) |
| 829 |
> |
if (epref && (epref->cap & enc_can_send)) |
| 830 |
|
{ |
| 831 |
|
/* Leave the space -- it is removed later. */ |
| 832 |
|
tl = ircsprintf(t, "%s ", epref->name); |
| 838 |
|
t = capend; /* truncate string before ENC:, below */ |
| 839 |
|
} |
| 840 |
|
#endif |
| 841 |
< |
*(t-1) = '\0'; |
| 841 |
> |
*(t - 1) = '\0'; |
| 842 |
|
sendto_one(client_p, "CAPAB :%s", msgbuf); |
| 843 |
|
} |
| 844 |
|
|
| 845 |
|
/* sendnick_TS() |
| 846 |
|
* |
| 847 |
|
* inputs - client (server) to send nick towards |
| 848 |
< |
* - client to send nick for |
| 848 |
> |
* - client to send nick for |
| 849 |
|
* output - NONE |
| 850 |
|
* side effects - NICK message is sent towards given client_p |
| 851 |
|
*/ |
| 867 |
|
} |
| 868 |
|
|
| 869 |
|
/* XXX Both of these need to have a :me.name or :mySID!?!?! */ |
| 870 |
< |
if (HasID(target_p) && IsCapable(client_p, CAP_TS6)) |
| 871 |
< |
sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
| 872 |
< |
target_p->servptr->id, |
| 873 |
< |
target_p->name, target_p->hopcount + 1, |
| 874 |
< |
(unsigned long) target_p->tsinfo, |
| 875 |
< |
ubuf, target_p->username, target_p->host, |
| 876 |
< |
((MyClient(target_p)&&!IsIPSpoof(target_p))?target_p->sockhost:"0"), |
| 877 |
< |
target_p->id, target_p->info); |
| 870 |
> |
if (IsCapable(client_p, CAP_SVS)) |
| 871 |
> |
{ |
| 872 |
> |
if (HasID(target_p) && IsCapable(client_p, CAP_TS6)) |
| 873 |
> |
sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %lu :%s", |
| 874 |
> |
target_p->servptr->id, |
| 875 |
> |
target_p->name, target_p->hopcount + 1, |
| 876 |
> |
(unsigned long) target_p->tsinfo, |
| 877 |
> |
ubuf, target_p->username, target_p->host, |
| 878 |
> |
(MyClient(target_p) && IsIPSpoof(target_p)) ? |
| 879 |
> |
"0" : target_p->sockhost, target_p->id, |
| 880 |
> |
(unsigned long)target_p->servicestamp, target_p->info); |
| 881 |
> |
else |
| 882 |
> |
sendto_one(client_p, "NICK %s %d %lu %s %s %s %s %lu :%s", |
| 883 |
> |
target_p->name, target_p->hopcount + 1, |
| 884 |
> |
(unsigned long) target_p->tsinfo, |
| 885 |
> |
ubuf, target_p->username, target_p->host, |
| 886 |
> |
target_p->servptr->name, (unsigned long)target_p->servicestamp, |
| 887 |
> |
target_p->info); |
| 888 |
> |
} |
| 889 |
|
else |
| 890 |
< |
sendto_one(client_p, "NICK %s %d %lu %s %s %s %s :%s", |
| 891 |
< |
target_p->name, target_p->hopcount + 1, |
| 892 |
< |
(unsigned long) target_p->tsinfo, |
| 893 |
< |
ubuf, target_p->username, target_p->host, |
| 894 |
< |
target_p->servptr->name, target_p->info); |
| 890 |
> |
{ |
| 891 |
> |
if (HasID(target_p) && IsCapable(client_p, CAP_TS6)) |
| 892 |
> |
sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
| 893 |
> |
target_p->servptr->id, |
| 894 |
> |
target_p->name, target_p->hopcount + 1, |
| 895 |
> |
(unsigned long) target_p->tsinfo, |
| 896 |
> |
ubuf, target_p->username, target_p->host, |
| 897 |
> |
(MyClient(target_p) && IsIPSpoof(target_p)) ? |
| 898 |
> |
"0" : target_p->sockhost, target_p->id, target_p->info); |
| 899 |
> |
else |
| 900 |
> |
sendto_one(client_p, "NICK %s %d %lu %s %s %s %s :%s", |
| 901 |
> |
target_p->name, target_p->hopcount + 1, |
| 902 |
> |
(unsigned long) target_p->tsinfo, |
| 903 |
> |
ubuf, target_p->username, target_p->host, |
| 904 |
> |
target_p->servptr->name, target_p->info); |
| 905 |
> |
} |
| 906 |
> |
|
| 907 |
|
if (IsConfAwayBurst((struct AccessItem *)map_to_conf(client_p->serv->sconf))) |
| 908 |
|
if (!EmptyString(target_p->away)) |
| 909 |
|
sendto_one(client_p, ":%s AWAY :%s", target_p->name, |
| 911 |
|
|
| 912 |
|
} |
| 913 |
|
|
| 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 |
– |
|
| 914 |
|
/* |
| 915 |
|
* show_capabilities - show current server capabilities |
| 916 |
|
* |
| 957 |
|
make_server(struct Client *client_p) |
| 958 |
|
{ |
| 959 |
|
if (client_p->serv == NULL) |
| 976 |
– |
{ |
| 960 |
|
client_p->serv = MyMalloc(sizeof(struct Server)); |
| 978 |
– |
client_p->serv->dep_servers = 1; |
| 979 |
– |
} |
| 961 |
|
|
| 962 |
|
return client_p->serv; |
| 963 |
|
} |
| 977 |
|
char *host; |
| 978 |
|
const char *inpath; |
| 979 |
|
static char inpath_ip[HOSTLEN * 2 + USERLEN + 6]; |
| 999 |
– |
dlink_node *m; |
| 980 |
|
dlink_node *ptr; |
| 981 |
|
|
| 982 |
|
assert(client_p != NULL); |
| 1009 |
|
{ |
| 1010 |
|
if (client_p != serv_list.head->data || serv_list.head->next) |
| 1011 |
|
{ |
| 1012 |
< |
ServerStats->is_ref++; |
| 1012 |
> |
++ServerStats.is_ref; |
| 1013 |
|
sendto_one(client_p, "ERROR :I'm a leaf not a hub"); |
| 1014 |
|
exit_client(client_p, &me, "I'm a leaf"); |
| 1015 |
|
return; |
| 1016 |
|
} |
| 1017 |
|
} |
| 1018 |
|
|
| 1019 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 1019 |
> |
aconf = map_to_conf(conf); |
| 1020 |
|
|
| 1021 |
|
if (IsUnknown(client_p) && !IsConfCryptLink(aconf)) |
| 1022 |
|
{ |
| 1024 |
|
* 2. Check aconf->spasswd, not aconf->passwd. |
| 1025 |
|
*/ |
| 1026 |
|
if (!EmptyString(aconf->spasswd)) |
| 1027 |
< |
{ |
| 1028 |
< |
/* only send ts6 format PASS if we have ts6 enabled */ |
| 1049 |
< |
if (me.id[0] != '\0') /* Send TS 6 form only if id */ |
| 1050 |
< |
sendto_one(client_p, "PASS %s TS %d %s", |
| 1051 |
< |
aconf->spasswd, TS_CURRENT, me.id); |
| 1052 |
< |
else |
| 1053 |
< |
sendto_one(client_p, "PASS %s TS 5", |
| 1054 |
< |
aconf->spasswd); |
| 1055 |
< |
} |
| 1027 |
> |
sendto_one(client_p, "PASS %s TS %d %s", |
| 1028 |
> |
aconf->spasswd, TS_CURRENT, me.id); |
| 1029 |
|
|
| 1030 |
|
/* Pass my info to the new server |
| 1031 |
|
* |
| 1059 |
– |
* If trying to negotiate LazyLinks, pass on CAP_LL |
| 1060 |
– |
* If this is a HUB, pass on CAP_HUB |
| 1032 |
|
* Pass on ZIP if supported |
| 1033 |
|
* Pass on TB if supported. |
| 1034 |
|
* - Dianora |
| 1035 |
|
*/ |
| 1036 |
|
|
| 1037 |
< |
send_capabilities(client_p, aconf, |
| 1038 |
< |
(IsConfLazyLink(aconf) ? find_capability("LL") : 0) |
| 1039 |
< |
| (IsConfCompressed(aconf) ? find_capability("ZIP") : 0) |
| 1069 |
< |
| (IsConfTopicBurst(aconf) ? find_capability("TB") : 0) |
| 1070 |
< |
, 0); |
| 1037 |
> |
send_capabilities(client_p, aconf, |
| 1038 |
> |
(IsConfCompressed(aconf) ? CAP_ZIP : 0) |
| 1039 |
> |
| (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), 0); |
| 1040 |
|
|
| 1041 |
|
/* SERVER is the last command sent before switching to ziplinks. |
| 1042 |
|
* We set TCPNODELAY on the socket to make sure it gets sent out |
| 1049 |
|
* Nagle is already disabled at this point --adx |
| 1050 |
|
*/ |
| 1051 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", |
| 1052 |
< |
my_name_for_link(conf), |
| 1084 |
< |
ConfigServerHide.hidden ? "(H) " : "", |
| 1085 |
< |
(me.info[0]) ? (me.info) : "IRCers United"); |
| 1052 |
> |
me.name, ConfigServerHide.hidden ? "(H) " : "", me.info); |
| 1053 |
|
send_queued_write(client_p); |
| 1054 |
|
} |
| 1055 |
|
|
| 1073 |
|
SetServlink(client_p); |
| 1074 |
|
} |
| 1075 |
|
|
| 1076 |
< |
/* only send ts6 format SVINFO if we have ts6 enabled */ |
| 1110 |
< |
sendto_one(client_p, "SVINFO %d %d 0 :%lu", |
| 1111 |
< |
(me.id[0] ? TS_CURRENT : 5), TS_MIN, |
| 1076 |
> |
sendto_one(client_p, "SVINFO %d %d 0 :%lu", TS_CURRENT, TS_MIN, |
| 1077 |
|
(unsigned long)CurrentTime); |
| 1078 |
|
|
| 1079 |
|
/* assumption here is if they passed the correct TS version, they also passed an SID */ |
| 1105 |
|
set_chcap_usage_counts(client_p); |
| 1106 |
|
|
| 1107 |
|
/* Some day, all these lists will be consolidated *sigh* */ |
| 1108 |
< |
dlinkAdd(client_p, &client_p->lnode, &me.serv->servers); |
| 1108 |
> |
dlinkAdd(client_p, &client_p->lnode, &me.serv->server_list); |
| 1109 |
|
|
| 1110 |
< |
m = dlinkFind(&unknown_list, client_p); |
| 1146 |
< |
assert(NULL != m); |
| 1110 |
> |
assert(dlinkFind(&unknown_list, client_p)); |
| 1111 |
|
|
| 1112 |
< |
dlinkDelete(m, &unknown_list); |
| 1113 |
< |
dlinkAdd(client_p, m, &serv_list); |
| 1112 |
> |
dlink_move_node(&client_p->localClient->lclient_node, |
| 1113 |
> |
&unknown_list, &serv_list); |
| 1114 |
|
|
| 1115 |
|
Count.myserver++; |
| 1116 |
|
|
| 1123 |
|
/* fixing eob timings.. -gnp */ |
| 1124 |
|
client_p->firsttime = CurrentTime; |
| 1125 |
|
|
| 1126 |
+ |
|
| 1127 |
+ |
if (find_matching_name_conf(SERVICE_TYPE, client_p->name, NULL, NULL, 0)) |
| 1128 |
+ |
SetService(client_p); |
| 1129 |
+ |
|
| 1130 |
|
/* Show the real host/IP to admins */ |
| 1131 |
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 1132 |
|
"Link with %s established: (%s) link", |
| 1162 |
|
if (target_p == client_p) |
| 1163 |
|
continue; |
| 1164 |
|
|
| 1197 |
– |
if ((conf = target_p->serv->sconf) && |
| 1198 |
– |
match(my_name_for_link(conf), client_p->name)) |
| 1199 |
– |
continue; |
| 1200 |
– |
|
| 1165 |
|
if (IsCapable(target_p, CAP_TS6) && HasID(client_p)) |
| 1166 |
|
sendto_one(target_p, ":%s SID %s 2 %s :%s%s", |
| 1167 |
|
me.id, client_p->name, client_p->id, |
| 1192 |
|
** is destroyed...) |
| 1193 |
|
*/ |
| 1194 |
|
|
| 1231 |
– |
conf = client_p->serv->sconf; |
| 1232 |
– |
|
| 1195 |
|
DLINK_FOREACH_PREV(ptr, global_serv_list.tail) |
| 1196 |
|
{ |
| 1197 |
|
target_p = ptr->data; |
| 1198 |
|
|
| 1199 |
|
/* target_p->from == target_p for target_p == client_p */ |
| 1200 |
< |
if (target_p->from == client_p) |
| 1239 |
< |
continue; |
| 1240 |
< |
|
| 1241 |
< |
if (match(my_name_for_link(conf), target_p->name)) |
| 1200 |
> |
if (IsMe(target_p) || target_p->from == client_p) |
| 1201 |
|
continue; |
| 1202 |
|
|
| 1203 |
|
if (IsCapable(client_p, CAP_TS6)) |
| 1218 |
|
IsHidden(target_p) ? "(H) " : "", target_p->info); |
| 1219 |
|
} |
| 1220 |
|
|
| 1262 |
– |
if ((ServerInfo.hub == 0) && MyConnect(client_p)) |
| 1263 |
– |
uplink = client_p; |
| 1264 |
– |
|
| 1221 |
|
server_burst(client_p); |
| 1222 |
|
} |
| 1223 |
|
|
| 1295 |
|
memcpy(buf, &block->data[0], block->size); |
| 1296 |
|
buf += block->size; |
| 1297 |
|
} |
| 1298 |
+ |
|
| 1299 |
|
dbuf_clear(&lserver->buf_recvq); |
| 1300 |
|
|
| 1301 |
|
/* pass the whole sendq to servlink */ |
| 1308 |
|
memcpy(buf, &block->data[0], block->size); |
| 1309 |
|
buf += block->size; |
| 1310 |
|
} |
| 1311 |
+ |
|
| 1312 |
|
dbuf_clear(&lserver->buf_sendq); |
| 1313 |
|
|
| 1314 |
|
/* start io */ |
| 1415 |
|
** -orabidoo |
| 1416 |
|
*/ |
| 1417 |
|
|
| 1418 |
< |
/* 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 |
< |
} |
| 1418 |
> |
burst_all(client_p); |
| 1419 |
|
|
| 1420 |
|
/* EOB stuff is now in burst_all */ |
| 1421 |
|
/* Always send a PING after connect burst is done */ |
| 1431 |
|
static void |
| 1432 |
|
burst_all(struct Client *client_p) |
| 1433 |
|
{ |
| 1434 |
< |
struct Client *target_p; |
| 1494 |
< |
struct Channel *chptr; |
| 1495 |
< |
dlink_node *gptr; |
| 1496 |
< |
dlink_node *ptr; |
| 1434 |
> |
dlink_node *ptr = NULL; |
| 1435 |
|
|
| 1436 |
< |
DLINK_FOREACH(gptr, global_channel_list.head) |
| 1436 |
> |
DLINK_FOREACH(ptr, global_channel_list.head) |
| 1437 |
|
{ |
| 1438 |
< |
chptr = gptr->data; |
| 1438 |
> |
struct Channel *chptr = ptr->data; |
| 1439 |
|
|
| 1440 |
|
if (dlink_list_length(&chptr->members) != 0) |
| 1441 |
|
{ |
| 1442 |
|
burst_members(client_p, chptr); |
| 1443 |
|
send_channel_modes(client_p, chptr); |
| 1444 |
< |
if (IsCapable(client_p, CAP_TB)) |
| 1444 |
> |
|
| 1445 |
> |
if (IsCapable(client_p, CAP_TBURST) || |
| 1446 |
> |
IsCapable(client_p, CAP_TB)) |
| 1447 |
|
send_tb(client_p, chptr); |
| 1448 |
|
} |
| 1449 |
|
} |
| 1452 |
|
*/ |
| 1453 |
|
DLINK_FOREACH(ptr, global_client_list.head) |
| 1454 |
|
{ |
| 1455 |
< |
target_p = ptr->data; |
| 1455 |
> |
struct Client *target_p = ptr->data; |
| 1456 |
|
|
| 1457 |
|
if (!IsBursted(target_p) && target_p->from != client_p) |
| 1458 |
|
sendnick_TS(client_p, target_p); |
| 1471 |
|
/* |
| 1472 |
|
* send_tb |
| 1473 |
|
* |
| 1474 |
< |
* inputs - pointer to Client |
| 1475 |
< |
* - 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 |
| 1474 |
> |
* inputs - pointer to Client |
| 1475 |
> |
* - pointer to channel |
| 1476 |
|
* output - NONE |
| 1477 |
< |
* side effects - CJOINS for all the leafs known channels is sent |
| 1477 |
> |
* side effects - Called on a server burst when |
| 1478 |
> |
* server is CAP_TB|CAP_TBURST capable |
| 1479 |
|
*/ |
| 1480 |
|
static void |
| 1481 |
< |
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. |
| 1617 |
< |
*/ |
| 1618 |
< |
static void |
| 1619 |
< |
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) |
| 1481 |
> |
send_tb(struct Client *client_p, struct Channel *chptr) |
| 1482 |
|
{ |
| 1483 |
< |
dlink_node *ptr; |
| 1484 |
< |
dlink_node *next_ptr; |
| 1485 |
< |
struct Channel *chptr; |
| 1486 |
< |
struct Client *target_p; |
| 1487 |
< |
unsigned long clear_mask; |
| 1488 |
< |
|
| 1489 |
< |
if (!mask) /* On 0 mask, don't do anything */ |
| 1490 |
< |
return; |
| 1491 |
< |
|
| 1492 |
< |
clear_mask = ~mask; |
| 1493 |
< |
freeMask |= mask; |
| 1494 |
< |
|
| 1495 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, lazylink_channels.head) |
| 1483 |
> |
/* |
| 1484 |
> |
* We may also send an empty topic here, but only if topic_time isn't 0, |
| 1485 |
> |
* i.e. if we had a topic that got unset. This is required for syncing |
| 1486 |
> |
* topics properly. |
| 1487 |
> |
* |
| 1488 |
> |
* Imagine the following scenario: Our downlink introduces a channel |
| 1489 |
> |
* to us with a TS that is equal to ours, but the channel topic on |
| 1490 |
> |
* their side got unset while the servers were in splitmode, which means |
| 1491 |
> |
* their 'topic' is newer. They simply wanted to unset it, so we have to |
| 1492 |
> |
* deal with it in a more sophisticated fashion instead of just resetting |
| 1493 |
> |
* it to their old topic they had before. Read m_tburst.c:ms_tburst |
| 1494 |
> |
* for further information -Michael |
| 1495 |
> |
*/ |
| 1496 |
> |
if (chptr->topic_time != 0) |
| 1497 |
|
{ |
| 1498 |
< |
chptr = ptr->data; |
| 1499 |
< |
|
| 1500 |
< |
chptr->lazyLinkChannelExists &= clear_mask; |
| 1501 |
< |
|
| 1502 |
< |
if (chptr->lazyLinkChannelExists == 0) |
| 1498 |
> |
if (IsCapable(client_p, CAP_TBURST)) |
| 1499 |
> |
sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s", |
| 1500 |
> |
me.name, (unsigned long)chptr->channelts, chptr->chname, |
| 1501 |
> |
(unsigned long)chptr->topic_time, |
| 1502 |
> |
chptr->topic_info ? chptr->topic_info : "", |
| 1503 |
> |
chptr->topic ? chptr->topic : ""); |
| 1504 |
> |
else if (IsCapable(client_p, CAP_TB)) |
| 1505 |
|
{ |
| 1506 |
< |
dlinkDelete(ptr, &lazylink_channels); |
| 1507 |
< |
free_dlink_node(ptr); |
| 1506 |
> |
if (ConfigChannel.burst_topicwho) |
| 1507 |
> |
{ |
| 1508 |
> |
sendto_one(client_p, ":%s TB %s %lu %s :%s", |
| 1509 |
> |
me.name, chptr->chname, |
| 1510 |
> |
(unsigned long)chptr->topic_time, |
| 1511 |
> |
chptr->topic_info, chptr->topic ? chptr->topic : ""); |
| 1512 |
> |
} |
| 1513 |
> |
else |
| 1514 |
> |
{ |
| 1515 |
> |
sendto_one(client_p, ":%s TB %s %lu :%s", |
| 1516 |
> |
me.name, chptr->chname, |
| 1517 |
> |
(unsigned long)chptr->topic_time, |
| 1518 |
> |
chptr->topic ? chptr->topic : ""); |
| 1519 |
> |
} |
| 1520 |
|
} |
| 1521 |
|
} |
| 1694 |
– |
|
| 1695 |
– |
DLINK_FOREACH(ptr, global_client_list.head) |
| 1696 |
– |
{ |
| 1697 |
– |
target_p = ptr->data; |
| 1698 |
– |
target_p->lazyLinkClientExists &= clear_mask; |
| 1699 |
– |
} |
| 1522 |
|
} |
| 1523 |
|
|
| 1524 |
|
/* burst_members() |
| 1550 |
|
} |
| 1551 |
|
} |
| 1552 |
|
|
| 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 |
– |
|
| 1553 |
|
/* New server connection code |
| 1554 |
|
* Based upon the stuff floating about in s_bsd.c |
| 1555 |
|
* -- adrian |
| 1590 |
|
conf = unmap_conf_item(aconf); |
| 1591 |
|
|
| 1592 |
|
/* log */ |
| 1593 |
< |
irc_getnameinfo((struct sockaddr*)&aconf->ipnum, aconf->ipnum.ss_len, |
| 1594 |
< |
buf, HOSTIPLEN, NULL, 0, NI_NUMERICHOST); |
| 1593 |
> |
getnameinfo((struct sockaddr *)&aconf->ipnum, aconf->ipnum.ss_len, |
| 1594 |
> |
buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); |
| 1595 |
|
ilog(L_NOTICE, "Connect to %s[%s] @%s", aconf->user, aconf->host, |
| 1596 |
|
buf); |
| 1597 |
|
|
| 1598 |
|
/* Still processing a DNS lookup? -> exit */ |
| 1599 |
< |
if (aconf->dns_query != NULL) |
| 1599 |
> |
if (aconf->dns_pending) |
| 1600 |
|
{ |
| 1601 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
| 1602 |
< |
"Error connecting to %s: Error during DNS lookup", conf->name); |
| 1601 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 1602 |
> |
"Error connecting to %s: DNS lookup for connect{} in progress.", |
| 1603 |
> |
conf->name); |
| 1604 |
> |
return (0); |
| 1605 |
> |
} |
| 1606 |
> |
|
| 1607 |
> |
if (aconf->dns_failed) |
| 1608 |
> |
{ |
| 1609 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 1610 |
> |
"Error connecting to %s: DNS lookup for connect{} failed.", |
| 1611 |
> |
conf->name); |
| 1612 |
|
return (0); |
| 1613 |
|
} |
| 1614 |
|
|
| 1615 |
|
/* Make sure this server isn't already connected |
| 1616 |
|
* Note: aconf should ALWAYS be a valid C: line |
| 1617 |
|
*/ |
| 1618 |
< |
if ((client_p = find_server(conf->name)) != NULL) |
| 1618 |
> |
if ((client_p = hash_find_server(conf->name)) != NULL) |
| 1619 |
|
{ |
| 1620 |
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 1621 |
|
"Server %s already present from %s", |
| 1638 |
|
strlcpy(client_p->host, aconf->host, sizeof(client_p->host)); |
| 1639 |
|
|
| 1640 |
|
/* We already converted the ip once, so lets use it - stu */ |
| 1641 |
< |
strlcpy(client_p->sockhost, buf, HOSTIPLEN); |
| 1641 |
> |
strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost)); |
| 1642 |
|
|
| 1643 |
|
/* create a socket for the server connection */ |
| 1644 |
|
if (comm_open(&client_p->localClient->fd, aconf->ipnum.ss.ss_family, |
| 1848 |
|
#endif |
| 1849 |
|
|
| 1850 |
|
/* jdc -- Check and send spasswd, not passwd. */ |
| 1851 |
< |
if (!EmptyString(aconf->spasswd) && (me.id[0] != '\0')) |
| 1851 |
> |
if (!EmptyString(aconf->spasswd)) |
| 1852 |
|
/* Send TS 6 form only if id */ |
| 1853 |
|
sendto_one(client_p, "PASS %s TS %d %s", |
| 1854 |
|
aconf->spasswd, TS_CURRENT, me.id); |
| 2129 |
– |
else |
| 2130 |
– |
sendto_one(client_p, "PASS %s TS 5", |
| 2131 |
– |
aconf->spasswd); |
| 1855 |
|
|
| 1856 |
|
/* Pass my info to the new server |
| 1857 |
|
* |
| 2135 |
– |
* If trying to negotiate LazyLinks, pass on CAP_LL |
| 2136 |
– |
* If this is a HUB, pass on CAP_HUB |
| 1858 |
|
* Pass on ZIP if supported |
| 1859 |
|
* Pass on TB if supported. |
| 1860 |
|
* - Dianora |
| 1861 |
|
*/ |
| 1862 |
|
send_capabilities(client_p, aconf, |
| 1863 |
< |
(IsConfLazyLink(aconf) ? find_capability("LL") : 0) |
| 1864 |
< |
| (IsConfCompressed(aconf) ? find_capability("ZIP") : 0) |
| 2144 |
< |
| (IsConfTopicBurst(aconf) ? find_capability("TB") : 0) |
| 2145 |
< |
, 0); |
| 1863 |
> |
(IsConfCompressed(aconf) ? CAP_ZIP : 0) |
| 1864 |
> |
| (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), 0); |
| 1865 |
|
|
| 1866 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", |
| 1867 |
< |
my_name_for_link(conf), |
| 2149 |
< |
ConfigServerHide.hidden ? "(H) " : "", |
| 1867 |
> |
me.name, ConfigServerHide.hidden ? "(H) " : "", |
| 1868 |
|
me.info); |
| 1869 |
|
|
| 1870 |
|
/* If we've been marked dead because a send failed, just exit |
| 1897 |
|
cptr = ptr->data; |
| 1898 |
|
|
| 1899 |
|
if (cptr && cptr->name[0]) |
| 1900 |
< |
if (match(cptr->name, name) || match(name, cptr->name)) |
| 1900 |
> |
if (match(name, cptr->name)) |
| 1901 |
|
return cptr; |
| 1902 |
|
} |
| 1903 |
|
|
| 1969 |
|
} |
| 1970 |
|
|
| 1971 |
|
send_capabilities(client_p, aconf, |
| 1972 |
< |
(IsConfLazyLink(aconf) ? find_capability("LL") : 0) |
| 1973 |
< |
| (IsConfCompressed(aconf) ? find_capability("ZIP") : 0) |
| 2256 |
< |
| (IsConfTopicBurst(aconf) ? find_capability("TB") : 0) |
| 2257 |
< |
, CAP_ENC_MASK); |
| 1972 |
> |
(IsConfCompressed(aconf) ? CAP_ZIP : 0) |
| 1973 |
> |
| (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), CAP_ENC_MASK); |
| 1974 |
|
|
| 1975 |
+ |
sendto_one(client_p, "PASS . TS %d %s", TS_CURRENT, me.id); |
| 1976 |
|
sendto_one(client_p, "CRYPTLINK SERV %s %s :%s%s", |
| 1977 |
< |
my_name_for_link(conf), key_to_send, |
| 1977 |
> |
me.name, key_to_send, |
| 1978 |
|
ConfigServerHide.hidden ? "(H) " : "", me.info); |
| 1979 |
|
|
| 1980 |
|
SetHandshake(client_p); |