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

Comparing ircd-hybrid/trunk/modules/core/m_server.c (file contents):
Revision 3096 by michael, Sat Mar 1 23:31:45 2014 UTC vs.
Revision 3135 by michael, Mon Mar 10 21:11:25 2014 UTC

# Line 234 | Line 234 | mr_server(struct Client *client_p, struc
234    return 0;
235   }
236  
237 /* ms_server()
238 *  parv[0] = command
239 *  parv[1] = servername
240 *  parv[2] = serverinfo/hopcount
241 *  parv[3] = serverinfo
242 */
243 static int
244 ms_server(struct Client *client_p, struct Client *source_p,
245          int parc, char *parv[])
246 {
247  char *name;
248  struct Client *target_p;
249  struct MaskItem *conf = NULL;
250  int hop;
251  int hlined = 0;
252  int llined = 0;
253  dlink_node *ptr = NULL;
254
255  /* Just to be sure -A1kmm. */
256  if (!IsServer(source_p))
257    return 0;
258
259  if (EmptyString(parv[3]))
260  {
261    sendto_one(client_p, "ERROR :No servername");
262    return 0;
263  }
264
265  name = parv[1];
266  hop  = atoi(parv[2]);
267
268  if (!valid_servname(name))
269  {
270    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
271                         "Link %s introduced server with bogus server name %s",
272                         get_client_name(client_p, SHOW_IP), name);
273    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
274                         "Link %s introduced server with bogus server name %s",
275                         get_client_name(client_p, MASK_IP), name);
276    sendto_one(client_p, "ERROR :Bogus server name introduced");
277    exit_client(client_p, &me, "Bogus server name intoduced");
278    return 0;
279  }
280
281  if ((target_p = hash_find_server(name)))
282  {
283    /* This link is trying feed me a server that I already have
284     * access through another path -- multiple paths not accepted
285     * currently, kill this link immediately!!
286     *
287     * Rather than KILL the link which introduced it, KILL the
288     * youngest of the two links. -avalon
289     *
290     * I think that we should exit the link itself, not the introducer,
291     * and we should always exit the most recently received(i.e. the
292     * one we are receiving this SERVER for. -A1kmm
293     *
294     * You *cant* do this, if you link somewhere, it bursts you a server
295     * that already exists, then sends you a client burst, you squit the
296     * server, but you keep getting the burst of clients on a server that
297     * doesnt exist, although ircd can handle it, its not a realistic
298     * solution.. --fl_
299     */
300    sendto_one(client_p, "ERROR :Server %s already exists", name);
301    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
302                         "Link %s cancelled, server %s already exists",
303                         get_client_name(client_p, SHOW_IP), name);
304    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
305                         "Link %s cancelled, server %s already exists",
306                         client_p->name, name);
307    exit_client(client_p, &me, "Server Exists");
308    return 0;
309  }
310
311  /* XXX If somehow there is a connect in progress and
312   * a connect comes in with same name toss the pending one,
313   * but only if it's not the same client! - Dianora
314   */
315  if ((target_p = find_servconn_in_progress(name)))
316    if (target_p != client_p)
317      exit_client(target_p, &me, "Overridden");
318
319  conf = client_p->localClient->confs.head->data;
320
321  /* See if the newly found server is behind a guaranteed
322   * leaf. If so, close the link.
323   */
324  DLINK_FOREACH(ptr, conf->leaf_list.head)
325    if (!match(ptr->data, name))
326    {
327      llined = 1;
328      break;
329    }
330
331  DLINK_FOREACH(ptr, conf->hub_list.head)
332    if (!match(ptr->data, name))
333    {
334      hlined = 1;
335      break;
336    }
337
338  /* Ok, this way this works is
339   *
340   * A server can have a CONF_HUB allowing it to introduce servers
341   * behind it.
342   *
343   * connect {
344   *            name = "irc.bighub.net";
345   *            hub_mask="*";
346   *            ...
347   *
348   * That would allow "irc.bighub.net" to introduce anything it wanted..
349   *
350   * However
351   *
352   * connect {
353   *            name = "irc.somehub.fi";
354   *            hub_mask="*";
355   *            leaf_mask="*.edu";
356   *...
357   * Would allow this server in finland to hub anything but
358   * .edu's
359   */
360
361  /* Ok, check client_p can hub the new server */
362  if (!hlined)
363  {
364    /* OOOPs nope can't HUB */
365    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
366                         "Non-Hub link %s introduced %s.",
367                         get_client_name(client_p, HIDE_IP), name);
368    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
369                         "Non-Hub link %s introduced %s.",
370                         get_client_name(client_p, MASK_IP), name);
371    exit_client(source_p, &me, "No matching hub_mask.");
372    return 0;
373  }
374
375  /* Check for the new server being leafed behind this HUB */
376  if (llined)
377  {
378    /* OOOPs nope can't HUB this leaf */
379    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
380                         "Link %s introduced leafed server %s.",
381                         get_client_name(client_p, HIDE_IP), name);
382    sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
383                         "Link %s introduced leafed server %s.",
384                         get_client_name(client_p, MASK_IP), name);
385    /* If it is new, we are probably misconfigured, so split the
386     * non-hub server introducing this. Otherwise, split the new
387     * server. -A1kmm.
388     */
389    /* wastes too much bandwidth, generates too many errors on
390     * larger networks, dont bother. --fl_
391     */
392    exit_client(client_p, &me, "Leafed Server.");
393    return 0;
394  }
395
396  target_p = make_client(client_p);
397  make_server(target_p);
398  target_p->hopcount = hop;
399  target_p->servptr = source_p;
400
401  strlcpy(target_p->name, name, sizeof(target_p->name));
402
403  set_server_gecos(target_p, parv[3]);
404  SetServer(target_p);
405
406  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_SERVICE, target_p->name, NULL, NULL, 0))
407    AddFlag(target_p, FLAGS_SERVICE);
408
409  dlinkAdd(target_p, &target_p->node, &global_client_list);
410  dlinkAdd(target_p, make_dlink_node(), &global_serv_list);
411  dlinkAdd(target_p, &target_p->lnode, &target_p->servptr->serv->server_list);
412
413  hash_add_client(target_p);
414
415  sendto_server(client_p, NOCAPS, NOCAPS, ":%s SERVER %s %d :%s%s",
416                source_p->name, target_p->name, hop + 1,
417                IsHidden(target_p) ? "(H) " : "", target_p->info);
418
419  sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE,
420                       "Server %s being introduced by %s",
421                       target_p->name, source_p->name);
422  return 0;
423 }
424
237   /* ms_sid()
238   *  parv[0] = command
239   *  parv[1] = servername
# Line 606 | Line 418 | ms_sid(struct Client *client_p, struct C
418    hash_add_client(target_p);
419    hash_add_id(target_p);
420  
421 <  sendto_server(client_p, CAP_TS6, NOCAPS, ":%s SID %s %d %s :%s%s",
421 >  sendto_server(client_p, NOCAPS, NOCAPS, ":%s SID %s %d %s :%s%s",
422                  ID_or_name(source_p, client_p), target_p->name, hop + 1,
423                  target_p->id, IsHidden(target_p) ? "(H) " : "", target_p->info);
612  sendto_server(client_p, NOCAPS, CAP_TS6, ":%s SERVER %s %d :%s%s",
613                source_p->name, target_p->name, hop + 1,
614                IsHidden(target_p) ? "(H) " : "", target_p->info);
615
424    sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE,
425                         "Server %s being introduced by %s",
426                         target_p->name, source_p->name);
# Line 622 | Line 430 | ms_sid(struct Client *client_p, struct C
430   static struct Message server_msgtab =
431   {
432    "SERVER", 0, 0, 4, MAXPARA, MFLG_SLOW, 0,
433 <  { mr_server, m_registered, ms_server, m_ignore, m_registered, m_ignore }
433 >  { mr_server, m_registered, m_ignore, m_ignore, m_registered, m_ignore }
434   };
435  
436   static struct Message sid_msgtab =

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines