| 80 |
|
free_dlink_node(ptr); |
| 81 |
|
} |
| 82 |
|
|
| 83 |
< |
DLINK_FOREACH(ptr, global_serv_list.head) |
| 83 |
> |
DLINK_FOREACH(ptr, global_server_list.head) |
| 84 |
|
{ |
| 85 |
|
const struct Client *target_p = ptr->data; |
| 86 |
|
|
| 157 |
|
const int server, const int parc, char *parv[]) |
| 158 |
|
{ |
| 159 |
|
struct Client *target_p = NULL; |
| 160 |
< |
struct Client *target_tmp = NULL; |
| 161 |
< |
dlink_node *ptr; |
| 160 |
> |
dlink_node *ptr = NULL; |
| 161 |
|
|
| 162 |
|
/* Assume it's me, if no server */ |
| 163 |
|
if (parc <= server || EmptyString(parv[server])) |
| 164 |
|
return HUNTED_ISME; |
| 165 |
|
|
| 166 |
< |
if (!strcmp(parv[server], me.id) || !match(parv[server], me.name)) |
| 167 |
< |
return HUNTED_ISME; |
| 166 |
> |
if ((target_p = find_person(source_p, parv[server])) == NULL) |
| 167 |
> |
target_p = hash_find_server(parv[server]); |
| 168 |
|
|
| 169 |
< |
/* These are to pickup matches that would cause the following |
| 169 |
> |
/* |
| 170 |
> |
* These are to pickup matches that would cause the following |
| 171 |
|
* message to go in the wrong direction while doing quick fast |
| 172 |
|
* non-matching lookups. |
| 173 |
|
*/ |
| 174 |
– |
if (MyClient(source_p)) |
| 175 |
– |
target_p = hash_find_client(parv[server]); |
| 176 |
– |
else |
| 177 |
– |
target_p = find_person(source_p, parv[server]); |
| 178 |
– |
|
| 174 |
|
if (target_p) |
| 175 |
|
if (target_p->from == source_p->from && !MyConnect(target_p)) |
| 176 |
|
target_p = NULL; |
| 177 |
|
|
| 178 |
< |
if (target_p == NULL && (target_p = hash_find_server(parv[server]))) |
| 184 |
< |
if (target_p->from == source_p->from && !MyConnect(target_p)) |
| 185 |
< |
target_p = NULL; |
| 186 |
< |
|
| 187 |
< |
/* Again, if there are no wild cards involved in the server |
| 188 |
< |
* name, use the hash lookup |
| 189 |
< |
*/ |
| 190 |
< |
if (target_p == NULL) |
| 178 |
> |
if (!target_p && has_wildcards(parv[server])) |
| 179 |
|
{ |
| 180 |
< |
if (!has_wildcards(parv[server])) |
| 193 |
< |
{ |
| 194 |
< |
if (!(target_p = hash_find_server(parv[server]))) |
| 195 |
< |
{ |
| 196 |
< |
sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, parv[server]); |
| 197 |
< |
return HUNTED_NOSUCH; |
| 198 |
< |
} |
| 199 |
< |
} |
| 200 |
< |
else |
| 180 |
> |
DLINK_FOREACH(ptr, global_client_list.head) |
| 181 |
|
{ |
| 182 |
< |
DLINK_FOREACH(ptr, global_client_list.head) |
| 203 |
< |
{ |
| 204 |
< |
target_tmp = ptr->data; |
| 182 |
> |
struct Client *tmp = ptr->data; |
| 183 |
|
|
| 184 |
< |
if (!match(parv[server], target_tmp->name)) |
| 185 |
< |
{ |
| 186 |
< |
if (target_tmp->from == source_p->from && !MyConnect(target_tmp)) |
| 187 |
< |
continue; |
| 188 |
< |
target_p = ptr->data; |
| 184 |
> |
assert(IsMe(tmp) || IsServer(tmp) || IsClient(tmp)); |
| 185 |
> |
if (!match(parv[server], tmp->name)) |
| 186 |
> |
{ |
| 187 |
> |
if (tmp->from == source_p->from && !MyConnect(tmp)) |
| 188 |
> |
continue; |
| 189 |
|
|
| 190 |
< |
if (IsRegistered(target_p) && (target_p != source_p->from)) |
| 191 |
< |
break; |
| 214 |
< |
} |
| 190 |
> |
target_p = ptr->data; |
| 191 |
> |
break; |
| 192 |
|
} |
| 193 |
|
} |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
if (target_p) |
| 197 |
|
{ |
| 198 |
< |
if (!IsRegistered(target_p)) |
| 222 |
< |
{ |
| 223 |
< |
sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, parv[server]); |
| 224 |
< |
return HUNTED_NOSUCH; |
| 225 |
< |
} |
| 226 |
< |
|
| 198 |
> |
assert(IsMe(target_p) || IsServer(target_p) || IsClient(target_p)); |
| 199 |
|
if (IsMe(target_p) || MyClient(target_p)) |
| 200 |
|
return HUNTED_ISME; |
| 201 |
|
|
| 202 |
< |
if (match(target_p->name, parv[server])) |
| 203 |
< |
parv[server] = target_p->name; |
| 232 |
< |
|
| 233 |
< |
/* This is a little kludgy but should work... */ |
| 234 |
< |
sendto_one(target_p, command, ID_or_name(source_p, target_p), |
| 202 |
> |
parv[server] = target_p->id; |
| 203 |
> |
sendto_one(target_p, command, source_p->id, |
| 204 |
|
parv[1], parv[2], parv[3], parv[4], |
| 205 |
|
parv[5], parv[6], parv[7], parv[8]); |
| 206 |
|
return HUNTED_PASS; |
| 238 |
|
|
| 239 |
|
/* Also when already connecting! (update holdtimes) --SRB |
| 240 |
|
*/ |
| 241 |
< |
if (!conf->port ||!IsConfAllowAutoConn(conf)) |
| 241 |
> |
if (!conf->port || !IsConfAllowAutoConn(conf)) |
| 242 |
|
continue; |
| 243 |
|
|
| 244 |
|
|
| 251 |
|
if (conf->until > CurrentTime) |
| 252 |
|
continue; |
| 253 |
|
|
| 254 |
< |
if (conf->class == NULL) |
| 255 |
< |
confrq = DEFAULT_CONNECTFREQUENCY; |
| 256 |
< |
else |
| 257 |
< |
{ |
| 258 |
< |
confrq = conf->class->con_freq; |
| 290 |
< |
if (confrq < MIN_CONN_FREQ) |
| 291 |
< |
confrq = MIN_CONN_FREQ; |
| 292 |
< |
} |
| 254 |
> |
assert(conf->class); |
| 255 |
> |
|
| 256 |
> |
confrq = conf->class->con_freq; |
| 257 |
> |
if (confrq < MIN_CONN_FREQ) |
| 258 |
> |
confrq = MIN_CONN_FREQ; |
| 259 |
|
|
| 260 |
|
conf->until = CurrentTime + confrq; |
| 261 |
|
|
| 405 |
|
void |
| 406 |
|
add_capability(const char *capab_name, int cap_flag, int add_to_default) |
| 407 |
|
{ |
| 408 |
< |
struct Capability *cap = MyMalloc(sizeof(*cap)); |
| 408 |
> |
struct Capability *cap = MyCalloc(sizeof(*cap)); |
| 409 |
|
|
| 410 |
|
cap->name = xstrdup(capab_name); |
| 411 |
|
cap->cap = cap_flag; |
| 479 |
|
void |
| 480 |
|
send_capabilities(struct Client *client_p, int cap_can_send) |
| 481 |
|
{ |
| 482 |
< |
char msgbuf[IRCD_BUFSIZE] = ""; |
| 483 |
< |
char *t = msgbuf; |
| 518 |
< |
int tl; |
| 519 |
< |
dlink_node *ptr = NULL; |
| 482 |
> |
char buf[IRCD_BUFSIZE] = ""; |
| 483 |
> |
const dlink_node *ptr = NULL; |
| 484 |
|
|
| 485 |
|
DLINK_FOREACH(ptr, cap_list.head) |
| 486 |
|
{ |
| 487 |
< |
struct Capability *cap = ptr->data; |
| 487 |
> |
const struct Capability *cap = ptr->data; |
| 488 |
|
|
| 489 |
|
if (cap->cap & (cap_can_send|default_server_capabs)) |
| 490 |
|
{ |
| 491 |
< |
tl = sprintf(t, "%s ", cap->name); |
| 492 |
< |
t += tl; |
| 491 |
> |
strlcat(buf, cap->name, sizeof(buf)); |
| 492 |
> |
if (ptr->next) |
| 493 |
> |
strlcat(buf, " ", sizeof(buf)); |
| 494 |
|
} |
| 495 |
|
} |
| 496 |
|
|
| 497 |
< |
*(t - 1) = '\0'; |
| 533 |
< |
sendto_one(client_p, "CAPAB :%s", msgbuf); |
| 497 |
> |
sendto_one(client_p, "CAPAB :%s", buf); |
| 498 |
|
} |
| 499 |
|
|
| 500 |
|
/* |
| 537 |
|
make_server(struct Client *client_p) |
| 538 |
|
{ |
| 539 |
|
if (client_p->serv == NULL) |
| 540 |
< |
client_p->serv = MyMalloc(sizeof(struct Server)); |
| 540 |
> |
client_p->serv = MyCalloc(sizeof(struct Server)); |
| 541 |
|
|
| 542 |
|
return client_p->serv; |
| 543 |
|
} |
| 668 |
|
strlcpy(client_p->serv->by, "AutoConn.", sizeof(client_p->serv->by)); |
| 669 |
|
|
| 670 |
|
SetConnecting(client_p); |
| 707 |
– |
dlinkAdd(client_p, &client_p->node, &global_client_list); |
| 708 |
– |
|
| 671 |
|
client_p->localClient->aftype = conf->aftype; |
| 672 |
|
|
| 673 |
|
/* Now, initiate the connection */ |
| 839 |
|
{ |
| 840 |
|
unsigned int n = 0; |
| 841 |
|
|
| 842 |
< |
if (X509_digest(cert, EVP_sha256(), md, &n)) |
| 842 |
> |
if (X509_digest(cert, ServerInfo.message_digest_algorithm, md, &n)) |
| 843 |
|
{ |
| 844 |
< |
for (unsigned int i = 0; i < n; ++i) |
| 883 |
< |
snprintf(buf + 2 * i, 3, "%02X", md[i]); |
| 844 |
> |
binary_to_hex(md, buf, n); |
| 845 |
|
client_p->certfp = xstrdup(buf); |
| 846 |
|
} |
| 847 |
|
} |