]>
Commit | Line | Data |
---|---|---|
54ac8b60 VY |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * listener.c: Listens on a port. | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 | * USA | |
23 | * | |
24 | * $Id: listener.c 3460 2007-05-18 20:31:33Z jilles $ | |
25 | */ | |
26 | ||
27 | #include "stdinc.h" | |
28 | #include "setup.h" | |
29 | #include "listener.h" | |
30 | #include "client.h" | |
4562c604 | 31 | #include "match.h" |
54ac8b60 VY |
32 | #include "ircd.h" |
33 | #include "ircd_defs.h" | |
34 | #include "numeric.h" | |
35 | #include "s_conf.h" | |
36 | #include "s_newconf.h" | |
37 | #include "s_stats.h" | |
38 | #include "send.h" | |
39 | #include "s_auth.h" | |
40 | #include "reject.h" | |
41 | #include "s_conf.h" | |
42 | #include "hostmask.h" | |
c6d72037 VY |
43 | #include "sslproc.h" |
44 | #include "hash.h" | |
54ac8b60 VY |
45 | |
46 | #ifndef INADDR_NONE | |
47 | #define INADDR_NONE ((unsigned int) 0xffffffff) | |
48 | #endif | |
49 | ||
9ea3ea10 | 50 | #if defined(NO_IN6ADDR_ANY) && defined(RB_IPV6) |
54ac8b60 VY |
51 | static const struct in6_addr in6addr_any = |
52 | { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }; | |
53 | #endif | |
54 | ||
54ac8b60 | 55 | static listener_t *ListenerPollList = NULL; |
1087485c | 56 | static int accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, void *data); |
8e09c4a2 | 57 | static void accept_callback(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t addrlen, void *data); |
54ac8b60 VY |
58 | |
59 | static listener_t * | |
e7046ee5 | 60 | make_listener(struct rb_sockaddr_storage *addr) |
54ac8b60 VY |
61 | { |
62 | listener_t *listener = (listener_t *) rb_malloc(sizeof(listener_t)); | |
63 | s_assert(0 != listener); | |
54ac8b60 | 64 | listener->name = me.name; |
f691939a VY |
65 | listener->F = NULL; |
66 | ||
e7046ee5 | 67 | memcpy(&listener->addr, addr, sizeof(struct rb_sockaddr_storage)); |
54ac8b60 VY |
68 | listener->next = NULL; |
69 | return listener; | |
70 | } | |
71 | ||
72 | void | |
73 | free_listener(listener_t *listener) | |
74 | { | |
75 | s_assert(NULL != listener); | |
76 | if(listener == NULL) | |
77 | return; | |
78 | /* | |
79 | * remove from listener list | |
80 | */ | |
81 | if(listener == ListenerPollList) | |
82 | ListenerPollList = listener->next; | |
83 | else | |
84 | { | |
85 | listener_t *prev = ListenerPollList; | |
86 | for (; prev; prev = prev->next) | |
87 | { | |
88 | if(listener == prev->next) | |
89 | { | |
90 | prev->next = listener->next; | |
91 | break; | |
92 | } | |
93 | } | |
94 | } | |
95 | ||
96 | /* free */ | |
97 | rb_free(listener); | |
98 | } | |
99 | ||
100 | #define PORTNAMELEN 6 /* ":31337" */ | |
101 | ||
102 | /* | |
103 | * get_listener_name - return displayable listener name and port | |
104 | * returns "host.foo.org:6667" for a given listener | |
105 | */ | |
106 | const char * | |
107 | get_listener_name(const listener_t *listener) | |
108 | { | |
109 | static char buf[HOSTLEN + HOSTLEN + PORTNAMELEN + 4]; | |
110 | int port = 0; | |
111 | ||
112 | s_assert(NULL != listener); | |
113 | if(listener == NULL) | |
114 | return NULL; | |
115 | ||
9ea3ea10 | 116 | #ifdef RB_IPV6 |
54ac8b60 VY |
117 | if(listener->addr.ss_family == AF_INET6) |
118 | port = ntohs(((const struct sockaddr_in6 *)&listener->addr)->sin6_port); | |
119 | else | |
120 | #endif | |
121 | port = ntohs(((const struct sockaddr_in *)&listener->addr)->sin_port); | |
122 | ||
123 | rb_snprintf(buf, sizeof(buf), "%s[%s/%u]", me.name, listener->name, port); | |
124 | return buf; | |
125 | } | |
126 | ||
127 | /* | |
128 | * show_ports - send port listing to a client | |
129 | * inputs - pointer to client to show ports to | |
130 | * output - none | |
131 | * side effects - show ports | |
132 | */ | |
133 | void | |
134 | show_ports(struct Client *source_p) | |
135 | { | |
136 | listener_t *listener = 0; | |
137 | ||
138 | for (listener = ListenerPollList; listener; listener = listener->next) | |
139 | { | |
140 | sendto_one_numeric(source_p, RPL_STATSPLINE, | |
141 | form_str(RPL_STATSPLINE), 'P', | |
9ea3ea10 | 142 | #ifdef RB_IPV6 |
54ac8b60 VY |
143 | ntohs(listener->addr.ss_family == AF_INET ? ((struct sockaddr_in *)&listener->addr)->sin_port : |
144 | ((struct sockaddr_in6 *)&listener->addr)->sin6_port), | |
145 | #else | |
146 | ntohs(((struct sockaddr_in *)&listener->addr)->sin_port), | |
147 | #endif | |
148 | IsOperAdmin(source_p) ? listener->name : me.name, | |
8bd5767b | 149 | listener->ref_count, (listener->active) ? "active" : "disabled", |
c6d72037 | 150 | listener->ssl ? " ssl" : ""); |
54ac8b60 VY |
151 | } |
152 | } | |
153 | ||
154 | /* | |
155 | * inetport - create a listener socket in the AF_INET or AF_INET6 domain, | |
156 | * bind it to the port given in 'port' and listen to it | |
157 | * returns true (1) if successful false (0) on error. | |
158 | * | |
159 | * If the operating system has a define for SOMAXCONN, use it, otherwise | |
160 | * use RATBOX_SOMAXCONN | |
161 | */ | |
162 | #ifdef SOMAXCONN | |
163 | #undef RATBOX_SOMAXCONN | |
164 | #define RATBOX_SOMAXCONN SOMAXCONN | |
165 | #endif | |
166 | ||
167 | static int | |
168 | inetport(listener_t *listener) | |
169 | { | |
f691939a | 170 | rb_fde_t *F; |
0d89d5cd | 171 | int ret; |
54ac8b60 VY |
172 | int opt = 1; |
173 | ||
174 | /* | |
175 | * At first, open a new socket | |
176 | */ | |
177 | ||
f691939a | 178 | F = rb_socket(GET_SS_FAMILY(&listener->addr), SOCK_STREAM, 0, "Listener socket"); |
54ac8b60 | 179 | |
9ea3ea10 | 180 | #ifdef RB_IPV6 |
54ac8b60 VY |
181 | if(listener->addr.ss_family == AF_INET6) |
182 | { | |
183 | struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)&listener->addr; | |
184 | if(!IN6_ARE_ADDR_EQUAL(&in6->sin6_addr, &in6addr_any)) | |
185 | { | |
caa4d9d2 | 186 | rb_inet_ntop(AF_INET6, &in6->sin6_addr, listener->vhost, sizeof(listener->vhost)); |
54ac8b60 VY |
187 | listener->name = listener->vhost; |
188 | } | |
189 | } else | |
190 | #endif | |
191 | { | |
192 | struct sockaddr_in *in = (struct sockaddr_in *)&listener->addr; | |
193 | if(in->sin_addr.s_addr != INADDR_ANY) | |
194 | { | |
caa4d9d2 | 195 | rb_inet_ntop(AF_INET, &in->sin_addr, listener->vhost, sizeof(listener->vhost)); |
54ac8b60 VY |
196 | listener->name = listener->vhost; |
197 | } | |
198 | } | |
199 | ||
1087485c JT |
200 | if(F == NULL) |
201 | { | |
825ddf13 | 202 | ilog_error("opening listener socket"); |
1087485c JT |
203 | return 0; |
204 | } | |
205 | else if((maxconnections - 10) < rb_get_fd(F)) /* XXX this is kinda bogus*/ | |
206 | { | |
825ddf13 | 207 | ilog_error("no more connections left for listener"); |
1087485c JT |
208 | rb_close(F); |
209 | return 0; | |
54ac8b60 VY |
210 | } |
211 | ||
1087485c JT |
212 | /* |
213 | * XXX - we don't want to do all this crap for a listener | |
214 | * set_sock_opts(listener); | |
215 | */ | |
216 | if(setsockopt(rb_get_fd(F), SOL_SOCKET, SO_REUSEADDR, (char *) &opt, sizeof(opt))) | |
217 | { | |
825ddf13 | 218 | ilog_error("setting SO_REUSEADDR for listener"); |
1087485c JT |
219 | rb_close(F); |
220 | return 0; | |
54ac8b60 VY |
221 | } |
222 | ||
1087485c JT |
223 | /* |
224 | * Bind a port to listen for new connections if port is non-null, | |
225 | * else assume it is already open and try get something from it. | |
226 | */ | |
227 | ||
228 | if(bind(rb_get_fd(F), (struct sockaddr *) &listener->addr, GET_SS_LEN(&listener->addr))) | |
229 | { | |
825ddf13 | 230 | ilog_error("binding listener socket"); |
1087485c JT |
231 | rb_close(F); |
232 | return 0; | |
54ac8b60 VY |
233 | } |
234 | ||
1087485c JT |
235 | if((ret = rb_listen(F, RATBOX_SOMAXCONN))) |
236 | { | |
825ddf13 | 237 | ilog_error("listen()"); |
1087485c JT |
238 | rb_close(F); |
239 | return 0; | |
54ac8b60 VY |
240 | } |
241 | ||
1087485c JT |
242 | listener->F = F; |
243 | ||
f691939a | 244 | rb_accept_tcp(listener->F, accept_precallback, accept_callback, listener); |
54ac8b60 VY |
245 | return 1; |
246 | } | |
247 | ||
248 | static listener_t * | |
e7046ee5 | 249 | find_listener(struct rb_sockaddr_storage *addr) |
54ac8b60 VY |
250 | { |
251 | listener_t *listener = NULL; | |
252 | listener_t *last_closed = NULL; | |
253 | ||
254 | for (listener = ListenerPollList; listener; listener = listener->next) | |
255 | { | |
256 | if(addr->ss_family != listener->addr.ss_family) | |
257 | continue; | |
258 | ||
259 | switch(addr->ss_family) | |
260 | { | |
261 | case AF_INET: | |
262 | { | |
263 | struct sockaddr_in *in4 = (struct sockaddr_in *)addr; | |
264 | struct sockaddr_in *lin4 = (struct sockaddr_in *)&listener->addr; | |
265 | if(in4->sin_addr.s_addr == lin4->sin_addr.s_addr && | |
266 | in4->sin_port == lin4->sin_port ) | |
267 | { | |
1087485c JT |
268 | if(listener->F == NULL) |
269 | last_closed = listener; | |
270 | else | |
54ac8b60 VY |
271 | return(listener); |
272 | } | |
273 | break; | |
274 | } | |
9ea3ea10 | 275 | #ifdef RB_IPV6 |
54ac8b60 VY |
276 | case AF_INET6: |
277 | { | |
278 | struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr; | |
279 | struct sockaddr_in6 *lin6 =(struct sockaddr_in6 *)&listener->addr; | |
280 | if(IN6_ARE_ADDR_EQUAL(&in6->sin6_addr, &lin6->sin6_addr) && | |
281 | in6->sin6_port == lin6->sin6_port) | |
282 | { | |
1087485c JT |
283 | if(listener->F == NULL) |
284 | last_closed = listener; | |
285 | else | |
54ac8b60 VY |
286 | return(listener); |
287 | } | |
288 | break; | |
289 | ||
290 | } | |
291 | #endif | |
292 | ||
293 | default: | |
294 | break; | |
295 | } | |
296 | } | |
297 | return last_closed; | |
298 | } | |
299 | ||
300 | ||
301 | /* | |
302 | * add_listener- create a new listener | |
303 | * port - the port number to listen on | |
304 | * vhost_ip - if non-null must contain a valid IP address string in | |
305 | * the format "255.255.255.255" | |
306 | */ | |
307 | void | |
c6d72037 | 308 | add_listener(int port, const char *vhost_ip, int family, int ssl) |
54ac8b60 VY |
309 | { |
310 | listener_t *listener; | |
e7046ee5 | 311 | struct rb_sockaddr_storage vaddr; |
54ac8b60 VY |
312 | |
313 | /* | |
314 | * if no port in conf line, don't bother | |
315 | */ | |
316 | if(port == 0) | |
317 | return; | |
318 | memset(&vaddr, 0, sizeof(vaddr)); | |
319 | vaddr.ss_family = family; | |
320 | ||
321 | if(vhost_ip != NULL) | |
322 | { | |
323 | if(family == AF_INET) | |
324 | { | |
caa4d9d2 | 325 | if(rb_inet_pton(family, vhost_ip, &((struct sockaddr_in *)&vaddr)->sin_addr) <= 0) |
54ac8b60 VY |
326 | return; |
327 | } | |
9ea3ea10 | 328 | #ifdef RB_IPV6 |
54ac8b60 VY |
329 | else |
330 | { | |
caa4d9d2 | 331 | if(rb_inet_pton(family, vhost_ip, &((struct sockaddr_in6 *)&vaddr)->sin6_addr) <= 0) |
54ac8b60 VY |
332 | return; |
333 | ||
334 | } | |
335 | #endif | |
336 | } else | |
337 | { | |
338 | switch(family) | |
339 | { | |
340 | case AF_INET: | |
341 | ((struct sockaddr_in *)&vaddr)->sin_addr.s_addr = INADDR_ANY; | |
342 | break; | |
9ea3ea10 | 343 | #ifdef RB_IPV6 |
54ac8b60 VY |
344 | case AF_INET6: |
345 | memcpy(&((struct sockaddr_in6 *)&vaddr)->sin6_addr, &in6addr_any, sizeof(struct in6_addr)); | |
346 | break; | |
347 | default: | |
348 | return; | |
349 | #endif | |
350 | } | |
351 | } | |
352 | switch(family) | |
353 | { | |
354 | case AF_INET: | |
99c4835f | 355 | SET_SS_LEN(&vaddr, sizeof(struct sockaddr_in)); |
54ac8b60 VY |
356 | ((struct sockaddr_in *)&vaddr)->sin_port = htons(port); |
357 | break; | |
9ea3ea10 | 358 | #ifdef RB_IPV6 |
54ac8b60 | 359 | case AF_INET6: |
99c4835f | 360 | SET_SS_LEN(&vaddr, sizeof(struct sockaddr_in6)); |
54ac8b60 VY |
361 | ((struct sockaddr_in6 *)&vaddr)->sin6_port = htons(port); |
362 | break; | |
363 | #endif | |
364 | default: | |
365 | break; | |
366 | } | |
367 | if((listener = find_listener(&vaddr))) | |
368 | { | |
1087485c | 369 | if(listener->F != NULL) |
54ac8b60 VY |
370 | return; |
371 | } | |
372 | else | |
373 | { | |
374 | listener = make_listener(&vaddr); | |
375 | listener->next = ListenerPollList; | |
376 | ListenerPollList = listener; | |
377 | } | |
378 | ||
f691939a | 379 | listener->F = NULL; |
c6d72037 | 380 | listener->ssl = ssl; |
54ac8b60 VY |
381 | |
382 | if(inetport(listener)) | |
383 | listener->active = 1; | |
384 | else | |
385 | close_listener(listener); | |
386 | } | |
387 | ||
388 | /* | |
389 | * close_listener - close a single listener | |
390 | */ | |
391 | void | |
392 | close_listener(listener_t *listener) | |
393 | { | |
394 | s_assert(listener != NULL); | |
395 | if(listener == NULL) | |
396 | return; | |
1087485c JT |
397 | if(listener->F != NULL) |
398 | { | |
399 | rb_close(listener->F); | |
400 | listener->F = NULL; | |
54ac8b60 VY |
401 | } |
402 | ||
403 | listener->active = 0; | |
404 | ||
405 | if(listener->ref_count) | |
406 | return; | |
407 | ||
408 | free_listener(listener); | |
409 | } | |
410 | ||
411 | /* | |
412 | * close_listeners - close and free all listeners that are not being used | |
413 | */ | |
414 | void | |
415 | close_listeners() | |
416 | { | |
417 | listener_t *listener; | |
418 | listener_t *listener_next = 0; | |
419 | /* | |
420 | * close all 'extra' listening ports we have | |
421 | */ | |
422 | for (listener = ListenerPollList; listener; listener = listener_next) | |
423 | { | |
424 | listener_next = listener->next; | |
425 | close_listener(listener); | |
426 | } | |
427 | } | |
428 | ||
429 | #define DLINE_WARNING "ERROR :You have been D-lined.\r\n" | |
430 | ||
431 | /* | |
432 | * add_connection - creates a client which has just connected to us on | |
433 | * the given fd. The sockhost field is initialized with the ip# of the host. | |
434 | * The client is sent to the auth module for verification, and not put in | |
435 | * any client list yet. | |
436 | */ | |
1087485c | 437 | static void |
4679c2c1 | 438 | add_connection(struct Listener *listener, rb_fde_t *F, struct sockaddr *sai, void *ssl_ctl) |
54ac8b60 VY |
439 | { |
440 | struct Client *new_client; | |
441 | s_assert(NULL != listener); | |
442 | ||
443 | /* | |
444 | * get the client socket name from the socket | |
445 | * the client has already been checked out in accept_connection | |
446 | */ | |
447 | new_client = make_client(NULL); | |
448 | ||
e7046ee5 | 449 | memcpy(&new_client->localClient->ip, sai, sizeof(struct rb_sockaddr_storage)); |
54ac8b60 VY |
450 | |
451 | /* | |
452 | * copy address to 'sockhost' as a string, copy it to host too | |
453 | * so we have something valid to put into error messages... | |
454 | */ | |
caa4d9d2 | 455 | rb_inet_ntop_sock((struct sockaddr *)&new_client->localClient->ip, new_client->sockhost, |
54ac8b60 VY |
456 | sizeof(new_client->sockhost)); |
457 | ||
458 | ||
f427c8b0 | 459 | rb_strlcpy(new_client->host, new_client->sockhost, sizeof(new_client->host)); |
54ac8b60 | 460 | |
99c4835f | 461 | new_client->localClient->F = F; |
c6d72037 | 462 | add_to_cli_fd_hash(new_client); |
54ac8b60 | 463 | new_client->localClient->listener = listener; |
8bd5767b JT |
464 | new_client->localClient->ssl_ctl = ssl_ctl; |
465 | if(ssl_ctl != NULL || rb_fd_ssl(F)) | |
c6d72037 VY |
466 | SetSSL(new_client); |
467 | ||
54ac8b60 VY |
468 | ++listener->ref_count; |
469 | ||
54ac8b60 VY |
470 | start_auth(new_client); |
471 | } | |
0d89d5cd | 472 | |
43946961 JT |
473 | static const char *toofast = "ERROR :Reconnecting too fast, throttled.\r\n"; |
474 | ||
1087485c JT |
475 | static int |
476 | accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, void *data) | |
477 | { | |
478 | struct Listener *listener = (struct Listener *)data; | |
479 | char buf[BUFSIZE]; | |
480 | struct ConfItem *aconf; | |
481 | static time_t last_oper_notice = 0; | |
482 | ||
8bd5767b JT |
483 | if(listener->ssl && (!ssl_ok || !get_ssld_count())) |
484 | { | |
485 | rb_close(F); | |
486 | return 0; | |
c6d72037 VY |
487 | } |
488 | ||
1087485c JT |
489 | if((maxconnections - 10) < rb_get_fd(F)) /* XXX this is kinda bogus */ |
490 | { | |
47adde3d | 491 | ++ServerStats.is_ref; |
1087485c JT |
492 | /* |
493 | * slow down the whining to opers bit | |
494 | */ | |
495 | if((last_oper_notice + 20) <= rb_current_time()) | |
496 | { | |
26716d6d | 497 | sendto_realops_snomask(SNO_GENERAL, L_ALL, |
1087485c JT |
498 | "All connections in use. (%s)", |
499 | get_listener_name(listener)); | |
500 | last_oper_notice = rb_current_time(); | |
501 | } | |
502 | ||
503 | rb_write(F, "ERROR :All connections in use\r\n", 32); | |
504 | rb_close(F); | |
505 | /* Re-register a new IO request for the next accept .. */ | |
506 | return 0; | |
507 | } | |
508 | ||
41d7fefa | 509 | aconf = find_dline(addr, addr->sa_family); |
1087485c JT |
510 | if(aconf != NULL && (aconf->status & CONF_EXEMPTDLINE)) |
511 | return 1; | |
512 | ||
513 | /* Do an initial check we aren't connecting too fast or with too many | |
514 | * from this IP... */ | |
515 | if(aconf != NULL) | |
516 | { | |
47adde3d | 517 | ServerStats.is_ref++; |
1087485c JT |
518 | |
519 | if(ConfigFileEntry.dline_with_reason) | |
520 | { | |
521 | if (rb_snprintf(buf, sizeof(buf), "ERROR :*** Banned: %s\r\n", aconf->passwd) >= (int)(sizeof(buf)-1)) | |
522 | { | |
523 | buf[sizeof(buf) - 3] = '\r'; | |
524 | buf[sizeof(buf) - 2] = '\n'; | |
525 | buf[sizeof(buf) - 1] = '\0'; | |
526 | } | |
527 | } | |
528 | else | |
529 | strcpy(buf, "ERROR :You have been D-lined.\r\n"); | |
530 | ||
531 | rb_write(F, buf, strlen(buf)); | |
532 | rb_close(F); | |
533 | return 0; | |
534 | } | |
535 | ||
43946961 JT |
536 | if(check_reject(F, addr)) |
537 | return 0; | |
538 | ||
539 | if(throttle_add(addr)) | |
540 | { | |
541 | rb_write(F, toofast, strlen(toofast)); | |
542 | rb_close(F); | |
543 | return 0; | |
544 | } | |
545 | ||
1087485c JT |
546 | return 1; |
547 | } | |
548 | ||
8bd5767b JT |
549 | static void |
550 | accept_ssld(rb_fde_t *F, struct sockaddr *addr, struct sockaddr *laddr, struct Listener *listener) | |
551 | { | |
552 | ssl_ctl_t *ctl; | |
553 | rb_fde_t *xF[2]; | |
554 | rb_socketpair(AF_UNIX, SOCK_STREAM, 0, &xF[0], &xF[1], "Incoming ssld Connection"); | |
555 | ctl = start_ssld_accept(F, xF[1], rb_get_fd(xF[0])); /* this will close F for us */ | |
4679c2c1 | 556 | add_connection(listener, xF[0], addr, ctl); |
c6d72037 VY |
557 | } |
558 | ||
1087485c JT |
559 | static void |
560 | accept_callback(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t addrlen, void *data) | |
561 | { | |
562 | struct Listener *listener = data; | |
563 | struct rb_sockaddr_storage lip; | |
564 | unsigned int locallen = sizeof(struct rb_sockaddr_storage); | |
565 | ||
47adde3d | 566 | ServerStats.is_ac++; |
1087485c JT |
567 | |
568 | if(getsockname(rb_get_fd(F), (struct sockaddr *) &lip, &locallen) < 0) | |
569 | { | |
570 | /* this shouldn't fail so... */ | |
571 | /* XXX add logging of this */ | |
572 | rb_close(F); | |
573 | } | |
574 | ||
8bd5767b JT |
575 | if(listener->ssl) |
576 | accept_ssld(F, addr, (struct sockaddr *)&lip, listener); | |
577 | else | |
4679c2c1 | 578 | add_connection(listener, F, addr, NULL); |
0d89d5cd | 579 | } |