254 |
parv[1], parv[2], parv[3], parv[4], |
parv[1], parv[2], parv[3], parv[4], |
255 |
parv[5], parv[6], parv[7], parv[8]); |
parv[5], parv[6], parv[7], parv[8]); |
256 |
return HUNTED_PASS; |
return HUNTED_PASS; |
257 |
} |
} |
258 |
|
|
259 |
sendto_one(source_p, form_str(ERR_NOSUCHSERVER), |
sendto_one(source_p, form_str(ERR_NOSUCHSERVER), |
260 |
me.name, source_p->name, parv[server]); |
me.name, source_p->name, parv[server]); |
288 |
|
|
289 |
assert(conf->type == CONF_SERVER); |
assert(conf->type == CONF_SERVER); |
290 |
|
|
291 |
/* Also when already connecting! (update holdtimes) --SRB |
/* Also when already connecting! (update holdtimes) --SRB |
292 |
*/ |
*/ |
293 |
if (!conf->port ||!IsConfAllowAutoConn(conf)) |
if (!conf->port ||!IsConfAllowAutoConn(conf)) |
294 |
continue; |
continue; |
399 |
|
|
400 |
/* XXX: Fix me for IPv6 */ |
/* XXX: Fix me for IPv6 */ |
401 |
/* XXX sockhost is the IPv4 ip as a string */ |
/* XXX sockhost is the IPv4 ip as a string */ |
402 |
if (!match(conf->host, client_p->host) || |
if (!match(conf->host, client_p->host) || |
403 |
!match(conf->host, client_p->sockhost)) |
!match(conf->host, client_p->sockhost)) |
404 |
{ |
{ |
405 |
error = -2; |
error = -2; |
430 |
switch (server_conf->aftype) |
switch (server_conf->aftype) |
431 |
{ |
{ |
432 |
#ifdef IPV6 |
#ifdef IPV6 |
433 |
case AF_INET6: |
case AF_INET6: |
434 |
v6 = (struct sockaddr_in6 *)&server_conf->addr; |
v6 = (struct sockaddr_in6 *)&server_conf->addr; |
435 |
|
|
436 |
if (IN6_IS_ADDR_UNSPECIFIED(&v6->sin6_addr)) |
if (IN6_IS_ADDR_UNSPECIFIED(&v6->sin6_addr)) |
441 |
v4 = (struct sockaddr_in *)&server_conf->addr; |
v4 = (struct sockaddr_in *)&server_conf->addr; |
442 |
|
|
443 |
if (v4->sin_addr.s_addr == INADDR_NONE) |
if (v4->sin_addr.s_addr == INADDR_NONE) |
444 |
memcpy(&server_conf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr)); |
memcpy(&server_conf->addr, &client_p->localClient->ip, sizeof(struct irc_ssaddr)); |
445 |
break; |
break; |
446 |
} |
} |
447 |
} |
} |
561 |
} |
} |
562 |
|
|
563 |
/* sendnick_TS() |
/* sendnick_TS() |
564 |
* |
* |
565 |
* inputs - client (server) to send nick towards |
* inputs - client (server) to send nick towards |
566 |
* - client to send nick for |
* - client to send nick for |
567 |
* output - NONE |
* output - NONE |
721 |
/* If there is something in the serv_list, it might be this |
/* If there is something in the serv_list, it might be this |
722 |
* connecting server.. |
* connecting server.. |
723 |
*/ |
*/ |
724 |
if (!ServerInfo.hub && serv_list.head) |
if (!ServerInfo.hub && serv_list.head) |
725 |
{ |
{ |
726 |
if (client_p != serv_list.head->data || serv_list.head->next) |
if (client_p != serv_list.head->data || serv_list.head->next) |
727 |
{ |
{ |
854 |
IsHidden(client_p) ? "(H) " : "", |
IsHidden(client_p) ? "(H) " : "", |
855 |
client_p->info); |
client_p->info); |
856 |
else |
else |
857 |
sendto_one(target_p,":%s SERVER %s 2 :%s%s", |
sendto_one(target_p,":%s SERVER %s 2 :%s%s", |
858 |
me.name, client_p->name, |
me.name, client_p->name, |
859 |
IsHidden(client_p) ? "(H) " : "", |
IsHidden(client_p) ? "(H) " : "", |
860 |
client_p->info); |
client_p->info); |
861 |
} |
} |
862 |
|
|
863 |
/* Pass on my client information to the new server |
/* |
864 |
** |
* Pass on my client information to the new server |
865 |
** First, pass only servers (idea is that if the link gets |
* |
866 |
** cancelled beacause the server was already there, |
* First, pass only servers (idea is that if the link gets |
867 |
** there are no NICK's to be cancelled...). Of course, |
* cancelled beacause the server was already there, |
868 |
** if cancellation occurs, all this info is sent anyway, |
* there are no NICK's to be cancelled...). Of course, |
869 |
** and I guess the link dies when a read is attempted...? --msa |
* if cancellation occurs, all this info is sent anyway, |
870 |
** |
* and I guess the link dies when a read is attempted...? --msa |
871 |
** Note: Link cancellation to occur at this point means |
* |
872 |
** that at least two servers from my fragment are building |
* Note: Link cancellation to occur at this point means |
873 |
** up connection this other fragment at the same time, it's |
* that at least two servers from my fragment are building |
874 |
** a race condition, not the normal way of operation... |
* up connection this other fragment at the same time, it's |
875 |
** |
* a race condition, not the normal way of operation... |
876 |
** ALSO NOTE: using the get_client_name for server names-- |
* |
877 |
** see previous *WARNING*!!! (Also, original inpath |
* ALSO NOTE: using the get_client_name for server names-- |
878 |
** is destroyed...) |
* see previous *WARNING*!!! (Also, original inpath |
879 |
*/ |
* is destroyed...) |
880 |
|
*/ |
881 |
|
|
882 |
DLINK_FOREACH_PREV(ptr, global_serv_list.tail) |
DLINK_FOREACH_PREV(ptr, global_serv_list.tail) |
883 |
{ |
{ |
900 |
IsHidden(target_p) ? "(H) " : "", target_p->info); |
IsHidden(target_p) ? "(H) " : "", target_p->info); |
901 |
} |
} |
902 |
else |
else |
903 |
sendto_one(client_p, ":%s SERVER %s %d :%s%s", |
sendto_one(client_p, ":%s SERVER %s %d :%s%s", |
904 |
target_p->servptr->name, target_p->name, target_p->hopcount+1, |
target_p->servptr->name, target_p->name, target_p->hopcount+1, |
905 |
IsHidden(target_p) ? "(H) " : "", target_p->info); |
IsHidden(target_p) ? "(H) " : "", target_p->info); |
906 |
|
|
941 |
|
|
942 |
/* burst_all() |
/* burst_all() |
943 |
* |
* |
944 |
* inputs - pointer to server to send burst to |
* inputs - pointer to server to send burst to |
945 |
* output - NONE |
* output - NONE |
946 |
* side effects - complete burst of channels/nicks is sent to client_p |
* side effects - complete burst of channels/nicks is sent to client_p |
947 |
*/ |
*/ |
972 |
|
|
973 |
if (!HasFlag(target_p, FLAGS_BURSTED) && target_p->from != client_p) |
if (!HasFlag(target_p, FLAGS_BURSTED) && target_p->from != client_p) |
974 |
sendnick_TS(client_p, target_p); |
sendnick_TS(client_p, target_p); |
975 |
|
|
976 |
DelFlag(target_p, FLAGS_BURSTED); |
DelFlag(target_p, FLAGS_BURSTED); |
977 |
} |
} |
978 |
|
|
1050 |
|
|
1051 |
/* serv_connect() - initiate a server connection |
/* serv_connect() - initiate a server connection |
1052 |
* |
* |
1053 |
* inputs - pointer to conf |
* inputs - pointer to conf |
1054 |
* - pointer to client doing the connect |
* - pointer to client doing the connect |
1055 |
* output - |
* output - |
1056 |
* side effects - |
* side effects - |
1102 |
* Note: conf should ALWAYS be a valid C: line |
* Note: conf should ALWAYS be a valid C: line |
1103 |
*/ |
*/ |
1104 |
if ((client_p = hash_find_server(conf->name)) != NULL) |
if ((client_p = hash_find_server(conf->name)) != NULL) |
1105 |
{ |
{ |
1106 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
1107 |
"Server %s already present from %s", |
"Server %s already present from %s", |
1108 |
conf->name, get_client_name(client_p, SHOW_IP)); |
conf->name, get_client_name(client_p, SHOW_IP)); |
1115 |
get_client_name(client_p, MASK_IP)); |
get_client_name(client_p, MASK_IP)); |
1116 |
return 0; |
return 0; |
1117 |
} |
} |
1118 |
|
|
1119 |
/* Create a local client */ |
/* Create a local client */ |
1120 |
client_p = make_client(NULL); |
client_p = make_client(NULL); |
1121 |
|
|
1126 |
/* We already converted the ip once, so lets use it - stu */ |
/* We already converted the ip once, so lets use it - stu */ |
1127 |
strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost)); |
strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost)); |
1128 |
|
|
1129 |
/* create a socket for the server connection */ |
/* create a socket for the server connection */ |
1130 |
if (comm_open(&client_p->localClient->fd, conf->addr.ss.ss_family, |
if (comm_open(&client_p->localClient->fd, conf->addr.ss.ss_family, |
1131 |
SOCK_STREAM, 0, NULL) < 0) |
SOCK_STREAM, 0, NULL) < 0) |
1132 |
{ |
{ |
1149 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1150 |
"Host %s is not enabled for connecting: no connect{} block", |
"Host %s is not enabled for connecting: no connect{} block", |
1151 |
conf->name); |
conf->name); |
1152 |
if (by && IsClient(by) && !MyClient(by)) |
if (by && IsClient(by) && !MyClient(by)) |
1153 |
sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.", |
sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.", |
1154 |
me.name, by->name, client_p->name); |
me.name, by->name, client_p->name); |
1155 |
SetDead(client_p); |
SetDead(client_p); |
1176 |
client_p->localClient->aftype = conf->aftype; |
client_p->localClient->aftype = conf->aftype; |
1177 |
|
|
1178 |
/* Now, initiate the connection */ |
/* Now, initiate the connection */ |
1179 |
/* XXX assume that a non 0 type means a specific bind address |
/* XXX assume that a non 0 type means a specific bind address |
1180 |
* for this connect. |
* for this connect. |
1181 |
*/ |
*/ |
1182 |
switch (conf->aftype) |
switch (conf->aftype) |
1191 |
ipn.ss_port = 0; |
ipn.ss_port = 0; |
1192 |
memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr)); |
memcpy(&ipn, &conf->bind, sizeof(struct irc_ssaddr)); |
1193 |
comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port, |
comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port, |
1194 |
(struct sockaddr *)&ipn, ipn.ss_len, |
(struct sockaddr *)&ipn, ipn.ss_len, |
1195 |
serv_connect_callback, client_p, conf->aftype, |
serv_connect_callback, client_p, conf->aftype, |
1196 |
CONNECTTIMEOUT); |
CONNECTTIMEOUT); |
1197 |
} |
} |
1208 |
CONNECTTIMEOUT); |
CONNECTTIMEOUT); |
1209 |
} |
} |
1210 |
else |
else |
1211 |
comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port, |
comm_connect_tcp(&client_p->localClient->fd, conf->host, conf->port, |
1212 |
NULL, 0, serv_connect_callback, client_p, conf->aftype, |
NULL, 0, serv_connect_callback, client_p, conf->aftype, |
1213 |
CONNECTTIMEOUT); |
CONNECTTIMEOUT); |
1214 |
break; |
break; |
1215 |
#ifdef IPV6 |
#ifdef IPV6 |
1230 |
ipn.ss_port = 0; |
ipn.ss_port = 0; |
1231 |
comm_connect_tcp(&client_p->localClient->fd, |
comm_connect_tcp(&client_p->localClient->fd, |
1232 |
conf->host, conf->port, |
conf->host, conf->port, |
1233 |
(struct sockaddr *)&ipn, ipn.ss_len, |
(struct sockaddr *)&ipn, ipn.ss_len, |
1234 |
serv_connect_callback, client_p, |
serv_connect_callback, client_p, |
1235 |
conf->aftype, CONNECTTIMEOUT); |
conf->aftype, CONNECTTIMEOUT); |
1236 |
} |
} |
1247 |
} |
} |
1248 |
else |
else |
1249 |
comm_connect_tcp(&client_p->localClient->fd, |
comm_connect_tcp(&client_p->localClient->fd, |
1250 |
conf->host, conf->port, |
conf->host, conf->port, |
1251 |
NULL, 0, serv_connect_callback, client_p, |
NULL, 0, serv_connect_callback, client_p, |
1252 |
conf->aftype, CONNECTTIMEOUT); |
conf->aftype, CONNECTTIMEOUT); |
1253 |
} |
} |
1359 |
#endif |
#endif |
1360 |
|
|
1361 |
/* serv_connect_callback() - complete a server connection. |
/* serv_connect_callback() - complete a server connection. |
1362 |
* |
* |
1363 |
* This routine is called after the server connection attempt has |
* This routine is called after the server connection attempt has |
1364 |
* completed. If unsucessful, an error is sent to ops and the client |
* completed. If unsucessful, an error is sent to ops and the client |
1365 |
* is closed. If sucessful, it goes through the initialisation/check |
* is closed. If sucessful, it goes through the initialisation/check |
1441 |
/* If we've been marked dead because a send failed, just exit |
/* If we've been marked dead because a send failed, just exit |
1442 |
* here now and save everyone the trouble of us ever existing. |
* here now and save everyone the trouble of us ever existing. |
1443 |
*/ |
*/ |
1444 |
if (IsDead(client_p)) |
if (IsDead(client_p)) |
1445 |
{ |
{ |
1446 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
1447 |
"%s[%s] went dead during handshake", |
"%s[%s] went dead during handshake", |
1471 |
if (!match(name, cptr->name)) |
if (!match(name, cptr->name)) |
1472 |
return cptr; |
return cptr; |
1473 |
} |
} |
1474 |
|
|
1475 |
return NULL; |
return NULL; |
1476 |
} |
} |