23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
– |
#include "handlers.h" |
26 |
|
#include "client.h" |
27 |
|
#include "ircd.h" |
28 |
|
#include "irc_string.h" |
29 |
|
#include "numeric.h" |
30 |
|
#include "fdlist.h" |
31 |
|
#include "s_bsd.h" |
32 |
< |
#include "s_conf.h" |
33 |
< |
#include "s_log.h" |
32 |
> |
#include "conf.h" |
33 |
> |
#include "log.h" |
34 |
|
#include "s_serv.h" |
35 |
|
#include "send.h" |
37 |
– |
#include "msg.h" |
36 |
|
#include "parse.h" |
37 |
|
#include "hash.h" |
38 |
|
#include "modules.h" |
39 |
|
|
42 |
– |
static void mo_connect(struct Client *, struct Client *, int, char **); |
43 |
– |
static void ms_connect(struct Client *, struct Client *, int, char **); |
44 |
– |
|
45 |
– |
struct Message connect_msgtab = { |
46 |
– |
"CONNECT", 0, 0, 2, 0, MFLG_SLOW, 0, |
47 |
– |
{m_unregistered, m_not_oper, ms_connect, m_ignore, mo_connect, m_ignore} |
48 |
– |
}; |
49 |
– |
|
50 |
– |
#ifndef STATIC_MODULES |
51 |
– |
void |
52 |
– |
_modinit(void) |
53 |
– |
{ |
54 |
– |
mod_add_cmd(&connect_msgtab); |
55 |
– |
} |
56 |
– |
|
57 |
– |
void |
58 |
– |
_moddeinit(void) |
59 |
– |
{ |
60 |
– |
mod_del_cmd(&connect_msgtab); |
61 |
– |
} |
62 |
– |
|
63 |
– |
const char *_version = "$Revision$"; |
64 |
– |
#endif |
40 |
|
|
41 |
|
/* |
42 |
|
* mo_connect - CONNECT command handler |
50 |
|
* parv[3] = remote server |
51 |
|
*/ |
52 |
|
static void |
53 |
< |
mo_connect(struct Client* client_p, struct Client* source_p, |
54 |
< |
int parc, char* parv[]) |
53 |
> |
mo_connect(struct Client *client_p, struct Client *source_p, |
54 |
> |
int parc, char *parv[]) |
55 |
|
{ |
56 |
|
int port; |
57 |
|
int tmpport; |
58 |
|
struct ConfItem *conf = NULL; |
59 |
|
struct AccessItem *aconf = NULL; |
60 |
< |
struct Client *target_p; |
60 |
> |
const struct Client *target_p = NULL; |
61 |
|
|
62 |
< |
/* always privileged with handlers */ |
88 |
< |
if (MyConnect(source_p) && !IsOperRemote(source_p) && parc > 3) |
62 |
> |
if (EmptyString(parv[1])) |
63 |
|
{ |
64 |
< |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
65 |
< |
me.name, source_p->name, "connect"); |
64 |
> |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
65 |
> |
me.name, source_p->name, "CONNECT"); |
66 |
|
return; |
67 |
|
} |
68 |
|
|
69 |
< |
if (hunt_server(client_p, source_p, |
96 |
< |
":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME) |
97 |
< |
return; |
98 |
< |
|
99 |
< |
if (*parv[1] == '\0') |
69 |
> |
if (parc > 3) |
70 |
|
{ |
71 |
< |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
72 |
< |
me.name, source_p->name, "CONNECT"); |
73 |
< |
return; |
71 |
> |
if (!HasOFlag(source_p, OPER_FLAG_REMOTE)) |
72 |
> |
{ |
73 |
> |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
74 |
> |
me.name, source_p->name, "connect"); |
75 |
> |
return; |
76 |
> |
} |
77 |
> |
|
78 |
> |
if (hunt_server(client_p, source_p, ":%s CONNECT %s %s :%s", 3, |
79 |
> |
parc, parv) != HUNTED_ISME) |
80 |
> |
return; |
81 |
|
} |
82 |
|
|
83 |
< |
if ((target_p = find_server(parv[1]))) |
83 |
> |
if ((target_p = hash_find_server(parv[1]))) |
84 |
|
{ |
85 |
|
sendto_one(source_p, |
86 |
|
":%s NOTICE %s :Connect: Server %s already exists from %s.", |
98 |
|
NULL, NULL, parv[1], 0)) != NULL) |
99 |
|
aconf = (struct AccessItem *)map_to_conf(conf); |
100 |
|
|
101 |
< |
if (conf == NULL) |
101 |
> |
if (conf == NULL || aconf == NULL) |
102 |
|
{ |
103 |
|
sendto_one(source_p, |
104 |
|
":%s NOTICE %s :Connect: Host %s not listed in ircd.conf", |
105 |
|
me.name, source_p->name, parv[1]); |
106 |
|
return; |
107 |
|
} |
108 |
< |
|
108 |
> |
|
109 |
|
/* Get port number from user, if given. If not specified, |
110 |
|
* use the default form configuration structure. If missing |
111 |
|
* from there, then use the precompiled default. |
138 |
|
/* |
139 |
|
* Notify all operators about remote connect requests |
140 |
|
*/ |
141 |
< |
ilog(L_TRACE, "CONNECT From %s : %s %s", |
141 |
> |
ilog(LOG_TYPE_IRCD, "CONNECT From %s : %s %s", |
142 |
|
source_p->name, parv[1], parv[2] ? parv[2] : ""); |
143 |
|
|
144 |
|
aconf->port = port; |
148 |
|
*/ |
149 |
|
if (serv_connect(aconf, source_p)) |
150 |
|
{ |
151 |
< |
if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p)) |
151 |
> |
if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN)) |
152 |
|
sendto_one(source_p, ":%s NOTICE %s :*** Connecting to %s[%s].%d", |
153 |
|
me.name, source_p->name, aconf->host, |
154 |
|
conf->name, aconf->port); |
187 |
|
int tmpport; |
188 |
|
struct ConfItem *conf = NULL; |
189 |
|
struct AccessItem *aconf = NULL; |
190 |
< |
struct Client *target_p; |
190 |
> |
const struct Client *target_p = NULL; |
191 |
|
|
192 |
|
if (hunt_server(client_p, source_p, |
193 |
|
":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME) |
200 |
|
return; |
201 |
|
} |
202 |
|
|
203 |
< |
if ((target_p = find_server(parv[1]))) |
203 |
> |
if ((target_p = hash_find_server(parv[1]))) |
204 |
|
{ |
205 |
|
sendto_one(source_p, |
206 |
|
":%s NOTICE %s :Connect: Server %s already exists from %s.", |
213 |
|
*/ |
214 |
|
if ((conf = find_matching_name_conf(SERVER_TYPE, |
215 |
|
parv[1], NULL, NULL, 0)) != NULL) |
216 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
216 |
> |
aconf = map_to_conf(conf); |
217 |
|
else if ((conf = find_matching_name_conf(SERVER_TYPE, |
218 |
|
NULL, NULL, parv[1], 0)) != NULL) |
219 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
219 |
> |
aconf = map_to_conf(conf); |
220 |
|
|
221 |
< |
if (aconf == NULL) |
221 |
> |
if (conf == NULL || aconf == NULL) |
222 |
|
{ |
223 |
|
sendto_one(source_p, |
224 |
|
":%s NOTICE %s :Connect: Host %s not listed in ircd.conf", |
226 |
|
return; |
227 |
|
} |
228 |
|
|
252 |
– |
assert(aconf != NULL); |
253 |
– |
|
229 |
|
/* Get port number from user, if given. If not specified, |
230 |
|
* use the default form configuration structure. If missing |
231 |
|
* from there, then use the precompiled default. |
265 |
|
*/ |
266 |
|
sendto_wallops_flags(UMODE_WALLOP, &me, "Remote CONNECT %s %d from %s", |
267 |
|
parv[1], port, source_p->name); |
268 |
< |
sendto_server(NULL, NULL, NULL, NOCAPS, NOCAPS, NOFLAGS, |
268 |
> |
sendto_server(NULL, NULL, NOCAPS, NOCAPS, |
269 |
|
":%s WALLOPS :Remote CONNECT %s %d from %s", |
270 |
|
me.name, parv[1], port, source_p->name); |
271 |
|
|
272 |
< |
ilog(L_TRACE, "CONNECT From %s : %s %d", |
272 |
> |
ilog(LOG_TYPE_IRCD, "CONNECT From %s : %s %d", |
273 |
|
source_p->name, parv[1], port); |
274 |
|
|
275 |
|
aconf->port = port; |
276 |
|
|
277 |
< |
/* at this point we should be calling connect_server with a valid |
277 |
> |
/* |
278 |
> |
* At this point we should be calling connect_server with a valid |
279 |
|
* C:line and a valid port in the C:line |
280 |
|
*/ |
281 |
|
if (serv_connect(aconf, source_p)) |
284 |
|
else |
285 |
|
sendto_one(source_p, ":%s NOTICE %s :*** Couldn't connect to %s.%d", |
286 |
|
me.name, source_p->name, conf->name, aconf->port); |
287 |
< |
/* client is either connecting with all the data it needs or has been |
287 |
> |
/* |
288 |
> |
* Client is either connecting with all the data it needs or has been |
289 |
|
* destroyed |
290 |
|
*/ |
291 |
|
aconf->port = tmpport; |
292 |
|
} |
293 |
|
|
294 |
+ |
static struct Message connect_msgtab = { |
295 |
+ |
"CONNECT", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
296 |
+ |
{ m_unregistered, m_not_oper, ms_connect, m_ignore, mo_connect, m_ignore } |
297 |
+ |
}; |
298 |
+ |
|
299 |
+ |
static void |
300 |
+ |
module_init(void) |
301 |
+ |
{ |
302 |
+ |
mod_add_cmd(&connect_msgtab); |
303 |
+ |
} |
304 |
+ |
|
305 |
+ |
static void |
306 |
+ |
module_exit(void) |
307 |
+ |
{ |
308 |
+ |
mod_del_cmd(&connect_msgtab); |
309 |
+ |
} |
310 |
+ |
|
311 |
+ |
struct module module_entry = { |
312 |
+ |
.node = { NULL, NULL, NULL }, |
313 |
+ |
.name = NULL, |
314 |
+ |
.version = "$Revision$", |
315 |
+ |
.handle = NULL, |
316 |
+ |
.modinit = module_init, |
317 |
+ |
.modexit = module_exit, |
318 |
+ |
.flags = 0 |
319 |
+ |
}; |