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

Comparing ircd-hybrid/trunk/src/s_serv.c (file contents):
Revision 2718 by michael, Wed Dec 25 13:43:46 2013 UTC vs.
Revision 3136 by michael, Tue Mar 11 18:24:03 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  s_serv.c: Server related functions.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2005 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file s_serv.c
23 > * \brief Server related functions.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
# Line 31 | Line 33
33   #include "channel.h"
34   #include "channel_mode.h"
35   #include "client.h"
34 #include "dbuf.h"
36   #include "event.h"
37   #include "fdlist.h"
38   #include "hash.h"
# Line 49 | Line 50
50   #include "s_user.h"
51   #include "send.h"
52   #include "memory.h"
53 < #include "channel.h" /* chcap_usage_counts stuff...*/
53 > #include "channel.h"
54   #include "parse.h"
55  
56   #define MIN_CONN_FREQ 300
# Line 205 | Line 206 | hunt_server(struct Client *client_p, str
206      {
207        if (!(target_p = hash_find_server(parv[server])))
208        {
209 <        sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
209 <                   me.name, source_p->name, parv[server]);
209 >        sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, parv[server]);
210          return HUNTED_NOSUCH;
211        }
212      }
# Line 233 | Line 233 | hunt_server(struct Client *client_p, str
233    {
234      if(!IsRegistered(target_p))
235      {
236 <      sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
237 <                 me.name, source_p->name, parv[server]);
236 >      sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, parv[server]);
237        return HUNTED_NOSUCH;
238      }
239  
# Line 245 | Line 244 | hunt_server(struct Client *client_p, str
244        parv[server] = target_p->name;
245  
246      /* This is a little kludgy but should work... */
247 <    if (IsClient(source_p) &&
249 <        ((MyConnect(target_p) && IsCapable(target_p, CAP_TS6)) ||
250 <         (!MyConnect(target_p) && IsCapable(target_p->from, CAP_TS6))))
251 <      parv[0] = ID(source_p);
252 <
253 <    sendto_one(target_p, command, parv[0],
247 >    sendto_one(target_p, command, ID_or_name(source_p, target_p),
248                 parv[1], parv[2], parv[3], parv[4],
249                 parv[5], parv[6], parv[7], parv[8]);
250      return HUNTED_PASS;
251    }
252  
253 <  sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
260 <             me.name, source_p->name, parv[server]);
253 >  sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, parv[server]);
254    return HUNTED_NOSUCH;
255   }
256  
# Line 584 | Line 577 | sendnick_TS(struct Client *client_p, str
577    }
578  
579    if (IsCapable(client_p, CAP_SVS))
580 <  {
581 <    if (HasID(target_p) && IsCapable(client_p, CAP_TS6))
582 <      sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %s :%s",
583 <                 target_p->servptr->id,
584 <                 target_p->name, target_p->hopcount + 1,
585 <                 (unsigned long) target_p->tsinfo,
586 <                 ubuf, target_p->username, target_p->host,
587 <                 (MyClient(target_p) && IsIPSpoof(target_p)) ?
595 <                 "0" : target_p->sockhost, target_p->id,
596 <                 target_p->svid, target_p->info);
597 <    else
598 <      sendto_one(client_p, "NICK %s %d %lu %s %s %s %s %s :%s",
599 <                 target_p->name, target_p->hopcount + 1,
600 <                 (unsigned long) target_p->tsinfo,
601 <                 ubuf, target_p->username, target_p->host,
602 <                 target_p->servptr->name, target_p->svid,
603 <                 target_p->info);
604 <  }
580 >    sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %s :%s",
581 >               target_p->servptr->id,
582 >               target_p->name, target_p->hopcount + 1,
583 >               (unsigned long) target_p->tsinfo,
584 >               ubuf, target_p->username, target_p->host,
585 >               (MyClient(target_p) && IsIPSpoof(target_p)) ?
586 >               "0" : target_p->sockhost, target_p->id,
587 >               target_p->svid, target_p->info);
588    else
589 <  {
590 <    if (HasID(target_p) && IsCapable(client_p, CAP_TS6))
591 <      sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s :%s",
592 <                 target_p->servptr->id,
593 <                 target_p->name, target_p->hopcount + 1,
594 <                 (unsigned long) target_p->tsinfo,
595 <                 ubuf, target_p->username, target_p->host,
613 <                 (MyClient(target_p) && IsIPSpoof(target_p)) ?
614 <                 "0" : target_p->sockhost, target_p->id, target_p->info);
615 <    else
616 <      sendto_one(client_p, "NICK %s %d %lu %s %s %s %s :%s",
617 <                 target_p->name, target_p->hopcount + 1,
618 <                 (unsigned long) target_p->tsinfo,
619 <                 ubuf, target_p->username, target_p->host,
620 <                 target_p->servptr->name, target_p->info);
621 <  }
589 >    sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s :%s",
590 >               target_p->servptr->id,
591 >               target_p->name, target_p->hopcount + 1,
592 >               (unsigned long) target_p->tsinfo,
593 >               ubuf, target_p->username, target_p->host,
594 >               (MyClient(target_p) && IsIPSpoof(target_p)) ?
595 >               "0" : target_p->sockhost, target_p->id, target_p->info);
596  
597    if (!EmptyString(target_p->certfp))
598      sendto_one(client_p, ":%s CERTFP %s",
# Line 745 | Line 719 | server_estab(struct Client *client_p)
719    sendto_one(client_p, "SVINFO %d %d 0 :%lu", TS_CURRENT, TS_MIN,
720               (unsigned long)CurrentTime);
721  
722 <  /* assumption here is if they passed the correct TS version, they also passed an SID */
749 <  if (IsCapable(client_p, CAP_TS6))
722 >  if (HasID(client_p))
723      hash_add_id(client_p);
724  
725    /* XXX Does this ever happen? I don't think so -db */
# Line 837 | Line 810 | server_estab(struct Client *client_p)
810  
811    fd_note(&client_p->localClient->fd, "Server: %s", client_p->name);
812  
813 <  /* Old sendto_serv_but_one() call removed because we now
814 <  ** need to send different names to different servers
815 <  ** (domain name matching) Send new server to other servers.
843 <  */
844 <  DLINK_FOREACH(ptr, serv_list.head)
845 <  {
846 <    target_p = ptr->data;
847 <
848 <    if (target_p == client_p)
849 <      continue;
850 <
851 <    if (IsCapable(target_p, CAP_TS6) && HasID(client_p))
852 <      sendto_one(target_p, ":%s SID %s 2 %s :%s%s",
853 <                 me.id, client_p->name, client_p->id,
854 <                 IsHidden(client_p) ? "(H) " : "",
855 <                 client_p->info);
856 <    else
857 <      sendto_one(target_p,":%s SERVER %s 2 :%s%s",
858 <                 me.name, client_p->name,
859 <                 IsHidden(client_p) ? "(H) " : "",
860 <                 client_p->info);
861 <  }
813 >  sendto_server(client_p, NOCAPS, NOCAPS, ":%s SID %s 2 %s :%s%s",
814 >                me.id, client_p->name, client_p->id,
815 >                IsHidden(client_p) ? "(H) " : "", client_p->info);
816  
817    /*
818     * Pass on my client information to the new server
# Line 887 | Line 841 | server_estab(struct Client *client_p)
841      if (IsMe(target_p) || target_p->from == client_p)
842        continue;
843  
844 <    if (IsCapable(client_p, CAP_TS6))
845 <    {
846 <      if (HasID(target_p))
847 <        sendto_one(client_p, ":%s SID %s %d %s :%s%s",
894 <                   ID(target_p->servptr), target_p->name, target_p->hopcount+1,
895 <                   target_p->id, IsHidden(target_p) ? "(H) " : "",
896 <                   target_p->info);
897 <      else  /* introducing non-ts6 server */
898 <        sendto_one(client_p, ":%s SERVER %s %d :%s%s",
899 <                   ID(target_p->servptr), target_p->name, target_p->hopcount+1,
900 <                   IsHidden(target_p) ? "(H) " : "", target_p->info);
901 <    }
902 <    else
903 <      sendto_one(client_p, ":%s SERVER %s %d :%s%s",
904 <                 target_p->servptr->name, target_p->name, target_p->hopcount+1,
905 <                 IsHidden(target_p) ? "(H) " : "", target_p->info);
844 >    sendto_one(client_p, ":%s SID %s %d %s :%s%s",
845 >               ID(target_p->servptr), target_p->name, target_p->hopcount+1,
846 >               target_p->id, IsHidden(target_p) ? "(H) " : "",
847 >               target_p->info);
848  
849      if (HasFlag(target_p, FLAGS_EOB))
850        sendto_one(client_p, ":%s EOB", ID_or_name(target_p, client_p));
# Line 1110 | Line 1052 | serv_connect(struct MaskItem *conf, stru
1052                           "Server %s already present from %s",
1053                           conf->name, get_client_name(client_p, MASK_IP));
1054      if (by && IsClient(by) && !MyClient(by))
1055 <      sendto_one(by, ":%s NOTICE %s :Server %s already present from %s",
1056 <                 me.name, by->name, conf->name,
1115 <                 get_client_name(client_p, MASK_IP));
1055 >      sendto_one_notice(by, &me, ":Server %s already present from %s",
1056 >                        conf->name, get_client_name(client_p, MASK_IP));
1057      return 0;
1058    }
1059  
# Line 1150 | Line 1091 | serv_connect(struct MaskItem *conf, stru
1091                           "Host %s is not enabled for connecting: no connect{} block",
1092                           conf->name);
1093      if (by && IsClient(by) && !MyClient(by))
1094 <      sendto_one(by, ":%s NOTICE %s :Connect to host %s failed.",
1095 <                 me.name, by->name, client_p->name);
1094 >      sendto_one_notice(by, &me, ":Connect to host %s failed.", client_p->name);
1095 >
1096      SetDead(client_p);
1097      exit_client(client_p, client_p, "Connection failed");
1098      return 0;

Diff Legend

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