ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/s_bsd.c
(Generate patch)

Comparing:
ircd-hybrid-7.3/src/s_bsd.c (file contents), Revision 1122 by michael, Mon Jan 10 09:14:19 2011 UTC vs.
ircd-hybrid/trunk/src/s_bsd.c (file contents), Revision 1649 by michael, Sat Nov 10 19:27:13 2012 UTC

# Line 30 | Line 30
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"
# Line 133 | Line 129 | report_error(int level, const char* text
129   {
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));
134 <  ilog(L_ERROR, text, who, strerror(error));
132 >  sendto_realops_flags(UMODE_DEBUG, level, SEND_NOTICE,
133 >                       text, who, strerror(error));
134 >  ilog(LOG_TYPE_IRCD, text, who, strerror(error));
135   }
136  
137   /*
# Line 181 | Line 177 | init_comm(void)
177   void
178   close_connection(struct Client *client_p)
179   {
180 <  struct ConfItem *conf;
185 <  struct AccessItem *aconf;
186 <  struct ClassItem *aclass;
180 >  dlink_node *ptr = NULL;
181  
182 <  assert(NULL != client_p);
182 >  assert(client_p);
183  
184    if (!IsDead(client_p))
185    {
# Line 198 | Line 192 | close_connection(struct Client *client_p
192      send_queued_write(client_p);
193    }
194  
195 <  if (IsServer(client_p))
195 >  if (IsClient(client_p))
196 >  {
197 >    ++ServerStats.is_cl;
198 >    ServerStats.is_cbs += client_p->localClient->send.bytes;
199 >    ServerStats.is_cbr += client_p->localClient->recv.bytes;
200 >    ServerStats.is_cti += CurrentTime - client_p->localClient->firsttime;
201 >  }
202 >  else if (IsServer(client_p))
203    {
204      ++ServerStats.is_sv;
205      ServerStats.is_sbs += client_p->localClient->send.bytes;
206      ServerStats.is_sbr += client_p->localClient->recv.bytes;
207 <    ServerStats.is_sti += CurrentTime - client_p->firsttime;
207 >    ServerStats.is_sti += CurrentTime - client_p->localClient->firsttime;
208  
209 <    /* XXX Does this even make any sense at all anymore?
209 <     * scheduling a 'quick' reconnect could cause a pile of
210 <     * nick collides under TSora protocol... -db
211 <     */
212 <    /*
213 <     * If the connection has been up for a long amount of time, schedule
214 <     * a 'quick' reconnect, else reset the next-connect cycle.
215 <     */
216 <    if ((conf = find_conf_exact(SERVER_TYPE, client_p->name,
217 <                                client_p->username, client_p->host)))
209 >    DLINK_FOREACH(ptr, server_items.head)
210      {
211 +      struct MaskItem *conf = ptr->data;
212 +
213 +      if (irccmp(conf->name, client_p->name))
214 +        continue;
215 +
216        /*
217 <       * Reschedule a faster reconnect, if this was a automatically
218 <       * connected configuration entry. (Note that if we have had
222 <       * a rehash in between, the status has been changed to
223 <       * CONF_ILLEGAL). But only do this if it was a "good" link.
217 >       * Reset next-connect cycle of all connect{} blocks that match
218 >       * this servername.
219         */
220 <      aconf  = map_to_conf(conf);
226 <      aclass = map_to_conf(aconf->class_ptr);
227 <      aconf->hold = time(NULL);
228 <      aconf->hold += (aconf->hold - client_p->since > HANGONGOODLINK) ?
229 <        HANGONRETRYDELAY : ConFreq(aclass);
220 >      conf->until = CurrentTime + conf->class->con_freq;
221      }
222    }
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  }
223    else
224      ++ServerStats.is_ni;
225  
# Line 251 | Line 235 | close_connection(struct Client *client_p
235    if (client_p->localClient->fd.flags.open)
236      fd_close(&client_p->localClient->fd);
237  
254  if (HasServlink(client_p))
255  {
256    if (client_p->localClient->ctrlfd.flags.open)
257      fd_close(&client_p->localClient->ctrlfd);
258  }
259
238    dbuf_clear(&client_p->localClient->buf_sendq);
239    dbuf_clear(&client_p->localClient->buf_recvq);
240    
241    MyFree(client_p->localClient->passwd);
242 <  detach_conf(client_p, CONF_TYPE);
242 >  detach_conf(client_p, CONF_CLIENT|CONF_OPER|CONF_SERVER);
243    client_p->from = NULL; /* ...this should catch them! >:) --msa */
244   }
245  
# Line 307 | Line 285 | ssl_handshake(int fd, struct Client *cli
285   void
286   add_connection(struct Listener *listener, struct irc_ssaddr *irn, int fd)
287   {
288 <  struct Client *new_client;
311 <
312 <  assert(NULL != listener);
313 <
314 <  new_client = make_client(NULL);
288 >  struct Client *new_client = make_client(NULL);
289  
290    fd_open(&new_client->localClient->fd, fd, 1,
291            (listener->flags & LISTENER_SSL) ?
292            "Incoming SSL connection" : "Incoming connection");
293  
294 <  /*
294 >  /*
295     * copy address to 'sockhost' as a string, copy it to host too
296     * so we have something valid to put into error messages...
297     */
298    memcpy(&new_client->localClient->ip, irn, sizeof(struct irc_ssaddr));
299  
300 <  irc_getnameinfo((struct sockaddr*)&new_client->localClient->ip,
301 <        new_client->localClient->ip.ss_len, new_client->sockhost,
302 <        sizeof(new_client->sockhost), NULL, 0, NI_NUMERICHOST);
300 >  getnameinfo((struct sockaddr *)&new_client->localClient->ip,
301 >              new_client->localClient->ip.ss_len, new_client->sockhost,
302 >              sizeof(new_client->sockhost), NULL, 0, NI_NUMERICHOST);
303    new_client->localClient->aftype = new_client->localClient->ip.ss.ss_family;
304  
305 <  if (new_client->sockhost[0] == ':')
305 >  if (new_client->sockhost[0] == ':' && new_client->sockhost[1] == ':')
306    {
307      strlcpy(new_client->host, "0", sizeof(new_client->host));
308      strlcpy(new_client->host+1, new_client->sockhost, sizeof(new_client->host)-1);
309 +    memmove(new_client->sockhost+1, new_client->sockhost, sizeof(new_client->sockhost)-1);
310 +    new_client->sockhost[0] = '0';
311    }
312    else
313      strlcpy(new_client->host, new_client->sockhost, sizeof(new_client->host));
# Line 344 | Line 320 | add_connection(struct Listener *listener
320    {
321      if ((new_client->localClient->fd.ssl = SSL_new(ServerInfo.server_ctx)) == NULL)
322      {
323 <      ilog(L_CRIT, "SSL_new() ERROR! -- %s",
323 >      ilog(LOG_TYPE_IRCD, "SSL_new() ERROR! -- %s",
324             ERR_error_string(ERR_get_error(), NULL));
325  
326        SetDead(new_client);
# Line 521 | Line 497 | comm_connect_tcp(fde_t *fd, const char *
497  
498    snprintf(portname, sizeof(portname), "%d", port);
499  
500 <  if (irc_getaddrinfo(host, portname, &hints, &res))
500 >  if (getaddrinfo(host, portname, &hints, &res))
501    {
502      /* Send the DNS request, for the next level */
503      if (aftype == AF_INET6)
# Line 537 | Line 513 | comm_connect_tcp(fde_t *fd, const char *
513      memcpy(&fd->connect.hostaddr, res->ai_addr, res->ai_addrlen);
514      fd->connect.hostaddr.ss_len = res->ai_addrlen;
515      fd->connect.hostaddr.ss.ss_family = res->ai_family;
516 <    irc_freeaddrinfo(res);
516 >    freeaddrinfo(res);
517      comm_settimeout(fd, timeout*1000, comm_connect_timeout, NULL);
518      comm_connect_tryconnect(fd, NULL);
519    }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)