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

Comparing:
ircd-hybrid/modules/m_pong.c (file contents), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid/trunk/modules/m_pong.c (file contents), Revision 3109 by michael, Thu Mar 6 19:25:12 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  m_pong.c: The reply to a ping message.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 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: m_pong.c,v 1.44 2005/07/16 12:19:44 michael Exp $
20 > */
21 >
22 > /*! \file m_pong.c
23 > * \brief Includes required functions for processing the PONG command.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
28   #include "ircd.h"
27 #include "handlers.h"
29   #include "s_user.h"
30   #include "client.h"
31 < #include "hash.h"       /* for find_client() */
31 > #include "hash.h"
32   #include "numeric.h"
33 < #include "s_conf.h"
33 > #include "conf.h"
34   #include "send.h"
35   #include "irc_string.h"
35 #include "msg.h"
36   #include "parse.h"
37   #include "modules.h"
38  
39 static void mr_pong(struct Client *, struct Client *, int, char **);
40 static void ms_pong(struct Client *, struct Client *, int, char **);
41
42 struct Message pong_msgtab = {
43  "PONG", 0, 0, 1, 0, MFLG_SLOW | MFLG_UNREG, 0,
44  {mr_pong, m_ignore, ms_pong, m_ignore, m_ignore, m_ignore}
45 };
46
47 #ifndef STATIC_MODULES
48 void
49 _modinit(void)
50 {
51  mod_add_cmd(&pong_msgtab);
52 }
53
54 void
55 _moddeinit(void)
56 {
57  mod_del_cmd(&pong_msgtab);
58 }
39  
40 < const char *_version = "$Revision: 1.44 $";
61 < #endif
62 <
63 < static void
40 > static int
41   ms_pong(struct Client *client_p, struct Client *source_p,
42          int parc, char *parv[])
43   {
44    struct Client *target_p;
45    const char *origin, *destination;
46  
47 <  if (parc < 2 || *parv[1] == '\0')
47 >  if (parc < 2 || EmptyString(parv[1]))
48    {
49 <    sendto_one(source_p, form_str(ERR_NOORIGIN),
50 <               me.name, parv[0]);
74 <    return;
49 >    sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
50 >    return 0;
51    }
52  
53    origin = parv[1];
# Line 83 | Line 59 | ms_pong(struct Client *client_p, struct
59     * That being the case, we will route, but only for registered clients (a
60     * case can be made to allow them only from servers). -Shadowfax
61     */
62 <  if (!EmptyString(destination) && !match(destination, me.name) &&
62 >  if (!EmptyString(destination) && match(destination, me.name) &&
63        irccmp(destination, me.id))
64    {
65 <      if ((target_p = find_client(destination)) ||
66 <          (target_p = find_server(destination)))
67 <        sendto_one(target_p,":%s PONG %s %s",
68 <                   parv[0], origin, destination);
69 <      else
70 <        {
95 <          sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
96 <                     me.name, parv[0], destination);
97 <          return;
98 <        }
65 >    if ((target_p = hash_find_client(destination)) ||
66 >        (target_p = hash_find_server(destination)))
67 >      sendto_one(target_p, ":%s PONG %s %s",
68 >                 source_p->name, origin, destination);
69 >    else
70 >      sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, destination);
71    }
72 +
73 +  return 0;
74   }
75  
76 < static void
76 > static int
77   mr_pong(struct Client *client_p, struct Client *source_p,
78          int parc, char *parv[])
79   {
80 +  assert(source_p == client_p);
81 +
82    if (parc == 2 && *parv[1] != '\0')
83    {
84 <    if(ConfigFileEntry.ping_cookie && (source_p->flags&FLAGS_GOTUSER) && source_p->name[0])
84 >    if (ConfigFileEntry.ping_cookie && !source_p->localClient->registration)
85      {
86 <        unsigned long incoming_ping = strtoul(parv[1], NULL, 10);
87 <        if(incoming_ping)
88 <        {
89 <          if(source_p->localClient->random_ping == incoming_ping)
90 <          {
91 <                char buf[USERLEN+1];
92 <                strlcpy(buf, source_p->username, sizeof(buf));
93 <                SetPingCookie(source_p);
94 <                register_local_user(client_p, source_p, source_p->name, buf);
95 <          }
96 <          else
97 <          {
122 <                sendto_one(source_p, form_str(ERR_WRONGPONG), me.name,
123 <                           source_p->name, source_p->localClient->random_ping);
124 <                return;
125 <          }
126 <        }
86 >      unsigned int incoming_ping = strtoul(parv[1], NULL, 10);
87 >
88 >      if (incoming_ping)
89 >      {
90 >        if (source_p->localClient->random_ping == incoming_ping)
91 >        {
92 >          SetPingCookie(source_p);
93 >          register_local_user(source_p);
94 >        }
95 >        else
96 >          sendto_one_numeric(source_p, &me, ERR_WRONGPONG,
97 >                             source_p->localClient->random_ping);
98        }
128    
99      }
100 +  }
101    else
102 <    sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
102 >    sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
103 >
104 >  return 0;
105 > }
106 >
107 > static struct Message pong_msgtab =
108 > {
109 >  "PONG", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
110 >  { mr_pong, m_ignore, ms_pong, m_ignore, m_ignore, m_ignore }
111 > };
112 >
113 > static void
114 > module_init(void)
115 > {
116 >  mod_add_cmd(&pong_msgtab);
117 > }
118 >
119 > static void
120 > module_exit(void)
121 > {
122 >  mod_del_cmd(&pong_msgtab);
123   }
124  
125 + struct module module_entry =
126 + {
127 +  .node    = { NULL, NULL, NULL },
128 +  .name    = NULL,
129 +  .version = "$Revision$",
130 +  .handle  = NULL,
131 +  .modinit = module_init,
132 +  .modexit = module_exit,
133 +  .flags   = 0
134 + };

Comparing:
ircd-hybrid/modules/m_pong.c (property svn:keywords), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid/trunk/modules/m_pong.c (property svn:keywords), Revision 3109 by michael, Thu Mar 6 19:25:12 2014 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

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