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 |
|
|
400 |
|
* modules to dynamically add or subtract their capability. |
401 |
|
*/ |
402 |
|
void |
403 |
< |
add_capability(const char *capab_name, int cap_flag, int add_to_default) |
403 |
> |
add_capability(const char *name, unsigned int flag) |
404 |
|
{ |
405 |
|
struct Capability *cap = MyCalloc(sizeof(*cap)); |
406 |
|
|
407 |
< |
cap->name = xstrdup(capab_name); |
408 |
< |
cap->cap = cap_flag; |
409 |
< |
dlinkAdd(cap, &cap->node, &cap_list); |
410 |
< |
|
411 |
< |
if (add_to_default) |
412 |
< |
default_server_capabs |= cap_flag; |
407 |
> |
cap->name = xstrdup(name); |
408 |
> |
cap->cap = flag; |
409 |
> |
dlinkAdd(cap, &cap->node, &server_capabilities_list); |
410 |
|
} |
411 |
|
|
412 |
|
/* delete_capability() |
416 |
|
* side effects - delete given capability from ones known. |
417 |
|
*/ |
418 |
|
void |
419 |
< |
delete_capability(const char *capab_name) |
419 |
> |
delete_capability(const char *name) |
420 |
|
{ |
421 |
|
dlink_node *node = NULL, *node_next = NULL; |
422 |
|
|
423 |
< |
DLINK_FOREACH_SAFE(node, node_next, cap_list.head) |
423 |
> |
DLINK_FOREACH_SAFE(node, node_next, server_capabilities_list.head) |
424 |
|
{ |
425 |
|
struct Capability *cap = node->data; |
426 |
|
|
427 |
< |
if (cap->cap) |
427 |
> |
if (!irccmp(cap->name, name)) |
428 |
|
{ |
429 |
< |
if (!irccmp(cap->name, capab_name)) |
430 |
< |
{ |
431 |
< |
default_server_capabs &= ~(cap->cap); |
435 |
< |
dlinkDelete(node, &cap_list); |
436 |
< |
MyFree(cap->name); |
437 |
< |
MyFree(cap); |
438 |
< |
} |
429 |
> |
dlinkDelete(node, &server_capabilities_list); |
430 |
> |
MyFree(cap->name); |
431 |
> |
MyFree(cap); |
432 |
|
} |
433 |
|
} |
434 |
|
} |
441 |
|
* side effects - none |
442 |
|
*/ |
443 |
|
unsigned int |
444 |
< |
find_capability(const char *capab) |
444 |
> |
find_capability(const char *name) |
445 |
|
{ |
446 |
|
const dlink_node *node = NULL; |
447 |
|
|
448 |
< |
DLINK_FOREACH(node, cap_list.head) |
448 |
> |
DLINK_FOREACH(node, server_capabilities_list.head) |
449 |
|
{ |
450 |
|
const struct Capability *cap = node->data; |
451 |
|
|
452 |
< |
if (cap->cap && !irccmp(cap->name, capab)) |
452 |
> |
if (!irccmp(cap->name, name)) |
453 |
|
return cap->cap; |
454 |
|
} |
455 |
|
|
465 |
|
* |
466 |
|
*/ |
467 |
|
void |
468 |
< |
send_capabilities(struct Client *client_p, int cap_can_send) |
468 |
> |
send_capabilities(struct Client *client_p) |
469 |
|
{ |
470 |
|
char buf[IRCD_BUFSIZE] = ""; |
471 |
|
const dlink_node *node = NULL; |
472 |
|
|
473 |
< |
DLINK_FOREACH(node, cap_list.head) |
473 |
> |
DLINK_FOREACH(node, server_capabilities_list.head) |
474 |
|
{ |
475 |
|
const struct Capability *cap = node->data; |
476 |
|
|
477 |
< |
if (cap->cap & (cap_can_send|default_server_capabs)) |
478 |
< |
{ |
479 |
< |
strlcat(buf, cap->name, sizeof(buf)); |
480 |
< |
if (node->next) |
488 |
< |
strlcat(buf, " ", sizeof(buf)); |
489 |
< |
} |
477 |
> |
strlcat(buf, cap->name, sizeof(buf)); |
478 |
> |
|
479 |
> |
if (node->next) |
480 |
> |
strlcat(buf, " ", sizeof(buf)); |
481 |
|
} |
482 |
|
|
483 |
|
sendto_one(client_p, "CAPAB :%s", buf); |
498 |
|
|
499 |
|
strlcpy(msgbuf, "TS", sizeof(msgbuf)); |
500 |
|
|
501 |
< |
DLINK_FOREACH(node, cap_list.head) |
501 |
> |
DLINK_FOREACH(node, server_capabilities_list.head) |
502 |
|
{ |
503 |
|
const struct Capability *cap = node->data; |
504 |
|
|
757 |
|
|
758 |
|
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
759 |
|
|
760 |
< |
send_capabilities(client_p, 0); |
760 |
> |
send_capabilities(client_p); |
761 |
|
|
762 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", |
763 |
|
me.name, ConfigServerHide.hidden ? "(H) " : "", |
945 |
|
|
946 |
|
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
947 |
|
|
948 |
< |
send_capabilities(client_p, 0); |
948 |
> |
send_capabilities(client_p); |
949 |
|
|
950 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", me.name, |
951 |
|
ConfigServerHide.hidden ? "(H) " : "", me.info); |