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" |
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 *); |
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; |
81 |
< |
MessageFileLine *newMessageLine = 0; |
82 |
< |
MessageFile *MessageFileptr; |
83 |
< |
const char *p; |
84 |
< |
FILE *file; |
85 |
< |
char buff[512]; |
86 |
< |
dlink_node *ptr; |
87 |
< |
|
88 |
< |
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 = fopen(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 |
|
|
99 |
– |
MessageFileptr->contentsOfFile = NULL; |
100 |
– |
currentMessageLine = NULL; |
101 |
– |
|
92 |
|
DLINK_FOREACH(ptr, global_serv_list.head) |
93 |
|
{ |
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 */ |
111 |
< |
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; |
116 |
< |
else |
117 |
< |
p = "(Unknown Location)"; |
118 |
< |
|
119 |
< |
newMessageLine = MyMalloc(sizeof(MessageFileLine)); |
120 |
< |
|
121 |
< |
/* 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 |
|
|
127 |
– |
/* |
128 |
– |
* For now, check this ircsprintf wont overflow - it shouldnt on a |
129 |
– |
* default config but it is configurable.. |
130 |
– |
* This should be changed to an snprintf at some point, but I'm wanting to |
131 |
– |
* know if this is a cause of a bug - cryogen |
132 |
– |
*/ |
133 |
– |
assert(strlen(target_p->name) + strlen(me.name) + 6 + strlen(p) <= |
134 |
– |
MESSAGELINELEN); |
135 |
– |
snprintf(newMessageLine->line, sizeof(newMessageLine->line), "%s %s :1 %s", |
136 |
– |
target_p->name, me.name, p); |
137 |
– |
newMessageLine->next = NULL; |
138 |
– |
|
139 |
– |
if (MessageFileptr->contentsOfFile) |
140 |
– |
{ |
141 |
– |
if (currentMessageLine) |
142 |
– |
currentMessageLine->next = newMessageLine; |
143 |
– |
currentMessageLine = newMessageLine; |
144 |
– |
} |
145 |
– |
else |
146 |
– |
{ |
147 |
– |
MessageFileptr->contentsOfFile = newMessageLine; |
148 |
– |
currentMessageLine = newMessageLine; |
149 |
– |
} |
150 |
– |
|
151 |
– |
snprintf(buff, sizeof(buff), "%s %s :1 %s\n", target_p->name, me.name, p); |
118 |
|
fputs(buff, file); |
119 |
|
} |
120 |
|
|
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; |
153 |
|
if (parc <= server || EmptyString(parv[server])) |
154 |
|
return HUNTED_ISME; |
155 |
|
|
156 |
< |
if (!strcmp(parv[server], me.id) || match(parv[server], me.name)) |
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 |
173 |
|
if (target_p->from == source_p->from && !MyConnect(target_p)) |
174 |
|
target_p = NULL; |
175 |
|
|
176 |
< |
collapse(parv[server]); |
211 |
< |
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 |
186 |
|
{ |
187 |
|
sendto_one(source_p, form_str(ERR_NOSUCHSERVER), |
188 |
|
me.name, source_p->name, parv[server]); |
189 |
< |
return(HUNTED_NOSUCH); |
189 |
> |
return HUNTED_NOSUCH; |
190 |
|
} |
191 |
|
} |
192 |
|
else |
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; |
293 |
< |
struct AccessItem *aconf; |
294 |
< |
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 || |
309 |
< |
!(IsConfAllowAutoConn(aconf))) |
272 |
> |
if (!conf->port ||!IsConfAllowAutoConn(conf)) |
273 |
|
continue; |
274 |
|
|
312 |
– |
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 = cltmp->con_freq; |
289 |
> |
confrq = conf->class->con_freq; |
290 |
|
if (confrq < MIN_CONN_FREQ) |
291 |
< |
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 (cltmp->curr_user_count < cltmp->max_total) |
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; |
401 |
< |
struct AccessItem *server_aconf = NULL; |
402 |
< |
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 |
|
|
407 |
– |
if (client_p == NULL) |
408 |
– |
return(error); |
409 |
– |
|
410 |
– |
if (strlen(name) > HOSTLEN) |
411 |
– |
return(-4); |
412 |
– |
|
369 |
|
/* loop through looking for all possible connect items that might work */ |
370 |
|
DLINK_FOREACH(ptr, server_items.head) |
371 |
|
{ |
372 |
|
conf = ptr->data; |
417 |
– |
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; |
430 |
– |
{ |
431 |
– |
/* A NULL password is as good as a bad one */ |
432 |
– |
if (EmptyString(client_p->localClient->passwd)) |
433 |
– |
return(-2); |
434 |
– |
|
435 |
– |
/* code in s_conf.c should not have allowed this to be NULL */ |
436 |
– |
if (aconf->passwd == NULL) |
437 |
– |
return(-2); |
385 |
|
|
386 |
< |
if (IsConfEncrypted(aconf)) |
387 |
< |
{ |
388 |
< |
if (strcmp(aconf->passwd, |
389 |
< |
(const char *)crypt(client_p->localClient->passwd, |
443 |
< |
aconf->passwd)) == 0) |
444 |
< |
server_conf = conf; |
445 |
< |
} |
446 |
< |
else |
447 |
< |
{ |
448 |
< |
if (strcmp(aconf->passwd, client_p->localClient->passwd) == 0) |
449 |
< |
server_conf = conf; |
450 |
< |
} |
451 |
< |
} |
386 |
> |
if (!match_conf_password(client_p->localClient->passwd, conf)) |
387 |
> |
return -2; |
388 |
> |
|
389 |
> |
server_conf = conf; |
390 |
|
} |
391 |
|
} |
392 |
|
|
393 |
|
if (server_conf == NULL) |
394 |
< |
return(error); |
394 |
> |
return error; |
395 |
|
|
396 |
|
attach_conf(client_p, server_conf); |
397 |
|
|
460 |
– |
server_aconf = map_to_conf(server_conf); |
398 |
|
|
399 |
< |
if (!IsConfTopicBurst(server_aconf)) |
463 |
< |
{ |
464 |
< |
ClearCap(client_p, CAP_TB); |
465 |
< |
ClearCap(client_p, CAP_TBURST); |
466 |
< |
} |
467 |
< |
|
468 |
< |
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 |
|
} |
423 |
|
|
424 |
< |
return(0); |
424 |
> |
return 0; |
425 |
|
} |
426 |
|
|
427 |
|
/* add_capability() |
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; |
543 |
< |
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 |
577 |
– |
* - 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, |
585 |
< |
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 |
|
|
633 |
– |
/* 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, |
674 |
< |
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; |
733 |
< |
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]; |
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 |
|
|
779 |
– |
aconf = map_to_conf(conf); |
780 |
– |
|
705 |
|
if (IsUnknown(client_p)) |
706 |
|
{ |
707 |
< |
/* jdc -- 1. Use EmptyString(), not [0] index reference. |
784 |
< |
* 2. Check aconf->spasswd, not aconf->passwd. |
785 |
< |
*/ |
786 |
< |
if (!EmptyString(aconf->spasswd)) |
787 |
< |
sendto_one(client_p, "PASS %s TS %d %s", |
788 |
< |
aconf->spasswd, TS_CURRENT, me.id); |
789 |
< |
|
790 |
< |
/* Pass my info to the new server |
791 |
< |
* |
792 |
< |
* Pass on ZIP if supported |
793 |
< |
* Pass on TB if supported. |
794 |
< |
* - Dianora |
795 |
< |
*/ |
707 |
> |
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
708 |
|
|
709 |
< |
send_capabilities(client_p, aconf, |
798 |
< |
(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 */ |
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, |
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, |
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", |
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 |
|
|
897 |
– |
client_p->serv->sconf = conf; |
898 |
– |
|
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)) |
1021 |
< |
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 |
|
|
1037 |
– |
/* We send the time we started the burst, and let the remote host determine an EOB time, |
1038 |
– |
** as otherwise we end up sending a EOB of 0 Sending here means it gets sent last -- fl |
1039 |
– |
*/ |
1040 |
– |
/* 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, |
1077 |
< |
chptr->topic); |
1078 |
< |
else if (IsCapable(client_p, CAP_TB)) |
1079 |
< |
{ |
1080 |
< |
if (ConfigChannel.burst_topicwho) |
1081 |
< |
{ |
1082 |
< |
sendto_one(client_p, ":%s TB %s %lu %s :%s", |
1083 |
< |
me.name, chptr->chname, |
1084 |
< |
(unsigned long)chptr->topic_time, |
1085 |
< |
chptr->topic_info, chptr->topic); |
1086 |
< |
} |
1087 |
< |
else |
1088 |
< |
{ |
1089 |
< |
sendto_one(client_p, ":%s TB %s %lu :%s", |
1090 |
< |
me.name, chptr->chname, |
1091 |
< |
(unsigned long)chptr->topic_time, |
1092 |
< |
chptr->topic); |
1093 |
< |
} |
1094 |
< |
} |
1095 |
< |
} |
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 |
|
{ |
1151 |
– |
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); |
1159 |
< |
|
1160 |
< |
if(aconf == NULL) |
1161 |
< |
return (0); |
1044 |
> |
/* Make sure conf is useful */ |
1045 |
> |
assert(conf != NULL); |
1046 |
|
|
1163 |
– |
/* XXX should be passing struct ConfItem in the first place */ |
1164 |
– |
conf = unmap_conf_item(aconf); |
1047 |
|
|
1048 |
< |
/* log */ |
1167 |
< |
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 |
1185 |
|
case AF_INET6: |
1186 |
|
{ |
1187 |
< |
struct irc_ssaddr ipn; |
1188 |
< |
struct sockaddr_in6 *v6; |
1189 |
< |
struct sockaddr_in6 *v6conf; |
1190 |
< |
|
1191 |
< |
memset(&ipn, 0, sizeof(struct irc_ssaddr)); |
1192 |
< |
v6conf = (struct sockaddr_in6 *)&aconf->my_ipnum; |
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)); |
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, |
1203 |
< |
(struct sockaddr *)&ipn, ipn.ss_len, |
1204 |
< |
serv_connect_callback, client_p, |
1205 |
< |
aconf->aftype, CONNECTTIMEOUT); |
1206 |
< |
} |
1326 |
< |
else if (ServerInfo.specific_ipv6_vhost) |
1187 |
> |
struct irc_ssaddr ipn; |
1188 |
> |
struct sockaddr_in6 *v6; |
1189 |
> |
struct sockaddr_in6 *v6conf; |
1190 |
> |
|
1191 |
> |
memset(&ipn, 0, sizeof(struct irc_ssaddr)); |
1192 |
> |
v6conf = (struct sockaddr_in6 *)&conf->bind; |
1193 |
> |
v6 = (struct sockaddr_in6 *)&ipn; |
1194 |
> |
|
1195 |
> |
if (memcmp(&v6conf->sin6_addr, &v6->sin6_addr, sizeof(struct in6_addr)) != 0) |
1196 |
> |
{ |
1197 |
> |
memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr)); |
1198 |
> |
ipn.ss.ss_family = AF_INET6; |
1199 |
> |
ipn.ss_port = 0; |
1200 |
> |
comm_connect_tcp(&client_p->localClient->fd, |
1201 |
> |
conf->host, conf->port, |
1202 |
> |
(struct sockaddr *)&ipn, ipn.ss_len, |
1203 |
> |
serv_connect_callback, client_p, |
1204 |
> |
conf->aftype, CONNECTTIMEOUT); |
1205 |
> |
} |
1206 |
> |
else if (ServerInfo.specific_ipv6_vhost) |
1207 |
|
{ |
1208 |
< |
memcpy(&ipn, &ServerInfo.ip6, sizeof(struct irc_ssaddr)); |
1209 |
< |
ipn.ss.ss_family = AF_INET6; |
1210 |
< |
ipn.ss_port = 0; |
1211 |
< |
comm_connect_tcp(&client_p->localClient->fd, |
1212 |
< |
aconf->host, aconf->port, |
1213 |
< |
(struct sockaddr *)&ipn, ipn.ss_len, |
1214 |
< |
serv_connect_callback, client_p, |
1215 |
< |
aconf->aftype, CONNECTTIMEOUT); |
1216 |
< |
} |
1217 |
< |
else |
1218 |
< |
comm_connect_tcp(&client_p->localClient->fd, |
1219 |
< |
aconf->host, aconf->port, |
1220 |
< |
NULL, 0, serv_connect_callback, client_p, |
1221 |
< |
aconf->aftype, CONNECTTIMEOUT); |
1208 |
> |
memcpy(&ipn, &ServerInfo.ip6, sizeof(struct irc_ssaddr)); |
1209 |
> |
ipn.ss.ss_family = AF_INET6; |
1210 |
> |
ipn.ss_port = 0; |
1211 |
> |
comm_connect_tcp(&client_p->localClient->fd, |
1212 |
> |
conf->host, conf->port, |
1213 |
> |
(struct sockaddr *)&ipn, ipn.ss_len, |
1214 |
> |
serv_connect_callback, client_p, |
1215 |
> |
conf->aftype, CONNECTTIMEOUT); |
1216 |
> |
} |
1217 |
> |
else |
1218 |
> |
comm_connect_tcp(&client_p->localClient->fd, |
1219 |
> |
conf->host, conf->port, |
1220 |
> |
NULL, 0, serv_connect_callback, client_p, |
1221 |
> |
conf->aftype, CONNECTTIMEOUT); |
1222 |
|
} |
1223 |
|
#endif |
1224 |
|
} |
1225 |
< |
return (1); |
1225 |
> |
return 1; |
1226 |
|
} |
1227 |
|
|
1228 |
|
#ifdef HAVE_LIBCRYPTO |
1229 |
|
static void |
1230 |
|
finish_ssl_server_handshake(struct Client *client_p) |
1231 |
|
{ |
1232 |
< |
struct ConfItem *conf=NULL; |
1353 |
< |
struct AccessItem *aconf=NULL; |
1232 |
> |
struct MaskItem *conf = NULL; |
1233 |
|
|
1234 |
|
conf = find_conf_name(&client_p->localClient->confs, |
1235 |
< |
client_p->name, SERVER_TYPE); |
1235 |
> |
client_p->name, CONF_SERVER); |
1236 |
|
if (conf == NULL) |
1237 |
|
{ |
1238 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
1238 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
1239 |
|
"Lost connect{} block for %s", get_client_name(client_p, HIDE_IP)); |
1240 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
1240 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
1241 |
|
"Lost connect{} block for %s", get_client_name(client_p, MASK_IP)); |
1242 |
|
|
1243 |
|
exit_client(client_p, &me, "Lost connect{} block"); |
1244 |
|
return; |
1245 |
|
} |
1246 |
|
|
1247 |
< |
aconf = map_to_conf(conf); |
1369 |
< |
|
1370 |
< |
/* jdc -- Check and send spasswd, not passwd. */ |
1371 |
< |
if (!EmptyString(aconf->spasswd)) |
1372 |
< |
sendto_one(client_p, "PASS %s TS %d %s", |
1373 |
< |
aconf->spasswd, TS_CURRENT, me.id); |
1247 |
> |
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
1248 |
|
|
1249 |
< |
send_capabilities(client_p, aconf, |
1376 |
< |
(IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0)); |
1249 |
> |
send_capabilities(client_p, 0); |
1250 |
|
|
1251 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", |
1252 |
|
me.name, ConfigServerHide.hidden ? "(H) " : "", |
1257 |
|
*/ |
1258 |
|
if (IsDead(client_p)) |
1259 |
|
{ |
1260 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
1260 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
1261 |
|
"%s[%s] went dead during handshake", |
1262 |
|
client_p->name, |
1263 |
|
client_p->host); |
1264 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
1264 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
1265 |
|
"%s went dead during handshake", client_p->name); |
1266 |
|
return; |
1267 |
|
} |
1294 |
|
default: |
1295 |
|
{ |
1296 |
|
const char *sslerr = ERR_error_string(ERR_get_error(), NULL); |
1297 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
1297 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1298 |
|
"Error connecting to %s: %s", client_p->name, |
1299 |
|
sslerr ? sslerr : "unknown SSL error"); |
1300 |
|
exit_client(client_p, client_p, "Error during SSL handshake"); |
1307 |
|
} |
1308 |
|
|
1309 |
|
static void |
1310 |
< |
ssl_connect_init(struct Client *client_p, struct AccessItem *aconf, fde_t *fd) |
1310 |
> |
ssl_connect_init(struct Client *client_p, struct MaskItem *conf, fde_t *fd) |
1311 |
|
{ |
1312 |
|
if ((client_p->localClient->fd.ssl = SSL_new(ServerInfo.client_ctx)) == NULL) |
1313 |
|
{ |
1320 |
|
|
1321 |
|
SSL_set_fd(fd->ssl, fd->fd); |
1322 |
|
|
1323 |
< |
if (!EmptyString(aconf->cipher_list)) |
1324 |
< |
SSL_set_cipher_list(client_p->localClient->fd.ssl, aconf->cipher_list); |
1323 |
> |
if (!EmptyString(conf->cipher_list)) |
1324 |
> |
SSL_set_cipher_list(client_p->localClient->fd.ssl, conf->cipher_list); |
1325 |
|
|
1326 |
|
ssl_server_handshake(NULL, client_p); |
1327 |
|
} |
1339 |
|
serv_connect_callback(fde_t *fd, int status, void *data) |
1340 |
|
{ |
1341 |
|
struct Client *client_p = data; |
1342 |
< |
struct ConfItem *conf=NULL; |
1470 |
< |
struct AccessItem *aconf=NULL; |
1342 |
> |
struct MaskItem *conf = NULL; |
1343 |
|
|
1344 |
|
/* First, make sure its a real client! */ |
1345 |
|
assert(client_p != NULL); |
1355 |
|
* Admins get to see any IP, mere opers don't *sigh* |
1356 |
|
*/ |
1357 |
|
if (ConfigServerHide.hide_server_ips) |
1358 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
1358 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
1359 |
|
"Error connecting to %s: %s", |
1360 |
|
client_p->name, comm_errstr(status)); |
1361 |
|
else |
1362 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
1363 |
< |
"Error connecting to %s[%s]: %s", client_p->name, |
1364 |
< |
client_p->host, comm_errstr(status)); |
1365 |
< |
|
1366 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
1367 |
< |
"Error connecting to %s: %s", |
1368 |
< |
client_p->name, comm_errstr(status)); |
1362 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
1363 |
> |
"Error connecting to %s[%s]: %s", client_p->name, |
1364 |
> |
client_p->host, comm_errstr(status)); |
1365 |
> |
|
1366 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
1367 |
> |
"Error connecting to %s: %s", |
1368 |
> |
client_p->name, comm_errstr(status)); |
1369 |
|
|
1370 |
|
/* If a fd goes bad, call dead_link() the socket is no |
1371 |
|
* longer valid for reading or writing. |
1377 |
|
/* COMM_OK, so continue the connection procedure */ |
1378 |
|
/* Get the C/N lines */ |
1379 |
|
conf = find_conf_name(&client_p->localClient->confs, |
1380 |
< |
client_p->name, SERVER_TYPE); |
1380 |
> |
client_p->name, CONF_SERVER); |
1381 |
|
if (conf == NULL) |
1382 |
|
{ |
1383 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
1384 |
< |
"Lost connect{} block for %s", get_client_name(client_p, HIDE_IP)); |
1385 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
1386 |
< |
"Lost connect{} block for %s", get_client_name(client_p, MASK_IP)); |
1383 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
1384 |
> |
"Lost connect{} block for %s", get_client_name(client_p, HIDE_IP)); |
1385 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
1386 |
> |
"Lost connect{} block for %s", get_client_name(client_p, MASK_IP)); |
1387 |
|
|
1388 |
|
exit_client(client_p, &me, "Lost connect{} block"); |
1389 |
|
return; |
1390 |
|
} |
1391 |
|
|
1520 |
– |
aconf = map_to_conf(conf); |
1392 |
|
/* Next, send the initial handshake */ |
1393 |
|
SetHandshake(client_p); |
1394 |
|
|
1395 |
|
#ifdef HAVE_LIBCRYPTO |
1396 |
< |
if (IsConfSSL(aconf)) |
1396 |
> |
if (IsConfSSL(conf)) |
1397 |
|
{ |
1398 |
< |
ssl_connect_init(client_p, aconf, fd); |
1398 |
> |
ssl_connect_init(client_p, conf, fd); |
1399 |
|
return; |
1400 |
|
} |
1401 |
|
#endif |
1402 |
|
|
1403 |
< |
/* jdc -- Check and send spasswd, not passwd. */ |
1533 |
< |
if (!EmptyString(aconf->spasswd)) |
1534 |
< |
sendto_one(client_p, "PASS %s TS %d %s", |
1535 |
< |
aconf->spasswd, TS_CURRENT, me.id); |
1403 |
> |
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
1404 |
|
|
1405 |
< |
send_capabilities(client_p, aconf, |
1538 |
< |
(IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0)); |
1405 |
> |
send_capabilities(client_p, 0); |
1406 |
|
|
1407 |
< |
sendto_one(client_p, "SERVER %s 1 :%s%s", |
1408 |
< |
me.name, ConfigServerHide.hidden ? "(H) " : "", |
1542 |
< |
me.info); |
1407 |
> |
sendto_one(client_p, "SERVER %s 1 :%s%s", me.name, |
1408 |
> |
ConfigServerHide.hidden ? "(H) " : "", me.info); |
1409 |
|
|
1410 |
|
/* If we've been marked dead because a send failed, just exit |
1411 |
|
* here now and save everyone the trouble of us ever existing. |
1412 |
|
*/ |
1413 |
|
if (IsDead(client_p)) |
1414 |
|
{ |
1415 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
1416 |
< |
"%s[%s] went dead during handshake", |
1415 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
1416 |
> |
"%s[%s] went dead during handshake", |
1417 |
|
client_p->name, |
1418 |
< |
client_p->host); |
1419 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, |
1420 |
< |
"%s went dead during handshake", client_p->name); |
1418 |
> |
client_p->host); |
1419 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
1420 |
> |
"%s went dead during handshake", client_p->name); |
1421 |
|
return; |
1422 |
|
} |
1423 |
|
|
1437 |
|
cptr = ptr->data; |
1438 |
|
|
1439 |
|
if (cptr && cptr->name[0]) |
1440 |
< |
if (match(name, cptr->name)) |
1440 |
> |
if (!match(name, cptr->name)) |
1441 |
|
return cptr; |
1442 |
|
} |
1443 |
|
|