| 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) |
| 194 |
|
return; |
| 195 |
|
|
| 196 |
< |
if (*parv[1] == '\0') |
| 196 |
> |
if (EmptyString(parv[1])) |
| 197 |
|
{ |
| 198 |
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
| 199 |
|
me.name, source_p->name, "CONNECT"); |
| 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, NOCAPS, CAP_TS6, |
| 269 |
|
":%s WALLOPS :Remote CONNECT %s %d from %s", |
| 270 |
|
me.name, parv[1], port, source_p->name); |
| 271 |
+ |
sendto_server(NULL, CAP_TS6, NOCAPS, |
| 272 |
+ |
":%s WALLOPS :Remote CONNECT %s %d from %s", |
| 273 |
+ |
me.id, parv[1], port, source_p->name); |
| 274 |
|
|
| 275 |
< |
ilog(L_TRACE, "CONNECT From %s : %s %d", |
| 275 |
> |
ilog(LOG_TYPE_IRCD, "CONNECT From %s : %s %d", |
| 276 |
|
source_p->name, parv[1], port); |
| 277 |
|
|
| 278 |
|
aconf->port = port; |
| 279 |
|
|
| 280 |
< |
/* at this point we should be calling connect_server with a valid |
| 280 |
> |
/* |
| 281 |
> |
* At this point we should be calling connect_server with a valid |
| 282 |
|
* C:line and a valid port in the C:line |
| 283 |
|
*/ |
| 284 |
|
if (serv_connect(aconf, source_p)) |
| 287 |
|
else |
| 288 |
|
sendto_one(source_p, ":%s NOTICE %s :*** Couldn't connect to %s.%d", |
| 289 |
|
me.name, source_p->name, conf->name, aconf->port); |
| 290 |
< |
/* client is either connecting with all the data it needs or has been |
| 290 |
> |
/* |
| 291 |
> |
* Client is either connecting with all the data it needs or has been |
| 292 |
|
* destroyed |
| 293 |
|
*/ |
| 294 |
|
aconf->port = tmpport; |
| 295 |
|
} |
| 296 |
|
|
| 297 |
+ |
static struct Message connect_msgtab = { |
| 298 |
+ |
"CONNECT", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
| 299 |
+ |
{ m_unregistered, m_not_oper, ms_connect, m_ignore, mo_connect, m_ignore } |
| 300 |
+ |
}; |
| 301 |
+ |
|
| 302 |
+ |
static void |
| 303 |
+ |
module_init(void) |
| 304 |
+ |
{ |
| 305 |
+ |
mod_add_cmd(&connect_msgtab); |
| 306 |
+ |
} |
| 307 |
+ |
|
| 308 |
+ |
static void |
| 309 |
+ |
module_exit(void) |
| 310 |
+ |
{ |
| 311 |
+ |
mod_del_cmd(&connect_msgtab); |
| 312 |
+ |
} |
| 313 |
+ |
|
| 314 |
+ |
struct module module_entry = { |
| 315 |
+ |
.node = { NULL, NULL, NULL }, |
| 316 |
+ |
.name = NULL, |
| 317 |
+ |
.version = "$Revision$", |
| 318 |
+ |
.handle = NULL, |
| 319 |
+ |
.modinit = module_init, |
| 320 |
+ |
.modexit = module_exit, |
| 321 |
+ |
.flags = 0 |
| 322 |
+ |
}; |