| 30 |
|
#include "fdlist.h" |
| 31 |
|
#include "s_bsd.h" |
| 32 |
|
#include "client.h" |
| 33 |
– |
#include "common.h" |
| 33 |
|
#include "dbuf.h" |
| 34 |
|
#include "event.h" |
| 35 |
|
#include "irc_string.h" |
| 37 |
– |
#include "irc_getnameinfo.h" |
| 38 |
– |
#include "irc_getaddrinfo.h" |
| 36 |
|
#include "ircd.h" |
| 37 |
|
#include "listener.h" |
| 38 |
|
#include "numeric.h" |
| 39 |
|
#include "packet.h" |
| 40 |
|
#include "irc_res.h" |
| 44 |
– |
#include "inet_misc.h" |
| 41 |
|
#include "restart.h" |
| 42 |
|
#include "s_auth.h" |
| 43 |
< |
#include "s_conf.h" |
| 44 |
< |
#include "s_log.h" |
| 43 |
> |
#include "conf.h" |
| 44 |
> |
#include "log.h" |
| 45 |
|
#include "s_serv.h" |
| 46 |
|
#include "send.h" |
| 47 |
|
#include "memory.h" |
| 130 |
|
who = (who) ? who : ""; |
| 131 |
|
|
| 132 |
|
sendto_realops_flags(UMODE_DEBUG, level, text, who, strerror(error)); |
| 133 |
< |
log_oper_action(LOG_IOERR_TYPE, NULL, "%s %s %s\n", who, text, strerror(error)); |
| 138 |
< |
ilog(L_ERROR, text, who, strerror(error)); |
| 133 |
> |
ilog(LOG_TYPE_IRCD, text, who, strerror(error)); |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
/* |
| 193 |
|
send_queued_write(client_p); |
| 194 |
|
} |
| 195 |
|
|
| 196 |
< |
if (IsServer(client_p)) |
| 196 |
> |
if (IsClient(client_p)) |
| 197 |
> |
{ |
| 198 |
> |
++ServerStats.is_cl; |
| 199 |
> |
ServerStats.is_cbs += client_p->localClient->send.bytes; |
| 200 |
> |
ServerStats.is_cbr += client_p->localClient->recv.bytes; |
| 201 |
> |
ServerStats.is_cti += CurrentTime - client_p->localClient->firsttime; |
| 202 |
> |
} |
| 203 |
> |
else if (IsServer(client_p)) |
| 204 |
|
{ |
| 205 |
|
++ServerStats.is_sv; |
| 206 |
|
ServerStats.is_sbs += client_p->localClient->send.bytes; |
| 207 |
|
ServerStats.is_sbr += client_p->localClient->recv.bytes; |
| 208 |
< |
ServerStats.is_sti += CurrentTime - client_p->firsttime; |
| 208 |
> |
ServerStats.is_sti += CurrentTime - client_p->localClient->firsttime; |
| 209 |
|
|
| 210 |
|
/* XXX Does this even make any sense at all anymore? |
| 211 |
|
* scheduling a 'quick' reconnect could cause a pile of |
| 227 |
|
aconf = map_to_conf(conf); |
| 228 |
|
aclass = map_to_conf(aconf->class_ptr); |
| 229 |
|
aconf->hold = time(NULL); |
| 230 |
< |
aconf->hold += (aconf->hold - client_p->since > HANGONGOODLINK) ? |
| 231 |
< |
HANGONRETRYDELAY : ConFreq(aclass); |
| 230 |
> |
aconf->hold += (aconf->hold - client_p->localClient->since > HANGONGOODLINK) ? |
| 231 |
> |
HANGONRETRYDELAY : aclass->con_freq; |
| 232 |
|
} |
| 233 |
|
} |
| 232 |
– |
else if (IsClient(client_p)) |
| 233 |
– |
{ |
| 234 |
– |
++ServerStats.is_cl; |
| 235 |
– |
ServerStats.is_cbs += client_p->localClient->send.bytes; |
| 236 |
– |
ServerStats.is_cbr += client_p->localClient->recv.bytes; |
| 237 |
– |
ServerStats.is_cti += CurrentTime - client_p->firsttime; |
| 238 |
– |
} |
| 234 |
|
else |
| 235 |
|
++ServerStats.is_ni; |
| 236 |
|
|
| 246 |
|
if (client_p->localClient->fd.flags.open) |
| 247 |
|
fd_close(&client_p->localClient->fd); |
| 248 |
|
|
| 254 |
– |
if (HasServlink(client_p)) |
| 255 |
– |
{ |
| 256 |
– |
if (client_p->localClient->ctrlfd.flags.open) |
| 257 |
– |
fd_close(&client_p->localClient->ctrlfd); |
| 258 |
– |
} |
| 259 |
– |
|
| 249 |
|
dbuf_clear(&client_p->localClient->buf_sendq); |
| 250 |
|
dbuf_clear(&client_p->localClient->buf_recvq); |
| 251 |
|
|
| 296 |
|
void |
| 297 |
|
add_connection(struct Listener *listener, struct irc_ssaddr *irn, int fd) |
| 298 |
|
{ |
| 299 |
< |
struct Client *new_client; |
| 311 |
< |
|
| 312 |
< |
assert(NULL != listener); |
| 313 |
< |
|
| 314 |
< |
new_client = make_client(NULL); |
| 299 |
> |
struct Client *new_client = make_client(NULL); |
| 300 |
|
|
| 301 |
|
fd_open(&new_client->localClient->fd, fd, 1, |
| 302 |
|
(listener->flags & LISTENER_SSL) ? |
| 303 |
|
"Incoming SSL connection" : "Incoming connection"); |
| 304 |
|
|
| 305 |
< |
/* |
| 305 |
> |
/* |
| 306 |
|
* copy address to 'sockhost' as a string, copy it to host too |
| 307 |
|
* so we have something valid to put into error messages... |
| 308 |
|
*/ |
| 309 |
|
memcpy(&new_client->localClient->ip, irn, sizeof(struct irc_ssaddr)); |
| 310 |
|
|
| 311 |
< |
irc_getnameinfo((struct sockaddr*)&new_client->localClient->ip, |
| 312 |
< |
new_client->localClient->ip.ss_len, new_client->sockhost, |
| 313 |
< |
sizeof(new_client->sockhost), NULL, 0, NI_NUMERICHOST); |
| 311 |
> |
getnameinfo((struct sockaddr *)&new_client->localClient->ip, |
| 312 |
> |
new_client->localClient->ip.ss_len, new_client->sockhost, |
| 313 |
> |
sizeof(new_client->sockhost), NULL, 0, NI_NUMERICHOST); |
| 314 |
|
new_client->localClient->aftype = new_client->localClient->ip.ss.ss_family; |
| 330 |
– |
#ifdef IPV6 |
| 331 |
– |
if (new_client->sockhost[0] == ':') |
| 332 |
– |
strlcat(new_client->host, "0", HOSTLEN+1); |
| 315 |
|
|
| 316 |
< |
if (new_client->localClient->aftype == AF_INET6 && |
| 335 |
< |
ConfigFileEntry.dot_in_ip6_addr == 1) |
| 316 |
> |
if (new_client->sockhost[0] == ':' && new_client->sockhost[1] == ':') |
| 317 |
|
{ |
| 318 |
< |
strlcat(new_client->host, new_client->sockhost,HOSTLEN+1); |
| 319 |
< |
strlcat(new_client->host, ".", HOSTLEN+1); |
| 318 |
> |
strlcpy(new_client->host, "0", sizeof(new_client->host)); |
| 319 |
> |
strlcpy(new_client->host+1, new_client->sockhost, sizeof(new_client->host)-1); |
| 320 |
> |
memmove(new_client->sockhost+1, new_client->sockhost, sizeof(new_client->sockhost)-1); |
| 321 |
> |
new_client->sockhost[0] = '0'; |
| 322 |
|
} |
| 323 |
|
else |
| 324 |
< |
#endif |
| 342 |
< |
strlcat(new_client->host, new_client->sockhost,HOSTLEN+1); |
| 324 |
> |
strlcpy(new_client->host, new_client->sockhost, sizeof(new_client->host)); |
| 325 |
|
|
| 326 |
|
new_client->localClient->listener = listener; |
| 327 |
|
++listener->ref_count; |
| 331 |
|
{ |
| 332 |
|
if ((new_client->localClient->fd.ssl = SSL_new(ServerInfo.server_ctx)) == NULL) |
| 333 |
|
{ |
| 334 |
< |
ilog(L_CRIT, "SSL_new() ERROR! -- %s", |
| 334 |
> |
ilog(LOG_TYPE_IRCD, "SSL_new() ERROR! -- %s", |
| 335 |
|
ERR_error_string(ERR_get_error(), NULL)); |
| 336 |
|
|
| 337 |
|
SetDead(new_client); |
| 508 |
|
|
| 509 |
|
snprintf(portname, sizeof(portname), "%d", port); |
| 510 |
|
|
| 511 |
< |
if (irc_getaddrinfo(host, portname, &hints, &res)) |
| 511 |
> |
if (getaddrinfo(host, portname, &hints, &res)) |
| 512 |
|
{ |
| 513 |
|
/* Send the DNS request, for the next level */ |
| 514 |
|
if (aftype == AF_INET6) |
| 524 |
|
memcpy(&fd->connect.hostaddr, res->ai_addr, res->ai_addrlen); |
| 525 |
|
fd->connect.hostaddr.ss_len = res->ai_addrlen; |
| 526 |
|
fd->connect.hostaddr.ss.ss_family = res->ai_family; |
| 527 |
< |
irc_freeaddrinfo(res); |
| 527 |
> |
freeaddrinfo(res); |
| 528 |
|
comm_settimeout(fd, timeout*1000, comm_connect_timeout, NULL); |
| 529 |
|
comm_connect_tryconnect(fd, NULL); |
| 530 |
|
} |
| 734 |
|
|
| 735 |
|
/* |
| 736 |
|
* remove_ipv6_mapping() - Removes IPv4-In-IPv6 mapping from an address |
| 737 |
< |
* This function should really inspect the struct itself rather than relying |
| 756 |
< |
* on inet_pton and inet_ntop. OSes with IPv6 mapping listening on both |
| 737 |
> |
* OSes with IPv6 mapping listening on both |
| 738 |
|
* AF_INET and AF_INET6 map AF_INET connections inside AF_INET6 structures |
| 739 |
|
* |
| 740 |
|
*/ |
| 744 |
|
{ |
| 745 |
|
if (addr->ss.ss_family == AF_INET6) |
| 746 |
|
{ |
| 747 |
< |
struct sockaddr_in6 *v6; |
| 767 |
< |
|
| 768 |
< |
v6 = (struct sockaddr_in6*)addr; |
| 769 |
< |
if (IN6_IS_ADDR_V4MAPPED(&v6->sin6_addr)) |
| 747 |
> |
if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)addr)->sin6_addr)) |
| 748 |
|
{ |
| 749 |
< |
char v4ip[HOSTIPLEN]; |
| 750 |
< |
struct sockaddr_in *v4 = (struct sockaddr_in*)addr; |
| 751 |
< |
inetntop(AF_INET6, &v6->sin6_addr, v4ip, HOSTIPLEN); |
| 752 |
< |
inet_pton(AF_INET, v4ip, &v4->sin_addr); |
| 749 |
> |
struct sockaddr_in6 v6; |
| 750 |
> |
struct sockaddr_in *v4 = (struct sockaddr_in *)addr; |
| 751 |
> |
|
| 752 |
> |
memcpy(&v6, addr, sizeof(v6)); |
| 753 |
> |
memset(v4, 0, sizeof(struct sockaddr_in)); |
| 754 |
> |
memcpy(&v4->sin_addr, &v6.sin6_addr.s6_addr[12], sizeof(v4->sin_addr)); |
| 755 |
> |
|
| 756 |
|
addr->ss.ss_family = AF_INET; |
| 757 |
|
addr->ss_len = sizeof(struct sockaddr_in); |
| 758 |
|
} |