/[svn]/ircd-hybrid-7.2/src/s_bsd.c
ViewVC logotype

Diff of /ircd-hybrid-7.2/src/s_bsd.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 548 by michael, Sun Feb 12 16:19:54 2006 UTC revision 549 by michael, Thu Apr 20 12:46:18 2006 UTC
# Line 322  ssl_handshake(int fd, struct Client *cli Line 322  ssl_handshake(int fd, struct Client *cli
322   * any client list yet.   * any client list yet.
323   */   */
324  void  void
325  add_connection(struct Listener* listener, int fd)  add_connection(struct Listener *listener, struct irc_ssaddr *irn, int fd)
326  {  {
327    struct Client *new_client;    struct Client *new_client;
   socklen_t len = sizeof(struct irc_ssaddr);  
   struct irc_ssaddr irn;  
   assert(NULL != listener);  
   
   /*  
    * get the client socket name from the socket  
    * the client has already been checked out in accept_connection  
    */  
328    
329    memset(&irn, 0, sizeof(irn));    assert(NULL != listener);
   if (getpeername(fd, (struct sockaddr *)&irn, (socklen_t *)&len))  
   {  
 #ifdef _WIN32  
     errno = WSAGetLastError();  
 #endif  
     report_error(L_ALL, "Failed in adding new connection %s :%s",  
             get_listener_name(listener), errno);  
     ServerStats->is_ref++;  
 #ifdef _WIN32  
     closesocket(fd);  
 #else  
     close(fd);  
 #endif  
     return;  
   }  
330    
 #ifdef IPV6  
   remove_ipv6_mapping(&irn);  
 #else  
   irn.ss_len = len;  
 #endif  
331    new_client = make_client(NULL);    new_client = make_client(NULL);
332    
333    fd_open(&new_client->localClient->fd, fd, 1,    fd_open(&new_client->localClient->fd, fd, 1,
334            (listener->flags & LISTENER_SSL) ?            (listener->flags & LISTENER_SSL) ?
335            "Incoming SSL connection" : "Incoming connection");            "Incoming SSL connection" : "Incoming connection");
   memset(&new_client->localClient->ip, 0, sizeof(struct irc_ssaddr));  
336    
337    /*    /*
338     * copy address to 'sockhost' as a string, copy it to host too     * copy address to 'sockhost' as a string, copy it to host too
339     * so we have something valid to put into error messages...     * so we have something valid to put into error messages...
340     */     */
341    memcpy(&new_client->localClient->ip, &irn, sizeof(struct irc_ssaddr));    memcpy(&new_client->localClient->ip, irn, sizeof(struct irc_ssaddr));
342    
343    irc_getnameinfo((struct sockaddr*)&new_client->localClient->ip,    irc_getnameinfo((struct sockaddr*)&new_client->localClient->ip,
344          new_client->localClient->ip.ss_len,  new_client->sockhost,          new_client->localClient->ip.ss_len,  new_client->sockhost,
345          HOSTIPLEN, NULL, 0, NI_NUMERICHOST);          HOSTIPLEN, NULL, 0, NI_NUMERICHOST);
346    new_client->localClient->aftype = new_client->localClient->ip.ss.ss_family;    new_client->localClient->aftype = new_client->localClient->ip.ss.ss_family;
   
   *new_client->host = '\0';  
347  #ifdef IPV6  #ifdef IPV6
348    if (*new_client->sockhost == ':')    if (new_client->sockhost[0] == ':')
349      strlcat(new_client->host, "0", HOSTLEN+1);      strlcat(new_client->host, "0", HOSTLEN+1);
350    
351    if (new_client->localClient->aftype == AF_INET6 &&    if (new_client->localClient->aftype == AF_INET6 &&
# Line 383  add_connection(struct Listener* listener Line 353  add_connection(struct Listener* listener
353    {    {
354      strlcat(new_client->host, new_client->sockhost,HOSTLEN+1);      strlcat(new_client->host, new_client->sockhost,HOSTLEN+1);
355      strlcat(new_client->host, ".", HOSTLEN+1);      strlcat(new_client->host, ".", HOSTLEN+1);
356    } else    }
357      else
358  #endif  #endif
359      strlcat(new_client->host, new_client->sockhost,HOSTLEN+1);      strlcat(new_client->host, new_client->sockhost,HOSTLEN+1);
360    
361      new_client->connect_id = ++connect_id;
362    new_client->localClient->listener = listener;    new_client->localClient->listener = listener;
363    ++listener->ref_count;    ++listener->ref_count;
364    
   connect_id++;  
   new_client->connect_id = connect_id;  
   
365  #ifdef HAVE_LIBCRYPTO  #ifdef HAVE_LIBCRYPTO
366    if ((listener->flags & LISTENER_SSL))    if (listener->flags & LISTENER_SSL)
367    {    {
368      if ((new_client->localClient->fd.ssl = SSL_new(ServerInfo.ctx)) == NULL)      if ((new_client->localClient->fd.ssl = SSL_new(ServerInfo.ctx)) == NULL)
369      {      {

Legend:
Removed from v.548  
changed lines
  Added in v.549

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28