| 36 |
|
#include "fdlist.h" |
| 37 |
|
#include "hash.h" |
| 38 |
|
#include "irc_string.h" |
| 39 |
– |
#include "sprintf_irc.h" |
| 39 |
|
#include "ircd.h" |
| 40 |
|
#include "ircd_defs.h" |
| 41 |
|
#include "s_bsd.h" |
| 42 |
|
#include "numeric.h" |
| 43 |
|
#include "packet.h" |
| 44 |
|
#include "irc_res.h" |
| 45 |
< |
#include "s_conf.h" |
| 45 |
> |
#include "conf.h" |
| 46 |
|
#include "s_serv.h" |
| 47 |
< |
#include "s_log.h" |
| 47 |
> |
#include "log.h" |
| 48 |
|
#include "s_misc.h" |
| 49 |
|
#include "s_user.h" |
| 50 |
|
#include "send.h" |
| 54 |
|
|
| 55 |
|
#define MIN_CONN_FREQ 300 |
| 56 |
|
|
| 57 |
+ |
dlink_list flatten_links; |
| 58 |
|
static dlink_list cap_list = { NULL, NULL, 0 }; |
| 59 |
|
static void server_burst(struct Client *); |
| 60 |
|
static void burst_all(struct Client *); |
| 62 |
|
|
| 63 |
|
static CNCB serv_connect_callback; |
| 64 |
|
|
| 65 |
– |
static void start_io(struct Client *); |
| 65 |
|
static void burst_members(struct Client *, struct Channel *); |
| 66 |
|
|
| 67 |
|
/* |
| 73 |
|
* but in no particular order. |
| 74 |
|
*/ |
| 75 |
|
void |
| 76 |
< |
write_links_file(void* notused) |
| 76 |
> |
write_links_file(void *notused) |
| 77 |
|
{ |
| 78 |
< |
MessageFileLine *next_mptr = 0; |
| 79 |
< |
MessageFileLine *mptr = 0; |
| 80 |
< |
MessageFileLine *currentMessageLine = 0; |
| 82 |
< |
MessageFileLine *newMessageLine = 0; |
| 83 |
< |
MessageFile *MessageFileptr; |
| 84 |
< |
const char *p; |
| 85 |
< |
FBFILE *file; |
| 86 |
< |
char buff[512]; |
| 87 |
< |
dlink_node *ptr; |
| 88 |
< |
|
| 89 |
< |
MessageFileptr = &ConfigFileEntry.linksfile; |
| 78 |
> |
FILE *file = NULL; |
| 79 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL;; |
| 80 |
> |
char buff[IRCD_BUFSIZE] = { '\0' }; |
| 81 |
|
|
| 82 |
< |
if ((file = fbopen(MessageFileptr->fileName, "w")) == NULL) |
| 82 |
> |
if ((file = fopen(LIPATH, "w")) == NULL) |
| 83 |
|
return; |
| 84 |
|
|
| 85 |
< |
for (mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr) |
| 85 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, flatten_links.head) |
| 86 |
|
{ |
| 87 |
< |
next_mptr = mptr->next; |
| 88 |
< |
MyFree(mptr); |
| 87 |
> |
dlinkDelete(ptr, &flatten_links); |
| 88 |
> |
MyFree(ptr->data); |
| 89 |
> |
free_dlink_node(ptr); |
| 90 |
|
} |
| 91 |
|
|
| 100 |
– |
MessageFileptr->contentsOfFile = NULL; |
| 101 |
– |
currentMessageLine = NULL; |
| 102 |
– |
|
| 92 |
|
DLINK_FOREACH(ptr, global_serv_list.head) |
| 93 |
|
{ |
| 94 |
< |
size_t nbytes = 0; |
| 106 |
< |
struct Client *target_p = ptr->data; |
| 94 |
> |
const struct Client *target_p = ptr->data; |
| 95 |
|
|
| 96 |
< |
/* skip ourselves, we send ourselves in /links */ |
| 97 |
< |
if (IsMe(target_p)) |
| 96 |
> |
/* |
| 97 |
> |
* Skip hidden servers, aswell as ourselves, since we already send |
| 98 |
> |
* ourselves in /links |
| 99 |
> |
*/ |
| 100 |
> |
if (IsHidden(target_p) || IsMe(target_p)) |
| 101 |
|
continue; |
| 102 |
|
|
| 103 |
< |
/* skip hidden servers */ |
| 113 |
< |
if (IsHidden(target_p) && !ConfigServerHide.disable_hidden) |
| 103 |
> |
if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services) |
| 104 |
|
continue; |
| 105 |
|
|
| 106 |
< |
if (target_p->info[0]) |
| 107 |
< |
p = target_p->info; |
| 118 |
< |
else |
| 119 |
< |
p = "(Unknown Location)"; |
| 120 |
< |
|
| 121 |
< |
newMessageLine = MyMalloc(sizeof(MessageFileLine)); |
| 122 |
< |
|
| 123 |
< |
/* Attempt to format the file in such a way it follows the usual links output |
| 106 |
> |
/* |
| 107 |
> |
* Attempt to format the file in such a way it follows the usual links output |
| 108 |
|
* ie "servername uplink :hops info" |
| 109 |
|
* Mostly for aesthetic reasons - makes it look pretty in mIRC ;) |
| 110 |
|
* - madmax |
| 111 |
|
*/ |
| 112 |
+ |
snprintf(buff, sizeof(buff), "%s %s :1 %s", target_p->name, |
| 113 |
+ |
me.name, target_p->info); |
| 114 |
+ |
dlinkAdd(xstrdup(buff), make_dlink_node(), &flatten_links); |
| 115 |
+ |
snprintf(buff, sizeof(buff), "%s %s :1 %s\n", target_p->name, |
| 116 |
+ |
me.name, target_p->info); |
| 117 |
|
|
| 118 |
< |
/* |
| 130 |
< |
* For now, check this ircsprintf wont overflow - it shouldnt on a |
| 131 |
< |
* default config but it is configurable.. |
| 132 |
< |
* This should be changed to an snprintf at some point, but I'm wanting to |
| 133 |
< |
* know if this is a cause of a bug - cryogen |
| 134 |
< |
*/ |
| 135 |
< |
assert(strlen(target_p->name) + strlen(me.name) + 6 + strlen(p) <= |
| 136 |
< |
MESSAGELINELEN); |
| 137 |
< |
ircsprintf(newMessageLine->line, "%s %s :1 %s", |
| 138 |
< |
target_p->name, me.name, p); |
| 139 |
< |
newMessageLine->next = NULL; |
| 140 |
< |
|
| 141 |
< |
if (MessageFileptr->contentsOfFile) |
| 142 |
< |
{ |
| 143 |
< |
if (currentMessageLine) |
| 144 |
< |
currentMessageLine->next = newMessageLine; |
| 145 |
< |
currentMessageLine = newMessageLine; |
| 146 |
< |
} |
| 147 |
< |
else |
| 148 |
< |
{ |
| 149 |
< |
MessageFileptr->contentsOfFile = newMessageLine; |
| 150 |
< |
currentMessageLine = newMessageLine; |
| 151 |
< |
} |
| 152 |
< |
|
| 153 |
< |
nbytes = ircsprintf(buff, "%s %s :1 %s\n", target_p->name, me.name, p); |
| 154 |
< |
fbputs(buff, file, nbytes); |
| 118 |
> |
fputs(buff, file); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
< |
fbclose(file); |
| 121 |
> |
fclose(file); |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
/* hunt_server() |
| 142 |
|
*/ |
| 143 |
|
int |
| 144 |
|
hunt_server(struct Client *client_p, struct Client *source_p, const char *command, |
| 145 |
< |
int server, int parc, char *parv[]) |
| 145 |
> |
const int server, const int parc, char *parv[]) |
| 146 |
|
{ |
| 147 |
|
struct Client *target_p = NULL; |
| 148 |
|
struct Client *target_tmp = NULL; |
| 149 |
|
dlink_node *ptr; |
| 150 |
|
int wilds; |
| 151 |
|
|
| 152 |
< |
/* Assume it's me, if no server |
| 153 |
< |
*/ |
| 154 |
< |
if (parc <= server || EmptyString(parv[server]) || |
| 155 |
< |
match(me.name, parv[server]) || |
| 156 |
< |
match(parv[server], me.name) || |
| 157 |
< |
!strcmp(parv[server], me.id)) |
| 194 |
< |
return(HUNTED_ISME); |
| 152 |
> |
/* Assume it's me, if no server */ |
| 153 |
> |
if (parc <= server || EmptyString(parv[server])) |
| 154 |
> |
return HUNTED_ISME; |
| 155 |
> |
|
| 156 |
> |
if (!strcmp(parv[server], me.id) || !match(parv[server], me.name)) |
| 157 |
> |
return HUNTED_ISME; |
| 158 |
|
|
| 159 |
|
/* These are to pickup matches that would cause the following |
| 160 |
|
* message to go in the wrong direction while doing quick fast |
| 173 |
|
if (target_p->from == source_p->from && !MyConnect(target_p)) |
| 174 |
|
target_p = NULL; |
| 175 |
|
|
| 176 |
< |
collapse(parv[server]); |
| 214 |
< |
wilds = (strchr(parv[server], '?') || strchr(parv[server], '*')); |
| 176 |
> |
wilds = has_wildcards(parv[server]); |
| 177 |
|
|
| 178 |
|
/* Again, if there are no wild cards involved in the server |
| 179 |
|
* name, use the hash lookup |
| 195 |
|
{ |
| 196 |
|
target_tmp = ptr->data; |
| 197 |
|
|
| 198 |
< |
if (match(parv[server], target_tmp->name)) |
| 198 |
> |
if (!match(parv[server], target_tmp->name)) |
| 199 |
|
{ |
| 200 |
|
if (target_tmp->from == source_p->from && !MyConnect(target_tmp)) |
| 201 |
|
continue; |
| 220 |
|
if (IsMe(target_p) || MyClient(target_p)) |
| 221 |
|
return HUNTED_ISME; |
| 222 |
|
|
| 223 |
< |
if (!match(target_p->name, parv[server])) |
| 223 |
> |
if (match(target_p->name, parv[server])) |
| 224 |
|
parv[server] = target_p->name; |
| 225 |
|
|
| 226 |
|
/* This is a little kludgy but should work... */ |
| 232 |
|
sendto_one(target_p, command, parv[0], |
| 233 |
|
parv[1], parv[2], parv[3], parv[4], |
| 234 |
|
parv[5], parv[6], parv[7], parv[8]); |
| 235 |
< |
return(HUNTED_PASS); |
| 235 |
> |
return HUNTED_PASS; |
| 236 |
|
} |
| 237 |
|
|
| 238 |
|
sendto_one(source_p, form_str(ERR_NOSUCHSERVER), |
| 239 |
|
me.name, source_p->name, parv[server]); |
| 240 |
< |
return(HUNTED_NOSUCH); |
| 240 |
> |
return HUNTED_NOSUCH; |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
/* try_connections() |
| 253 |
|
void |
| 254 |
|
try_connections(void *unused) |
| 255 |
|
{ |
| 256 |
< |
dlink_node *ptr; |
| 257 |
< |
struct ConfItem *conf; |
| 296 |
< |
struct AccessItem *aconf; |
| 297 |
< |
struct ClassItem *cltmp; |
| 256 |
> |
dlink_node *ptr = NULL; |
| 257 |
> |
struct MaskItem *conf; |
| 258 |
|
int confrq; |
| 259 |
|
|
| 260 |
|
/* TODO: change this to set active flag to 0 when added to event! --Habeeb */ |
| 264 |
|
DLINK_FOREACH(ptr, server_items.head) |
| 265 |
|
{ |
| 266 |
|
conf = ptr->data; |
| 267 |
< |
aconf = map_to_conf(conf); |
| 267 |
> |
|
| 268 |
> |
assert(conf->type == CONF_SERVER); |
| 269 |
|
|
| 270 |
|
/* Also when already connecting! (update holdtimes) --SRB |
| 271 |
|
*/ |
| 272 |
< |
if (!(aconf->status & CONF_SERVER) || !aconf->port || |
| 312 |
< |
!(IsConfAllowAutoConn(aconf))) |
| 272 |
> |
if (!conf->port ||!IsConfAllowAutoConn(conf)) |
| 273 |
|
continue; |
| 274 |
|
|
| 315 |
– |
cltmp = map_to_conf(aconf->class_ptr); |
| 275 |
|
|
| 276 |
|
/* Skip this entry if the use of it is still on hold until |
| 277 |
|
* future. Otherwise handle this entry (and set it on hold |
| 279 |
|
* made one successfull connection... [this algorithm is |
| 280 |
|
* a bit fuzzy... -- msa >;) ] |
| 281 |
|
*/ |
| 282 |
< |
if (aconf->hold > CurrentTime) |
| 282 |
> |
if (conf->until > CurrentTime) |
| 283 |
|
continue; |
| 284 |
|
|
| 285 |
< |
if (cltmp == NULL) |
| 285 |
> |
if (conf->class == NULL) |
| 286 |
|
confrq = DEFAULT_CONNECTFREQUENCY; |
| 287 |
|
else |
| 288 |
|
{ |
| 289 |
< |
confrq = ConFreq(cltmp); |
| 290 |
< |
if (confrq < MIN_CONN_FREQ ) |
| 291 |
< |
confrq = MIN_CONN_FREQ; |
| 289 |
> |
confrq = conf->class->con_freq; |
| 290 |
> |
if (confrq < MIN_CONN_FREQ) |
| 291 |
> |
confrq = MIN_CONN_FREQ; |
| 292 |
|
} |
| 293 |
|
|
| 294 |
< |
aconf->hold = CurrentTime + confrq; |
| 294 |
> |
conf->until = CurrentTime + confrq; |
| 295 |
|
|
| 296 |
|
/* Found a CONNECT config with port specified, scan clients |
| 297 |
|
* and see if this server is already connected? |
| 299 |
|
if (hash_find_server(conf->name) != NULL) |
| 300 |
|
continue; |
| 301 |
|
|
| 302 |
< |
if (CurrUserCount(cltmp) < MaxTotal(cltmp)) |
| 302 |
> |
if (conf->class->ref_count < conf->class->max_total) |
| 303 |
|
{ |
| 304 |
|
/* Go to the end of the list, if not already last */ |
| 305 |
|
if (ptr->next != NULL) |
| 320 |
|
* -- adrian |
| 321 |
|
*/ |
| 322 |
|
if (ConfigServerHide.hide_server_ips) |
| 323 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "Connection to %s activated.", |
| 323 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 324 |
> |
"Connection to %s activated.", |
| 325 |
|
conf->name); |
| 326 |
|
else |
| 327 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "Connection to %s[%s] activated.", |
| 328 |
< |
conf->name, aconf->host); |
| 327 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 328 |
> |
"Connection to %s[%s] activated.", |
| 329 |
> |
conf->name, conf->host); |
| 330 |
|
|
| 331 |
< |
serv_connect(aconf, NULL); |
| 331 |
> |
serv_connect(conf, NULL); |
| 332 |
|
/* We connect only one at time... */ |
| 333 |
|
return; |
| 334 |
|
} |
| 360 |
|
check_server(const char *name, struct Client *client_p) |
| 361 |
|
{ |
| 362 |
|
dlink_node *ptr; |
| 363 |
< |
struct ConfItem *conf = NULL; |
| 364 |
< |
struct ConfItem *server_conf = NULL; |
| 404 |
< |
struct AccessItem *server_aconf = NULL; |
| 405 |
< |
struct AccessItem *aconf = NULL; |
| 363 |
> |
struct MaskItem *conf = NULL; |
| 364 |
> |
struct MaskItem *server_conf = NULL; |
| 365 |
|
int error = -1; |
| 366 |
|
|
| 367 |
|
assert(client_p != NULL); |
| 368 |
|
|
| 410 |
– |
if (client_p == NULL) |
| 411 |
– |
return(error); |
| 412 |
– |
|
| 413 |
– |
if (strlen(name) > HOSTLEN) |
| 414 |
– |
return(-4); |
| 415 |
– |
|
| 369 |
|
/* loop through looking for all possible connect items that might work */ |
| 370 |
|
DLINK_FOREACH(ptr, server_items.head) |
| 371 |
|
{ |
| 372 |
|
conf = ptr->data; |
| 420 |
– |
aconf = map_to_conf(conf); |
| 373 |
|
|
| 374 |
< |
if (!match(name, conf->name)) |
| 374 |
> |
if (match(name, conf->name)) |
| 375 |
|
continue; |
| 376 |
|
|
| 377 |
|
error = -3; |
| 378 |
|
|
| 379 |
|
/* XXX: Fix me for IPv6 */ |
| 380 |
|
/* XXX sockhost is the IPv4 ip as a string */ |
| 381 |
< |
if (match(aconf->host, client_p->host) || |
| 382 |
< |
match(aconf->host, client_p->sockhost)) |
| 381 |
> |
if (!match(conf->host, client_p->host) || |
| 382 |
> |
!match(conf->host, client_p->sockhost)) |
| 383 |
|
{ |
| 384 |
|
error = -2; |
| 433 |
– |
{ |
| 434 |
– |
/* A NULL password is as good as a bad one */ |
| 435 |
– |
if (EmptyString(client_p->localClient->passwd)) |
| 436 |
– |
return(-2); |
| 437 |
– |
|
| 438 |
– |
/* code in s_conf.c should not have allowed this to be NULL */ |
| 439 |
– |
if (aconf->passwd == NULL) |
| 440 |
– |
return(-2); |
| 385 |
|
|
| 386 |
< |
if (IsConfEncrypted(aconf)) |
| 387 |
< |
{ |
| 388 |
< |
if (strcmp(aconf->passwd, |
| 389 |
< |
(const char *)crypt(client_p->localClient->passwd, |
| 446 |
< |
aconf->passwd)) == 0) |
| 447 |
< |
server_conf = conf; |
| 448 |
< |
} |
| 449 |
< |
else |
| 450 |
< |
{ |
| 451 |
< |
if (strcmp(aconf->passwd, client_p->localClient->passwd) == 0) |
| 452 |
< |
server_conf = conf; |
| 453 |
< |
} |
| 454 |
< |
} |
| 386 |
> |
if (!match_conf_password(client_p->localClient->passwd, conf)) |
| 387 |
> |
return -2; |
| 388 |
> |
|
| 389 |
> |
server_conf = conf; |
| 390 |
|
} |
| 391 |
|
} |
| 392 |
|
|
| 395 |
|
|
| 396 |
|
attach_conf(client_p, server_conf); |
| 397 |
|
|
| 463 |
– |
/* Now find all leaf or hub config items for this server */ |
| 464 |
– |
DLINK_FOREACH(ptr, hub_items.head) |
| 465 |
– |
{ |
| 466 |
– |
conf = ptr->data; |
| 467 |
– |
|
| 468 |
– |
if (!match(name, conf->name)) |
| 469 |
– |
continue; |
| 470 |
– |
attach_conf(client_p, conf); |
| 471 |
– |
} |
| 472 |
– |
|
| 473 |
– |
DLINK_FOREACH(ptr, leaf_items.head) |
| 474 |
– |
{ |
| 475 |
– |
conf = ptr->data; |
| 476 |
– |
|
| 477 |
– |
if (!match(name, conf->name)) |
| 478 |
– |
continue; |
| 479 |
– |
attach_conf(client_p, conf); |
| 480 |
– |
} |
| 481 |
– |
|
| 482 |
– |
server_aconf = map_to_conf(server_conf); |
| 398 |
|
|
| 399 |
< |
if (!IsConfTopicBurst(server_aconf)) |
| 485 |
< |
{ |
| 486 |
< |
ClearCap(client_p, CAP_TB); |
| 487 |
< |
ClearCap(client_p, CAP_TBURST); |
| 488 |
< |
} |
| 489 |
< |
|
| 490 |
< |
if (aconf != NULL) |
| 399 |
> |
if (server_conf != NULL) |
| 400 |
|
{ |
| 401 |
|
struct sockaddr_in *v4; |
| 402 |
|
#ifdef IPV6 |
| 403 |
|
struct sockaddr_in6 *v6; |
| 404 |
|
#endif |
| 405 |
< |
switch (aconf->aftype) |
| 405 |
> |
switch (server_conf->aftype) |
| 406 |
|
{ |
| 407 |
|
#ifdef IPV6 |
| 408 |
|
case AF_INET6: |
| 409 |
< |
v6 = (struct sockaddr_in6 *)&aconf->ipnum; |
| 409 |
> |
v6 = (struct sockaddr_in6 *)&server_conf->addr; |
| 410 |
|
|
| 411 |
|
if (IN6_IS_ADDR_UNSPECIFIED(&v6->sin6_addr)) |
| 412 |
< |
memcpy(&aconf->ipnum, &client_p->localClient->ip, sizeof(struct irc_ssaddr)); |
| 412 |
> |
memcpy(&server_conf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr)); |
| 413 |
|
break; |
| 414 |
|
#endif |
| 415 |
|
case AF_INET: |
| 416 |
< |
v4 = (struct sockaddr_in *)&aconf->ipnum; |
| 416 |
> |
v4 = (struct sockaddr_in *)&server_conf->addr; |
| 417 |
|
|
| 418 |
|
if (v4->sin_addr.s_addr == INADDR_NONE) |
| 419 |
< |
memcpy(&aconf->ipnum, &client_p->localClient->ip, sizeof(struct irc_ssaddr)); |
| 419 |
> |
memcpy(&server_conf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr)); |
| 420 |
|
break; |
| 421 |
|
} |
| 422 |
|
} |
| 438 |
|
{ |
| 439 |
|
struct Capability *cap = MyMalloc(sizeof(*cap)); |
| 440 |
|
|
| 441 |
< |
DupString(cap->name, capab_name); |
| 441 |
> |
cap->name = xstrdup(capab_name); |
| 442 |
|
cap->cap = cap_flag; |
| 443 |
|
dlinkAdd(cap, &cap->node, &cap_list); |
| 444 |
|
|
| 467 |
|
{ |
| 468 |
|
if (irccmp(cap->name, capab_name) == 0) |
| 469 |
|
{ |
| 470 |
< |
default_server_capabs &= ~(cap->cap); |
| 471 |
< |
dlinkDelete(ptr, &cap_list); |
| 472 |
< |
MyFree(cap->name); |
| 473 |
< |
cap->name = NULL; |
| 565 |
< |
MyFree(cap); |
| 470 |
> |
default_server_capabs &= ~(cap->cap); |
| 471 |
> |
dlinkDelete(ptr, &cap_list); |
| 472 |
> |
MyFree(cap->name); |
| 473 |
> |
MyFree(cap); |
| 474 |
|
} |
| 475 |
|
} |
| 476 |
|
} |
| 485 |
|
* output - 0 if not found CAPAB otherwise |
| 486 |
|
* side effects - none |
| 487 |
|
*/ |
| 488 |
< |
int |
| 488 |
> |
unsigned int |
| 489 |
|
find_capability(const char *capab) |
| 490 |
|
{ |
| 491 |
|
const dlink_node *ptr = NULL; |
| 504 |
|
/* send_capabilities() |
| 505 |
|
* |
| 506 |
|
* inputs - Client pointer to send to |
| 599 |
– |
* - Pointer to AccessItem (for crypt) |
| 507 |
|
* - int flag of capabilities that this server can send |
| 508 |
|
* output - NONE |
| 509 |
|
* side effects - send the CAPAB line to a server -orabidoo |
| 510 |
|
* |
| 511 |
|
*/ |
| 512 |
|
void |
| 513 |
< |
send_capabilities(struct Client *client_p, struct AccessItem *aconf, |
| 607 |
< |
int cap_can_send) |
| 513 |
> |
send_capabilities(struct Client *client_p, int cap_can_send) |
| 514 |
|
{ |
| 515 |
|
struct Capability *cap=NULL; |
| 516 |
|
char msgbuf[IRCD_BUFSIZE]; |
| 526 |
|
|
| 527 |
|
if (cap->cap & (cap_can_send|default_server_capabs)) |
| 528 |
|
{ |
| 529 |
< |
tl = ircsprintf(t, "%s ", cap->name); |
| 529 |
> |
tl = sprintf(t, "%s ", cap->name); |
| 530 |
|
t += tl; |
| 531 |
|
} |
| 532 |
|
} |
| 558 |
|
ubuf[1] = '\0'; |
| 559 |
|
} |
| 560 |
|
|
| 655 |
– |
/* XXX Both of these need to have a :me.name or :mySID!?!?! */ |
| 561 |
|
if (IsCapable(client_p, CAP_SVS)) |
| 562 |
|
{ |
| 563 |
|
if (HasID(target_p) && IsCapable(client_p, CAP_TS6)) |
| 564 |
< |
sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %lu :%s", |
| 564 |
> |
sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %s :%s", |
| 565 |
|
target_p->servptr->id, |
| 566 |
|
target_p->name, target_p->hopcount + 1, |
| 567 |
|
(unsigned long) target_p->tsinfo, |
| 568 |
|
ubuf, target_p->username, target_p->host, |
| 569 |
|
(MyClient(target_p) && IsIPSpoof(target_p)) ? |
| 570 |
|
"0" : target_p->sockhost, target_p->id, |
| 571 |
< |
(unsigned long)target_p->servicestamp, target_p->info); |
| 571 |
> |
target_p->svid, target_p->info); |
| 572 |
|
else |
| 573 |
< |
sendto_one(client_p, "NICK %s %d %lu %s %s %s %s %lu :%s", |
| 573 |
> |
sendto_one(client_p, "NICK %s %d %lu %s %s %s %s %s :%s", |
| 574 |
|
target_p->name, target_p->hopcount + 1, |
| 575 |
|
(unsigned long) target_p->tsinfo, |
| 576 |
|
ubuf, target_p->username, target_p->host, |
| 577 |
< |
target_p->servptr->name, (unsigned long)target_p->servicestamp, |
| 577 |
> |
target_p->servptr->name, target_p->svid, |
| 578 |
|
target_p->info); |
| 579 |
|
} |
| 580 |
|
else |
| 595 |
|
target_p->servptr->name, target_p->info); |
| 596 |
|
} |
| 597 |
|
|
| 598 |
< |
if (IsConfAwayBurst((struct AccessItem *)map_to_conf(client_p->serv->sconf))) |
| 599 |
< |
if (!EmptyString(target_p->away)) |
| 600 |
< |
sendto_one(client_p, ":%s AWAY :%s", target_p->name, |
| 696 |
< |
target_p->away); |
| 598 |
> |
if (target_p->away[0]) |
| 599 |
> |
sendto_one(client_p, ":%s AWAY :%s", ID_or_name(target_p, client_p), |
| 600 |
> |
target_p->away); |
| 601 |
|
|
| 602 |
|
} |
| 603 |
|
|
| 615 |
|
char *t = msgbuf; |
| 616 |
|
dlink_node *ptr; |
| 617 |
|
|
| 618 |
< |
t += ircsprintf(msgbuf, "TS "); |
| 618 |
> |
t += sprintf(msgbuf, "TS "); |
| 619 |
|
|
| 620 |
|
DLINK_FOREACH(ptr, cap_list.head) |
| 621 |
|
{ |
| 622 |
|
const struct Capability *cap = ptr->data; |
| 623 |
|
|
| 624 |
|
if (IsCapable(target_p, cap->cap)) |
| 625 |
< |
t += ircsprintf(t, "%s ", cap->name); |
| 625 |
> |
t += sprintf(t, "%s ", cap->name); |
| 626 |
|
} |
| 627 |
|
|
| 628 |
|
*(t - 1) = '\0'; |
| 655 |
|
server_estab(struct Client *client_p) |
| 656 |
|
{ |
| 657 |
|
struct Client *target_p; |
| 658 |
< |
struct ConfItem *conf; |
| 755 |
< |
struct AccessItem *aconf=NULL; |
| 658 |
> |
struct MaskItem *conf = NULL; |
| 659 |
|
char *host; |
| 660 |
|
const char *inpath; |
| 661 |
|
static char inpath_ip[HOSTLEN * 2 + USERLEN + 6]; |
| 662 |
|
dlink_node *ptr; |
| 663 |
+ |
#ifdef HAVE_LIBCRYPTO |
| 664 |
+ |
const COMP_METHOD *compression = NULL, *expansion = NULL; |
| 665 |
+ |
#endif |
| 666 |
|
|
| 667 |
|
assert(client_p != NULL); |
| 668 |
|
|
| 671 |
|
inpath = get_client_name(client_p, MASK_IP); /* "refresh" inpath with host */ |
| 672 |
|
host = client_p->name; |
| 673 |
|
|
| 674 |
< |
if ((conf = find_conf_name(&client_p->localClient->confs, host, SERVER_TYPE)) |
| 674 |
> |
if ((conf = find_conf_name(&client_p->localClient->confs, host, CONF_SERVER)) |
| 675 |
|
== NULL) |
| 676 |
|
{ |
| 677 |
|
/* This shouldn't happen, better tell the ops... -A1kmm */ |
| 678 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "Warning: Lost connect{} block " |
| 678 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 679 |
> |
"Warning: Lost connect{} block " |
| 680 |
|
"for server %s(this shouldn't happen)!", host); |
| 681 |
|
exit_client(client_p, &me, "Lost connect{} block!"); |
| 682 |
|
return; |
| 702 |
|
} |
| 703 |
|
} |
| 704 |
|
|
| 798 |
– |
aconf = map_to_conf(conf); |
| 799 |
– |
|
| 705 |
|
if (IsUnknown(client_p)) |
| 706 |
|
{ |
| 707 |
< |
/* jdc -- 1. Use EmptyString(), not [0] index reference. |
| 803 |
< |
* 2. Check aconf->spasswd, not aconf->passwd. |
| 804 |
< |
*/ |
| 805 |
< |
if (!EmptyString(aconf->spasswd)) |
| 806 |
< |
sendto_one(client_p, "PASS %s TS %d %s", |
| 807 |
< |
aconf->spasswd, TS_CURRENT, me.id); |
| 808 |
< |
|
| 809 |
< |
/* Pass my info to the new server |
| 810 |
< |
* |
| 811 |
< |
* Pass on ZIP if supported |
| 812 |
< |
* Pass on TB if supported. |
| 813 |
< |
* - Dianora |
| 814 |
< |
*/ |
| 707 |
> |
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
| 708 |
|
|
| 709 |
< |
send_capabilities(client_p, aconf, |
| 817 |
< |
(IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0)); |
| 709 |
> |
send_capabilities(client_p, 0); |
| 710 |
|
|
| 711 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", |
| 712 |
|
me.name, ConfigServerHide.hidden ? "(H) " : "", me.info); |
| 720 |
|
hash_add_id(client_p); |
| 721 |
|
|
| 722 |
|
/* XXX Does this ever happen? I don't think so -db */ |
| 723 |
< |
detach_conf(client_p, OPER_TYPE); |
| 723 |
> |
detach_conf(client_p, CONF_OPER); |
| 724 |
|
|
| 725 |
|
/* *WARNING* |
| 726 |
|
** In the following code in place of plain server's |
| 762 |
|
/* fixing eob timings.. -gnp */ |
| 763 |
|
client_p->localClient->firsttime = CurrentTime; |
| 764 |
|
|
| 765 |
< |
if (find_matching_name_conf(SERVICE_TYPE, client_p->name, NULL, NULL, 0)) |
| 765 |
> |
if (find_matching_name_conf(CONF_SERVICE, client_p->name, NULL, NULL, 0)) |
| 766 |
|
AddFlag(client_p, FLAGS_SERVICE); |
| 767 |
|
|
| 768 |
|
/* Show the real host/IP to admins */ |
| 769 |
+ |
#ifdef HAVE_LIBCRYPTO |
| 770 |
|
if (client_p->localClient->fd.ssl) |
| 771 |
|
{ |
| 772 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 773 |
< |
"Link with %s established: [SSL: %s] (Capabilities: %s)", |
| 772 |
> |
compression = SSL_get_current_compression(client_p->localClient->fd.ssl); |
| 773 |
> |
expansion = SSL_get_current_expansion(client_p->localClient->fd.ssl); |
| 774 |
> |
|
| 775 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 776 |
> |
"Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)", |
| 777 |
|
inpath_ip, ssl_get_cipher(client_p->localClient->fd.ssl), |
| 778 |
+ |
compression ? SSL_COMP_get_name(compression) : "NONE", |
| 779 |
+ |
expansion ? SSL_COMP_get_name(expansion) : "NONE", |
| 780 |
|
show_capabilities(client_p)); |
| 781 |
|
/* Now show the masked hostname/IP to opers */ |
| 782 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
| 783 |
< |
"Link with %s established: [SSL: %s] (Capabilities: %s)", |
| 782 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 783 |
> |
"Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)", |
| 784 |
|
inpath, ssl_get_cipher(client_p->localClient->fd.ssl), |
| 785 |
+ |
compression ? SSL_COMP_get_name(compression) : "NONE", |
| 786 |
+ |
expansion ? SSL_COMP_get_name(expansion) : "NONE", |
| 787 |
|
show_capabilities(client_p)); |
| 788 |
< |
ilog(LOG_TYPE_IRCD, "Link with %s established: [SSL: %s] (Capabilities: %s)", |
| 788 |
> |
ilog(LOG_TYPE_IRCD, "Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)", |
| 789 |
|
inpath_ip, ssl_get_cipher(client_p->localClient->fd.ssl), |
| 790 |
+ |
compression ? SSL_COMP_get_name(compression) : "NONE", |
| 791 |
+ |
expansion ? SSL_COMP_get_name(expansion) : "NONE", |
| 792 |
|
show_capabilities(client_p)); |
| 793 |
|
} |
| 794 |
|
else |
| 795 |
+ |
#endif |
| 796 |
|
{ |
| 797 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 797 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 798 |
|
"Link with %s established: (Capabilities: %s)", |
| 799 |
< |
inpath_ip,show_capabilities(client_p)); |
| 799 |
> |
inpath_ip, show_capabilities(client_p)); |
| 800 |
|
/* Now show the masked hostname/IP to opers */ |
| 801 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
| 801 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 802 |
|
"Link with %s established: (Capabilities: %s)", |
| 803 |
< |
inpath,show_capabilities(client_p)); |
| 803 |
> |
inpath, show_capabilities(client_p)); |
| 804 |
|
ilog(LOG_TYPE_IRCD, "Link with %s established: (Capabilities: %s)", |
| 805 |
|
inpath_ip, show_capabilities(client_p)); |
| 806 |
|
} |
| 807 |
|
|
| 905 |
– |
client_p->serv->sconf = conf; |
| 906 |
– |
|
| 808 |
|
fd_note(&client_p->localClient->fd, "Server: %s", client_p->name); |
| 809 |
|
|
| 810 |
|
/* Old sendto_serv_but_one() call removed because we now |
| 872 |
|
sendto_one(client_p, ":%s SERVER %s %d :%s%s", |
| 873 |
|
target_p->servptr->name, target_p->name, target_p->hopcount+1, |
| 874 |
|
IsHidden(target_p) ? "(H) " : "", target_p->info); |
| 875 |
+ |
|
| 876 |
+ |
if (HasFlag(target_p, FLAGS_EOB)) |
| 877 |
+ |
sendto_one(client_p, ":%s EOB", ID_or_name(client_p, target_p)); |
| 878 |
|
} |
| 879 |
|
|
| 880 |
|
server_burst(client_p); |
| 928 |
|
burst_members(client_p, chptr); |
| 929 |
|
send_channel_modes(client_p, chptr); |
| 930 |
|
|
| 931 |
< |
if (IsCapable(client_p, CAP_TBURST) || |
| 932 |
< |
IsCapable(client_p, CAP_TB)) |
| 1029 |
< |
send_tb(client_p, chptr); |
| 931 |
> |
if (IsCapable(client_p, CAP_TBURST)) |
| 932 |
> |
send_tb(client_p, chptr); |
| 933 |
|
} |
| 934 |
|
} |
| 935 |
|
|
| 945 |
|
DelFlag(target_p, FLAGS_BURSTED); |
| 946 |
|
} |
| 947 |
|
|
| 1045 |
– |
/* We send the time we started the burst, and let the remote host determine an EOB time, |
| 1046 |
– |
** as otherwise we end up sending a EOB of 0 Sending here means it gets sent last -- fl |
| 1047 |
– |
*/ |
| 1048 |
– |
/* Its simpler to just send EOB and use the time its been connected.. --fl_ */ |
| 948 |
|
if (IsCapable(client_p, CAP_EOB)) |
| 949 |
|
sendto_one(client_p, ":%s EOB", ID_or_name(&me, client_p)); |
| 950 |
|
} |
| 956 |
|
* - pointer to channel |
| 957 |
|
* output - NONE |
| 958 |
|
* side effects - Called on a server burst when |
| 959 |
< |
* server is CAP_TB|CAP_TBURST capable |
| 959 |
> |
* server is CAP_TBURST capable |
| 960 |
|
*/ |
| 961 |
|
static void |
| 962 |
|
send_tb(struct Client *client_p, struct Channel *chptr) |
| 975 |
|
* for further information -Michael |
| 976 |
|
*/ |
| 977 |
|
if (chptr->topic_time != 0) |
| 978 |
< |
{ |
| 979 |
< |
if (IsCapable(client_p, CAP_TBURST)) |
| 980 |
< |
sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s", |
| 981 |
< |
me.name, (unsigned long)chptr->channelts, chptr->chname, |
| 982 |
< |
(unsigned long)chptr->topic_time, |
| 983 |
< |
chptr->topic_info, |
| 1085 |
< |
chptr->topic); |
| 1086 |
< |
else if (IsCapable(client_p, CAP_TB)) |
| 1087 |
< |
{ |
| 1088 |
< |
if (ConfigChannel.burst_topicwho) |
| 1089 |
< |
{ |
| 1090 |
< |
sendto_one(client_p, ":%s TB %s %lu %s :%s", |
| 1091 |
< |
me.name, chptr->chname, |
| 1092 |
< |
(unsigned long)chptr->topic_time, |
| 1093 |
< |
chptr->topic_info, chptr->topic); |
| 1094 |
< |
} |
| 1095 |
< |
else |
| 1096 |
< |
{ |
| 1097 |
< |
sendto_one(client_p, ":%s TB %s %lu :%s", |
| 1098 |
< |
me.name, chptr->chname, |
| 1099 |
< |
(unsigned long)chptr->topic_time, |
| 1100 |
< |
chptr->topic); |
| 1101 |
< |
} |
| 1102 |
< |
} |
| 1103 |
< |
} |
| 978 |
> |
sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s", |
| 979 |
> |
ID_or_name(&me, client_p), |
| 980 |
> |
(unsigned long)chptr->channelts, chptr->chname, |
| 981 |
> |
(unsigned long)chptr->topic_time, |
| 982 |
> |
chptr->topic_info, |
| 983 |
> |
chptr->topic); |
| 984 |
|
} |
| 985 |
|
|
| 986 |
|
/* burst_members() |
| 1034 |
|
* it suceeded or not, and 0 if it fails in here somewhere. |
| 1035 |
|
*/ |
| 1036 |
|
int |
| 1037 |
< |
serv_connect(struct AccessItem *aconf, struct Client *by) |
| 1037 |
> |
serv_connect(struct MaskItem *conf, struct Client *by) |
| 1038 |
|
{ |
| 1159 |
– |
struct ConfItem *conf; |
| 1039 |
|
struct Client *client_p; |
| 1040 |
< |
char buf[HOSTIPLEN]; |
| 1040 |
> |
char buf[HOSTIPLEN + 1]; |
| 1041 |
|
|
| 1042 |
|
/* conversion structs */ |
| 1043 |
|
struct sockaddr_in *v4; |
| 1044 |
< |
/* Make sure aconf is useful */ |
| 1045 |
< |
assert(aconf != NULL); |
| 1167 |
< |
|
| 1168 |
< |
if(aconf == NULL) |
| 1169 |
< |
return (0); |
| 1044 |
> |
/* Make sure conf is useful */ |
| 1045 |
> |
assert(conf != NULL); |
| 1046 |
|
|
| 1171 |
– |
/* XXX should be passing struct ConfItem in the first place */ |
| 1172 |
– |
conf = unmap_conf_item(aconf); |
| 1047 |
|
|
| 1048 |
< |
/* log */ |
| 1175 |
< |
getnameinfo((struct sockaddr *)&aconf->ipnum, aconf->ipnum.ss_len, |
| 1048 |
> |
getnameinfo((struct sockaddr *)&conf->addr, conf->addr.ss_len, |
| 1049 |
|
buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); |
| 1050 |
< |
ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", aconf->user, aconf->host, |
| 1050 |
> |
ilog(LOG_TYPE_IRCD, "Connect to %s[%s] @%s", conf->name, conf->host, |
| 1051 |
|
buf); |
| 1052 |
|
|
| 1053 |
|
/* Still processing a DNS lookup? -> exit */ |
| 1054 |
< |
if (aconf->dns_pending) |
| 1054 |
> |
if (conf->dns_pending) |
| 1055 |
|
{ |
| 1056 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 1056 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 1057 |
|
"Error connecting to %s: DNS lookup for connect{} in progress.", |
| 1058 |
|
conf->name); |
| 1059 |
|
return (0); |
| 1060 |
|
} |
| 1061 |
|
|
| 1062 |
< |
if (aconf->dns_failed) |
| 1062 |
> |
if (conf->dns_failed) |
| 1063 |
|
{ |
| 1064 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 1064 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 1065 |
|
"Error connecting to %s: DNS lookup for connect{} failed.", |
| 1066 |
|
conf->name); |
| 1067 |
|
return (0); |
| 1068 |
|
} |
| 1069 |
|
|
| 1070 |
|
/* Make sure this server isn't already connected |
| 1071 |
< |
* Note: aconf should ALWAYS be a valid C: line |
| 1071 |
> |
* Note: conf should ALWAYS be a valid C: line |
| 1072 |
|
*/ |
| 1073 |
|
if ((client_p = hash_find_server(conf->name)) != NULL) |
| 1074 |
|
{ |
| 1075 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 1076 |
< |
"Server %s already present from %s", |
| 1077 |
< |
conf->name, get_client_name(client_p, SHOW_IP)); |
| 1078 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
| 1079 |
< |
"Server %s already present from %s", |
| 1080 |
< |
conf->name, get_client_name(client_p, MASK_IP)); |
| 1075 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 1076 |
> |
"Server %s already present from %s", |
| 1077 |
> |
conf->name, get_client_name(client_p, SHOW_IP)); |
| 1078 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 1079 |
> |
"Server %s already present from %s", |
| 1080 |
> |
conf->name, get_client_name(client_p, MASK_IP)); |
| 1081 |
|
if (by && IsClient(by) && !MyClient(by)) |
| 1082 |
|
sendto_one(by, ":%s NOTICE %s :Server %s already present from %s", |
| 1083 |
< |
me.name, by->name, conf->name, |
| 1084 |
< |
get_client_name(client_p, MASK_IP)); |
| 1085 |
< |
return (0); |
| 1083 |
> |
me.name, by->name, conf->name, |
| 1084 |
> |
get_client_name(client_p, MASK_IP)); |
| 1085 |
> |
return 0; |
| 1086 |
|
} |
| 1087 |
|
|
| 1088 |
|
/* Create a local client */ |
| 1090 |
|
|
| 1091 |
|
/* Copy in the server, hostname, fd */ |
| 1092 |
|
strlcpy(client_p->name, conf->name, sizeof(client_p->name)); |
| 1093 |
< |
strlcpy(client_p->host, aconf->host, sizeof(client_p->host)); |
| 1093 |
> |
strlcpy(client_p->host, conf->host, sizeof(client_p->host)); |
| 1094 |
|
|
| 1095 |
|
/* We already converted the ip once, so lets use it - stu */ |
| 1096 |
|
strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost)); |
| 1097 |
|
|
| 1098 |
|
/* create a socket for the server connection */ |
| 1099 |
< |
if (comm_open(&client_p->localClient->fd, aconf->ipnum.ss.ss_family, |
| 1099 |
> |
if (comm_open(&client_p->localClient->fd, conf->addr.ss.ss_family, |
| 1100 |
|
SOCK_STREAM, 0, NULL) < 0) |
| 1101 |
|
{ |
| 1102 |
|
/* Eek, failure to create the socket */ |
| 1103 |
< |
report_error(L_ALL, |
| 1104 |
< |
"opening stream socket to %s: %s", conf->name, errno); |
| 1103 |
> |
report_error(L_ALL, "opening stream socket to %s: %s", |
| 1104 |
> |
conf->name, errno); |
| 1105 |
|
SetDead(client_p); |
| 1106 |
|
exit_client(client_p, &me, "Connection failed"); |
| 1107 |
< |
return (0); |
| 1107 |
> |
return 0; |
| 1108 |
|
} |
| 1109 |
|
|
| 1110 |
|
/* servernames are always guaranteed under HOSTLEN chars */ |
| 1113 |
|
/* Attach config entries to client here rather than in |
| 1114 |
|
* serv_connect_callback(). This to avoid null pointer references. |
| 1115 |
|
*/ |
| 1116 |
< |
if (!attach_connect_block(client_p, conf->name, aconf->host)) |
| 1116 |
> |
if (!attach_connect_block(client_p, conf->name, conf->host)) |
| 1117 |
|
{ |
| 1118 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 1119 |
< |
"Host %s is not enabled for connecting:no C/N-line", |
| 1120 |
< |
conf->name); |
| 1118 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 1119 |
> |
"Host %s is not enabled for connecting: no connect{} block", |
| 1120 |
> |
conf->name); |
| 1121 |
|
if (by && IsClient(by) && !MyClient(by)) |
| 1122 |
|
sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.", |
| 1123 |
< |
me.name, by->name, client_p->name); |
| 1123 |
> |
me.name, by->name, client_p->name); |
| 1124 |
|
SetDead(client_p); |
| 1125 |
|
exit_client(client_p, client_p, "Connection failed"); |
| 1126 |
< |
return (0); |
| 1126 |
> |
return 0; |
| 1127 |
|
} |
| 1128 |
|
|
| 1129 |
|
/* at this point we have a connection in progress and C/N lines |
| 1142 |
|
SetConnecting(client_p); |
| 1143 |
|
dlinkAdd(client_p, &client_p->node, &global_client_list); |
| 1144 |
|
/* from def_fam */ |
| 1145 |
< |
client_p->localClient->aftype = aconf->aftype; |
| 1145 |
> |
client_p->localClient->aftype = conf->aftype; |
| 1146 |
|
|
| 1147 |
|
/* Now, initiate the connection */ |
| 1148 |
|
/* XXX assume that a non 0 type means a specific bind address |
| 1149 |
|
* for this connect. |
| 1150 |
|
*/ |
| 1151 |
< |
switch (aconf->aftype) |
| 1151 |
> |
switch (conf->aftype) |
| 1152 |
|
{ |
| 1153 |
|
case AF_INET: |
| 1154 |
< |
v4 = (struct sockaddr_in*)&aconf->my_ipnum; |
| 1154 |
> |
v4 = (struct sockaddr_in*)&conf->bind; |
| 1155 |
|
if (v4->sin_addr.s_addr != 0) |
| 1156 |
|
{ |
| 1157 |
|
struct irc_ssaddr ipn; |
| 1158 |
|
memset(&ipn, 0, sizeof(struct irc_ssaddr)); |
| 1159 |
|
ipn.ss.ss_family = AF_INET; |
| 1160 |
|
ipn.ss_port = 0; |
| 1161 |
< |
memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr)); |
| 1162 |
< |
comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port, |
| 1163 |
< |
(struct sockaddr *)&ipn, ipn.ss_len, |
| 1164 |
< |
serv_connect_callback, client_p, aconf->aftype, |
| 1165 |
< |
CONNECTTIMEOUT); |
| 1161 |
> |
memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr)); |
| 1162 |
> |
comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port, |
| 1163 |
> |
(struct sockaddr *)&ipn, ipn.ss_len, |
| 1164 |
> |
serv_connect_callback, client_p, conf->aftype, |
| 1165 |
> |
CONNECTTIMEOUT); |
| 1166 |
|
} |
| 1167 |
|
else if (ServerInfo.specific_ipv4_vhost) |
| 1168 |
|
{ |
| 1171 |
|
ipn.ss.ss_family = AF_INET; |
| 1172 |
|
ipn.ss_port = 0; |
| 1173 |
|
memcpy(&ipn, &ServerInfo.ip, sizeof(struct irc_ssaddr)); |
| 1174 |
< |
comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port, |
| 1174 |
> |
comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port, |
| 1175 |
|
(struct sockaddr *)&ipn, ipn.ss_len, |
| 1176 |
< |
serv_connect_callback, client_p, aconf->aftype, |
| 1177 |
< |
CONNECTTIMEOUT); |
| 1176 |
> |
serv_connect_callback, client_p, conf->aftype, |
| 1177 |
> |
CONNECTTIMEOUT); |
| 1178 |
|
} |
| 1179 |
|
else |
| 1180 |
< |
comm_connect_tcp(&client_p->localClient->fd, aconf->host, aconf->port, |
| 1181 |
< |
NULL, 0, serv_connect_callback, client_p, aconf->aftype, |
| 1180 |
> |
comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port, |
| 1181 |
> |
NULL, 0, serv_connect_callback, client_p, conf->aftype, |
| 1182 |
|
CONNECTTIMEOUT); |
| 1183 |
|
break; |
| 1184 |
|
#ifdef IPV6 |
| 1189 |
|
struct sockaddr_in6 *v6conf; |
| 1190 |
|
|
| 1191 |
|
memset(&ipn, 0, sizeof(struct irc_ssaddr)); |
| 1192 |
< |
v6conf = (struct sockaddr_in6 *)&aconf->my_ipnum; |
| 1192 |
> |
v6conf = (struct sockaddr_in6 *)&conf->bind; |
| 1193 |
|
v6 = (struct sockaddr_in6 *)&ipn; |
| 1194 |
|
|
| 1195 |
|
if (memcmp(&v6conf->sin6_addr, &v6->sin6_addr, |
| 1196 |
|
sizeof(struct in6_addr)) != 0) |
| 1197 |
|
{ |
| 1198 |
< |
memcpy(&ipn, &aconf->my_ipnum, sizeof(struct irc_ssaddr)); |
| 1198 |
> |
memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr)); |
| 1199 |
|
ipn.ss.ss_family = AF_INET6; |
| 1200 |
|
ipn.ss_port = 0; |
| 1201 |
|
comm_connect_tcp(&client_p->localClient->fd, |
| 1202 |
< |
aconf->host, aconf->port, |
| 1202 |
> |
conf->host, conf->port, |
| 1203 |
|
(struct sockaddr *)&ipn, ipn.ss_len, |
| 1204 |
|
serv_connect_callback, client_p, |
| 1205 |
< |
aconf->aftype, CONNECTTIMEOUT); |
| 1205 |
> |
conf->aftype, CONNECTTIMEOUT); |
| 1206 |
|
} |
| 1207 |
|
else if (ServerInfo.specific_ipv6_vhost) |
| 1208 |
|
{ |
| 1210 |
|
ipn.ss.ss_family = AF_INET6; |
| 1211 |
|
ipn.ss_port = 0; |
| 1212 |
|
comm_connect_tcp(&client_p->localClient->fd, |
| 1213 |
< |
aconf->host, aconf->port, |
| 1213 |
> |
conf->host, conf->port, |
| 1214 |
|
(struct sockaddr *)&ipn, ipn.ss_len, |
| 1215 |
|
serv_connect_callback, client_p, |
| 1216 |
< |
aconf->aftype, CONNECTTIMEOUT); |
| 1216 |
> |
conf->aftype, CONNECTTIMEOUT); |
| 1217 |
|
} |
| 1218 |
|
else |
| 1219 |
|
comm_connect_tcp(&client_p->localClient->fd, |
| 1220 |
< |
aconf->host, aconf->port, |
| 1220 |
> |
conf->host, conf->port, |
| 1221 |
|
NULL, 0, serv_connect_callback, client_p, |
| 1222 |
< |
aconf->aftype, CONNECTTIMEOUT); |
| 1222 |
> |
conf->aftype, CONNECTTIMEOUT); |
| 1223 |
|
} |
| 1224 |
|
#endif |
| 1225 |
|
} |
| 1230 |
|
static void |
| 1231 |
|
finish_ssl_server_handshake(struct Client *client_p) |
| 1232 |
|
{ |
| 1233 |
< |
struct ConfItem *conf=NULL; |
| 1361 |
< |
struct AccessItem *aconf=NULL; |
| 1233 |
> |
struct MaskItem *conf = NULL; |
| 1234 |
|
|
| 1235 |
|
conf = find_conf_name(&client_p->localClient->confs, |
| 1236 |
< |
client_p->name, SERVER_TYPE); |
| 1236 |
> |
client_p->name, CONF_SERVER); |
| 1237 |
|
if (conf == NULL) |
| 1238 |
|
{ |
| 1239 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 1239 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 1240 |
|
"Lost connect{} block for %s", get_client_name(client_p, HIDE_IP)); |
| 1241 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
| 1241 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 1242 |
|
"Lost connect{} block for %s", get_client_name(client_p, MASK_IP)); |
| 1243 |
|
|
| 1244 |
|
exit_client(client_p, &me, "Lost connect{} block"); |
| 1245 |
|
return; |
| 1246 |
|
} |
| 1247 |
|
|
| 1248 |
< |
aconf = map_to_conf(conf); |
| 1377 |
< |
|
| 1378 |
< |
/* jdc -- Check and send spasswd, not passwd. */ |
| 1379 |
< |
if (!EmptyString(aconf->spasswd)) |
| 1380 |
< |
sendto_one(client_p, "PASS %s TS %d %s", |
| 1381 |
< |
aconf->spasswd, TS_CURRENT, me.id); |
| 1248 |
> |
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
| 1249 |
|
|
| 1250 |
< |
send_capabilities(client_p, aconf, |
| 1384 |
< |
(IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0)); |
| 1250 |
> |
send_capabilities(client_p, 0); |
| 1251 |
|
|
| 1252 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", |
| 1253 |
|
me.name, ConfigServerHide.hidden ? "(H) " : "", |
| 1258 |
|
*/ |
| 1259 |
|
if (IsDead(client_p)) |
| 1260 |
|
{ |
| 1261 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 1261 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 1262 |
|
"%s[%s] went dead during handshake", |
| 1263 |
|
client_p->name, |
| 1264 |
|
client_p->host); |
| 1265 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
| 1265 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 1266 |
|
"%s went dead during handshake", client_p->name); |
| 1267 |
|
return; |
| 1268 |
|
} |
| 1273 |
|
} |
| 1274 |
|
|
| 1275 |
|
static void |
| 1276 |
< |
ssl_server_handshake(struct Client *client_p) |
| 1276 |
> |
ssl_server_handshake(fde_t *fd, struct Client *client_p) |
| 1277 |
|
{ |
| 1278 |
|
int ret; |
| 1279 |
|
int err; |
| 1286 |
|
{ |
| 1287 |
|
case SSL_ERROR_WANT_WRITE: |
| 1288 |
|
comm_setselect(&client_p->localClient->fd, COMM_SELECT_WRITE, |
| 1289 |
< |
(PF *) ssl_server_handshake, client_p, 0); |
| 1289 |
> |
(PF *)ssl_server_handshake, client_p, 0); |
| 1290 |
|
return; |
| 1291 |
|
case SSL_ERROR_WANT_READ: |
| 1292 |
|
comm_setselect(&client_p->localClient->fd, COMM_SELECT_READ, |
| 1293 |
< |
(PF *) ssl_server_handshake, client_p, 0); |
| 1293 |
> |
(PF *)ssl_server_handshake, client_p, 0); |
| 1294 |
|
return; |
| 1295 |
|
default: |
| 1296 |
+ |
{ |
| 1297 |
+ |
const char *sslerr = ERR_error_string(ERR_get_error(), NULL); |
| 1298 |
+ |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 1299 |
+ |
"Error connecting to %s: %s", client_p->name, |
| 1300 |
+ |
sslerr ? sslerr : "unknown SSL error"); |
| 1301 |
|
exit_client(client_p, client_p, "Error during SSL handshake"); |
| 1302 |
|
return; |
| 1303 |
+ |
} |
| 1304 |
|
} |
| 1305 |
|
} |
| 1306 |
|
|
| 1308 |
|
} |
| 1309 |
|
|
| 1310 |
|
static void |
| 1311 |
< |
ssl_connect_init(struct Client *client_p, fde_t *fd) |
| 1311 |
> |
ssl_connect_init(struct Client *client_p, struct MaskItem *conf, fde_t *fd) |
| 1312 |
|
{ |
| 1313 |
|
if ((client_p->localClient->fd.ssl = SSL_new(ServerInfo.client_ctx)) == NULL) |
| 1314 |
|
{ |
| 1320 |
|
} |
| 1321 |
|
|
| 1322 |
|
SSL_set_fd(fd->ssl, fd->fd); |
| 1323 |
< |
ssl_server_handshake(client_p); |
| 1323 |
> |
|
| 1324 |
> |
if (!EmptyString(conf->cipher_list)) |
| 1325 |
> |
SSL_set_cipher_list(client_p->localClient->fd.ssl, conf->cipher_list); |
| 1326 |
> |
|
| 1327 |
> |
ssl_server_handshake(NULL, client_p); |
| 1328 |
|
} |
| 1329 |
|
#endif |
| 1330 |
|
|
| 1340 |
|
serv_connect_callback(fde_t *fd, int status, void *data) |
| 1341 |
|
{ |
| 1342 |
|
struct Client *client_p = data; |
| 1343 |
< |
struct ConfItem *conf=NULL; |
| 1468 |
< |
struct AccessItem *aconf=NULL; |
| 1343 |
> |
struct MaskItem *conf = NULL; |
| 1344 |
|
|
| 1345 |
|
/* First, make sure its a real client! */ |
| 1346 |
|
assert(client_p != NULL); |
| 1356 |
|
* Admins get to see any IP, mere opers don't *sigh* |
| 1357 |
|
*/ |
| 1358 |
|
if (ConfigServerHide.hide_server_ips) |
| 1359 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 1359 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 1360 |
|
"Error connecting to %s: %s", |
| 1361 |
|
client_p->name, comm_errstr(status)); |
| 1362 |
|
else |
| 1363 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 1364 |
< |
"Error connecting to %s[%s]: %s", client_p->name, |
| 1365 |
< |
client_p->host, comm_errstr(status)); |
| 1366 |
< |
|
| 1367 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
| 1368 |
< |
"Error connecting to %s: %s", |
| 1369 |
< |
client_p->name, comm_errstr(status)); |
| 1363 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 1364 |
> |
"Error connecting to %s[%s]: %s", client_p->name, |
| 1365 |
> |
client_p->host, comm_errstr(status)); |
| 1366 |
> |
|
| 1367 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 1368 |
> |
"Error connecting to %s: %s", |
| 1369 |
> |
client_p->name, comm_errstr(status)); |
| 1370 |
|
|
| 1371 |
|
/* If a fd goes bad, call dead_link() the socket is no |
| 1372 |
|
* longer valid for reading or writing. |
| 1378 |
|
/* COMM_OK, so continue the connection procedure */ |
| 1379 |
|
/* Get the C/N lines */ |
| 1380 |
|
conf = find_conf_name(&client_p->localClient->confs, |
| 1381 |
< |
client_p->name, SERVER_TYPE); |
| 1381 |
> |
client_p->name, CONF_SERVER); |
| 1382 |
|
if (conf == NULL) |
| 1383 |
|
{ |
| 1384 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 1385 |
< |
"Lost connect{} block for %s", get_client_name(client_p, HIDE_IP)); |
| 1386 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
| 1387 |
< |
"Lost connect{} block for %s", get_client_name(client_p, MASK_IP)); |
| 1384 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 1385 |
> |
"Lost connect{} block for %s", get_client_name(client_p, HIDE_IP)); |
| 1386 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 1387 |
> |
"Lost connect{} block for %s", get_client_name(client_p, MASK_IP)); |
| 1388 |
|
|
| 1389 |
|
exit_client(client_p, &me, "Lost connect{} block"); |
| 1390 |
|
return; |
| 1391 |
|
} |
| 1392 |
|
|
| 1518 |
– |
aconf = map_to_conf(conf); |
| 1393 |
|
/* Next, send the initial handshake */ |
| 1394 |
|
SetHandshake(client_p); |
| 1395 |
|
|
| 1396 |
|
#ifdef HAVE_LIBCRYPTO |
| 1397 |
< |
if (IsConfSSL(aconf)) |
| 1397 |
> |
if (IsConfSSL(conf)) |
| 1398 |
|
{ |
| 1399 |
< |
ssl_connect_init(client_p, fd); |
| 1399 |
> |
ssl_connect_init(client_p, conf, fd); |
| 1400 |
|
return; |
| 1401 |
|
} |
| 1402 |
|
#endif |
| 1403 |
|
|
| 1404 |
< |
/* jdc -- Check and send spasswd, not passwd. */ |
| 1531 |
< |
if (!EmptyString(aconf->spasswd)) |
| 1532 |
< |
sendto_one(client_p, "PASS %s TS %d %s", |
| 1533 |
< |
aconf->spasswd, TS_CURRENT, me.id); |
| 1404 |
> |
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
| 1405 |
|
|
| 1406 |
< |
send_capabilities(client_p, aconf, |
| 1536 |
< |
(IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0)); |
| 1406 |
> |
send_capabilities(client_p, 0); |
| 1407 |
|
|
| 1408 |
< |
sendto_one(client_p, "SERVER %s 1 :%s%s", |
| 1409 |
< |
me.name, ConfigServerHide.hidden ? "(H) " : "", |
| 1540 |
< |
me.info); |
| 1408 |
> |
sendto_one(client_p, "SERVER %s 1 :%s%s", me.name, |
| 1409 |
> |
ConfigServerHide.hidden ? "(H) " : "", me.info); |
| 1410 |
|
|
| 1411 |
|
/* If we've been marked dead because a send failed, just exit |
| 1412 |
|
* here now and save everyone the trouble of us ever existing. |
| 1413 |
|
*/ |
| 1414 |
|
if (IsDead(client_p)) |
| 1415 |
|
{ |
| 1416 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 1417 |
< |
"%s[%s] went dead during handshake", |
| 1416 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 1417 |
> |
"%s[%s] went dead during handshake", |
| 1418 |
|
client_p->name, |
| 1419 |
< |
client_p->host); |
| 1420 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
| 1421 |
< |
"%s went dead during handshake", client_p->name); |
| 1419 |
> |
client_p->host); |
| 1420 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 1421 |
> |
"%s went dead during handshake", client_p->name); |
| 1422 |
|
return; |
| 1423 |
|
} |
| 1424 |
|
|
| 1438 |
|
cptr = ptr->data; |
| 1439 |
|
|
| 1440 |
|
if (cptr && cptr->name[0]) |
| 1441 |
< |
if (match(name, cptr->name)) |
| 1441 |
> |
if (!match(name, cptr->name)) |
| 1442 |
|
return cptr; |
| 1443 |
|
} |
| 1444 |
|
|