| 51 |
|
#define MIN_CONN_FREQ 300 |
| 52 |
|
|
| 53 |
|
dlink_list flatten_links; |
| 54 |
< |
static dlink_list cap_list; |
| 54 |
> |
static dlink_list server_capabilities_list; |
| 55 |
|
static void serv_connect_callback(fde_t *, int, void *); |
| 56 |
|
|
| 57 |
|
|
| 177 |
|
|
| 178 |
|
if (!target_p && has_wildcards(parv[server])) |
| 179 |
|
{ |
| 180 |
< |
DLINK_FOREACH(node, global_client_list.head) |
| 180 |
> |
DLINK_FOREACH(node, global_server_list.head) |
| 181 |
|
{ |
| 182 |
|
struct Client *tmp = node->data; |
| 183 |
|
|
| 184 |
< |
assert(IsMe(tmp) || IsServer(tmp) || IsClient(tmp)); |
| 184 |
> |
assert(IsMe(tmp) || IsServer(tmp)); |
| 185 |
|
if (!match(parv[server], tmp->name)) |
| 186 |
|
{ |
| 187 |
|
if (tmp->from == source_p->from && !MyConnect(tmp)) |
| 191 |
|
break; |
| 192 |
|
} |
| 193 |
|
} |
| 194 |
+ |
|
| 195 |
+ |
if (!target_p) |
| 196 |
+ |
{ |
| 197 |
+ |
DLINK_FOREACH(node, global_client_list.head) |
| 198 |
+ |
{ |
| 199 |
+ |
struct Client *tmp = node->data; |
| 200 |
+ |
|
| 201 |
+ |
assert(IsMe(tmp) || IsServer(tmp) || IsClient(tmp)); |
| 202 |
+ |
if (!match(parv[server], tmp->name)) |
| 203 |
+ |
{ |
| 204 |
+ |
if (tmp->from == source_p->from && !MyConnect(tmp)) |
| 205 |
+ |
continue; |
| 206 |
+ |
|
| 207 |
+ |
target_p = node->data; |
| 208 |
+ |
break; |
| 209 |
+ |
} |
| 210 |
+ |
} |
| 211 |
+ |
} |
| 212 |
|
} |
| 213 |
|
|
| 214 |
|
if (target_p) |
| 306 |
|
* -- adrian |
| 307 |
|
*/ |
| 308 |
|
if (ConfigServerHide.hide_server_ips) |
| 309 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 309 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
| 310 |
|
"Connection to %s activated.", |
| 311 |
|
conf->name); |
| 312 |
|
else |
| 313 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 313 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
| 314 |
|
"Connection to %s[%s] activated.", |
| 315 |
|
conf->name, conf->host); |
| 316 |
|
|
| 418 |
|
* modules to dynamically add or subtract their capability. |
| 419 |
|
*/ |
| 420 |
|
void |
| 421 |
< |
add_capability(const char *capab_name, int cap_flag, int add_to_default) |
| 421 |
> |
add_capability(const char *name, unsigned int flag) |
| 422 |
|
{ |
| 423 |
|
struct Capability *cap = MyCalloc(sizeof(*cap)); |
| 424 |
|
|
| 425 |
< |
cap->name = xstrdup(capab_name); |
| 426 |
< |
cap->cap = cap_flag; |
| 427 |
< |
dlinkAdd(cap, &cap->node, &cap_list); |
| 410 |
< |
|
| 411 |
< |
if (add_to_default) |
| 412 |
< |
default_server_capabs |= cap_flag; |
| 425 |
> |
cap->name = xstrdup(name); |
| 426 |
> |
cap->cap = flag; |
| 427 |
> |
dlinkAdd(cap, &cap->node, &server_capabilities_list); |
| 428 |
|
} |
| 429 |
|
|
| 430 |
|
/* delete_capability() |
| 433 |
|
* output - NONE |
| 434 |
|
* side effects - delete given capability from ones known. |
| 435 |
|
*/ |
| 436 |
< |
int |
| 437 |
< |
delete_capability(const char *capab_name) |
| 436 |
> |
void |
| 437 |
> |
delete_capability(const char *name) |
| 438 |
|
{ |
| 439 |
|
dlink_node *node = NULL, *node_next = NULL; |
| 440 |
|
|
| 441 |
< |
DLINK_FOREACH_SAFE(node, node_next, cap_list.head) |
| 441 |
> |
DLINK_FOREACH_SAFE(node, node_next, server_capabilities_list.head) |
| 442 |
|
{ |
| 443 |
|
struct Capability *cap = node->data; |
| 444 |
|
|
| 445 |
< |
if (cap->cap) |
| 445 |
> |
if (!irccmp(cap->name, name)) |
| 446 |
|
{ |
| 447 |
< |
if (!irccmp(cap->name, capab_name)) |
| 448 |
< |
{ |
| 449 |
< |
default_server_capabs &= ~(cap->cap); |
| 435 |
< |
dlinkDelete(node, &cap_list); |
| 436 |
< |
MyFree(cap->name); |
| 437 |
< |
MyFree(cap); |
| 438 |
< |
} |
| 447 |
> |
dlinkDelete(node, &server_capabilities_list); |
| 448 |
> |
MyFree(cap->name); |
| 449 |
> |
MyFree(cap); |
| 450 |
|
} |
| 451 |
|
} |
| 441 |
– |
|
| 442 |
– |
return 0; |
| 452 |
|
} |
| 453 |
|
|
| 454 |
|
/* |
| 459 |
|
* side effects - none |
| 460 |
|
*/ |
| 461 |
|
unsigned int |
| 462 |
< |
find_capability(const char *capab) |
| 462 |
> |
find_capability(const char *name) |
| 463 |
|
{ |
| 464 |
|
const dlink_node *node = NULL; |
| 465 |
|
|
| 466 |
< |
DLINK_FOREACH(node, cap_list.head) |
| 466 |
> |
DLINK_FOREACH(node, server_capabilities_list.head) |
| 467 |
|
{ |
| 468 |
|
const struct Capability *cap = node->data; |
| 469 |
|
|
| 470 |
< |
if (cap->cap && !irccmp(cap->name, capab)) |
| 470 |
> |
if (!irccmp(cap->name, name)) |
| 471 |
|
return cap->cap; |
| 472 |
|
} |
| 473 |
|
|
| 483 |
|
* |
| 484 |
|
*/ |
| 485 |
|
void |
| 486 |
< |
send_capabilities(struct Client *client_p, int cap_can_send) |
| 486 |
> |
send_capabilities(struct Client *client_p) |
| 487 |
|
{ |
| 488 |
|
char buf[IRCD_BUFSIZE] = ""; |
| 489 |
|
const dlink_node *node = NULL; |
| 490 |
|
|
| 491 |
< |
DLINK_FOREACH(node, cap_list.head) |
| 491 |
> |
DLINK_FOREACH(node, server_capabilities_list.head) |
| 492 |
|
{ |
| 493 |
|
const struct Capability *cap = node->data; |
| 494 |
|
|
| 495 |
< |
if (cap->cap & (cap_can_send|default_server_capabs)) |
| 496 |
< |
{ |
| 497 |
< |
strlcat(buf, cap->name, sizeof(buf)); |
| 498 |
< |
if (node->next) |
| 490 |
< |
strlcat(buf, " ", sizeof(buf)); |
| 491 |
< |
} |
| 495 |
> |
strlcat(buf, cap->name, sizeof(buf)); |
| 496 |
> |
|
| 497 |
> |
if (node->next) |
| 498 |
> |
strlcat(buf, " ", sizeof(buf)); |
| 499 |
|
} |
| 500 |
|
|
| 501 |
|
sendto_one(client_p, "CAPAB :%s", buf); |
| 516 |
|
|
| 517 |
|
strlcpy(msgbuf, "TS", sizeof(msgbuf)); |
| 518 |
|
|
| 519 |
< |
DLINK_FOREACH(node, cap_list.head) |
| 519 |
> |
DLINK_FOREACH(node, server_capabilities_list.head) |
| 520 |
|
{ |
| 521 |
|
const struct Capability *cap = node->data; |
| 522 |
|
|
| 587 |
|
/* Still processing a DNS lookup? -> exit */ |
| 588 |
|
if (conf->dns_pending) |
| 589 |
|
{ |
| 590 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 590 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
| 591 |
|
"Error connecting to %s: DNS lookup for connect{} in progress.", |
| 592 |
|
conf->name); |
| 593 |
|
return 0; |
| 595 |
|
|
| 596 |
|
if (conf->dns_failed) |
| 597 |
|
{ |
| 598 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 598 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
| 599 |
|
"Error connecting to %s: DNS lookup for connect{} failed.", |
| 600 |
|
conf->name); |
| 601 |
|
return 0; |
| 606 |
|
*/ |
| 607 |
|
if ((client_p = hash_find_server(conf->name))) |
| 608 |
|
{ |
| 609 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 609 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
| 610 |
|
"Server %s already present from %s", |
| 611 |
|
conf->name, get_client_name(client_p, SHOW_IP)); |
| 612 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 612 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
| 613 |
|
"Server %s already present from %s", |
| 614 |
|
conf->name, get_client_name(client_p, MASK_IP)); |
| 615 |
|
if (by && IsClient(by) && !MyClient(by)) |
| 647 |
|
*/ |
| 648 |
|
if (!attach_connect_block(client_p, conf->name, conf->host)) |
| 649 |
|
{ |
| 650 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 650 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
| 651 |
|
"Host %s is not enabled for connecting: no connect {} block", |
| 652 |
|
conf->name); |
| 653 |
|
if (by && IsClient(by) && !MyClient(by)) |
| 764 |
|
client_p->name, CONF_SERVER); |
| 765 |
|
if (conf == NULL) |
| 766 |
|
{ |
| 767 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 767 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
| 768 |
|
"Lost connect{} block for %s", get_client_name(client_p, HIDE_IP)); |
| 769 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 769 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
| 770 |
|
"Lost connect{} block for %s", get_client_name(client_p, MASK_IP)); |
| 771 |
|
|
| 772 |
|
exit_client(client_p, "Lost connect{} block"); |
| 775 |
|
|
| 776 |
|
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
| 777 |
|
|
| 778 |
< |
send_capabilities(client_p, 0); |
| 778 |
> |
send_capabilities(client_p); |
| 779 |
|
|
| 780 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", |
| 781 |
|
me.name, ConfigServerHide.hidden ? "(H) " : "", |
| 786 |
|
*/ |
| 787 |
|
if (IsDead(client_p)) |
| 788 |
|
{ |
| 789 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 789 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
| 790 |
|
"%s[%s] went dead during handshake", |
| 791 |
|
client_p->name, |
| 792 |
|
client_p->host); |
| 793 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 793 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
| 794 |
|
"%s went dead during handshake", client_p->name); |
| 795 |
|
return; |
| 796 |
|
} |
| 828 |
|
default: |
| 829 |
|
{ |
| 830 |
|
const char *sslerr = ERR_error_string(ERR_get_error(), NULL); |
| 831 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 831 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
| 832 |
|
"Error connecting to %s: %s", client_p->name, |
| 833 |
|
sslerr ? sslerr : "unknown SSL error"); |
| 834 |
|
exit_client(client_p, "Error during SSL handshake"); |
| 916 |
|
* Admins get to see any IP, mere opers don't *sigh* |
| 917 |
|
*/ |
| 918 |
|
if (ConfigServerHide.hide_server_ips) |
| 919 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 919 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
| 920 |
|
"Error connecting to %s: %s", |
| 921 |
|
client_p->name, comm_errstr(status)); |
| 922 |
|
else |
| 923 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 923 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
| 924 |
|
"Error connecting to %s[%s]: %s", client_p->name, |
| 925 |
|
client_p->host, comm_errstr(status)); |
| 926 |
|
|
| 927 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 927 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
| 928 |
|
"Error connecting to %s: %s", |
| 929 |
|
client_p->name, comm_errstr(status)); |
| 930 |
|
|
| 941 |
|
client_p->name, CONF_SERVER); |
| 942 |
|
if (conf == NULL) |
| 943 |
|
{ |
| 944 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 944 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
| 945 |
|
"Lost connect{} block for %s", get_client_name(client_p, HIDE_IP)); |
| 946 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 946 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
| 947 |
|
"Lost connect{} block for %s", get_client_name(client_p, MASK_IP)); |
| 948 |
|
|
| 949 |
|
exit_client(client_p, "Lost connect{} block"); |
| 963 |
|
|
| 964 |
|
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
| 965 |
|
|
| 966 |
< |
send_capabilities(client_p, 0); |
| 966 |
> |
send_capabilities(client_p); |
| 967 |
|
|
| 968 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", me.name, |
| 969 |
|
ConfigServerHide.hidden ? "(H) " : "", me.info); |
| 973 |
|
*/ |
| 974 |
|
if (IsDead(client_p)) |
| 975 |
|
{ |
| 976 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 976 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
| 977 |
|
"%s[%s] went dead during handshake", |
| 978 |
|
client_p->name, |
| 979 |
|
client_p->host); |
| 980 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 980 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
| 981 |
|
"%s went dead during handshake", client_p->name); |
| 982 |
|
return; |
| 983 |
|
} |