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

Diff of /ircd-hybrid/src/listener.c

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

revision 538 by michael, Sun Mar 5 09:26:04 2006 UTC revision 539 by michael, Sat Mar 25 10:17:25 2006 UTC
# Line 47  make_listener(int port, struct irc_ssadd Line 47  make_listener(int port, struct irc_ssadd
47    struct Listener *listener = MyMalloc(sizeof(struct Listener));    struct Listener *listener = MyMalloc(sizeof(struct Listener));
48    assert(listener != 0);    assert(listener != 0);
49    
50    listener->name = me.name;    listener->name = me.name; /* XXX - me.name can be uninitialized if a
51                                 * listener{} block comes before serverinfo{} */
52    listener->port = port;    listener->port = port;
53    memcpy(&listener->addr, addr, sizeof(struct irc_ssaddr));    memcpy(&listener->addr, addr, sizeof(struct irc_ssaddr));
54    
# Line 77  get_listener_name(const struct Listener Line 78  get_listener_name(const struct Listener
78    
79    assert(listener != NULL);    assert(listener != NULL);
80    
81    if (listener == NULL)    ircsprintf(buf, "%s[%s/%u]", me.name, listener->name,
82      return(NULL);               listener->port);
83      return buf;
   ircsprintf(buf, "%s[%s/%u]",  
              me.name, listener->name, listener->port);  
   return(buf);  
84  }  }
85    
86  /* show_ports()  /* show_ports()
# Line 153  inetport(struct Listener *listener) Line 151  inetport(struct Listener *listener)
151    memset(&lsin, 0, sizeof(lsin));    memset(&lsin, 0, sizeof(lsin));
152    memcpy(&lsin, &listener->addr, sizeof(struct irc_ssaddr));    memcpy(&lsin, &listener->addr, sizeof(struct irc_ssaddr));
153        
154    irc_getnameinfo((struct sockaddr*)&lsin, lsin.ss_len, listener->vhost,    irc_getnameinfo((struct sockaddr *)&lsin, lsin.ss_len, listener->vhost,
155          HOSTLEN, NULL, 0, NI_NUMERICHOST);                    HOSTLEN, NULL, 0, NI_NUMERICHOST);
156    listener->name = listener->vhost;    listener->name = listener->vhost;
157    
158    /*    /*
# Line 197  inetport(struct Listener *listener) Line 195  inetport(struct Listener *listener)
195      report_error(L_ALL, "listen failed for %s:%s",      report_error(L_ALL, "listen failed for %s:%s",
196                   get_listener_name(listener), errno);                   get_listener_name(listener), errno);
197      fd_close(&listener->fd);      fd_close(&listener->fd);
198      return(0);      return 0;
199    }    }
200    
201    /* Listen completion events are READ events .. */    /* Listen completion events are READ events .. */
# Line 373  static void Line 371  static void
371  accept_connection(fde_t *pfd, void *data)  accept_connection(fde_t *pfd, void *data)
372  {  {
373    static time_t last_oper_notice = 0;    static time_t last_oper_notice = 0;
   struct irc_ssaddr sai;  
374    struct irc_ssaddr addr;    struct irc_ssaddr addr;
375    int fd;    int fd;
376    int pe;    int pe;
377    struct Listener *listener = data;    struct Listener *listener = data;
378    
   memset(&sai, 0, sizeof(sai));  
379    memset(&addr, 0, sizeof(addr));    memset(&addr, 0, sizeof(addr));
380    
381    assert(listener != NULL);    assert(listener != NULL);
# Line 394  accept_connection(fde_t *pfd, void *data Line 390  accept_connection(fde_t *pfd, void *data
390     * point, just assume that connections cannot     * point, just assume that connections cannot
391     * be accepted until some old is closed first.     * be accepted until some old is closed first.
392     */     */
393    while ((fd = comm_accept(pfd, &sai)) != -1)    while ((fd = comm_accept(pfd, &addr)) != -1)
394    {    {
     memcpy(&addr, &sai, sizeof(struct irc_ssaddr));  
   
395      /*      /*
396       * check for connection limit       * check for connection limit
397       */       */
# Line 426  accept_connection(fde_t *pfd, void *data Line 420  accept_connection(fde_t *pfd, void *data
420    
421      /* Do an initial check we aren't connecting too fast or with too many      /* Do an initial check we aren't connecting too fast or with too many
422       * from this IP... */       * from this IP... */
423      if ((pe = conf_connect_allowed(&addr, sai.ss.ss_family)) != 0)      if ((pe = conf_connect_allowed(&addr)))
424      {      {
425        ++ServerStats.is_ref;        ++ServerStats.is_ref;
426        if (!(listener->flags & LISTENER_SSL))        if (!(listener->flags & LISTENER_SSL))

Legend:
Removed from v.538  
changed lines
  Added in v.539

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