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

Comparing:
ircd-hybrid-7.3/src/s_bsd.c (file contents), Revision 1123 by michael, Sun Feb 6 21:57:50 2011 UTC vs.
ircd-hybrid/trunk/src/s_bsd.c (file contents), Revision 2235 by michael, Sat Jun 15 18:14:12 2013 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"
# Line 41 | Line 40
40   #include "irc_res.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 130 | 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 178 | Line 177 | init_comm(void)
177   void
178   close_connection(struct Client *client_p)
179   {
180 <  struct ConfItem *conf;
182 <  struct AccessItem *aconf;
183 <  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 195 | 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?
206 <     * scheduling a 'quick' reconnect could cause a pile of
207 <     * nick collides under TSora protocol... -db
208 <     */
209 <    /*
210 <     * If the connection has been up for a long amount of time, schedule
211 <     * a 'quick' reconnect, else reset the next-connect cycle.
212 <     */
213 <    if ((conf = find_conf_exact(SERVER_TYPE, client_p->name,
214 <                                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
219 <       * a rehash in between, the status has been changed to
220 <       * 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);
223 <      aclass = map_to_conf(aconf->class_ptr);
224 <      aconf->hold = time(NULL);
225 <      aconf->hold += (aconf->hold - client_p->since > HANGONGOODLINK) ?
226 <        HANGONRETRYDELAY : ConFreq(aclass);
220 >      conf->until = CurrentTime + conf->class->con_freq;
221      }
222    }
229  else if (IsClient(client_p))
230  {
231    ++ServerStats.is_cl;
232    ServerStats.is_cbs += client_p->localClient->send.bytes;
233    ServerStats.is_cbr += client_p->localClient->recv.bytes;
234    ServerStats.is_cti += CurrentTime - client_p->firsttime;
235  }
223    else
224      ++ServerStats.is_ni;
225  
# Line 248 | Line 235 | close_connection(struct Client *client_p
235    if (client_p->localClient->fd.flags.open)
236      fd_close(&client_p->localClient->fd);
237  
251  if (HasServlink(client_p))
252  {
253    if (client_p->localClient->ctrlfd.flags.open)
254      fd_close(&client_p->localClient->ctrlfd);
255  }
256
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 270 | Line 251 | close_connection(struct Client *client_p
251   static void
252   ssl_handshake(int fd, struct Client *client_p)
253   {
254 +  X509 *cert = NULL;
255    int ret = SSL_accept(client_p->localClient->fd.ssl);
256 +  int err = SSL_get_error(client_p->localClient->fd.ssl, ret);
257 +
258 +  ilog(LOG_TYPE_IRCD, "SSL Error %d %s", err, ERR_error_string(err, NULL));
259 +
260 +  if ((cert = SSL_get_peer_certificate(client_p->localClient->fd.ssl)))
261 +  {
262 +    int res = SSL_get_verify_result(client_p->localClient->fd.ssl);
263 +    char buf[EVP_MAX_MD_SIZE * 2 + 1] = { '\0' };
264 +    unsigned char md[EVP_MAX_MD_SIZE * 2 + 1] = { '\0' };
265 +
266 +    if (res == X509_V_OK || res == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN ||
267 +        res == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE ||
268 +        res == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT)
269 +    {
270 +      unsigned int i = 0, n = 0;
271 +
272 +      if (X509_digest(cert, EVP_sha256(), md, &n))
273 +      {
274 +        for (; i < n; ++i)
275 +          snprintf(buf + 2 * i, 3, "%02X", md[i]);
276 +        client_p->certfp = xstrdup(buf);
277 +      }
278 +    }
279 +    else
280 +      ilog(LOG_TYPE_IRCD, "Client %s!%s@%s gave bad SSL client certificate: %d",
281 +           client_p->name, client_p->username, client_p->host, res);
282 +    X509_free(cert);
283 +  }
284  
285    if (ret <= 0)
286 +  {
287      switch (SSL_get_error(client_p->localClient->fd.ssl, ret))
288      {
289        case SSL_ERROR_WANT_WRITE:
# Line 289 | Line 300 | ssl_handshake(int fd, struct Client *cli
300          exit_client(client_p, client_p, "Error during SSL handshake");
301          return;
302      }
303 +  }
304  
305 <  execute_callback(auth_cb, client_p);
305 >  start_auth(client_p);
306   }
307   #endif
308  
# Line 321 | Line 333 | add_connection(struct Listener *listener
333                sizeof(new_client->sockhost), NULL, 0, NI_NUMERICHOST);
334    new_client->localClient->aftype = new_client->localClient->ip.ss.ss_family;
335  
336 + #ifdef HAVE_LIBGEOIP
337 +  /* XXX IPV6 SUPPORT XXX */
338 +  if (irn->ss.ss_family == AF_INET && geoip_ctx)
339 +  {
340 +    const struct sockaddr_in *v4 = (const struct sockaddr_in *)&new_client->localClient->ip;
341 +    new_client->localClient->country_id = GeoIP_id_by_ipnum(geoip_ctx, (unsigned long)ntohl(v4->sin_addr.s_addr));
342 +  }
343 + #endif
344 +
345    if (new_client->sockhost[0] == ':' && new_client->sockhost[1] == ':')
346    {
347      strlcpy(new_client->host, "0", sizeof(new_client->host));
# Line 339 | Line 360 | add_connection(struct Listener *listener
360    {
361      if ((new_client->localClient->fd.ssl = SSL_new(ServerInfo.server_ctx)) == NULL)
362      {
363 <      ilog(L_CRIT, "SSL_new() ERROR! -- %s",
363 >      ilog(LOG_TYPE_IRCD, "SSL_new() ERROR! -- %s",
364             ERR_error_string(ERR_get_error(), NULL));
365  
366        SetDead(new_client);
# Line 352 | Line 373 | add_connection(struct Listener *listener
373    }
374    else
375   #endif
376 <    execute_callback(auth_cb, new_client);
376 >    start_auth(new_client);
377   }
378  
379   /*

Diff Legend

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