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