37 |
|
#include "fdlist.h" |
38 |
|
#include "hash.h" |
39 |
|
#include "irc_string.h" |
40 |
– |
#include "inet_misc.h" |
40 |
|
#include "sprintf_irc.h" |
41 |
|
#include "ircd.h" |
42 |
|
#include "ircd_defs.h" |
43 |
|
#include "s_bsd.h" |
45 |
– |
#include "irc_getnameinfo.h" |
44 |
|
#include "numeric.h" |
45 |
|
#include "packet.h" |
46 |
|
#include "irc_res.h" |
234 |
|
} |
235 |
|
#endif /* HAVE_LIBCRYPTO */ |
236 |
|
|
239 |
– |
/* my_name_for_link() |
240 |
– |
* return wildcard name of my server name |
241 |
– |
* according to given config entry --Jto |
242 |
– |
*/ |
243 |
– |
const char * |
244 |
– |
my_name_for_link(struct ConfItem *conf) |
245 |
– |
{ |
246 |
– |
struct AccessItem *aconf; |
247 |
– |
|
248 |
– |
aconf = (struct AccessItem *)map_to_conf(conf); |
249 |
– |
if (aconf->fakename != NULL) |
250 |
– |
return aconf->fakename; |
251 |
– |
else |
252 |
– |
return me.name; |
253 |
– |
} |
254 |
– |
|
237 |
|
/* |
238 |
|
* write_links_file |
239 |
|
* |
544 |
|
} |
545 |
|
|
546 |
|
int |
547 |
+ |
valid_servname(const char *name) |
548 |
+ |
{ |
549 |
+ |
unsigned int length = 0; |
550 |
+ |
unsigned int dots = 0; |
551 |
+ |
const char *p = name; |
552 |
+ |
|
553 |
+ |
for (; *p; ++p) |
554 |
+ |
{ |
555 |
+ |
if (!IsServChar(*p)) |
556 |
+ |
return 0; |
557 |
+ |
|
558 |
+ |
++length; |
559 |
+ |
|
560 |
+ |
if (*p == '.') |
561 |
+ |
++dots; |
562 |
+ |
} |
563 |
+ |
|
564 |
+ |
return dots != 0 && length <= HOSTLEN; |
565 |
+ |
} |
566 |
+ |
|
567 |
+ |
int |
568 |
|
check_server(const char *name, struct Client *client_p, int cryptlink) |
569 |
|
{ |
570 |
|
dlink_node *ptr; |
670 |
|
ClearCap(client_p, CAP_TBURST); |
671 |
|
} |
672 |
|
|
670 |
– |
/* Don't unset CAP_HUB here even if the server isn't a hub, |
671 |
– |
* it only indicates if the server thinks it's lazylinks are |
672 |
– |
* leafs or not.. if you unset it, bad things will happen |
673 |
– |
*/ |
673 |
|
if (aconf != NULL) |
674 |
|
{ |
675 |
|
struct sockaddr_in *v4; |
955 |
|
char *host; |
956 |
|
const char *inpath; |
957 |
|
static char inpath_ip[HOSTLEN * 2 + USERLEN + 6]; |
959 |
– |
dlink_node *m; |
958 |
|
dlink_node *ptr; |
959 |
|
|
960 |
|
assert(client_p != NULL); |
994 |
|
} |
995 |
|
} |
996 |
|
|
997 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
997 |
> |
aconf = map_to_conf(conf); |
998 |
|
|
999 |
|
if (IsUnknown(client_p) && !IsConfCryptLink(aconf)) |
1000 |
|
{ |
1002 |
|
* 2. Check aconf->spasswd, not aconf->passwd. |
1003 |
|
*/ |
1004 |
|
if (!EmptyString(aconf->spasswd)) |
1005 |
< |
{ |
1006 |
< |
/* only send ts6 format PASS if we have ts6 enabled */ |
1009 |
< |
if (me.id[0] != '\0') /* Send TS 6 form only if id */ |
1010 |
< |
sendto_one(client_p, "PASS %s TS %d %s", |
1011 |
< |
aconf->spasswd, TS_CURRENT, me.id); |
1012 |
< |
else |
1013 |
< |
sendto_one(client_p, "PASS %s TS 5", |
1014 |
< |
aconf->spasswd); |
1015 |
< |
} |
1005 |
> |
sendto_one(client_p, "PASS %s TS %d %s", |
1006 |
> |
aconf->spasswd, TS_CURRENT, me.id); |
1007 |
|
|
1008 |
|
/* Pass my info to the new server |
1009 |
|
* |
1019 |
– |
* If this is a HUB, pass on CAP_HUB |
1010 |
|
* Pass on ZIP if supported |
1011 |
|
* Pass on TB if supported. |
1012 |
|
* - Dianora |
1013 |
|
*/ |
1014 |
|
|
1015 |
< |
send_capabilities(client_p, aconf, (ServerInfo.hub ? CAP_HUB : 0) |
1016 |
< |
| (IsConfCompressed(aconf) ? CAP_ZIP : 0) |
1015 |
> |
send_capabilities(client_p, aconf, |
1016 |
> |
(IsConfCompressed(aconf) ? CAP_ZIP : 0) |
1017 |
|
| (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), 0); |
1018 |
|
|
1019 |
|
/* SERVER is the last command sent before switching to ziplinks. |
1027 |
|
* Nagle is already disabled at this point --adx |
1028 |
|
*/ |
1029 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", |
1030 |
< |
my_name_for_link(conf), |
1041 |
< |
ConfigServerHide.hidden ? "(H) " : "", |
1042 |
< |
(me.info[0]) ? (me.info) : "IRCers United"); |
1030 |
> |
me.name, ConfigServerHide.hidden ? "(H) " : "", me.info); |
1031 |
|
send_queued_write(client_p); |
1032 |
|
} |
1033 |
|
|
1051 |
|
SetServlink(client_p); |
1052 |
|
} |
1053 |
|
|
1054 |
< |
/* only send ts6 format SVINFO if we have ts6 enabled */ |
1067 |
< |
sendto_one(client_p, "SVINFO %d %d 0 :%lu", |
1068 |
< |
(me.id[0] ? TS_CURRENT : 5), TS_MIN, |
1054 |
> |
sendto_one(client_p, "SVINFO %d %d 0 :%lu", TS_CURRENT, TS_MIN, |
1055 |
|
(unsigned long)CurrentTime); |
1056 |
|
|
1057 |
|
/* assumption here is if they passed the correct TS version, they also passed an SID */ |
1085 |
|
/* Some day, all these lists will be consolidated *sigh* */ |
1086 |
|
dlinkAdd(client_p, &client_p->lnode, &me.serv->server_list); |
1087 |
|
|
1088 |
< |
m = dlinkFind(&unknown_list, client_p); |
1103 |
< |
assert(NULL != m); |
1088 |
> |
assert(dlinkFind(&unknown_list, client_p)); |
1089 |
|
|
1090 |
< |
dlinkDelete(m, &unknown_list); |
1091 |
< |
dlinkAdd(client_p, m, &serv_list); |
1090 |
> |
dlink_move_node(&client_p->localClient->lclient_node, |
1091 |
> |
&unknown_list, &serv_list); |
1092 |
|
|
1093 |
|
Count.myserver++; |
1094 |
|
|
1101 |
|
/* fixing eob timings.. -gnp */ |
1102 |
|
client_p->firsttime = CurrentTime; |
1103 |
|
|
1104 |
+ |
|
1105 |
+ |
if (find_matching_name_conf(SERVICE_TYPE, client_p->name, NULL, NULL, 0)) |
1106 |
+ |
SetService(client_p); |
1107 |
+ |
|
1108 |
|
/* Show the real host/IP to admins */ |
1109 |
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
1110 |
|
"Link with %s established: (%s) link", |
1140 |
|
if (target_p == client_p) |
1141 |
|
continue; |
1142 |
|
|
1154 |
– |
if ((conf = target_p->serv->sconf) && |
1155 |
– |
match(my_name_for_link(conf), client_p->name)) |
1156 |
– |
continue; |
1157 |
– |
|
1143 |
|
if (IsCapable(target_p, CAP_TS6) && HasID(client_p)) |
1144 |
|
sendto_one(target_p, ":%s SID %s 2 %s :%s%s", |
1145 |
|
me.id, client_p->name, client_p->id, |
1170 |
|
** is destroyed...) |
1171 |
|
*/ |
1172 |
|
|
1188 |
– |
conf = client_p->serv->sconf; |
1189 |
– |
|
1173 |
|
DLINK_FOREACH_PREV(ptr, global_serv_list.tail) |
1174 |
|
{ |
1175 |
|
target_p = ptr->data; |
1176 |
|
|
1177 |
|
/* target_p->from == target_p for target_p == client_p */ |
1178 |
< |
if (target_p->from == client_p) |
1196 |
< |
continue; |
1197 |
< |
|
1198 |
< |
if (match(my_name_for_link(conf), target_p->name)) |
1178 |
> |
if (IsMe(target_p) || target_p->from == client_p) |
1179 |
|
continue; |
1180 |
|
|
1181 |
|
if (IsCapable(client_p, CAP_TS6)) |
1568 |
|
conf = unmap_conf_item(aconf); |
1569 |
|
|
1570 |
|
/* log */ |
1571 |
< |
irc_getnameinfo((struct sockaddr*)&aconf->ipnum, aconf->ipnum.ss_len, |
1572 |
< |
buf, HOSTIPLEN, NULL, 0, NI_NUMERICHOST); |
1571 |
> |
getnameinfo((struct sockaddr *)&aconf->ipnum, aconf->ipnum.ss_len, |
1572 |
> |
buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); |
1573 |
|
ilog(L_NOTICE, "Connect to %s[%s] @%s", aconf->user, aconf->host, |
1574 |
|
buf); |
1575 |
|
|
1616 |
|
strlcpy(client_p->host, aconf->host, sizeof(client_p->host)); |
1617 |
|
|
1618 |
|
/* We already converted the ip once, so lets use it - stu */ |
1619 |
< |
strlcpy(client_p->sockhost, buf, HOSTIPLEN); |
1619 |
> |
strlcpy(client_p->sockhost, buf, sizeof(client_p->sockhost)); |
1620 |
|
|
1621 |
|
/* create a socket for the server connection */ |
1622 |
|
if (comm_open(&client_p->localClient->fd, aconf->ipnum.ss.ss_family, |
1826 |
|
#endif |
1827 |
|
|
1828 |
|
/* jdc -- Check and send spasswd, not passwd. */ |
1829 |
< |
if (!EmptyString(aconf->spasswd) && (me.id[0] != '\0')) |
1829 |
> |
if (!EmptyString(aconf->spasswd)) |
1830 |
|
/* Send TS 6 form only if id */ |
1831 |
|
sendto_one(client_p, "PASS %s TS %d %s", |
1832 |
|
aconf->spasswd, TS_CURRENT, me.id); |
1853 |
– |
else |
1854 |
– |
sendto_one(client_p, "PASS %s TS 5", |
1855 |
– |
aconf->spasswd); |
1833 |
|
|
1834 |
|
/* Pass my info to the new server |
1835 |
|
* |
1859 |
– |
* If this is a HUB, pass on CAP_HUB |
1836 |
|
* Pass on ZIP if supported |
1837 |
|
* Pass on TB if supported. |
1838 |
|
* - Dianora |
1839 |
|
*/ |
1840 |
< |
send_capabilities(client_p, aconf, (ServerInfo.hub ? CAP_HUB : 0) |
1841 |
< |
| (IsConfCompressed(aconf) ? CAP_ZIP : 0) |
1840 |
> |
send_capabilities(client_p, aconf, |
1841 |
> |
(IsConfCompressed(aconf) ? CAP_ZIP : 0) |
1842 |
|
| (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), 0); |
1843 |
|
|
1844 |
|
sendto_one(client_p, "SERVER %s 1 :%s%s", |
1845 |
< |
my_name_for_link(conf), |
1870 |
< |
ConfigServerHide.hidden ? "(H) " : "", |
1845 |
> |
me.name, ConfigServerHide.hidden ? "(H) " : "", |
1846 |
|
me.info); |
1847 |
|
|
1848 |
|
/* If we've been marked dead because a send failed, just exit |
1875 |
|
cptr = ptr->data; |
1876 |
|
|
1877 |
|
if (cptr && cptr->name[0]) |
1878 |
< |
if (match(cptr->name, name) || match(name, cptr->name)) |
1878 |
> |
if (match(name, cptr->name)) |
1879 |
|
return cptr; |
1880 |
|
} |
1881 |
|
|
1946 |
|
return; |
1947 |
|
} |
1948 |
|
|
1949 |
< |
send_capabilities(client_p, aconf, (ServerInfo.hub ? CAP_HUB : 0) |
1950 |
< |
| (IsConfCompressed(aconf) ? CAP_ZIP : 0) |
1949 |
> |
send_capabilities(client_p, aconf, |
1950 |
> |
(IsConfCompressed(aconf) ? CAP_ZIP : 0) |
1951 |
|
| (IsConfTopicBurst(aconf) ? CAP_TBURST|CAP_TB : 0), CAP_ENC_MASK); |
1952 |
|
|
1953 |
< |
if (me.id[0]) |
1979 |
< |
sendto_one(client_p, "PASS . TS %d %s", TS_CURRENT, me.id); |
1980 |
< |
|
1953 |
> |
sendto_one(client_p, "PASS . TS %d %s", TS_CURRENT, me.id); |
1954 |
|
sendto_one(client_p, "CRYPTLINK SERV %s %s :%s%s", |
1955 |
< |
my_name_for_link(conf), key_to_send, |
1955 |
> |
me.name, key_to_send, |
1956 |
|
ConfigServerHide.hidden ? "(H) " : "", me.info); |
1957 |
|
|
1958 |
|
SetHandshake(client_p); |