| 1 |
adx |
30 |
/* |
| 2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
adx |
30 |
* |
| 4 |
michael |
2820 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
| 5 |
adx |
30 |
* |
| 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 |
| 8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
|
|
* (at your option) any later version. |
| 10 |
|
|
* |
| 11 |
|
|
* This program is distributed in the hope that it will be useful, |
| 12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
|
|
* GNU General Public License for more details. |
| 15 |
|
|
* |
| 16 |
|
|
* You should have received a copy of the GNU General Public License |
| 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 |
|
|
|
| 22 |
michael |
2820 |
/*! \file m_server.c |
| 23 |
|
|
* \brief Includes required functions for processing the SERVER/SID command. |
| 24 |
|
|
* \version $Id$ |
| 25 |
|
|
*/ |
| 26 |
|
|
|
| 27 |
adx |
30 |
#include "stdinc.h" |
| 28 |
michael |
1011 |
#include "list.h" |
| 29 |
michael |
2820 |
#include "client.h" |
| 30 |
adx |
30 |
#include "event.h" |
| 31 |
michael |
2820 |
#include "hash.h" |
| 32 |
|
|
#include "irc_string.h" |
| 33 |
|
|
#include "ircd.h" |
| 34 |
|
|
#include "numeric.h" |
| 35 |
|
|
#include "conf.h" |
| 36 |
|
|
#include "log.h" |
| 37 |
michael |
3347 |
#include "misc.h" |
| 38 |
|
|
#include "server.h" |
| 39 |
|
|
#include "user.h" |
| 40 |
michael |
2820 |
#include "send.h" |
| 41 |
adx |
30 |
#include "parse.h" |
| 42 |
michael |
3303 |
#include "memory.h" |
| 43 |
adx |
30 |
#include "modules.h" |
| 44 |
|
|
|
| 45 |
|
|
|
| 46 |
michael |
3303 |
/* |
| 47 |
|
|
* send_tb |
| 48 |
|
|
* |
| 49 |
|
|
* inputs - pointer to Client |
| 50 |
|
|
* - pointer to channel |
| 51 |
|
|
* output - NONE |
| 52 |
|
|
* side effects - Called on a server burst when |
| 53 |
|
|
* server is CAP_TBURST capable |
| 54 |
|
|
*/ |
| 55 |
|
|
static void |
| 56 |
|
|
send_tb(struct Client *client_p, struct Channel *chptr) |
| 57 |
|
|
{ |
| 58 |
|
|
/* |
| 59 |
|
|
* We may also send an empty topic here, but only if topic_time isn't 0, |
| 60 |
|
|
* i.e. if we had a topic that got unset. This is required for syncing |
| 61 |
|
|
* topics properly. |
| 62 |
|
|
* |
| 63 |
|
|
* Imagine the following scenario: Our downlink introduces a channel |
| 64 |
|
|
* to us with a TS that is equal to ours, but the channel topic on |
| 65 |
|
|
* their side got unset while the servers were in splitmode, which means |
| 66 |
|
|
* their 'topic' is newer. They simply wanted to unset it, so we have to |
| 67 |
|
|
* deal with it in a more sophisticated fashion instead of just resetting |
| 68 |
|
|
* it to their old topic they had before. Read m_tburst.c:ms_tburst |
| 69 |
|
|
* for further information -Michael |
| 70 |
|
|
*/ |
| 71 |
|
|
if (chptr->topic_time) |
| 72 |
|
|
sendto_one(client_p, ":%s TBURST %lu %s %lu %s :%s", me.id, |
| 73 |
|
|
(unsigned long)chptr->channelts, chptr->chname, |
| 74 |
|
|
(unsigned long)chptr->topic_time, |
| 75 |
|
|
chptr->topic_info, |
| 76 |
|
|
chptr->topic); |
| 77 |
|
|
} |
| 78 |
|
|
|
| 79 |
|
|
/* sendnick_TS() |
| 80 |
|
|
* |
| 81 |
|
|
* inputs - client (server) to send nick towards |
| 82 |
|
|
* - client to send nick for |
| 83 |
|
|
* output - NONE |
| 84 |
|
|
* side effects - NICK message is sent towards given client_p |
| 85 |
|
|
*/ |
| 86 |
michael |
3306 |
static void |
| 87 |
michael |
3303 |
sendnick_TS(struct Client *client_p, struct Client *target_p) |
| 88 |
|
|
{ |
| 89 |
|
|
char ubuf[IRCD_BUFSIZE] = ""; |
| 90 |
|
|
|
| 91 |
|
|
if (!IsClient(target_p)) |
| 92 |
|
|
return; |
| 93 |
|
|
|
| 94 |
michael |
4020 |
send_umode(NULL, target_p, 0, ubuf); |
| 95 |
michael |
3303 |
|
| 96 |
|
|
if (ubuf[0] == '\0') |
| 97 |
|
|
{ |
| 98 |
|
|
ubuf[0] = '+'; |
| 99 |
|
|
ubuf[1] = '\0'; |
| 100 |
|
|
} |
| 101 |
|
|
|
| 102 |
|
|
if (IsCapable(client_p, CAP_SVS)) |
| 103 |
|
|
sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s %s :%s", |
| 104 |
|
|
target_p->servptr->id, |
| 105 |
|
|
target_p->name, target_p->hopcount + 1, |
| 106 |
|
|
(unsigned long) target_p->tsinfo, |
| 107 |
|
|
ubuf, target_p->username, target_p->host, |
| 108 |
|
|
(MyClient(target_p) && IsIPSpoof(target_p)) ? |
| 109 |
|
|
"0" : target_p->sockhost, target_p->id, |
| 110 |
|
|
target_p->svid, target_p->info); |
| 111 |
|
|
else |
| 112 |
|
|
sendto_one(client_p, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
| 113 |
|
|
target_p->servptr->id, |
| 114 |
|
|
target_p->name, target_p->hopcount + 1, |
| 115 |
|
|
(unsigned long) target_p->tsinfo, |
| 116 |
|
|
ubuf, target_p->username, target_p->host, |
| 117 |
|
|
(MyClient(target_p) && IsIPSpoof(target_p)) ? |
| 118 |
|
|
"0" : target_p->sockhost, target_p->id, target_p->info); |
| 119 |
|
|
|
| 120 |
|
|
if (!EmptyString(target_p->certfp)) |
| 121 |
|
|
sendto_one(client_p, ":%s CERTFP %s", target_p->id, target_p->certfp); |
| 122 |
|
|
|
| 123 |
|
|
if (target_p->away[0]) |
| 124 |
|
|
sendto_one(client_p, ":%s AWAY :%s", target_p->id, target_p->away); |
| 125 |
|
|
|
| 126 |
|
|
} |
| 127 |
|
|
|
| 128 |
|
|
/* burst_members() |
| 129 |
|
|
* |
| 130 |
|
|
* inputs - pointer to server to send members to |
| 131 |
|
|
* - dlink_list pointer to membership list to send |
| 132 |
|
|
* output - NONE |
| 133 |
|
|
* side effects - |
| 134 |
|
|
*/ |
| 135 |
|
|
static void |
| 136 |
|
|
burst_members(struct Client *client_p, struct Channel *chptr) |
| 137 |
|
|
{ |
| 138 |
|
|
struct Client *target_p; |
| 139 |
|
|
struct Membership *ms; |
| 140 |
|
|
dlink_node *ptr; |
| 141 |
|
|
|
| 142 |
|
|
DLINK_FOREACH(ptr, chptr->members.head) |
| 143 |
|
|
{ |
| 144 |
|
|
ms = ptr->data; |
| 145 |
|
|
target_p = ms->client_p; |
| 146 |
|
|
|
| 147 |
|
|
if (!HasFlag(target_p, FLAGS_BURSTED)) |
| 148 |
|
|
{ |
| 149 |
|
|
AddFlag(target_p, FLAGS_BURSTED); |
| 150 |
|
|
|
| 151 |
|
|
if (target_p->from != client_p) |
| 152 |
|
|
sendnick_TS(client_p, target_p); |
| 153 |
|
|
} |
| 154 |
|
|
} |
| 155 |
|
|
} |
| 156 |
|
|
|
| 157 |
|
|
/* burst_all() |
| 158 |
|
|
* |
| 159 |
|
|
* inputs - pointer to server to send burst to |
| 160 |
|
|
* output - NONE |
| 161 |
|
|
* side effects - complete burst of channels/nicks is sent to client_p |
| 162 |
|
|
*/ |
| 163 |
|
|
static void |
| 164 |
|
|
burst_all(struct Client *client_p) |
| 165 |
|
|
{ |
| 166 |
|
|
dlink_node *ptr = NULL; |
| 167 |
|
|
|
| 168 |
michael |
3944 |
DLINK_FOREACH(ptr, channel_list.head) |
| 169 |
michael |
3303 |
{ |
| 170 |
|
|
struct Channel *chptr = ptr->data; |
| 171 |
|
|
|
| 172 |
|
|
if (dlink_list_length(&chptr->members)) |
| 173 |
|
|
{ |
| 174 |
|
|
burst_members(client_p, chptr); |
| 175 |
|
|
send_channel_modes(client_p, chptr); |
| 176 |
|
|
|
| 177 |
|
|
if (IsCapable(client_p, CAP_TBURST)) |
| 178 |
|
|
send_tb(client_p, chptr); |
| 179 |
|
|
} |
| 180 |
|
|
} |
| 181 |
|
|
|
| 182 |
|
|
/* also send out those that are not on any channel |
| 183 |
|
|
*/ |
| 184 |
|
|
DLINK_FOREACH(ptr, global_client_list.head) |
| 185 |
|
|
{ |
| 186 |
|
|
struct Client *target_p = ptr->data; |
| 187 |
|
|
|
| 188 |
|
|
if (!HasFlag(target_p, FLAGS_BURSTED) && target_p->from != client_p) |
| 189 |
|
|
sendnick_TS(client_p, target_p); |
| 190 |
|
|
|
| 191 |
|
|
DelFlag(target_p, FLAGS_BURSTED); |
| 192 |
|
|
} |
| 193 |
|
|
|
| 194 |
|
|
if (IsCapable(client_p, CAP_EOB)) |
| 195 |
|
|
sendto_one(client_p, ":%s EOB", me.id); |
| 196 |
|
|
} |
| 197 |
|
|
|
| 198 |
|
|
/* server_burst() |
| 199 |
|
|
* |
| 200 |
|
|
* inputs - struct Client pointer server |
| 201 |
|
|
* - |
| 202 |
|
|
* output - none |
| 203 |
|
|
* side effects - send a server burst |
| 204 |
|
|
* bugs - still too long |
| 205 |
|
|
*/ |
| 206 |
|
|
static void |
| 207 |
|
|
server_burst(struct Client *client_p) |
| 208 |
|
|
{ |
| 209 |
|
|
/* Send it in the shortened format with the TS, if |
| 210 |
|
|
** it's a TS server; walk the list of channels, sending |
| 211 |
|
|
** all the nicks that haven't been sent yet for each |
| 212 |
|
|
** channel, then send the channel itself -- it's less |
| 213 |
|
|
** obvious than sending all nicks first, but on the |
| 214 |
|
|
** receiving side memory will be allocated more nicely |
| 215 |
|
|
** saving a few seconds in the handling of a split |
| 216 |
|
|
** -orabidoo |
| 217 |
|
|
*/ |
| 218 |
|
|
|
| 219 |
|
|
burst_all(client_p); |
| 220 |
|
|
|
| 221 |
|
|
/* EOB stuff is now in burst_all */ |
| 222 |
|
|
/* Always send a PING after connect burst is done */ |
| 223 |
|
|
sendto_one(client_p, "PING :%s", me.id); |
| 224 |
|
|
} |
| 225 |
|
|
|
| 226 |
|
|
/* server_estab() |
| 227 |
|
|
* |
| 228 |
|
|
* inputs - pointer to a struct Client |
| 229 |
|
|
* output - |
| 230 |
|
|
* side effects - |
| 231 |
|
|
*/ |
| 232 |
michael |
3306 |
static void |
| 233 |
michael |
3303 |
server_estab(struct Client *client_p) |
| 234 |
|
|
{ |
| 235 |
|
|
struct MaskItem *conf = NULL; |
| 236 |
|
|
char *host; |
| 237 |
|
|
const char *inpath; |
| 238 |
|
|
static char inpath_ip[HOSTLEN * 2 + USERLEN + 6]; |
| 239 |
|
|
dlink_node *ptr; |
| 240 |
|
|
#ifdef HAVE_LIBCRYPTO |
| 241 |
|
|
const COMP_METHOD *compression = NULL, *expansion = NULL; |
| 242 |
|
|
#endif |
| 243 |
|
|
|
| 244 |
|
|
assert(client_p); |
| 245 |
|
|
|
| 246 |
|
|
strlcpy(inpath_ip, get_client_name(client_p, SHOW_IP), sizeof(inpath_ip)); |
| 247 |
|
|
|
| 248 |
|
|
inpath = get_client_name(client_p, MASK_IP); /* "refresh" inpath with host */ |
| 249 |
|
|
host = client_p->name; |
| 250 |
|
|
|
| 251 |
|
|
if ((conf = find_conf_name(&client_p->localClient->confs, host, CONF_SERVER)) |
| 252 |
|
|
== NULL) |
| 253 |
|
|
{ |
| 254 |
|
|
/* This shouldn't happen, better tell the ops... -A1kmm */ |
| 255 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 256 |
|
|
"Warning: Lost connect{} block " |
| 257 |
|
|
"for server %s(this shouldn't happen)!", host); |
| 258 |
|
|
exit_client(client_p, "Lost connect{} block!"); |
| 259 |
|
|
return; |
| 260 |
|
|
} |
| 261 |
|
|
|
| 262 |
|
|
MyFree(client_p->localClient->passwd); |
| 263 |
|
|
client_p->localClient->passwd = NULL; |
| 264 |
|
|
|
| 265 |
|
|
/* Its got identd, since its a server */ |
| 266 |
|
|
SetGotId(client_p); |
| 267 |
|
|
|
| 268 |
|
|
/* If there is something in the serv_list, it might be this |
| 269 |
|
|
* connecting server.. |
| 270 |
|
|
*/ |
| 271 |
michael |
4213 |
if (!ServerInfo.hub && local_server_list.head) |
| 272 |
michael |
3303 |
{ |
| 273 |
michael |
4213 |
if (client_p != local_server_list.head->data || local_server_list.head->next) |
| 274 |
michael |
3303 |
{ |
| 275 |
|
|
++ServerStats.is_ref; |
| 276 |
|
|
sendto_one(client_p, "ERROR :I'm a leaf not a hub"); |
| 277 |
|
|
exit_client(client_p, "I'm a leaf"); |
| 278 |
|
|
return; |
| 279 |
|
|
} |
| 280 |
|
|
} |
| 281 |
|
|
|
| 282 |
|
|
if (IsUnknown(client_p)) |
| 283 |
|
|
{ |
| 284 |
|
|
sendto_one(client_p, "PASS %s TS %d %s", conf->spasswd, TS_CURRENT, me.id); |
| 285 |
|
|
|
| 286 |
|
|
send_capabilities(client_p, 0); |
| 287 |
|
|
|
| 288 |
|
|
sendto_one(client_p, "SERVER %s 1 :%s%s", |
| 289 |
|
|
me.name, ConfigServerHide.hidden ? "(H) " : "", me.info); |
| 290 |
|
|
} |
| 291 |
|
|
|
| 292 |
michael |
4009 |
sendto_one(client_p, ":%s SVINFO %d %d 0 :%lu", me.id, TS_CURRENT, TS_MIN, |
| 293 |
michael |
3303 |
(unsigned long)CurrentTime); |
| 294 |
|
|
|
| 295 |
|
|
/* XXX Does this ever happen? I don't think so -db */ |
| 296 |
|
|
detach_conf(client_p, CONF_OPER); |
| 297 |
|
|
|
| 298 |
|
|
/* *WARNING* |
| 299 |
|
|
** In the following code in place of plain server's |
| 300 |
|
|
** name we send what is returned by get_client_name |
| 301 |
|
|
** which may add the "sockhost" after the name. It's |
| 302 |
|
|
** *very* *important* that there is a SPACE between |
| 303 |
|
|
** the name and sockhost (if present). The receiving |
| 304 |
|
|
** server will start the information field from this |
| 305 |
|
|
** first blank and thus puts the sockhost into info. |
| 306 |
|
|
** ...a bit tricky, but you have been warned, besides |
| 307 |
|
|
** code is more neat this way... --msa |
| 308 |
|
|
*/ |
| 309 |
|
|
client_p->servptr = &me; |
| 310 |
|
|
|
| 311 |
|
|
if (IsClosing(client_p)) |
| 312 |
|
|
return; |
| 313 |
|
|
|
| 314 |
|
|
SetServer(client_p); |
| 315 |
|
|
|
| 316 |
|
|
/* Some day, all these lists will be consolidated *sigh* */ |
| 317 |
|
|
dlinkAdd(client_p, &client_p->lnode, &me.serv->server_list); |
| 318 |
|
|
|
| 319 |
|
|
assert(dlinkFind(&unknown_list, client_p)); |
| 320 |
|
|
|
| 321 |
|
|
dlink_move_node(&client_p->localClient->lclient_node, |
| 322 |
michael |
4213 |
&unknown_list, &local_server_list); |
| 323 |
michael |
3303 |
|
| 324 |
|
|
Count.myserver++; |
| 325 |
|
|
|
| 326 |
michael |
4189 |
dlinkAdd(client_p, &client_p->node, &global_client_list); |
| 327 |
michael |
4209 |
dlinkAdd(client_p, make_dlink_node(), &global_server_list); |
| 328 |
michael |
3303 |
hash_add_client(client_p); |
| 329 |
|
|
hash_add_id(client_p); |
| 330 |
|
|
|
| 331 |
|
|
/* doesnt duplicate client_p->serv if allocated this struct already */ |
| 332 |
|
|
make_server(client_p); |
| 333 |
|
|
|
| 334 |
|
|
/* fixing eob timings.. -gnp */ |
| 335 |
|
|
client_p->localClient->firsttime = CurrentTime; |
| 336 |
|
|
|
| 337 |
|
|
if (find_matching_name_conf(CONF_SERVICE, client_p->name, NULL, NULL, 0)) |
| 338 |
|
|
AddFlag(client_p, FLAGS_SERVICE); |
| 339 |
|
|
|
| 340 |
|
|
/* Show the real host/IP to admins */ |
| 341 |
|
|
#ifdef HAVE_LIBCRYPTO |
| 342 |
|
|
if (client_p->localClient->fd.ssl) |
| 343 |
|
|
{ |
| 344 |
|
|
compression = SSL_get_current_compression(client_p->localClient->fd.ssl); |
| 345 |
|
|
expansion = SSL_get_current_expansion(client_p->localClient->fd.ssl); |
| 346 |
|
|
|
| 347 |
|
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 348 |
|
|
"Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)", |
| 349 |
|
|
inpath_ip, ssl_get_cipher(client_p->localClient->fd.ssl), |
| 350 |
|
|
compression ? SSL_COMP_get_name(compression) : "NONE", |
| 351 |
|
|
expansion ? SSL_COMP_get_name(expansion) : "NONE", |
| 352 |
|
|
show_capabilities(client_p)); |
| 353 |
|
|
/* Now show the masked hostname/IP to opers */ |
| 354 |
|
|
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 355 |
|
|
"Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)", |
| 356 |
|
|
inpath, ssl_get_cipher(client_p->localClient->fd.ssl), |
| 357 |
|
|
compression ? SSL_COMP_get_name(compression) : "NONE", |
| 358 |
|
|
expansion ? SSL_COMP_get_name(expansion) : "NONE", |
| 359 |
|
|
show_capabilities(client_p)); |
| 360 |
|
|
ilog(LOG_TYPE_IRCD, "Link with %s established: [SSL: %s, Compression/Expansion method: %s/%s] (Capabilities: %s)", |
| 361 |
|
|
inpath_ip, ssl_get_cipher(client_p->localClient->fd.ssl), |
| 362 |
|
|
compression ? SSL_COMP_get_name(compression) : "NONE", |
| 363 |
|
|
expansion ? SSL_COMP_get_name(expansion) : "NONE", |
| 364 |
|
|
show_capabilities(client_p)); |
| 365 |
|
|
} |
| 366 |
|
|
else |
| 367 |
|
|
#endif |
| 368 |
|
|
{ |
| 369 |
|
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 370 |
|
|
"Link with %s established: (Capabilities: %s)", |
| 371 |
|
|
inpath_ip, show_capabilities(client_p)); |
| 372 |
|
|
/* Now show the masked hostname/IP to opers */ |
| 373 |
|
|
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 374 |
|
|
"Link with %s established: (Capabilities: %s)", |
| 375 |
|
|
inpath, show_capabilities(client_p)); |
| 376 |
|
|
ilog(LOG_TYPE_IRCD, "Link with %s established: (Capabilities: %s)", |
| 377 |
|
|
inpath_ip, show_capabilities(client_p)); |
| 378 |
|
|
} |
| 379 |
|
|
|
| 380 |
|
|
fd_note(&client_p->localClient->fd, "Server: %s", client_p->name); |
| 381 |
|
|
|
| 382 |
|
|
sendto_server(client_p, NOCAPS, NOCAPS, ":%s SID %s 2 %s :%s%s", |
| 383 |
|
|
me.id, client_p->name, client_p->id, |
| 384 |
|
|
IsHidden(client_p) ? "(H) " : "", client_p->info); |
| 385 |
|
|
|
| 386 |
|
|
/* |
| 387 |
|
|
* Pass on my client information to the new server |
| 388 |
|
|
* |
| 389 |
|
|
* First, pass only servers (idea is that if the link gets |
| 390 |
|
|
* cancelled beacause the server was already there, |
| 391 |
|
|
* there are no NICK's to be cancelled...). Of course, |
| 392 |
|
|
* if cancellation occurs, all this info is sent anyway, |
| 393 |
|
|
* and I guess the link dies when a read is attempted...? --msa |
| 394 |
|
|
* |
| 395 |
|
|
* Note: Link cancellation to occur at this point means |
| 396 |
|
|
* that at least two servers from my fragment are building |
| 397 |
|
|
* up connection this other fragment at the same time, it's |
| 398 |
|
|
* a race condition, not the normal way of operation... |
| 399 |
|
|
* |
| 400 |
|
|
* ALSO NOTE: using the get_client_name for server names-- |
| 401 |
|
|
* see previous *WARNING*!!! (Also, original inpath |
| 402 |
|
|
* is destroyed...) |
| 403 |
|
|
*/ |
| 404 |
michael |
4209 |
DLINK_FOREACH_PREV(ptr, global_server_list.tail) |
| 405 |
michael |
3303 |
{ |
| 406 |
|
|
struct Client *target_p = ptr->data; |
| 407 |
|
|
|
| 408 |
|
|
/* target_p->from == target_p for target_p == client_p */ |
| 409 |
|
|
if (IsMe(target_p) || target_p->from == client_p) |
| 410 |
|
|
continue; |
| 411 |
|
|
|
| 412 |
|
|
sendto_one(client_p, ":%s SID %s %d %s :%s%s", |
| 413 |
|
|
target_p->servptr->id, target_p->name, target_p->hopcount+1, |
| 414 |
|
|
target_p->id, IsHidden(target_p) ? "(H) " : "", |
| 415 |
|
|
target_p->info); |
| 416 |
|
|
} |
| 417 |
|
|
|
| 418 |
|
|
server_burst(client_p); |
| 419 |
|
|
} |
| 420 |
|
|
|
| 421 |
michael |
1997 |
/* set_server_gecos() |
| 422 |
|
|
* |
| 423 |
|
|
* input - pointer to client |
| 424 |
|
|
* output - NONE |
| 425 |
|
|
* side effects - servers gecos field is set |
| 426 |
|
|
*/ |
| 427 |
|
|
static void |
| 428 |
|
|
set_server_gecos(struct Client *client_p, const char *info) |
| 429 |
|
|
{ |
| 430 |
|
|
const char *s = info; |
| 431 |
adx |
30 |
|
| 432 |
michael |
1997 |
/* check for (H) which is a hidden server */ |
| 433 |
|
|
if (!strncmp(s, "(H) ", 4)) |
| 434 |
|
|
{ |
| 435 |
|
|
SetHidden(client_p); |
| 436 |
|
|
s = s + 4; |
| 437 |
|
|
} |
| 438 |
|
|
|
| 439 |
|
|
if (!EmptyString(s)) |
| 440 |
|
|
strlcpy(client_p->info, s, sizeof(client_p->info)); |
| 441 |
|
|
else |
| 442 |
|
|
strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info)); |
| 443 |
|
|
} |
| 444 |
|
|
|
| 445 |
adx |
30 |
/* mr_server() |
| 446 |
michael |
3096 |
* parv[0] = command |
| 447 |
adx |
30 |
* parv[1] = servername |
| 448 |
michael |
3139 |
* parv[2] = hopcount |
| 449 |
adx |
30 |
* parv[3] = serverinfo |
| 450 |
|
|
*/ |
| 451 |
michael |
2820 |
static int |
| 452 |
michael |
3156 |
mr_server(struct Client *source_p, int parc, char *parv[]) |
| 453 |
adx |
30 |
{ |
| 454 |
michael |
3246 |
char *name = NULL; |
| 455 |
|
|
struct Client *target_p = NULL; |
| 456 |
adx |
30 |
|
| 457 |
michael |
1178 |
if (EmptyString(parv[3])) |
| 458 |
adx |
30 |
{ |
| 459 |
michael |
3156 |
sendto_one(source_p, "ERROR :No servername"); |
| 460 |
michael |
3171 |
exit_client(source_p, "Wrong number of args"); |
| 461 |
michael |
2820 |
return 0; |
| 462 |
adx |
30 |
} |
| 463 |
|
|
|
| 464 |
|
|
name = parv[1]; |
| 465 |
|
|
|
| 466 |
michael |
1118 |
/* |
| 467 |
|
|
* Reject a direct nonTS server connection if we're TS_ONLY -orabidoo |
| 468 |
adx |
30 |
*/ |
| 469 |
michael |
3156 |
if (!DoesTS(source_p)) |
| 470 |
adx |
30 |
{ |
| 471 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 472 |
michael |
1118 |
"Unauthorized server connection attempt from %s: Non-TS server " |
| 473 |
michael |
3156 |
"for server %s", get_client_name(source_p, HIDE_IP), name); |
| 474 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 475 |
michael |
1118 |
"Unauthorized server connection attempt from %s: Non-TS server " |
| 476 |
michael |
3156 |
"for server %s", get_client_name(source_p, MASK_IP), name); |
| 477 |
michael |
3171 |
exit_client(source_p, "Non-TS server"); |
| 478 |
michael |
2820 |
return 0; |
| 479 |
adx |
30 |
} |
| 480 |
|
|
|
| 481 |
michael |
1118 |
if (!valid_servname(name)) |
| 482 |
adx |
30 |
{ |
| 483 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 484 |
michael |
1118 |
"Unauthorized server connection attempt from %s: Bogus server name " |
| 485 |
michael |
3156 |
"for server %s", get_client_name(source_p, HIDE_IP), name); |
| 486 |
michael |
1624 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 487 |
michael |
1118 |
"Unauthorized server connection attempt from %s: Bogus server name " |
| 488 |
michael |
3156 |
"for server %s", get_client_name(source_p, MASK_IP), name); |
| 489 |
michael |
3171 |
exit_client(source_p, "Bogus server name"); |
| 490 |
michael |
2820 |
return 0; |
| 491 |
adx |
30 |
} |
| 492 |
|
|
|
| 493 |
michael |
3156 |
if (!valid_sid(source_p->id)) |
| 494 |
michael |
3148 |
{ |
| 495 |
|
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 496 |
|
|
"Link %s introduced server with bogus server ID %s", |
| 497 |
michael |
3156 |
get_client_name(source_p, SHOW_IP), source_p->id); |
| 498 |
michael |
3148 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 499 |
|
|
"Link %s introduced server with bogus server ID %s", |
| 500 |
michael |
3156 |
get_client_name(source_p, MASK_IP), source_p->id); |
| 501 |
|
|
sendto_one(source_p, "ERROR :Bogus server ID introduced"); |
| 502 |
michael |
3171 |
exit_client(source_p, "Bogus server ID intoduced"); |
| 503 |
michael |
3148 |
return 0; |
| 504 |
|
|
} |
| 505 |
|
|
|
| 506 |
adx |
30 |
/* Now we just have to call check_server and everything should |
| 507 |
|
|
* be check for us... -A1kmm. |
| 508 |
|
|
*/ |
| 509 |
michael |
3156 |
switch (check_server(name, source_p)) |
| 510 |
adx |
30 |
{ |
| 511 |
|
|
case -1: |
| 512 |
michael |
3473 |
if (ConfigFileEntry.warn_no_connect_block) |
| 513 |
adx |
30 |
{ |
| 514 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 515 |
adx |
30 |
"Unauthorized server connection attempt from %s: No entry for " |
| 516 |
michael |
3156 |
"servername %s", get_client_name(source_p, HIDE_IP), name); |
| 517 |
adx |
30 |
|
| 518 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 519 |
adx |
30 |
"Unauthorized server connection attempt from %s: No entry for " |
| 520 |
michael |
3156 |
"servername %s", get_client_name(source_p, MASK_IP), name); |
| 521 |
adx |
30 |
} |
| 522 |
|
|
|
| 523 |
michael |
3171 |
exit_client(source_p, "No connect{} block."); |
| 524 |
michael |
2820 |
return 0; |
| 525 |
adx |
30 |
/* NOT REACHED */ |
| 526 |
|
|
break; |
| 527 |
|
|
|
| 528 |
|
|
case -2: |
| 529 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 530 |
adx |
30 |
"Unauthorized server connection attempt from %s: Bad password " |
| 531 |
michael |
3156 |
"for server %s", get_client_name(source_p, HIDE_IP), name); |
| 532 |
adx |
30 |
|
| 533 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 534 |
adx |
30 |
"Unauthorized server connection attempt from %s: Bad password " |
| 535 |
michael |
3156 |
"for server %s", get_client_name(source_p, MASK_IP), name); |
| 536 |
adx |
30 |
|
| 537 |
michael |
3171 |
exit_client(source_p, "Invalid password."); |
| 538 |
michael |
2820 |
return 0; |
| 539 |
adx |
30 |
/* NOT REACHED */ |
| 540 |
|
|
break; |
| 541 |
|
|
|
| 542 |
|
|
case -3: |
| 543 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 544 |
adx |
30 |
"Unauthorized server connection attempt from %s: Invalid host " |
| 545 |
michael |
3156 |
"for server %s", get_client_name(source_p, HIDE_IP), name); |
| 546 |
adx |
30 |
|
| 547 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 548 |
adx |
30 |
"Unauthorized server connection attempt from %s: Invalid host " |
| 549 |
michael |
3156 |
"for server %s", get_client_name(source_p, MASK_IP), name); |
| 550 |
adx |
30 |
|
| 551 |
michael |
3171 |
exit_client(source_p, "Invalid host."); |
| 552 |
michael |
2820 |
return 0; |
| 553 |
michael |
2228 |
case -4: |
| 554 |
|
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 555 |
|
|
"Unauthorized server connection attempt from %s: Invalid certificate fingerprint " |
| 556 |
michael |
3156 |
"for server %s", get_client_name(source_p, HIDE_IP), name); |
| 557 |
michael |
2228 |
|
| 558 |
|
|
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 559 |
|
|
"Unauthorized server connection attempt from %s: Invalid certificate fingerprint " |
| 560 |
michael |
3156 |
"for server %s", get_client_name(source_p, MASK_IP), name); |
| 561 |
michael |
2228 |
|
| 562 |
michael |
3171 |
exit_client(source_p, "Invalid certificate fingerprint."); |
| 563 |
michael |
2820 |
return 0; |
| 564 |
adx |
30 |
/* NOT REACHED */ |
| 565 |
|
|
break; |
| 566 |
|
|
} |
| 567 |
|
|
|
| 568 |
michael |
2976 |
if ((target_p = hash_find_server(name))) |
| 569 |
adx |
30 |
{ |
| 570 |
|
|
/* This link is trying feed me a server that I already have |
| 571 |
|
|
* access through another path -- multiple paths not accepted |
| 572 |
|
|
* currently, kill this link immediately!! |
| 573 |
|
|
* |
| 574 |
|
|
* Rather than KILL the link which introduced it, KILL the |
| 575 |
|
|
* youngest of the two links. -avalon |
| 576 |
|
|
* |
| 577 |
|
|
* Definitely don't do that here. This is from an unregistered |
| 578 |
|
|
* connect - A1kmm. |
| 579 |
|
|
*/ |
| 580 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 581 |
michael |
2976 |
"Attempt to re-introduce server %s from %s", |
| 582 |
michael |
3156 |
name, get_client_name(source_p, HIDE_IP)); |
| 583 |
michael |
2976 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 584 |
|
|
"Attempt to re-introduce server %s from %s", |
| 585 |
michael |
3156 |
name, get_client_name(source_p, MASK_IP)); |
| 586 |
|
|
sendto_one(source_p, "ERROR :Server already exists."); |
| 587 |
michael |
3171 |
exit_client(source_p, "Server already exists"); |
| 588 |
michael |
2976 |
return 0; |
| 589 |
|
|
} |
| 590 |
|
|
|
| 591 |
michael |
3156 |
if ((target_p = hash_find_id(source_p->id))) |
| 592 |
michael |
2976 |
{ |
| 593 |
|
|
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 594 |
michael |
2820 |
"Attempt to re-introduce server %s SID %s from %s", |
| 595 |
michael |
3156 |
name, source_p->id, |
| 596 |
|
|
get_client_name(source_p, HIDE_IP)); |
| 597 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 598 |
michael |
2820 |
"Attempt to re-introduce server %s SID %s from %s", |
| 599 |
michael |
3156 |
name, source_p->id, |
| 600 |
|
|
get_client_name(source_p, MASK_IP)); |
| 601 |
|
|
sendto_one(source_p, "ERROR :Server ID already exists."); |
| 602 |
michael |
3171 |
exit_client(source_p, "Server ID already exists"); |
| 603 |
michael |
2820 |
return 0; |
| 604 |
adx |
30 |
} |
| 605 |
|
|
|
| 606 |
|
|
/* XXX If somehow there is a connect in progress and |
| 607 |
|
|
* a connect comes in with same name toss the pending one, |
| 608 |
|
|
* but only if it's not the same client! - Dianora |
| 609 |
|
|
*/ |
| 610 |
|
|
if ((target_p = find_servconn_in_progress(name))) |
| 611 |
michael |
3156 |
if (target_p != source_p) |
| 612 |
michael |
3171 |
exit_client(target_p, "Overridden"); |
| 613 |
adx |
30 |
|
| 614 |
|
|
/* if we are connecting (Handshake), we already have the name from the |
| 615 |
michael |
3156 |
* connect{} block in source_p->name |
| 616 |
adx |
30 |
*/ |
| 617 |
michael |
3156 |
strlcpy(source_p->name, name, sizeof(source_p->name)); |
| 618 |
|
|
set_server_gecos(source_p, parv[3]); |
| 619 |
michael |
3190 |
source_p->hopcount = atoi(parv[2]); |
| 620 |
michael |
3156 |
server_estab(source_p); |
| 621 |
michael |
2820 |
return 0; |
| 622 |
adx |
30 |
} |
| 623 |
|
|
|
| 624 |
|
|
/* ms_sid() |
| 625 |
michael |
3096 |
* parv[0] = command |
| 626 |
adx |
30 |
* parv[1] = servername |
| 627 |
michael |
3139 |
* parv[2] = hopcount |
| 628 |
adx |
30 |
* parv[3] = sid of new server |
| 629 |
|
|
* parv[4] = serverinfo |
| 630 |
|
|
*/ |
| 631 |
michael |
2820 |
static int |
| 632 |
michael |
3156 |
ms_sid(struct Client *source_p, int parc, char *parv[]) |
| 633 |
adx |
30 |
{ |
| 634 |
michael |
3139 |
dlink_node *ptr = NULL; |
| 635 |
|
|
struct Client *target_p = NULL; |
| 636 |
michael |
3156 |
struct Client *client_p = source_p->from; /* XXX */ |
| 637 |
michael |
3139 |
const struct MaskItem *conf = NULL; |
| 638 |
adx |
30 |
int hlined = 0; |
| 639 |
|
|
int llined = 0; |
| 640 |
|
|
|
| 641 |
|
|
/* Just to be sure -A1kmm. */ |
| 642 |
|
|
if (!IsServer(source_p)) |
| 643 |
michael |
2820 |
return 0; |
| 644 |
adx |
30 |
|
| 645 |
michael |
1178 |
if (EmptyString(parv[4])) |
| 646 |
michael |
1118 |
{ |
| 647 |
|
|
sendto_one(client_p, "ERROR :No servername"); |
| 648 |
michael |
2820 |
return 0; |
| 649 |
michael |
1118 |
} |
| 650 |
adx |
30 |
|
| 651 |
michael |
1118 |
if (!valid_servname(parv[1])) |
| 652 |
|
|
{ |
| 653 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 654 |
michael |
1118 |
"Link %s introduced server with bogus server name %s", |
| 655 |
|
|
get_client_name(client_p, SHOW_IP), parv[1]); |
| 656 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 657 |
michael |
1118 |
"Link %s introduced server with bogus server name %s", |
| 658 |
|
|
get_client_name(client_p, MASK_IP), parv[1]); |
| 659 |
|
|
sendto_one(client_p, "ERROR :Bogus server name introduced"); |
| 660 |
michael |
3171 |
exit_client(client_p, "Bogus server name intoduced"); |
| 661 |
michael |
2820 |
return 0; |
| 662 |
michael |
1118 |
} |
| 663 |
|
|
|
| 664 |
|
|
if (!valid_sid(parv[3])) |
| 665 |
|
|
{ |
| 666 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 667 |
michael |
1118 |
"Link %s introduced server with bogus server ID %s", |
| 668 |
|
|
get_client_name(client_p, SHOW_IP), parv[3]); |
| 669 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 670 |
michael |
1118 |
"Link %s introduced server with bogus server ID %s", |
| 671 |
|
|
get_client_name(client_p, MASK_IP), parv[3]); |
| 672 |
|
|
sendto_one(client_p, "ERROR :Bogus server ID introduced"); |
| 673 |
michael |
3171 |
exit_client(client_p, "Bogus server ID intoduced"); |
| 674 |
michael |
2820 |
return 0; |
| 675 |
michael |
1118 |
} |
| 676 |
|
|
|
| 677 |
adx |
30 |
/* collision on SID? */ |
| 678 |
michael |
1118 |
if ((target_p = hash_find_id(parv[3]))) |
| 679 |
adx |
30 |
{ |
| 680 |
michael |
1118 |
sendto_one(client_p, "ERROR :SID %s already exists", parv[3]); |
| 681 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 682 |
michael |
2820 |
"Link %s cancelled, SID %s already exists", |
| 683 |
michael |
1118 |
get_client_name(client_p, SHOW_IP), parv[3]); |
| 684 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 685 |
michael |
2820 |
"Link %s cancelled, SID %s already exists", |
| 686 |
michael |
1118 |
client_p->name, parv[3]); |
| 687 |
michael |
3171 |
exit_client(client_p, "SID Exists"); |
| 688 |
michael |
2820 |
return 0; |
| 689 |
adx |
30 |
} |
| 690 |
|
|
|
| 691 |
|
|
/* collision on name? */ |
| 692 |
michael |
1169 |
if ((target_p = hash_find_server(parv[1]))) |
| 693 |
adx |
30 |
{ |
| 694 |
michael |
1118 |
sendto_one(client_p, "ERROR :Server %s already exists", parv[1]); |
| 695 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 696 |
michael |
2820 |
"Link %s cancelled, server %s already exists", |
| 697 |
michael |
1118 |
get_client_name(client_p, SHOW_IP), parv[1]); |
| 698 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 699 |
michael |
2820 |
"Link %s cancelled, server %s already exists", |
| 700 |
michael |
1118 |
client_p->name, parv[1]); |
| 701 |
michael |
3171 |
exit_client(client_p, "Server Exists"); |
| 702 |
michael |
2820 |
return 0; |
| 703 |
adx |
30 |
} |
| 704 |
|
|
|
| 705 |
|
|
/* XXX If somehow there is a connect in progress and |
| 706 |
|
|
* a connect comes in with same name toss the pending one, |
| 707 |
|
|
* but only if it's not the same client! - Dianora |
| 708 |
|
|
*/ |
| 709 |
michael |
1118 |
if ((target_p = find_servconn_in_progress(parv[1]))) |
| 710 |
adx |
30 |
if (target_p != client_p) |
| 711 |
michael |
3171 |
exit_client(target_p, "Overridden"); |
| 712 |
adx |
30 |
|
| 713 |
michael |
1632 |
conf = client_p->localClient->confs.head->data; |
| 714 |
michael |
1384 |
|
| 715 |
adx |
30 |
/* See if the newly found server is behind a guaranteed |
| 716 |
|
|
* leaf. If so, close the link. |
| 717 |
|
|
*/ |
| 718 |
michael |
1632 |
DLINK_FOREACH(ptr, conf->leaf_list.head) |
| 719 |
michael |
3139 |
{ |
| 720 |
michael |
1652 |
if (!match(ptr->data, parv[1])) |
| 721 |
michael |
1529 |
{ |
| 722 |
|
|
llined = 1; |
| 723 |
|
|
break; |
| 724 |
|
|
} |
| 725 |
michael |
3139 |
} |
| 726 |
adx |
30 |
|
| 727 |
michael |
1632 |
DLINK_FOREACH(ptr, conf->hub_list.head) |
| 728 |
michael |
3139 |
{ |
| 729 |
michael |
1652 |
if (!match(ptr->data, parv[1])) |
| 730 |
michael |
1529 |
{ |
| 731 |
|
|
hlined = 1; |
| 732 |
|
|
break; |
| 733 |
|
|
} |
| 734 |
michael |
3139 |
} |
| 735 |
michael |
1118 |
|
| 736 |
adx |
30 |
/* Ok, this way this works is |
| 737 |
|
|
* |
| 738 |
|
|
* A server can have a CONF_HUB allowing it to introduce servers |
| 739 |
|
|
* behind it. |
| 740 |
|
|
* |
| 741 |
|
|
* connect { |
| 742 |
|
|
* name = "irc.bighub.net"; |
| 743 |
|
|
* hub_mask="*"; |
| 744 |
|
|
* ... |
| 745 |
michael |
2820 |
* |
| 746 |
adx |
30 |
* That would allow "irc.bighub.net" to introduce anything it wanted.. |
| 747 |
|
|
* |
| 748 |
|
|
* However |
| 749 |
|
|
* |
| 750 |
|
|
* connect { |
| 751 |
|
|
* name = "irc.somehub.fi"; |
| 752 |
|
|
* hub_mask="*"; |
| 753 |
|
|
* leaf_mask="*.edu"; |
| 754 |
|
|
*... |
| 755 |
|
|
* Would allow this server in finland to hub anything but |
| 756 |
|
|
* .edu's |
| 757 |
|
|
*/ |
| 758 |
|
|
|
| 759 |
|
|
/* Ok, check client_p can hub the new server, and make sure it's not a LL */ |
| 760 |
michael |
885 |
if (!hlined) |
| 761 |
adx |
30 |
{ |
| 762 |
|
|
/* OOOPs nope can't HUB */ |
| 763 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 764 |
|
|
"Non-Hub link %s introduced %s.", |
| 765 |
michael |
1118 |
get_client_name(client_p, SHOW_IP), parv[1]); |
| 766 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 767 |
|
|
"Non-Hub link %s introduced %s.", |
| 768 |
michael |
1118 |
get_client_name(client_p, MASK_IP), parv[1]); |
| 769 |
michael |
3171 |
exit_client(source_p, "No matching hub_mask."); |
| 770 |
michael |
2820 |
return 0; |
| 771 |
adx |
30 |
} |
| 772 |
|
|
|
| 773 |
|
|
/* Check for the new server being leafed behind this HUB */ |
| 774 |
|
|
if (llined) |
| 775 |
|
|
{ |
| 776 |
|
|
/* OOOPs nope can't HUB this leaf */ |
| 777 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 778 |
michael |
2820 |
"Link %s introduced leafed server %s.", |
| 779 |
michael |
1118 |
get_client_name(client_p, SHOW_IP), parv[1]); |
| 780 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 781 |
michael |
2820 |
"Link %s introduced leafed server %s.", |
| 782 |
michael |
1118 |
get_client_name(client_p, MASK_IP), parv[1]); |
| 783 |
michael |
3171 |
exit_client(client_p, "Leafed Server."); |
| 784 |
michael |
2820 |
return 0; |
| 785 |
adx |
30 |
} |
| 786 |
|
|
|
| 787 |
|
|
target_p = make_client(client_p); |
| 788 |
|
|
make_server(target_p); |
| 789 |
michael |
3190 |
target_p->hopcount = atoi(parv[2]); |
| 790 |
michael |
1118 |
target_p->servptr = source_p; |
| 791 |
adx |
30 |
|
| 792 |
michael |
1118 |
strlcpy(target_p->name, parv[1], sizeof(target_p->name)); |
| 793 |
|
|
strlcpy(target_p->id, parv[3], sizeof(target_p->id)); |
| 794 |
adx |
30 |
|
| 795 |
michael |
1533 |
set_server_gecos(target_p, parv[4]); |
| 796 |
adx |
30 |
SetServer(target_p); |
| 797 |
|
|
|
| 798 |
michael |
1632 |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_SERVICE, target_p->name, NULL, NULL, 0)) |
| 799 |
michael |
1219 |
AddFlag(target_p, FLAGS_SERVICE); |
| 800 |
michael |
1157 |
|
| 801 |
michael |
1118 |
dlinkAdd(target_p, &target_p->node, &global_client_list); |
| 802 |
michael |
4209 |
dlinkAdd(target_p, make_dlink_node(), &global_server_list); |
| 803 |
michael |
1118 |
dlinkAdd(target_p, &target_p->lnode, &target_p->servptr->serv->server_list); |
| 804 |
adx |
30 |
|
| 805 |
|
|
hash_add_client(target_p); |
| 806 |
|
|
hash_add_id(target_p); |
| 807 |
|
|
|
| 808 |
michael |
3135 |
sendto_server(client_p, NOCAPS, NOCAPS, ":%s SID %s %d %s :%s%s", |
| 809 |
michael |
3192 |
source_p->id, target_p->name, target_p->hopcount + 1, |
| 810 |
michael |
1527 |
target_p->id, IsHidden(target_p) ? "(H) " : "", target_p->info); |
| 811 |
michael |
1618 |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE, |
| 812 |
michael |
1118 |
"Server %s being introduced by %s", |
| 813 |
adx |
30 |
target_p->name, source_p->name); |
| 814 |
michael |
2820 |
return 0; |
| 815 |
adx |
30 |
} |
| 816 |
|
|
|
| 817 |
michael |
2820 |
static struct Message server_msgtab = |
| 818 |
|
|
{ |
| 819 |
michael |
1569 |
"SERVER", 0, 0, 4, MAXPARA, MFLG_SLOW, 0, |
| 820 |
michael |
3135 |
{ mr_server, m_registered, m_ignore, m_ignore, m_registered, m_ignore } |
| 821 |
michael |
1230 |
}; |
| 822 |
|
|
|
| 823 |
michael |
2820 |
static struct Message sid_msgtab = |
| 824 |
|
|
{ |
| 825 |
michael |
1230 |
"SID", 0, 0, 5, MAXPARA, MFLG_SLOW, 0, |
| 826 |
michael |
2820 |
{ m_ignore, m_ignore, ms_sid, m_ignore, m_ignore, m_ignore } |
| 827 |
michael |
1230 |
}; |
| 828 |
|
|
|
| 829 |
|
|
static void |
| 830 |
|
|
module_init(void) |
| 831 |
|
|
{ |
| 832 |
|
|
mod_add_cmd(&sid_msgtab); |
| 833 |
|
|
mod_add_cmd(&server_msgtab); |
| 834 |
|
|
} |
| 835 |
|
|
|
| 836 |
|
|
static void |
| 837 |
|
|
module_exit(void) |
| 838 |
|
|
{ |
| 839 |
|
|
mod_del_cmd(&sid_msgtab); |
| 840 |
|
|
mod_del_cmd(&server_msgtab); |
| 841 |
|
|
} |
| 842 |
|
|
|
| 843 |
michael |
2820 |
struct module module_entry = |
| 844 |
|
|
{ |
| 845 |
michael |
1230 |
.node = { NULL, NULL, NULL }, |
| 846 |
|
|
.name = NULL, |
| 847 |
|
|
.version = "$Revision$", |
| 848 |
|
|
.handle = NULL, |
| 849 |
|
|
.modinit = module_init, |
| 850 |
|
|
.modexit = module_exit, |
| 851 |
|
|
.flags = MODULE_FLAG_CORE |
| 852 |
|
|
}; |