1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* s_user.c: User related functions. |
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-2016 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 |
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 |
18 |
> |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
|
* USA |
20 |
< |
* |
21 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file user.c |
23 |
> |
* \brief User related functions. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
28 |
< |
#include "tools.h" |
29 |
< |
#include "s_user.h" |
28 |
< |
#include "s_misc.h" |
28 |
> |
#include "list.h" |
29 |
> |
#include "user.h" |
30 |
|
#include "channel.h" |
31 |
|
#include "channel_mode.h" |
32 |
|
#include "client.h" |
32 |
– |
#include "common.h" |
33 |
– |
#include "fdlist.h" |
33 |
|
#include "hash.h" |
34 |
+ |
#include "id.h" |
35 |
|
#include "irc_string.h" |
36 |
– |
#include "sprintf_irc.h" |
37 |
– |
#include "s_bsd.h" |
38 |
– |
#include "irc_getnameinfo.h" |
36 |
|
#include "ircd.h" |
40 |
– |
#include "list.h" |
37 |
|
#include "listener.h" |
38 |
|
#include "motd.h" |
39 |
|
#include "numeric.h" |
40 |
< |
#include "s_conf.h" |
41 |
< |
#include "s_log.h" |
42 |
< |
#include "s_serv.h" |
43 |
< |
#include "s_stats.h" |
40 |
> |
#include "conf.h" |
41 |
> |
#include "conf_gecos.h" |
42 |
> |
#include "log.h" |
43 |
> |
#include "server.h" |
44 |
|
#include "send.h" |
49 |
– |
#include "supported.h" |
50 |
– |
#include "whowas.h" |
45 |
|
#include "memory.h" |
46 |
|
#include "packet.h" |
47 |
+ |
#include "rng_mt.h" |
48 |
|
#include "userhost.h" |
49 |
< |
#include "hook.h" |
50 |
< |
#include "s_misc.h" |
51 |
< |
#include "msg.h" |
52 |
< |
#include "pcre.h" |
53 |
< |
|
59 |
< |
int MaxClientCount = 1; |
60 |
< |
int MaxConnectionCount = 1; |
61 |
< |
struct Callback *entering_umode_cb = NULL; |
62 |
< |
struct Callback *umode_cb = NULL; |
63 |
< |
struct Callback *uid_get_cb = NULL; |
49 |
> |
#include "misc.h" |
50 |
> |
#include "parse.h" |
51 |
> |
#include "watch.h" |
52 |
> |
#include "isupport.h" |
53 |
> |
#include "tls.h" |
54 |
|
|
55 |
|
static char umode_buffer[IRCD_BUFSIZE]; |
56 |
|
|
57 |
< |
static void user_welcome(struct Client *); |
58 |
< |
static void report_and_set_user_flags(struct Client *, const struct AccessItem *); |
69 |
< |
static int check_xline(struct Client *); |
70 |
< |
static void introduce_client(struct Client *, struct Client *); |
71 |
< |
static void *uid_get(va_list); |
72 |
< |
|
73 |
< |
/* Used for building up the isupport string, |
74 |
< |
* used with init_isupport, add_isupport, delete_isupport |
75 |
< |
*/ |
76 |
< |
|
77 |
< |
struct Isupport |
57 |
> |
const struct user_modes *umode_map[256]; |
58 |
> |
const struct user_modes umode_tab[] = |
59 |
|
{ |
60 |
< |
dlink_node node; |
61 |
< |
char *name; |
62 |
< |
char *options; |
63 |
< |
int number; |
64 |
< |
}; |
65 |
< |
|
66 |
< |
static dlink_list support_list = { NULL, NULL, 0 }; |
67 |
< |
MessageFile *isupportFile; |
68 |
< |
|
69 |
< |
/* memory is cheap. map 0-255 to equivalent mode */ |
70 |
< |
unsigned int user_modes[256] = |
71 |
< |
{ |
72 |
< |
/* 0x00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x0F */ |
73 |
< |
/* 0x10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x1F */ |
74 |
< |
/* 0x20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x2F */ |
75 |
< |
/* 0x30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x3F */ |
76 |
< |
0, /* @ */ |
77 |
< |
0, /* A */ |
78 |
< |
0, /* B */ |
79 |
< |
0, /* C */ |
80 |
< |
UMODE_DEAF, /* D */ |
81 |
< |
0, /* E */ |
82 |
< |
0, /* F */ |
83 |
< |
UMODE_SOFTCALLERID, /* G */ |
84 |
< |
0, /* H */ |
85 |
< |
0, /* I */ |
86 |
< |
0, /* J */ |
87 |
< |
0, /* K */ |
88 |
< |
0, /* L */ |
108 |
< |
0, /* M */ |
109 |
< |
0, /* N */ |
110 |
< |
0, /* O */ |
111 |
< |
0, /* P */ |
112 |
< |
0, /* Q */ |
113 |
< |
0, /* R */ |
114 |
< |
0, /* S */ |
115 |
< |
0, /* T */ |
116 |
< |
0, /* U */ |
117 |
< |
0, /* V */ |
118 |
< |
0, /* W */ |
119 |
< |
0, /* X */ |
120 |
< |
0, /* Y */ |
121 |
< |
0, /* Z 0x5A */ |
122 |
< |
0, 0, 0, 0, 0, /* 0x5F */ |
123 |
< |
0, /* 0x60 */ |
124 |
< |
UMODE_ADMIN, /* a */ |
125 |
< |
UMODE_BOTS, /* b */ |
126 |
< |
UMODE_CCONN, /* c */ |
127 |
< |
UMODE_DEBUG, /* d */ |
128 |
< |
0, /* e */ |
129 |
< |
UMODE_FULL, /* f */ |
130 |
< |
UMODE_CALLERID, /* g */ |
131 |
< |
0, /* h */ |
132 |
< |
UMODE_INVISIBLE, /* i */ |
133 |
< |
0, /* j */ |
134 |
< |
UMODE_SKILL, /* k */ |
135 |
< |
UMODE_LOCOPS, /* l */ |
136 |
< |
0, /* m */ |
137 |
< |
UMODE_NCHANGE, /* n */ |
138 |
< |
UMODE_OPER, /* o */ |
139 |
< |
0, /* p */ |
140 |
< |
0, /* q */ |
141 |
< |
UMODE_REJ, /* r */ |
142 |
< |
UMODE_SERVNOTICE, /* s */ |
143 |
< |
0, /* t */ |
144 |
< |
UMODE_UNAUTH, /* u */ |
145 |
< |
0, /* v */ |
146 |
< |
UMODE_WALLOP, /* w */ |
147 |
< |
UMODE_EXTERNAL, /* x */ |
148 |
< |
UMODE_SPY, /* y */ |
149 |
< |
UMODE_OPERWALL, /* z 0x7A */ |
150 |
< |
0,0,0,0,0, /* 0x7B - 0x7F */ |
151 |
< |
|
152 |
< |
/* 0x80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x8F */ |
153 |
< |
/* 0x90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x9F */ |
154 |
< |
/* 0xA0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xAF */ |
155 |
< |
/* 0xB0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xBF */ |
156 |
< |
/* 0xC0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xCF */ |
157 |
< |
/* 0xD0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xDF */ |
158 |
< |
/* 0xE0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xEF */ |
159 |
< |
/* 0xF0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xFF */ |
60 |
> |
{ 'D', UMODE_DEAF }, |
61 |
> |
{ 'F', UMODE_FARCONNECT }, |
62 |
> |
{ 'G', UMODE_SOFTCALLERID }, |
63 |
> |
{ 'H', UMODE_HIDDEN }, |
64 |
> |
{ 'R', UMODE_REGONLY }, |
65 |
> |
{ 'S', UMODE_SSL }, |
66 |
> |
{ 'W', UMODE_WEBIRC }, |
67 |
> |
{ 'a', UMODE_ADMIN }, |
68 |
> |
{ 'b', UMODE_BOTS }, |
69 |
> |
{ 'c', UMODE_CCONN }, |
70 |
> |
{ 'd', UMODE_DEBUG }, |
71 |
> |
{ 'e', UMODE_EXTERNAL }, |
72 |
> |
{ 'f', UMODE_FULL }, |
73 |
> |
{ 'g', UMODE_CALLERID }, |
74 |
> |
{ 'i', UMODE_INVISIBLE }, |
75 |
> |
{ 'j', UMODE_REJ }, |
76 |
> |
{ 'k', UMODE_SKILL }, |
77 |
> |
{ 'l', UMODE_LOCOPS }, |
78 |
> |
{ 'n', UMODE_NCHANGE }, |
79 |
> |
{ 'o', UMODE_OPER }, |
80 |
> |
{ 'p', UMODE_HIDECHANS }, |
81 |
> |
{ 'q', UMODE_HIDEIDLE }, |
82 |
> |
{ 'r', UMODE_REGISTERED }, |
83 |
> |
{ 's', UMODE_SERVNOTICE }, |
84 |
> |
{ 'u', UMODE_UNAUTH }, |
85 |
> |
{ 'w', UMODE_WALLOP }, |
86 |
> |
{ 'x', UMODE_HIDDENHOST }, |
87 |
> |
{ 'y', UMODE_SPY }, |
88 |
> |
{ '\0', 0 } |
89 |
|
}; |
90 |
|
|
91 |
|
void |
92 |
< |
assemble_umode_buffer(void) |
92 |
> |
user_modes_init(void) |
93 |
|
{ |
165 |
– |
unsigned int idx = 0; |
94 |
|
char *umode_buffer_ptr = umode_buffer; |
95 |
|
|
96 |
< |
for (; idx < (sizeof(user_modes) / sizeof(int)); ++idx) |
97 |
< |
if (user_modes[idx]) |
98 |
< |
*umode_buffer_ptr++ = idx; |
96 |
> |
for (const struct user_modes *tab = umode_tab; tab->c; ++tab) |
97 |
> |
{ |
98 |
> |
umode_map[tab->c] = tab; |
99 |
> |
*umode_buffer_ptr++ = tab->c; |
100 |
> |
} |
101 |
|
|
102 |
|
*umode_buffer_ptr = '\0'; |
103 |
|
} |
109 |
|
* side effects - display to client user counts etc. |
110 |
|
*/ |
111 |
|
void |
112 |
< |
show_lusers(struct Client *source_p) |
112 |
> |
show_lusers(struct Client *client_p) |
113 |
|
{ |
114 |
< |
const char *from, *to; |
114 |
> |
if (!ConfigServerHide.hide_servers || HasUMode(client_p, UMODE_OPER)) |
115 |
> |
sendto_one_numeric(client_p, &me, RPL_LUSERCLIENT, (Count.total - Count.invisi), |
116 |
> |
Count.invisi, dlink_list_length(&global_server_list)); |
117 |
> |
else |
118 |
> |
sendto_one_numeric(client_p, &me, RPL_LUSERCLIENT, (Count.total - Count.invisi), |
119 |
> |
Count.invisi, 1); |
120 |
> |
|
121 |
> |
if (Count.oper) |
122 |
> |
sendto_one_numeric(client_p, &me, RPL_LUSEROP, Count.oper); |
123 |
> |
|
124 |
> |
if (dlink_list_length(&unknown_list)) |
125 |
> |
sendto_one_numeric(client_p, &me, RPL_LUSERUNKNOWN, dlink_list_length(&unknown_list)); |
126 |
> |
|
127 |
> |
if (dlink_list_length(&channel_list)) |
128 |
> |
sendto_one_numeric(client_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&channel_list)); |
129 |
|
|
130 |
< |
if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
130 |
> |
if (!ConfigServerHide.hide_servers || HasUMode(client_p, UMODE_OPER)) |
131 |
|
{ |
132 |
< |
from = me.id; |
133 |
< |
to = source_p->id; |
132 |
> |
sendto_one_numeric(client_p, &me, RPL_LUSERME, Count.local, Count.myserver); |
133 |
> |
sendto_one_numeric(client_p, &me, RPL_LOCALUSERS, Count.local, Count.max_loc); |
134 |
|
} |
135 |
|
else |
136 |
|
{ |
137 |
< |
from = me.name; |
138 |
< |
to = source_p->name; |
137 |
> |
sendto_one_numeric(client_p, &me, RPL_LUSERME, Count.total, 0); |
138 |
> |
sendto_one_numeric(client_p, &me, RPL_LOCALUSERS, Count.total, Count.max_tot); |
139 |
|
} |
140 |
|
|
141 |
< |
if (!ConfigServerHide.hide_servers || IsOper(source_p)) |
142 |
< |
sendto_one(source_p, form_str(RPL_LUSERCLIENT), |
143 |
< |
from, to, (Count.total-Count.invisi), |
144 |
< |
Count.invisi, dlink_list_length(&global_serv_list)); |
145 |
< |
else |
146 |
< |
sendto_one(source_p, form_str(RPL_LUSERCLIENT), from, to, |
147 |
< |
(Count.total-Count.invisi), Count.invisi, 1); |
141 |
> |
sendto_one_numeric(client_p, &me, RPL_GLOBALUSERS, Count.total, Count.max_tot); |
142 |
> |
|
143 |
> |
if (!ConfigServerHide.hide_servers || HasUMode(client_p, UMODE_OPER)) |
144 |
> |
sendto_one_numeric(client_p, &me, RPL_STATSCONN, Count.max_loc_con, |
145 |
> |
Count.max_loc_cli, Count.totalrestartcount); |
146 |
> |
|
147 |
> |
if (Count.local > Count.max_loc_cli) |
148 |
> |
Count.max_loc_cli = Count.local; |
149 |
> |
|
150 |
> |
if ((Count.local + Count.myserver) > Count.max_loc_con) |
151 |
> |
Count.max_loc_con = Count.local + Count.myserver; |
152 |
> |
} |
153 |
> |
|
154 |
> |
/* report_and_set_user_flags() |
155 |
> |
* |
156 |
> |
* inputs - pointer to client_p |
157 |
> |
* - pointer to conf for this user |
158 |
> |
* output - NONE |
159 |
> |
* side effects - Report to user any special flags |
160 |
> |
* they are getting, and set them. |
161 |
> |
*/ |
162 |
> |
static void |
163 |
> |
report_and_set_user_flags(struct Client *client_p, const struct MaskItem *conf) |
164 |
> |
{ |
165 |
> |
/* If this user is being spoofed, tell them so */ |
166 |
> |
if (IsConfDoSpoofIp(conf)) |
167 |
> |
sendto_one_notice(client_p, &me, ":*** Spoofing your IP"); |
168 |
|
|
169 |
< |
if (Count.oper > 0) |
170 |
< |
sendto_one(source_p, form_str(RPL_LUSEROP), |
171 |
< |
from, to, Count.oper); |
172 |
< |
|
173 |
< |
if (dlink_list_length(&unknown_list) > 0) |
210 |
< |
sendto_one(source_p, form_str(RPL_LUSERUNKNOWN), |
211 |
< |
from, to, dlink_list_length(&unknown_list)); |
212 |
< |
|
213 |
< |
if (dlink_list_length(&global_channel_list) > 0) |
214 |
< |
sendto_one(source_p, form_str(RPL_LUSERCHANNELS), |
215 |
< |
from, to, dlink_list_length(&global_channel_list)); |
216 |
< |
|
217 |
< |
if (!ConfigServerHide.hide_servers || IsOper(source_p)) |
218 |
< |
{ |
219 |
< |
sendto_one(source_p, form_str(RPL_LUSERME), |
220 |
< |
from, to, Count.local, Count.myserver); |
221 |
< |
sendto_one(source_p, form_str(RPL_LOCALUSERS), |
222 |
< |
from, to, Count.local, Count.max_loc, |
223 |
< |
Count.local, Count.max_loc); |
169 |
> |
/* If this user is in the exception class, set it "E lined" */ |
170 |
> |
if (IsConfExemptKline(conf)) |
171 |
> |
{ |
172 |
> |
AddFlag(client_p, FLAGS_EXEMPTKLINE); |
173 |
> |
sendto_one_notice(client_p, &me, ":*** You are exempt from K/D lines"); |
174 |
|
} |
175 |
< |
else |
175 |
> |
|
176 |
> |
if (IsConfExemptXline(conf)) |
177 |
|
{ |
178 |
< |
sendto_one(source_p, form_str(RPL_LUSERME), |
179 |
< |
from, to, Count.total, 0); |
180 |
< |
sendto_one(source_p, form_str(RPL_LOCALUSERS), |
230 |
< |
from, to, Count.total, Count.max_tot, |
231 |
< |
Count.total, Count.max_tot); |
232 |
< |
} |
233 |
< |
|
234 |
< |
sendto_one(source_p, form_str(RPL_GLOBALUSERS), |
235 |
< |
from, to, Count.total, Count.max_tot, |
236 |
< |
Count.total, Count.max_tot); |
237 |
< |
|
238 |
< |
if (!ConfigServerHide.hide_servers || IsOper(source_p)) |
239 |
< |
sendto_one(source_p, form_str(RPL_STATSCONN), from, to, |
240 |
< |
MaxConnectionCount, MaxClientCount, Count.totalrestartcount); |
178 |
> |
AddFlag(client_p, FLAGS_EXEMPTXLINE); |
179 |
> |
sendto_one_notice(client_p, &me, ":*** You are exempt from X lines"); |
180 |
> |
} |
181 |
|
|
182 |
< |
if (Count.local > MaxClientCount) |
183 |
< |
MaxClientCount = Count.local; |
182 |
> |
if (IsConfExemptResv(conf)) |
183 |
> |
{ |
184 |
> |
AddFlag(client_p, FLAGS_EXEMPTRESV); |
185 |
> |
sendto_one_notice(client_p, &me, ":*** You are exempt from resvs"); |
186 |
> |
} |
187 |
|
|
188 |
< |
if ((Count.local + Count.myserver) > MaxConnectionCount) |
189 |
< |
MaxConnectionCount = Count.local + Count.myserver; |
188 |
> |
/* If this user is exempt from user limits set it "F lined" */ |
189 |
> |
if (IsConfExemptLimits(conf)) |
190 |
> |
{ |
191 |
> |
AddFlag(client_p, FLAGS_NOLIMIT); |
192 |
> |
sendto_one_notice(client_p, &me, ":*** You are exempt from user limits"); |
193 |
> |
} |
194 |
> |
|
195 |
> |
if (IsConfCanFlood(conf)) |
196 |
> |
{ |
197 |
> |
AddFlag(client_p, FLAGS_CANFLOOD); |
198 |
> |
sendto_one_notice(client_p, &me, ":*** You are exempt from flood protection"); |
199 |
> |
} |
200 |
|
} |
201 |
|
|
202 |
< |
/* show_isupport() |
202 |
> |
/* introduce_client() |
203 |
|
* |
204 |
< |
* inputs - pointer to client |
204 |
> |
* inputs - client_p |
205 |
|
* output - NONE |
206 |
< |
* side effects - display to client what we support (for them) |
206 |
> |
* side effects - This common function introduces a client to the rest |
207 |
> |
* of the net, either from a local client connect or |
208 |
> |
* from a remote connect. |
209 |
|
*/ |
210 |
< |
void |
211 |
< |
show_isupport(struct Client *source_p) |
210 |
> |
static void |
211 |
> |
introduce_client(struct Client *client_p) |
212 |
|
{ |
213 |
< |
send_message_file(source_p, isupportFile); |
213 |
> |
dlink_node *node = NULL; |
214 |
> |
char ubuf[IRCD_BUFSIZE] = ""; |
215 |
> |
|
216 |
> |
send_umode(client_p, MyConnect(client_p), 0, ubuf); |
217 |
> |
watch_check_hash(client_p, RPL_LOGON); |
218 |
> |
|
219 |
> |
if (ubuf[0] == '\0') |
220 |
> |
{ |
221 |
> |
ubuf[0] = '+'; |
222 |
> |
ubuf[1] = '\0'; |
223 |
> |
} |
224 |
> |
|
225 |
> |
DLINK_FOREACH(node, local_server_list.head) |
226 |
> |
{ |
227 |
> |
struct Client *server_p = node->data; |
228 |
> |
|
229 |
> |
if (server_p == client_p->from) |
230 |
> |
continue; |
231 |
> |
|
232 |
> |
sendto_one(server_p, ":%s UID %s %u %ju %s %s %s %s %s %s :%s", |
233 |
> |
client_p->servptr->id, |
234 |
> |
client_p->name, client_p->hopcount+1, |
235 |
> |
client_p->tsinfo, |
236 |
> |
ubuf, client_p->username, client_p->host, |
237 |
> |
client_p->sockhost, client_p->id, |
238 |
> |
client_p->account, |
239 |
> |
client_p->info); |
240 |
> |
|
241 |
> |
if (!EmptyString(client_p->certfp)) |
242 |
> |
sendto_one(server_p, ":%s CERTFP %s", client_p->id, client_p->certfp); |
243 |
> |
} |
244 |
|
} |
245 |
|
|
246 |
< |
/* |
247 |
< |
** register_local_user |
248 |
< |
** This function is called when both NICK and USER messages |
249 |
< |
** have been accepted for the client, in whatever order. Only |
250 |
< |
** after this, is the USER message propagated. |
251 |
< |
** |
252 |
< |
** NICK's must be propagated at once when received, although |
253 |
< |
** it would be better to delay them too until full info is |
254 |
< |
** available. Doing it is not so simple though, would have |
255 |
< |
** to implement the following: |
256 |
< |
** |
257 |
< |
** (actually it has been implemented already for a while) -orabidoo |
258 |
< |
** |
259 |
< |
** 1) user telnets in and gives only "NICK foobar" and waits |
260 |
< |
** 2) another user far away logs in normally with the nick |
261 |
< |
** "foobar" (quite legal, as this server didn't propagate |
262 |
< |
** it). |
263 |
< |
** 3) now this server gets nick "foobar" from outside, but |
264 |
< |
** has alread the same defined locally. Current server |
265 |
< |
** would just issue "KILL foobar" to clean out dups. But, |
266 |
< |
** this is not fair. It should actually request another |
267 |
< |
** nick from local user or kill him/her... |
268 |
< |
*/ |
246 |
> |
/* user_welcome() |
247 |
> |
* |
248 |
> |
* inputs - client pointer to client to welcome |
249 |
> |
* output - NONE |
250 |
> |
* side effects - |
251 |
> |
*/ |
252 |
> |
static void |
253 |
> |
user_welcome(struct Client *client_p) |
254 |
> |
{ |
255 |
> |
static const char built_date[] = __DATE__ " at " __TIME__; |
256 |
> |
|
257 |
> |
if (HasFlag(client_p, FLAGS_SSL)) |
258 |
> |
{ |
259 |
> |
AddUMode(client_p, UMODE_SSL); |
260 |
> |
sendto_one_notice(client_p, &me, ":*** Connected securely via %s", |
261 |
> |
tls_get_cipher(&client_p->connection->fd.ssl)); |
262 |
> |
} |
263 |
> |
|
264 |
> |
sendto_one_numeric(client_p, &me, RPL_WELCOME, ConfigServerInfo.network_name, |
265 |
> |
client_p->name); |
266 |
> |
sendto_one_numeric(client_p, &me, RPL_YOURHOST, |
267 |
> |
listener_get_name(client_p->connection->listener), ircd_version); |
268 |
> |
sendto_one_numeric(client_p, &me, RPL_CREATED, built_date); |
269 |
> |
sendto_one_numeric(client_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer); |
270 |
> |
|
271 |
> |
isupport_show(client_p); |
272 |
> |
show_lusers(client_p); |
273 |
> |
motd_signon(client_p); |
274 |
> |
} |
275 |
> |
|
276 |
> |
/* check_xline() |
277 |
> |
* |
278 |
> |
* inputs - pointer to client to test |
279 |
> |
* outupt - 1 if exiting 0 if ok |
280 |
> |
* side effects - |
281 |
> |
*/ |
282 |
> |
static int |
283 |
> |
check_xline(struct Client *client_p) |
284 |
> |
{ |
285 |
> |
const struct GecosItem *gecos = NULL; |
286 |
> |
|
287 |
> |
if (HasFlag(client_p, FLAGS_EXEMPTXLINE)) |
288 |
> |
return 0; |
289 |
> |
|
290 |
> |
if ((gecos = gecos_find(client_p->info, match))) |
291 |
> |
{ |
292 |
> |
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE, |
293 |
> |
"X-line Rejecting [%s] [%s], user %s [%s]", |
294 |
> |
client_p->info, gecos->reason, |
295 |
> |
get_client_name(client_p, HIDE_IP), |
296 |
> |
client_p->sockhost); |
297 |
> |
|
298 |
> |
++ServerStats.is_ref; |
299 |
> |
exit_client(client_p, "Bad user info"); |
300 |
> |
return 1; |
301 |
> |
} |
302 |
> |
|
303 |
> |
return 0; |
304 |
> |
} |
305 |
> |
|
306 |
> |
/*! \brief This function is called when both NICK and USER messages |
307 |
> |
* have been accepted for the client, in whatever order. Only |
308 |
> |
* after this, is the UID message propagated. |
309 |
> |
* \param client_p Pointer to given client to introduce |
310 |
> |
*/ |
311 |
|
void |
312 |
< |
register_local_user(struct Client *client_p, struct Client *source_p, |
286 |
< |
const char *nick, const char *username) |
312 |
> |
register_local_user(struct Client *client_p) |
313 |
|
{ |
314 |
< |
const struct AccessItem *aconf = NULL; |
289 |
< |
char ipaddr[HOSTIPLEN]; |
290 |
< |
dlink_node *ptr = NULL; |
291 |
< |
dlink_node *m = NULL; |
292 |
< |
|
293 |
< |
assert(source_p != NULL); |
294 |
< |
assert(MyConnect(source_p)); |
295 |
< |
assert(source_p->username != username); |
296 |
< |
assert(!source_p->localClient->registration); |
314 |
> |
const struct MaskItem *conf = NULL; |
315 |
|
|
316 |
< |
ClearCap(client_p, CAP_TS6); |
316 |
> |
assert(client_p == client_p->from); |
317 |
> |
assert(MyConnect(client_p)); |
318 |
> |
assert(IsUnknown(client_p)); |
319 |
> |
assert(!client_p->connection->registration); |
320 |
|
|
321 |
< |
if (ConfigFileEntry.ping_cookie) |
321 |
> |
if (ConfigGeneral.ping_cookie) |
322 |
|
{ |
323 |
< |
if (!IsPingSent(source_p) && |
303 |
< |
source_p->localClient->random_ping == 0) |
323 |
> |
if (!HasFlag(client_p, FLAGS_PINGSENT) && !client_p->connection->random_ping) |
324 |
|
{ |
325 |
< |
source_p->localClient->random_ping = (unsigned long)rand(); |
326 |
< |
sendto_one(source_p, "PING :%lu", |
327 |
< |
source_p->localClient->random_ping); |
328 |
< |
SetPingSent(source_p); |
325 |
> |
do |
326 |
> |
client_p->connection->random_ping = genrand_int32(); |
327 |
> |
while (!client_p->connection->random_ping); |
328 |
> |
|
329 |
> |
sendto_one(client_p, "PING :%u", client_p->connection->random_ping); |
330 |
> |
AddFlag(client_p, FLAGS_PINGSENT); |
331 |
|
return; |
332 |
|
} |
333 |
|
|
334 |
< |
if (!HasPingCookie(source_p)) |
334 |
> |
if (!HasFlag(client_p, FLAGS_PING_COOKIE)) |
335 |
|
return; |
336 |
|
} |
337 |
|
|
338 |
< |
source_p->localClient->last = CurrentTime; |
338 |
> |
client_p->connection->last_privmsg = CurrentTime; |
339 |
|
/* Straight up the maximum rate of flooding... */ |
340 |
< |
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
340 |
> |
client_p->connection->allow_read = MAX_FLOOD_BURST; |
341 |
|
|
342 |
< |
if (!execute_callback(client_check_cb, source_p, username)) |
342 |
> |
if (!check_client(client_p)) |
343 |
|
return; |
344 |
|
|
345 |
< |
if (valid_hostname(source_p->host) == 0) |
345 |
> |
if (!valid_hostname(client_p->host)) |
346 |
|
{ |
347 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You have an illegal " |
348 |
< |
"character in your hostname", me.name, source_p->name); |
349 |
< |
strlcpy(source_p->host, source_p->sockhost, |
328 |
< |
sizeof(source_p->host)); |
347 |
> |
sendto_one_notice(client_p, &me, ":*** Notice -- You have an illegal " |
348 |
> |
"character in your hostname"); |
349 |
> |
strlcpy(client_p->host, client_p->sockhost, sizeof(client_p->host)); |
350 |
|
} |
351 |
|
|
352 |
< |
ptr = source_p->localClient->confs.head; |
332 |
< |
aconf = map_to_conf(ptr->data); |
352 |
> |
conf = client_p->connection->confs.head->data; |
353 |
|
|
354 |
< |
if (!IsGotId(source_p)) |
354 |
> |
if (!HasFlag(client_p, FLAGS_GOTID)) |
355 |
|
{ |
356 |
< |
const char *p = NULL; |
356 |
> |
char username[USERLEN + 1] = ""; |
357 |
|
unsigned int i = 0; |
358 |
|
|
359 |
< |
if (IsNeedIdentd(aconf)) |
359 |
> |
if (IsNeedIdentd(conf)) |
360 |
|
{ |
361 |
< |
ServerStats->is_ref++; |
362 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install " |
363 |
< |
"identd to use this server", me.name, source_p->name); |
364 |
< |
exit_client(source_p, &me, "Install identd"); |
361 |
> |
++ServerStats.is_ref; |
362 |
> |
sendto_one_notice(client_p, &me, ":*** Notice -- You need to install " |
363 |
> |
"identd to use this server"); |
364 |
> |
exit_client(client_p, "Install identd"); |
365 |
|
return; |
366 |
|
} |
367 |
|
|
368 |
< |
p = username; |
368 |
> |
strlcpy(username, client_p->username, sizeof(username)); |
369 |
|
|
370 |
< |
if (!IsNoTilde(aconf)) |
371 |
< |
source_p->username[i++] = '~'; |
370 |
> |
if (!IsNoTilde(conf)) |
371 |
> |
client_p->username[i++] = '~'; |
372 |
|
|
373 |
< |
while (*p && i < USERLEN) |
374 |
< |
{ |
355 |
< |
if (*p != '[') |
356 |
< |
source_p->username[i++] = *p; |
357 |
< |
p++; |
358 |
< |
} |
373 |
> |
for (const char *p = username; *p && i < USERLEN; ++p) |
374 |
> |
client_p->username[i++] = *p; |
375 |
|
|
376 |
< |
source_p->username[i] = '\0'; |
376 |
> |
client_p->username[i] = '\0'; |
377 |
|
} |
378 |
|
|
379 |
< |
/* password check */ |
380 |
< |
if (!EmptyString(aconf->passwd)) |
379 |
> |
/* Password check */ |
380 |
> |
if (!EmptyString(conf->passwd)) |
381 |
|
{ |
382 |
< |
const char *pass = source_p->localClient->passwd; |
367 |
< |
|
368 |
< |
if (!match_conf_password(pass, aconf)) |
382 |
> |
if (!match_conf_password(client_p->connection->password, conf)) |
383 |
|
{ |
384 |
< |
ServerStats->is_ref++; |
385 |
< |
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), |
386 |
< |
me.name, source_p->name); |
387 |
< |
exit_client(source_p, &me, "Bad Password"); |
384 |
> |
++ServerStats.is_ref; |
385 |
> |
|
386 |
> |
sendto_one_numeric(client_p, &me, ERR_PASSWDMISMATCH); |
387 |
> |
exit_client(client_p, "Bad Password"); |
388 |
|
return; |
389 |
|
} |
390 |
|
} |
391 |
|
|
392 |
< |
/* don't free source_p->localClient->passwd here - it can be required |
393 |
< |
* by masked /stats I if there are auth{} blocks with need_password = no; |
392 |
> |
/* |
393 |
> |
* Don't free client_p->connection->password here - it can be required |
394 |
> |
* by masked /stats I if there are auth {} blocks with need_password = no; |
395 |
|
* --adx |
396 |
|
*/ |
397 |
|
|
398 |
< |
/* report if user has &^>= etc. and set flags as needed in source_p */ |
399 |
< |
report_and_set_user_flags(source_p, aconf); |
398 |
> |
/* |
399 |
> |
* Report if user has &^>= etc. and set flags as needed in client_p |
400 |
> |
*/ |
401 |
> |
report_and_set_user_flags(client_p, conf); |
402 |
|
|
403 |
< |
/* Limit clients - |
403 |
> |
if (IsDead(client_p)) |
404 |
> |
return; |
405 |
> |
|
406 |
> |
/* |
407 |
> |
* Limit clients - |
408 |
|
* We want to be able to have servers and F-line clients |
409 |
|
* connect, so save room for "buffer" connections. |
410 |
|
* Smaller servers may want to decrease this, and it should |
411 |
|
* probably be just a percentage of the MAXCLIENTS... |
412 |
|
* -Taner |
413 |
|
*/ |
414 |
< |
/* Except "F:" clients */ |
415 |
< |
if ((Count.local >= ServerInfo.max_clients + MAX_BUFFER) || |
395 |
< |
(Count.local >= ServerInfo.max_clients && !IsExemptLimits(source_p))) |
414 |
> |
if ((Count.local >= GlobalSetOptions.maxclients + MAX_BUFFER) || |
415 |
> |
(Count.local >= GlobalSetOptions.maxclients && !HasFlag(client_p, FLAGS_NOLIMIT))) |
416 |
|
{ |
417 |
< |
sendto_realops_flags(UMODE_FULL, L_ALL, |
417 |
> |
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
418 |
|
"Too many clients, rejecting %s[%s].", |
419 |
< |
nick, source_p->host); |
420 |
< |
ServerStats->is_ref++; |
421 |
< |
exit_client(source_p, &me, "Sorry, server is full - try later"); |
419 |
> |
client_p->name, client_p->host); |
420 |
> |
++ServerStats.is_ref; |
421 |
> |
exit_client(client_p, "Sorry, server is full - try later"); |
422 |
|
return; |
423 |
|
} |
424 |
|
|
425 |
< |
/* valid user name check */ |
406 |
< |
if (valid_username(source_p->username) == 0) |
425 |
> |
if (!valid_username(client_p->username, 1)) |
426 |
|
{ |
427 |
< |
char tmpstr2[IRCD_BUFSIZE]; |
427 |
> |
char buf[IRCD_BUFSIZE] = ""; |
428 |
|
|
429 |
< |
sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)", |
430 |
< |
nick, source_p->username, source_p->host); |
431 |
< |
ServerStats->is_ref++; |
432 |
< |
ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username); |
433 |
< |
exit_client(source_p, &me, tmpstr2); |
429 |
> |
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE, |
430 |
> |
"Invalid username: %s (%s@%s)", |
431 |
> |
client_p->name, client_p->username, client_p->host); |
432 |
> |
++ServerStats.is_ref; |
433 |
> |
snprintf(buf, sizeof(buf), "Invalid username [%s]", client_p->username); |
434 |
> |
exit_client(client_p, buf); |
435 |
|
return; |
436 |
|
} |
437 |
|
|
438 |
< |
assert(source_p == client_p); |
419 |
< |
|
420 |
< |
if (check_xline(source_p)) |
438 |
> |
if (check_xline(client_p)) |
439 |
|
return; |
440 |
|
|
441 |
< |
if (IsDead(client_p)) |
442 |
< |
return; |
443 |
< |
|
426 |
< |
if (me.id[0]) |
427 |
< |
{ |
428 |
< |
const char *id = execute_callback(uid_get_cb, source_p); |
429 |
< |
|
430 |
< |
while (hash_find_id(id) != NULL) |
431 |
< |
id = uid_get(NULL); |
432 |
< |
|
433 |
< |
strlcpy(source_p->id, id, sizeof(source_p->id)); |
434 |
< |
hash_add_id(source_p); |
435 |
< |
} |
441 |
> |
const char *id; |
442 |
> |
while (hash_find_id((id = uid_get()))) |
443 |
> |
; |
444 |
|
|
445 |
< |
irc_getnameinfo((struct sockaddr *)&source_p->localClient->ip, |
446 |
< |
source_p->localClient->ip.ss_len, ipaddr, |
439 |
< |
HOSTIPLEN, NULL, 0, NI_NUMERICHOST); |
445 |
> |
strlcpy(client_p->id, id, sizeof(client_p->id)); |
446 |
> |
hash_add_id(client_p); |
447 |
|
|
448 |
< |
sendto_realops_flags(UMODE_CCONN, L_ALL, |
449 |
< |
"Client connecting: %s (%s@%s) [%s] {%s} [%s]", |
450 |
< |
nick, source_p->username, source_p->host, |
451 |
< |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
452 |
< |
"255.255.255.255" : ipaddr, get_client_class(source_p), |
453 |
< |
source_p->info); |
448 |
> |
sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE, |
449 |
> |
"Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>", |
450 |
> |
client_p->name, client_p->username, client_p->host, |
451 |
> |
client_p->sockhost, |
452 |
> |
get_client_class(&client_p->connection->confs), |
453 |
> |
client_p->info, client_p->id); |
454 |
|
|
455 |
< |
/* If they have died in send_* don't do anything. */ |
449 |
< |
if (IsDead(source_p)) |
450 |
< |
return; |
451 |
< |
|
452 |
< |
if (ConfigFileEntry.invisible_on_connect) |
455 |
> |
if (ConfigGeneral.invisible_on_connect) |
456 |
|
{ |
457 |
< |
source_p->umodes |= UMODE_INVISIBLE; |
458 |
< |
Count.invisi++; |
457 |
> |
AddUMode(client_p, UMODE_INVISIBLE); |
458 |
> |
++Count.invisi; |
459 |
|
} |
460 |
|
|
461 |
< |
if ((++Count.local) > Count.max_loc) |
461 |
> |
if (++Count.local > Count.max_loc) |
462 |
|
{ |
463 |
|
Count.max_loc = Count.local; |
464 |
|
|
465 |
|
if (!(Count.max_loc % 10)) |
466 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "New Max Local Clients: %d", |
466 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
467 |
> |
"New maximum local client connections: %u", |
468 |
|
Count.max_loc); |
469 |
|
} |
470 |
|
|
467 |
– |
SetClient(source_p); |
468 |
– |
|
469 |
– |
source_p->servptr = &me; |
470 |
– |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users); |
471 |
– |
|
472 |
– |
/* Increment our total user count here */ |
471 |
|
if (++Count.total > Count.max_tot) |
472 |
|
Count.max_tot = Count.total; |
473 |
< |
Count.totalrestartcount++; |
473 |
> |
++Count.totalrestartcount; |
474 |
|
|
475 |
< |
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
475 |
> |
assert(client_p->servptr == &me); |
476 |
> |
SetClient(client_p); |
477 |
> |
dlinkAdd(client_p, &client_p->lnode, &client_p->servptr->serv->client_list); |
478 |
> |
dlinkAdd(client_p, &client_p->node, &global_client_list); |
479 |
|
|
480 |
< |
if ((m = dlinkFindDelete(&unknown_list, source_p)) != NULL) |
481 |
< |
{ |
482 |
< |
free_dlink_node(m); |
483 |
< |
dlinkAdd(source_p, &source_p->localClient->lclient_node, &local_client_list); |
483 |
< |
} |
484 |
< |
else assert(0); |
480 |
> |
assert(dlinkFind(&unknown_list, client_p)); |
481 |
> |
|
482 |
> |
dlink_move_node(&client_p->connection->lclient_node, |
483 |
> |
&unknown_list, &local_client_list); |
484 |
|
|
485 |
< |
user_welcome(source_p); |
486 |
< |
add_user_host(source_p->username, source_p->host, 0); |
487 |
< |
SetUserHost(source_p); |
485 |
> |
user_welcome(client_p); |
486 |
> |
userhost_add(client_p->sockhost, 0); |
487 |
> |
AddFlag(client_p, FLAGS_USERHOST); |
488 |
|
|
489 |
< |
introduce_client(client_p, source_p); |
489 |
> |
introduce_client(client_p); |
490 |
|
} |
491 |
|
|
492 |
|
/* register_remote_user() |
493 |
|
* |
494 |
< |
* inputs - client_p directly connected client |
496 |
< |
* - source_p remote or directly connected client |
494 |
> |
* inputs - client_p remote or directly connected client |
495 |
|
* - username to register as |
496 |
|
* - host name to register as |
497 |
|
* - server name |
500 |
– |
* - realname (gecos) |
498 |
|
* output - NONE |
499 |
|
* side effects - This function is called when a remote client |
500 |
|
* is introduced by a server. |
501 |
|
*/ |
502 |
|
void |
503 |
< |
register_remote_user(struct Client *client_p, struct Client *source_p, |
507 |
< |
const char *username, const char *host, const char *server, |
508 |
< |
const char *realname) |
503 |
> |
register_remote_user(struct Client *client_p) |
504 |
|
{ |
505 |
< |
struct Client *target_p = NULL; |
511 |
< |
|
512 |
< |
assert(source_p != NULL); |
513 |
< |
assert(source_p->username != username); |
514 |
< |
|
515 |
< |
strlcpy(source_p->host, host, sizeof(source_p->host)); |
516 |
< |
strlcpy(source_p->info, realname, sizeof(source_p->info)); |
517 |
< |
strlcpy(source_p->username, username, sizeof(source_p->username)); |
505 |
> |
assert(client_p->servptr->from == client_p->from); |
506 |
|
|
507 |
|
/* |
508 |
< |
* coming from another server, take the servers word for it |
508 |
> |
* If the nick has been introduced by a services server, |
509 |
> |
* make it a service as well. |
510 |
|
*/ |
511 |
< |
source_p->servptr = find_server(server); |
511 |
> |
if (HasFlag(client_p->servptr, FLAGS_SERVICE)) |
512 |
> |
AddFlag(client_p, FLAGS_SERVICE); |
513 |
|
|
524 |
– |
/* Super GhostDetect: |
525 |
– |
* If we can't find the server the user is supposed to be on, |
526 |
– |
* then simply blow the user away. -Taner |
527 |
– |
*/ |
528 |
– |
if (source_p->servptr == NULL) |
529 |
– |
{ |
530 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
531 |
– |
"No server %s for user %s[%s@%s] from %s", |
532 |
– |
server, source_p->name, source_p->username, |
533 |
– |
source_p->host, source_p->from->name); |
534 |
– |
kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name); |
535 |
– |
|
536 |
– |
SetKilled(source_p); |
537 |
– |
exit_client(source_p, &me, "Ghosted Client"); |
538 |
– |
return; |
539 |
– |
} |
540 |
– |
|
541 |
– |
if ((target_p = source_p->servptr) && target_p->from != source_p->from) |
542 |
– |
{ |
543 |
– |
sendto_realops_flags(UMODE_DEBUG, L_ALL, |
544 |
– |
"Bad User [%s] :%s USER %s@%s %s, != %s[%s]", |
545 |
– |
client_p->name, source_p->name, source_p->username, |
546 |
– |
source_p->host, source_p->servptr->name, |
547 |
– |
target_p->name, target_p->from->name); |
548 |
– |
kill_client(client_p, source_p, |
549 |
– |
"%s (NICK from wrong direction (%s != %s))", |
550 |
– |
me.name, source_p->servptr->name, target_p->from->name); |
551 |
– |
SetKilled(source_p); |
552 |
– |
exit_client(source_p, &me, "USER server wrong direction"); |
553 |
– |
return; |
554 |
– |
} |
555 |
– |
|
556 |
– |
/* Increment our total user count here */ |
514 |
|
if (++Count.total > Count.max_tot) |
515 |
|
Count.max_tot = Count.total; |
516 |
|
|
517 |
< |
++source_p->from->serv->dep_users; |
518 |
< |
|
519 |
< |
SetClient(source_p); |
520 |
< |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users); |
521 |
< |
add_user_host(source_p->username, source_p->host, 1); |
522 |
< |
SetUserHost(source_p); |
523 |
< |
|
524 |
< |
introduce_client(client_p, source_p); |
525 |
< |
} |
526 |
< |
|
527 |
< |
/* introduce_client() |
528 |
< |
* |
572 |
< |
* inputs - client_p |
573 |
< |
* - source_p |
574 |
< |
* output - NONE |
575 |
< |
* side effects - This common function introduces a client to the rest |
576 |
< |
* of the net, either from a local client connect or |
577 |
< |
* from a remote connect. |
578 |
< |
*/ |
579 |
< |
static void |
580 |
< |
introduce_client(struct Client *client_p, struct Client *source_p) |
581 |
< |
{ |
582 |
< |
dlink_node *server_node = NULL; |
583 |
< |
static char ubuf[12]; |
584 |
< |
|
585 |
< |
if (MyClient(source_p)) |
586 |
< |
send_umode(source_p, source_p, 0, SEND_UMODES, ubuf); |
587 |
< |
else |
588 |
< |
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
589 |
< |
|
590 |
< |
if (*ubuf == '\0') |
591 |
< |
{ |
592 |
< |
ubuf[0] = '+'; |
593 |
< |
ubuf[1] = '\0'; |
594 |
< |
} |
595 |
< |
|
596 |
< |
/* arghhh one could try not introducing new nicks to ll leafs |
597 |
< |
* but then you have to introduce them "on the fly" in SJOIN |
598 |
< |
* not fun. |
599 |
< |
* Its not going to cost much more bandwidth to simply let new |
600 |
< |
* nicks just ride on through. |
601 |
< |
*/ |
602 |
< |
|
603 |
< |
/* We now introduce nicks "on the fly" in SJOIN anyway -- |
604 |
< |
* you _need_ to if you aren't going to burst everyone initially. |
605 |
< |
* |
606 |
< |
* Only send to non CAP_LL servers, unless we're a lazylink leaf, |
607 |
< |
* in that case just send it to the uplink. |
608 |
< |
* -davidt |
609 |
< |
* rewritten to cope with SIDs .. eww eww eww --is |
610 |
< |
*/ |
611 |
< |
if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) && |
612 |
< |
client_p != uplink) |
613 |
< |
{ |
614 |
< |
if (IsCapable(uplink, CAP_TS6) && HasID(source_p)) |
615 |
< |
{ |
616 |
< |
sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
617 |
< |
source_p->servptr->id, |
618 |
< |
source_p->name, source_p->hopcount+1, |
619 |
< |
(unsigned long)source_p->tsinfo, |
620 |
< |
ubuf, source_p->username, source_p->host, |
621 |
< |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
622 |
< |
"0" : source_p->sockhost, source_p->id, source_p->info); |
623 |
< |
} |
624 |
< |
else |
625 |
< |
{ |
626 |
< |
sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s", |
627 |
< |
source_p->name, source_p->hopcount+1, |
628 |
< |
(unsigned long)source_p->tsinfo, |
629 |
< |
ubuf, source_p->username, source_p->host, |
630 |
< |
source_p->servptr->name, source_p->info); |
631 |
< |
} |
632 |
< |
} |
633 |
< |
else |
634 |
< |
{ |
635 |
< |
DLINK_FOREACH(server_node, serv_list.head) |
636 |
< |
{ |
637 |
< |
struct Client *server = server_node->data; |
638 |
< |
|
639 |
< |
if (IsCapable(server, CAP_LL) || server == client_p) |
640 |
< |
continue; |
517 |
> |
SetClient(client_p); |
518 |
> |
dlinkAdd(client_p, &client_p->lnode, &client_p->servptr->serv->client_list); |
519 |
> |
dlinkAdd(client_p, &client_p->node, &global_client_list); |
520 |
> |
userhost_add(client_p->sockhost, 1); |
521 |
> |
AddFlag(client_p, FLAGS_USERHOST); |
522 |
> |
|
523 |
> |
if (HasFlag(client_p->servptr, FLAGS_EOB)) |
524 |
> |
sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE, |
525 |
> |
"Client connecting at %s: %s (%s@%s) [%s] [%s] <%s>", |
526 |
> |
client_p->servptr->name, |
527 |
> |
client_p->name, client_p->username, client_p->host, |
528 |
> |
client_p->sockhost, client_p->info, client_p->id); |
529 |
|
|
530 |
< |
if (IsCapable(server, CAP_TS6) && HasID(source_p)) |
643 |
< |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
644 |
< |
source_p->servptr->id, |
645 |
< |
source_p->name, source_p->hopcount+1, |
646 |
< |
(unsigned long)source_p->tsinfo, |
647 |
< |
ubuf, source_p->username, source_p->host, |
648 |
< |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
649 |
< |
"0" : source_p->sockhost, source_p->id, source_p->info); |
650 |
< |
else |
651 |
< |
sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s", |
652 |
< |
source_p->name, source_p->hopcount+1, |
653 |
< |
(unsigned long)source_p->tsinfo, |
654 |
< |
ubuf, source_p->username, source_p->host, |
655 |
< |
source_p->servptr->name, source_p->info); |
656 |
< |
} |
657 |
< |
} |
530 |
> |
introduce_client(client_p); |
531 |
|
} |
532 |
|
|
533 |
|
/* valid_hostname() |
544 |
|
{ |
545 |
|
const char *p = hostname; |
546 |
|
|
547 |
< |
assert(p != NULL); |
547 |
> |
assert(p); |
548 |
|
|
549 |
< |
if ('.' == *p || ':' == *p) |
549 |
> |
if (EmptyString(p) || *p == '.' || *p == ':') |
550 |
|
return 0; |
551 |
|
|
552 |
< |
while (*p) |
680 |
< |
{ |
552 |
> |
for (; *p; ++p) |
553 |
|
if (!IsHostChar(*p)) |
554 |
|
return 0; |
683 |
– |
p++; |
684 |
– |
} |
555 |
|
|
556 |
< |
return 1; |
556 |
> |
return p - hostname <= HOSTLEN; |
557 |
|
} |
558 |
|
|
559 |
|
/* valid_username() |
568 |
|
* style of username |
569 |
|
*/ |
570 |
|
int |
571 |
< |
valid_username(const char *username) |
571 |
> |
valid_username(const char *username, const int local) |
572 |
|
{ |
703 |
– |
int dots = 0; |
573 |
|
const char *p = username; |
574 |
|
|
575 |
< |
assert(p != NULL); |
575 |
> |
assert(p); |
576 |
|
|
577 |
< |
if ('~' == *p) |
577 |
> |
if (*p == '~') |
578 |
|
++p; |
579 |
|
|
580 |
< |
/* reject usernames that don't start with an alphanum |
580 |
> |
/* |
581 |
> |
* Reject usernames that don't start with an alphanum |
582 |
|
* i.e. reject jokers who have '-@somehost' or '.@somehost' |
583 |
|
* or "-hi-@somehost", "h-----@somehost" would still be accepted. |
584 |
|
*/ |
585 |
|
if (!IsAlNum(*p)) |
586 |
|
return 0; |
587 |
|
|
588 |
< |
while (*++p) |
588 |
> |
if (local) |
589 |
|
{ |
590 |
< |
if ((*p == '.') && ConfigFileEntry.dots_in_ident) |
721 |
< |
{ |
722 |
< |
dots++; |
590 |
> |
unsigned int dots = 0; |
591 |
|
|
592 |
< |
if (dots > ConfigFileEntry.dots_in_ident) |
593 |
< |
return 0; |
594 |
< |
if (!IsUserChar(p[1])) |
592 |
> |
while (*++p) |
593 |
> |
{ |
594 |
> |
if (*p == '.' && ConfigGeneral.dots_in_ident) |
595 |
> |
{ |
596 |
> |
if (++dots > ConfigGeneral.dots_in_ident) |
597 |
> |
return 0; |
598 |
> |
if (!IsUserChar(*(p + 1))) |
599 |
> |
return 0; |
600 |
> |
} |
601 |
> |
else if (!IsUserChar(*p)) |
602 |
|
return 0; |
603 |
|
} |
729 |
– |
else if (!IsUserChar(*p)) |
730 |
– |
return 0; |
604 |
|
} |
605 |
< |
|
733 |
< |
return 1; |
734 |
< |
} |
735 |
< |
|
736 |
< |
/* report_and_set_user_flags() |
737 |
< |
* |
738 |
< |
* inputs - pointer to source_p |
739 |
< |
* - pointer to aconf for this user |
740 |
< |
* output - NONE |
741 |
< |
* side effects - Report to user any special flags |
742 |
< |
* they are getting, and set them. |
743 |
< |
*/ |
744 |
< |
static void |
745 |
< |
report_and_set_user_flags(struct Client *source_p, const struct AccessItem *aconf) |
746 |
< |
{ |
747 |
< |
/* If this user is being spoofed, tell them so */ |
748 |
< |
if (IsConfDoSpoofIp(aconf)) |
749 |
< |
{ |
750 |
< |
sendto_one(source_p, |
751 |
< |
":%s NOTICE %s :*** Spoofing your IP. congrats.", |
752 |
< |
me.name, source_p->name); |
753 |
< |
} |
754 |
< |
|
755 |
< |
/* If this user is in the exception class, Set it "E lined" */ |
756 |
< |
if (IsConfExemptKline(aconf)) |
757 |
< |
{ |
758 |
< |
SetExemptKline(source_p); |
759 |
< |
sendto_one(source_p, |
760 |
< |
":%s NOTICE %s :*** You are exempt from K/D/G lines. congrats.", |
761 |
< |
me.name, source_p->name); |
762 |
< |
} |
763 |
< |
|
764 |
< |
/* The else here is to make sure that G line exempt users |
765 |
< |
* do not get noticed twice. |
766 |
< |
*/ |
767 |
< |
else if (IsConfExemptGline(aconf)) |
768 |
< |
{ |
769 |
< |
SetExemptGline(source_p); |
770 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines.", |
771 |
< |
me.name, source_p->name); |
772 |
< |
} |
773 |
< |
|
774 |
< |
if (IsConfExemptResv(aconf)) |
775 |
< |
{ |
776 |
< |
SetExemptResv(source_p); |
777 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs.", |
778 |
< |
me.name, source_p->name); |
779 |
< |
} |
780 |
< |
|
781 |
< |
/* If this user is exempt from user limits set it "F lined" */ |
782 |
< |
if (IsConfExemptLimits(aconf)) |
783 |
< |
{ |
784 |
< |
SetExemptLimits(source_p); |
785 |
< |
sendto_one(source_p, |
786 |
< |
":%s NOTICE %s :*** You are exempt from user limits. congrats.", |
787 |
< |
me.name,source_p->name); |
788 |
< |
} |
789 |
< |
|
790 |
< |
/* If this user is exempt from idle time outs */ |
791 |
< |
if (IsConfIdlelined(aconf)) |
605 |
> |
else |
606 |
|
{ |
607 |
< |
SetIdlelined(source_p); |
608 |
< |
sendto_one(source_p, |
609 |
< |
":%s NOTICE %s :*** You are exempt from idle limits. congrats.", |
796 |
< |
me.name, source_p->name); |
607 |
> |
while (*++p) |
608 |
> |
if (!IsUserChar(*p)) |
609 |
> |
return 0; |
610 |
|
} |
611 |
|
|
612 |
< |
if (IsConfCanFlood(aconf)) |
800 |
< |
{ |
801 |
< |
SetCanFlood(source_p); |
802 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from flood " |
803 |
< |
"protection, aren't you fearsome.", |
804 |
< |
me.name, source_p->name); |
805 |
< |
} |
612 |
> |
return p - username <= USERLEN; |
613 |
|
} |
614 |
|
|
615 |
< |
/* do_local_user() |
615 |
> |
/* clean_nick_name() |
616 |
|
* |
617 |
< |
* inputs - |
618 |
< |
* output - NONE |
619 |
< |
* side effects - |
617 |
> |
* input - nickname |
618 |
> |
* - whether it's a local nick (1) or remote (0) |
619 |
> |
* output - none |
620 |
> |
* side effects - walks through the nickname, returning 0 if erroneous |
621 |
|
*/ |
622 |
< |
void |
623 |
< |
do_local_user(const char *nick, struct Client *client_p, struct Client *source_p, |
816 |
< |
const char *username, const char *host, const char *server, |
817 |
< |
const char *realname) |
622 |
> |
int |
623 |
> |
valid_nickname(const char *nickname, const int local) |
624 |
|
{ |
625 |
< |
assert(source_p != NULL); |
820 |
< |
assert(source_p->username != username); |
821 |
< |
|
822 |
< |
if (source_p == NULL) |
823 |
< |
return; |
625 |
> |
const char *p = nickname; |
626 |
|
|
627 |
< |
if (!IsUnknown(source_p)) |
826 |
< |
{ |
827 |
< |
sendto_one(source_p, form_str(ERR_ALREADYREGISTRED), |
828 |
< |
me.name, nick); |
829 |
< |
return; |
830 |
< |
} |
831 |
< |
|
832 |
< |
source_p->localClient->registration &= ~REG_NEED_USER; |
627 |
> |
assert(p); |
628 |
|
|
629 |
|
/* |
630 |
< |
* don't take the clients word for it, ever |
630 |
> |
* Nicks can't start with a digit or - or be 0 length. |
631 |
|
*/ |
632 |
< |
source_p->servptr = &me; |
633 |
< |
|
839 |
< |
strlcpy(source_p->info, realname, sizeof(source_p->info)); |
840 |
< |
|
841 |
< |
if (!IsGotId(source_p)) |
842 |
< |
{ |
843 |
< |
/* save the username in the client |
844 |
< |
* If you move this you'll break ping cookies..you've been warned |
845 |
< |
*/ |
846 |
< |
strlcpy(source_p->username, username, sizeof(source_p->username)); |
847 |
< |
} |
848 |
< |
|
849 |
< |
if (!source_p->localClient->registration) |
850 |
< |
/* NICK already received, now I have USER... */ |
851 |
< |
register_local_user(client_p, source_p, source_p->name, username); |
852 |
< |
} |
853 |
< |
|
854 |
< |
/* change_simple_umode() |
855 |
< |
* |
856 |
< |
* this callback can be hooked to allow special handling of |
857 |
< |
* certain usermodes |
858 |
< |
*/ |
859 |
< |
static void * |
860 |
< |
change_simple_umode(va_list args) |
861 |
< |
{ |
862 |
< |
struct Client *client_p; |
863 |
< |
struct Client *source_p; |
864 |
< |
int what; |
865 |
< |
unsigned int flag; |
866 |
< |
|
867 |
< |
client_p = va_arg(args, struct Client *); |
868 |
< |
source_p = va_arg(args, struct Client *); |
869 |
< |
what = va_arg(args, int); |
870 |
< |
flag = va_arg(args, unsigned int); |
871 |
< |
|
872 |
< |
if (what == MODE_ADD) |
873 |
< |
source_p->umodes |= flag; |
874 |
< |
else |
875 |
< |
source_p->umodes &= ~flag; |
876 |
< |
|
877 |
< |
return NULL; |
878 |
< |
} |
879 |
< |
|
880 |
< |
/* set_user_mode() |
881 |
< |
* |
882 |
< |
* added 15/10/91 By Darren Reed. |
883 |
< |
* parv[0] - sender |
884 |
< |
* parv[1] - username to change mode for |
885 |
< |
* parv[2] - modes to change |
886 |
< |
*/ |
887 |
< |
void |
888 |
< |
set_user_mode(struct Client *client_p, struct Client *source_p, |
889 |
< |
int parc, char *parv[]) |
890 |
< |
{ |
891 |
< |
unsigned int flag, setflags; |
892 |
< |
char **p, *m, buf[IRCD_BUFSIZE]; |
893 |
< |
struct Client *target_p; |
894 |
< |
int what = MODE_ADD, badflag = 0, i; |
895 |
< |
|
896 |
< |
assert(!(parc < 2)); |
897 |
< |
|
898 |
< |
if ((target_p = find_person(client_p, parv[1])) == NULL) |
899 |
< |
{ |
900 |
< |
if (MyConnect(source_p)) |
901 |
< |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
902 |
< |
me.name, source_p->name, parv[1]); |
903 |
< |
return; |
904 |
< |
} |
905 |
< |
|
906 |
< |
if (IsServer(source_p)) |
907 |
< |
{ |
908 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "*** Mode for User %s from %s", |
909 |
< |
parv[1], source_p->name); |
910 |
< |
return; |
911 |
< |
} |
912 |
< |
|
913 |
< |
if (source_p != target_p || target_p->from != source_p->from) |
914 |
< |
{ |
915 |
< |
sendto_one(source_p, form_str(ERR_USERSDONTMATCH), |
916 |
< |
me.name, source_p->name); |
917 |
< |
return; |
918 |
< |
} |
919 |
< |
|
920 |
< |
if (parc < 3) |
921 |
< |
{ |
922 |
< |
m = buf; |
923 |
< |
*m++ = '+'; |
924 |
< |
|
925 |
< |
for (i = 0; i < 128; i++) |
926 |
< |
if (source_p->umodes & user_modes[i]) |
927 |
< |
*m++ = (char)i; |
928 |
< |
*m = '\0'; |
929 |
< |
|
930 |
< |
sendto_one(source_p, form_str(RPL_UMODEIS), |
931 |
< |
me.name, source_p->name, buf); |
932 |
< |
return; |
933 |
< |
} |
934 |
< |
|
935 |
< |
execute_callback(entering_umode_cb, client_p, source_p); |
936 |
< |
|
937 |
< |
/* find flags already set for user */ |
938 |
< |
setflags = source_p->umodes; |
939 |
< |
|
940 |
< |
/* parse mode change string(s) */ |
941 |
< |
for (p = &parv[2]; p && *p; p++) |
942 |
< |
{ |
943 |
< |
for (m = *p; *m; m++) |
944 |
< |
{ |
945 |
< |
switch (*m) |
946 |
< |
{ |
947 |
< |
case '+': |
948 |
< |
what = MODE_ADD; |
949 |
< |
break; |
950 |
< |
case '-': |
951 |
< |
what = MODE_DEL; |
952 |
< |
break; |
953 |
< |
case 'o': |
954 |
< |
if (what == MODE_ADD) |
955 |
< |
{ |
956 |
< |
if (IsServer(client_p) && !IsOper(source_p)) |
957 |
< |
{ |
958 |
< |
++Count.oper; |
959 |
< |
SetOper(source_p); |
960 |
< |
} |
961 |
< |
} |
962 |
< |
else |
963 |
< |
{ |
964 |
< |
/* Only decrement the oper counts if an oper to begin with |
965 |
< |
* found by Pat Szuta, Perly , perly@xnet.com |
966 |
< |
*/ |
967 |
< |
if (!IsOper(source_p)) |
968 |
< |
break; |
969 |
< |
|
970 |
< |
ClearOper(source_p); |
971 |
< |
source_p->umodes &= ~ConfigFileEntry.oper_only_umodes; |
972 |
< |
Count.oper--; |
973 |
< |
|
974 |
< |
if (MyConnect(source_p)) |
975 |
< |
{ |
976 |
< |
dlink_node *dm; |
977 |
< |
|
978 |
< |
detach_conf(source_p, OPER_TYPE); |
979 |
< |
ClearOperFlags(source_p); |
980 |
< |
|
981 |
< |
if ((dm = dlinkFindDelete(&oper_list, source_p)) != NULL) |
982 |
< |
free_dlink_node(dm); |
983 |
< |
} |
984 |
< |
} |
985 |
< |
|
986 |
< |
break; |
987 |
< |
|
988 |
< |
/* we may not get these, |
989 |
< |
* but they shouldnt be in default |
990 |
< |
*/ |
991 |
< |
case ' ' : |
992 |
< |
case '\n': |
993 |
< |
case '\r': |
994 |
< |
case '\t': |
995 |
< |
break; |
996 |
< |
|
997 |
< |
default: |
998 |
< |
if ((flag = user_modes[(unsigned char)*m])) |
999 |
< |
{ |
1000 |
< |
if (MyConnect(source_p) && !IsOper(source_p) && |
1001 |
< |
(ConfigFileEntry.oper_only_umodes & flag)) |
1002 |
< |
{ |
1003 |
< |
badflag = 1; |
1004 |
< |
} |
1005 |
< |
else |
1006 |
< |
execute_callback(umode_cb, client_p, source_p, what, flag); |
1007 |
< |
} |
1008 |
< |
else |
1009 |
< |
{ |
1010 |
< |
if (MyConnect(source_p)) |
1011 |
< |
badflag = 1; |
1012 |
< |
} |
1013 |
< |
|
1014 |
< |
break; |
1015 |
< |
} |
1016 |
< |
} |
1017 |
< |
} |
1018 |
< |
|
1019 |
< |
if (badflag) |
1020 |
< |
sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG), |
1021 |
< |
me.name, source_p->name); |
1022 |
< |
|
1023 |
< |
if ((source_p->umodes & UMODE_NCHANGE) && !IsOperN(source_p)) |
1024 |
< |
{ |
1025 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;", |
1026 |
< |
me.name, source_p->name); |
1027 |
< |
source_p->umodes &= ~UMODE_NCHANGE; /* only tcm's really need this */ |
1028 |
< |
} |
1029 |
< |
|
1030 |
< |
if (MyConnect(source_p) && (source_p->umodes & UMODE_ADMIN) && |
1031 |
< |
!IsOperAdmin(source_p) && !IsOperHiddenAdmin(source_p)) |
1032 |
< |
{ |
1033 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;", |
1034 |
< |
me.name, source_p->name); |
1035 |
< |
source_p->umodes &= ~UMODE_ADMIN; |
1036 |
< |
} |
632 |
> |
if (EmptyString(p) || *p == '-' || (IsDigit(*p) && local)) |
633 |
> |
return 0; |
634 |
|
|
635 |
< |
if (!(setflags & UMODE_INVISIBLE) && IsInvisible(source_p)) |
636 |
< |
++Count.invisi; |
637 |
< |
if ((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p)) |
1041 |
< |
--Count.invisi; |
635 |
> |
for (; *p; ++p) |
636 |
> |
if (!IsNickChar(*p)) |
637 |
> |
return 0; |
638 |
|
|
639 |
< |
/* |
1044 |
< |
* compare new flags with old flags and send string which |
1045 |
< |
* will cause servers to update correctly. |
1046 |
< |
*/ |
1047 |
< |
send_umode_out(client_p, source_p, setflags); |
639 |
> |
return p - nickname <= NICKLEN; |
640 |
|
} |
641 |
|
|
642 |
< |
/* send_umode() |
643 |
< |
* send the MODE string for user (user) to connection client_p |
644 |
< |
* -avalon |
642 |
> |
/*! \brief Builds a mode change string to buffer pointed by \a buf |
643 |
> |
* \param client_p Pointer to client |
644 |
> |
* \param dispatch Whether to send a MODE message to client_p |
645 |
> |
* \param old Old user mode to compare against when building new mode buffer |
646 |
> |
* \param buf Pointer to buffer to build string in |
647 |
|
*/ |
648 |
|
void |
649 |
< |
send_umode(struct Client *client_p, struct Client *source_p, |
650 |
< |
unsigned int old, unsigned int sendmask, char *umode_buf) |
649 |
> |
send_umode(struct Client *client_p, unsigned int dispatch, |
650 |
> |
unsigned int old, char *buf) |
651 |
|
{ |
652 |
+ |
char *m = buf; |
653 |
|
int what = 0; |
1059 |
– |
unsigned int i; |
1060 |
– |
unsigned int flag; |
1061 |
– |
char *m = umode_buf; |
654 |
|
|
655 |
|
/* |
656 |
< |
* build a string in umode_buf to represent the change in the user's |
657 |
< |
* mode between the new (source_p->umodes) and 'old'. |
656 |
> |
* Build a string in umode_buf to represent the change in the user's |
657 |
> |
* mode between the new (client_p->umodes) and 'old'. |
658 |
|
*/ |
659 |
< |
for (i = 0; i < 128; i++) |
659 |
> |
for (const struct user_modes *tab = umode_tab; tab->c; ++tab) |
660 |
|
{ |
661 |
< |
flag = user_modes[i]; |
1070 |
< |
if (!flag) |
1071 |
< |
continue; |
1072 |
< |
|
1073 |
< |
if (MyClient(source_p) && !(flag & sendmask)) |
1074 |
< |
continue; |
1075 |
< |
|
1076 |
< |
if ((flag & old) && !(source_p->umodes & flag)) |
661 |
> |
if ((tab->flag & old) && !HasUMode(client_p, tab->flag)) |
662 |
|
{ |
663 |
|
if (what == MODE_DEL) |
664 |
< |
*m++ = (char)i; |
664 |
> |
*m++ = tab->c; |
665 |
|
else |
666 |
|
{ |
667 |
|
what = MODE_DEL; |
668 |
|
*m++ = '-'; |
669 |
< |
*m++ = (char)i; |
669 |
> |
*m++ = tab->c; |
670 |
|
} |
671 |
|
} |
672 |
< |
else if (!(flag & old) && (source_p->umodes & flag)) |
672 |
> |
else if (!(tab->flag & old) && HasUMode(client_p, tab->flag)) |
673 |
|
{ |
674 |
|
if (what == MODE_ADD) |
675 |
< |
*m++ = (char)i; |
675 |
> |
*m++ = tab->c; |
676 |
|
else |
677 |
|
{ |
678 |
|
what = MODE_ADD; |
679 |
|
*m++ = '+'; |
680 |
< |
*m++ = (char)i; |
680 |
> |
*m++ = tab->c; |
681 |
|
} |
682 |
|
} |
683 |
|
} |
684 |
|
|
685 |
|
*m = '\0'; |
686 |
|
|
687 |
< |
if (*umode_buf && client_p) |
687 |
> |
if (dispatch && *buf) |
688 |
|
sendto_one(client_p, ":%s!%s@%s MODE %s :%s", |
689 |
< |
source_p->name, source_p->username, |
690 |
< |
source_p->host, source_p->name, umode_buf); |
689 |
> |
client_p->name, client_p->username, |
690 |
> |
client_p->host, client_p->name, buf); |
691 |
|
} |
692 |
|
|
693 |
|
/* send_umode_out() |
697 |
|
* side effects - Only send ubuf out to servers that know about this client |
698 |
|
*/ |
699 |
|
void |
700 |
< |
send_umode_out(struct Client *client_p, struct Client *source_p, |
1116 |
< |
unsigned int old) |
700 |
> |
send_umode_out(struct Client *client_p, unsigned int old) |
701 |
|
{ |
702 |
< |
char buf[IRCD_BUFSIZE] = { '\0' }; |
1119 |
< |
dlink_node *ptr = NULL; |
702 |
> |
char buf[IRCD_BUFSIZE] = ""; |
703 |
|
|
704 |
< |
send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ? |
1122 |
< |
SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf); |
704 |
> |
send_umode(client_p, MyConnect(client_p), old, buf); |
705 |
|
|
706 |
|
if (buf[0]) |
707 |
< |
{ |
708 |
< |
DLINK_FOREACH(ptr, serv_list.head) |
1127 |
< |
{ |
1128 |
< |
struct Client *target_p = ptr->data; |
1129 |
< |
|
1130 |
< |
if ((target_p != client_p) && (target_p != source_p)) |
1131 |
< |
{ |
1132 |
< |
if ((!(ServerInfo.hub && IsCapable(target_p, CAP_LL))) || |
1133 |
< |
(target_p->localClient->serverMask & |
1134 |
< |
source_p->lazyLinkClientExists)) |
1135 |
< |
sendto_one(target_p, ":%s MODE %s :%s", |
1136 |
< |
ID_or_name(source_p, target_p), |
1137 |
< |
ID_or_name(source_p, target_p), buf); |
1138 |
< |
} |
1139 |
< |
} |
1140 |
< |
} |
1141 |
< |
|
1142 |
< |
if (client_p && MyClient(client_p)) |
1143 |
< |
send_umode(client_p, source_p, old, 0xffffffff, buf); |
1144 |
< |
} |
1145 |
< |
|
1146 |
< |
/* user_welcome() |
1147 |
< |
* |
1148 |
< |
* inputs - client pointer to client to welcome |
1149 |
< |
* output - NONE |
1150 |
< |
* side effects - |
1151 |
< |
*/ |
1152 |
< |
static void |
1153 |
< |
user_welcome(struct Client *source_p) |
1154 |
< |
{ |
1155 |
< |
#if defined(__TIME__) && defined(__DATE__) |
1156 |
< |
static const char built_date[] = __DATE__ " at " __TIME__; |
1157 |
< |
#else |
1158 |
< |
static const char built_date[] = "unknown"; |
1159 |
< |
#endif |
1160 |
< |
|
1161 |
< |
#ifdef HAVE_LIBCRYPTO |
1162 |
< |
if (source_p->localClient->fd.ssl != NULL) |
1163 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Connected securely via %s", |
1164 |
< |
me.name, source_p->name, |
1165 |
< |
ssl_get_cipher(source_p->localClient->fd.ssl)); |
1166 |
< |
#endif |
1167 |
< |
|
1168 |
< |
sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name, |
1169 |
< |
ServerInfo.network_name, source_p->name); |
1170 |
< |
sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name, |
1171 |
< |
get_listener_name(source_p->localClient->listener), ircd_version); |
1172 |
< |
sendto_one(source_p, form_str(RPL_CREATED), |
1173 |
< |
me.name, source_p->name, built_date); |
1174 |
< |
sendto_one(source_p, form_str(RPL_MYINFO), |
1175 |
< |
me.name, source_p->name, me.name, ircd_version, umode_buffer); |
1176 |
< |
show_isupport(source_p); |
1177 |
< |
|
1178 |
< |
if (source_p->id[0] != '\0') |
1179 |
< |
sendto_one(source_p, form_str(RPL_YOURID), me.name, |
1180 |
< |
source_p->name, source_p->id); |
1181 |
< |
|
1182 |
< |
show_lusers(source_p); |
1183 |
< |
|
1184 |
< |
if (ConfigFileEntry.short_motd) |
1185 |
< |
{ |
1186 |
< |
sendto_one(source_p, "NOTICE %s :*** Notice -- motd was last changed at %s", |
1187 |
< |
source_p->name, ConfigFileEntry.motd.lastChangedDate); |
1188 |
< |
sendto_one(source_p, |
1189 |
< |
"NOTICE %s :*** Notice -- Please read the motd if you haven't " |
1190 |
< |
"read it", source_p->name); |
1191 |
< |
sendto_one(source_p, form_str(RPL_MOTDSTART), |
1192 |
< |
me.name, source_p->name, me.name); |
1193 |
< |
sendto_one(source_p, form_str(RPL_MOTD), |
1194 |
< |
me.name, source_p->name, |
1195 |
< |
"*** This is the short motd ***"); |
1196 |
< |
sendto_one(source_p, form_str(RPL_ENDOFMOTD), |
1197 |
< |
me.name, source_p->name); |
1198 |
< |
} |
1199 |
< |
else |
1200 |
< |
send_message_file(source_p, &ConfigFileEntry.motd); |
1201 |
< |
} |
1202 |
< |
|
1203 |
< |
/* check_xline() |
1204 |
< |
* |
1205 |
< |
* inputs - pointer to client to test |
1206 |
< |
* outupt - 1 if exiting 0 if ok |
1207 |
< |
* side effects - |
1208 |
< |
*/ |
1209 |
< |
static int |
1210 |
< |
check_xline(struct Client *source_p) |
1211 |
< |
{ |
1212 |
< |
struct ConfItem *conf = NULL; |
1213 |
< |
const char *reason = NULL; |
1214 |
< |
|
1215 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) || |
1216 |
< |
(conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0))) |
1217 |
< |
{ |
1218 |
< |
struct MatchItem *reg = map_to_conf(conf); |
1219 |
< |
|
1220 |
< |
++reg->count; |
1221 |
< |
|
1222 |
< |
if (reg->reason != NULL) |
1223 |
< |
reason = reg->reason; |
1224 |
< |
else |
1225 |
< |
reason = "No Reason"; |
1226 |
< |
|
1227 |
< |
sendto_realops_flags(UMODE_REJ, L_ALL, |
1228 |
< |
"X-line Rejecting [%s] [%s], user %s [%s]", |
1229 |
< |
source_p->info, reason, |
1230 |
< |
get_client_name(source_p, HIDE_IP), |
1231 |
< |
source_p->sockhost); |
1232 |
< |
|
1233 |
< |
ServerStats->is_ref++; |
1234 |
< |
if (REJECT_HOLD_TIME > 0) |
1235 |
< |
{ |
1236 |
< |
sendto_one(source_p, ":%s NOTICE %s :Bad user info", |
1237 |
< |
me.name, source_p->name); |
1238 |
< |
source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME; |
1239 |
< |
SetCaptured(source_p); |
1240 |
< |
} |
1241 |
< |
else |
1242 |
< |
exit_client(source_p, &me, "Bad user info"); |
1243 |
< |
return 1; |
1244 |
< |
} |
1245 |
< |
|
1246 |
< |
return 0; |
707 |
> |
sendto_server(client_p, 0, 0, ":%s MODE %s :%s", |
708 |
> |
client_p->id, client_p->id, buf); |
709 |
|
} |
710 |
|
|
1249 |
– |
/* oper_up() |
1250 |
– |
* |
1251 |
– |
* inputs - pointer to given client to oper |
1252 |
– |
* output - NONE |
1253 |
– |
* side effects - Blindly opers up given source_p, using aconf info |
1254 |
– |
* all checks on passwords have already been done. |
1255 |
– |
* This could also be used by rsa oper routines. |
1256 |
– |
*/ |
711 |
|
void |
712 |
< |
oper_up(struct Client *source_p) |
712 |
> |
user_set_hostmask(struct Client *client_p, const char *hostname, const int what) |
713 |
|
{ |
714 |
< |
unsigned int old = source_p->umodes; |
1261 |
< |
const char *operprivs = ""; |
1262 |
< |
const struct AccessItem *oconf = NULL; |
1263 |
< |
|
1264 |
< |
assert(source_p->localClient->confs.head); |
1265 |
< |
oconf = map_to_conf((source_p->localClient->confs.head)->data); |
1266 |
< |
|
1267 |
< |
++Count.oper; |
1268 |
< |
SetOper(source_p); |
1269 |
< |
|
1270 |
< |
if (oconf->modes) |
1271 |
< |
source_p->umodes |= oconf->modes; |
1272 |
< |
else if (ConfigFileEntry.oper_umodes) |
1273 |
< |
source_p->umodes |= ConfigFileEntry.oper_umodes; |
1274 |
< |
else |
1275 |
< |
source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL| |
1276 |
< |
UMODE_WALLOP|UMODE_LOCOPS); |
1277 |
< |
|
1278 |
< |
assert(dlinkFind(&oper_list, source_p) == NULL); |
1279 |
< |
dlinkAdd(source_p, make_dlink_node(), &oper_list); |
1280 |
< |
|
1281 |
< |
operprivs = oper_privs_as_string(oconf->port); |
1282 |
< |
|
1283 |
< |
SetOFlag(source_p, oconf->port); |
1284 |
< |
|
1285 |
< |
if (IsOperAdmin(source_p) || IsOperHiddenAdmin(source_p)) |
1286 |
< |
source_p->umodes |= UMODE_ADMIN; |
1287 |
< |
if (!IsOperN(source_p)) |
1288 |
< |
source_p->umodes &= ~UMODE_NCHANGE; |
1289 |
< |
|
1290 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s (%s@%s) is now an operator", |
1291 |
< |
source_p->name, source_p->username, source_p->host); |
1292 |
< |
send_umode_out(source_p, source_p, old); |
1293 |
< |
sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name); |
1294 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Oper privs are %s", |
1295 |
< |
me.name, source_p->name, operprivs); |
1296 |
< |
send_message_file(source_p, &ConfigFileEntry.opermotd); |
1297 |
< |
} |
714 |
> |
dlink_node *node = NULL; |
715 |
|
|
716 |
< |
static char new_uid[TOTALSIDUID + 1]; /* allow for \0 */ |
717 |
< |
|
1301 |
< |
int |
1302 |
< |
valid_sid(const char *sid) |
1303 |
< |
{ |
1304 |
< |
|
1305 |
< |
if (strlen(sid) == IRC_MAXSID) |
1306 |
< |
if (IsDigit(*sid)) |
1307 |
< |
if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2))) |
1308 |
< |
return 1; |
1309 |
< |
|
1310 |
< |
return 0; |
1311 |
< |
} |
1312 |
< |
|
1313 |
< |
/* |
1314 |
< |
* init_uid() |
1315 |
< |
* |
1316 |
< |
* inputs - NONE |
1317 |
< |
* output - NONE |
1318 |
< |
* side effects - new_uid is filled in with server id portion (sid) |
1319 |
< |
* (first 3 bytes) or defaulted to 'A'. |
1320 |
< |
* Rest is filled in with 'A' |
1321 |
< |
*/ |
1322 |
< |
void |
1323 |
< |
init_uid(void) |
1324 |
< |
{ |
1325 |
< |
int i; |
1326 |
< |
|
1327 |
< |
memset(new_uid, 0, sizeof(new_uid)); |
716 |
> |
if (!strcmp(client_p->host, hostname)) |
717 |
> |
return; |
718 |
|
|
719 |
< |
if (ServerInfo.sid != NULL) |
719 |
> |
switch (what) |
720 |
|
{ |
721 |
< |
strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid)); |
722 |
< |
strlcpy(me.id, ServerInfo.sid, sizeof(me.id)); |
723 |
< |
|
724 |
< |
hash_add_id(&me); |
721 |
> |
case MODE_ADD: |
722 |
> |
AddUMode(client_p, UMODE_HIDDENHOST); |
723 |
> |
break; |
724 |
> |
case MODE_DEL: |
725 |
> |
DelUMode(client_p, UMODE_HIDDENHOST); |
726 |
> |
break; |
727 |
> |
default: return; |
728 |
|
} |
729 |
|
|
730 |
< |
for (i = 0; i < IRC_MAXSID; i++) |
731 |
< |
if (new_uid[i] == '\0') |
732 |
< |
new_uid[i] = 'A'; |
730 |
> |
if (ConfigGeneral.cycle_on_host_change) |
731 |
> |
sendto_common_channels_local(client_p, 0, 0, CAP_CHGHOST, ":%s!%s@%s QUIT :Changing hostname", |
732 |
> |
client_p->name, client_p->username, client_p->host); |
733 |
|
|
734 |
< |
/* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */ |
735 |
< |
/* Yes nenolod, I have known it was off by one ever since I wrote it |
736 |
< |
* But *JUST* for you, though, it really doesn't look as *pretty* |
1344 |
< |
* -Dianora |
1345 |
< |
*/ |
1346 |
< |
memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID); |
734 |
> |
sendto_common_channels_local(client_p, 0, CAP_CHGHOST, 0, ":%s!%s@%s CHGHOST %s %s", |
735 |
> |
client_p->name, client_p->username, |
736 |
> |
client_p->host, client_p->username, hostname); |
737 |
|
|
738 |
< |
entering_umode_cb = register_callback("entering_umode", NULL); |
1349 |
< |
umode_cb = register_callback("changing_umode", change_simple_umode); |
1350 |
< |
uid_get_cb = register_callback("uid_get", uid_get); |
1351 |
< |
} |
738 |
> |
strlcpy(client_p->host, hostname, sizeof(client_p->host)); |
739 |
|
|
740 |
< |
/* |
1354 |
< |
* add_one_to_uid |
1355 |
< |
* |
1356 |
< |
* inputs - index number into new_uid |
1357 |
< |
* output - NONE |
1358 |
< |
* side effects - new_uid is incremented by one |
1359 |
< |
* note this is a recursive function |
1360 |
< |
*/ |
1361 |
< |
static void |
1362 |
< |
add_one_to_uid(int i) |
1363 |
< |
{ |
1364 |
< |
if (i != IRC_MAXSID) /* Not reached server SID portion yet? */ |
740 |
> |
if (MyConnect(client_p)) |
741 |
|
{ |
742 |
< |
if (new_uid[i] == 'Z') |
743 |
< |
new_uid[i] = '0'; |
1368 |
< |
else if (new_uid[i] == '9') |
1369 |
< |
{ |
1370 |
< |
new_uid[i] = 'A'; |
1371 |
< |
add_one_to_uid(i-1); |
1372 |
< |
} |
1373 |
< |
else |
1374 |
< |
++new_uid[i]; |
742 |
> |
sendto_one_numeric(client_p, &me, RPL_VISIBLEHOST, client_p->host); |
743 |
> |
clear_ban_cache_list(&client_p->channel); |
744 |
|
} |
1376 |
– |
else |
1377 |
– |
{ |
1378 |
– |
/* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */ |
1379 |
– |
if (new_uid[i] == 'Z') |
1380 |
– |
memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID); |
1381 |
– |
else |
1382 |
– |
++new_uid[i]; |
1383 |
– |
} |
1384 |
– |
} |
1385 |
– |
|
1386 |
– |
/* |
1387 |
– |
* uid_get |
1388 |
– |
* |
1389 |
– |
* inputs - struct Client * |
1390 |
– |
* output - new UID is returned to caller |
1391 |
– |
* side effects - new_uid is incremented by one. |
1392 |
– |
*/ |
1393 |
– |
static void * |
1394 |
– |
uid_get(va_list args) |
1395 |
– |
{ |
1396 |
– |
add_one_to_uid(TOTALSIDUID - 1); /* index from 0 */ |
1397 |
– |
return new_uid; |
1398 |
– |
} |
1399 |
– |
|
1400 |
– |
/* |
1401 |
– |
* init_isupport() |
1402 |
– |
* |
1403 |
– |
* input - NONE |
1404 |
– |
* output - NONE |
1405 |
– |
* side effects - Must be called before isupport is enabled |
1406 |
– |
*/ |
1407 |
– |
void |
1408 |
– |
init_isupport(void) |
1409 |
– |
{ |
1410 |
– |
isupportFile = init_MessageLine(); |
1411 |
– |
|
1412 |
– |
add_isupport("CALLERID", NULL, -1); |
1413 |
– |
add_isupport("CASEMAPPING", CASEMAP, -1); |
1414 |
– |
add_isupport("DEAF", "D", -1); |
1415 |
– |
add_isupport("KICKLEN", NULL, KICKLEN); |
1416 |
– |
add_isupport("MODES", NULL, MAXMODEPARAMS); |
1417 |
– |
add_isupport("NICKLEN", NULL, NICKLEN-1); |
1418 |
– |
#ifdef HALFOPS |
1419 |
– |
add_isupport("PREFIX", "(ohv)@%+", -1); |
1420 |
– |
add_isupport("STATUSMSG", "@%+", -1); |
1421 |
– |
#else |
1422 |
– |
add_isupport("PREFIX", "(ov)@+", -1); |
1423 |
– |
add_isupport("STATUSMSG", "@+", -1); |
1424 |
– |
#endif |
1425 |
– |
add_isupport("TOPICLEN", NULL, TOPICLEN); |
1426 |
– |
} |
745 |
|
|
746 |
< |
/* |
747 |
< |
* add_isupport() |
1430 |
< |
* |
1431 |
< |
* input - name of supported function |
1432 |
< |
* - options if any |
1433 |
< |
* - number if any |
1434 |
< |
* output - NONE |
1435 |
< |
* side effects - Each supported item must call this when activated |
1436 |
< |
*/ |
1437 |
< |
void |
1438 |
< |
add_isupport(const char *name, const char *options, int n) |
1439 |
< |
{ |
1440 |
< |
dlink_node *ptr; |
1441 |
< |
struct Isupport *support; |
746 |
> |
if (!ConfigGeneral.cycle_on_host_change) |
747 |
> |
return; |
748 |
|
|
749 |
< |
DLINK_FOREACH(ptr, support_list.head) |
749 |
> |
DLINK_FOREACH(node, client_p->channel.head) |
750 |
|
{ |
751 |
< |
support = ptr->data; |
752 |
< |
if (irccmp(support->name, name) == 0) |
753 |
< |
{ |
754 |
< |
MyFree(support->name); |
755 |
< |
MyFree(support->options); |
1450 |
< |
break; |
1451 |
< |
} |
1452 |
< |
} |
751 |
> |
char modebuf[CMEMBER_STATUS_FLAGS_LEN + 1]; |
752 |
> |
char nickbuf[CMEMBER_STATUS_FLAGS_LEN * NICKLEN + CMEMBER_STATUS_FLAGS_LEN] = ""; |
753 |
> |
char *p = modebuf; |
754 |
> |
int len = 0; |
755 |
> |
const struct Membership *member = node->data; |
756 |
|
|
757 |
< |
if (ptr == NULL) |
1455 |
< |
{ |
1456 |
< |
support = MyMalloc(sizeof(*support)); |
1457 |
< |
dlinkAddTail(support, &support->node, &support_list); |
1458 |
< |
} |
1459 |
< |
|
1460 |
< |
DupString(support->name, name); |
1461 |
< |
if (options != NULL) |
1462 |
< |
DupString(support->options, options); |
1463 |
< |
support->number = n; |
1464 |
< |
|
1465 |
< |
rebuild_isupport_message_line(); |
1466 |
< |
} |
1467 |
< |
|
1468 |
< |
/* |
1469 |
< |
* delete_isupport() |
1470 |
< |
* |
1471 |
< |
* input - name of supported function |
1472 |
< |
* output - NONE |
1473 |
< |
* side effects - Each supported item must call this when deactivated |
1474 |
< |
*/ |
1475 |
< |
void |
1476 |
< |
delete_isupport(const char *name) |
1477 |
< |
{ |
1478 |
< |
dlink_node *ptr; |
1479 |
< |
struct Isupport *support; |
1480 |
< |
|
1481 |
< |
DLINK_FOREACH(ptr, support_list.head) |
1482 |
< |
{ |
1483 |
< |
support = ptr->data; |
1484 |
< |
if (irccmp(support->name, name) == 0) |
757 |
> |
if (has_member_flags(member, CHFL_CHANOP)) |
758 |
|
{ |
759 |
< |
dlinkDelete(ptr, &support_list); |
760 |
< |
MyFree(support->name); |
1488 |
< |
MyFree(support->options); |
1489 |
< |
MyFree(support); |
1490 |
< |
break; |
759 |
> |
*p++ = 'o'; |
760 |
> |
len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", client_p->name); |
761 |
|
} |
1492 |
– |
} |
1493 |
– |
|
1494 |
– |
rebuild_isupport_message_line(); |
1495 |
– |
} |
1496 |
– |
|
1497 |
– |
/* |
1498 |
– |
* rebuild_isupport_message_line |
1499 |
– |
* |
1500 |
– |
* input - NONE |
1501 |
– |
* output - NONE |
1502 |
– |
* side effects - Destroy the isupport MessageFile lines, and rebuild. |
1503 |
– |
*/ |
1504 |
– |
void |
1505 |
– |
rebuild_isupport_message_line(void) |
1506 |
– |
{ |
1507 |
– |
char isupportbuffer[IRCD_BUFSIZE]; |
1508 |
– |
char *p = isupportbuffer; |
1509 |
– |
dlink_node *ptr = NULL; |
1510 |
– |
int n = 0; |
1511 |
– |
int tokens = 0; |
1512 |
– |
size_t len = 0; |
1513 |
– |
size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT)); |
1514 |
– |
|
1515 |
– |
destroy_MessageLine(isupportFile); |
1516 |
– |
|
1517 |
– |
DLINK_FOREACH(ptr, support_list.head) |
1518 |
– |
{ |
1519 |
– |
struct Isupport *support = ptr->data; |
762 |
|
|
763 |
< |
p += (n = ircsprintf(p, "%s", support->name)); |
1522 |
< |
len += n; |
1523 |
< |
|
1524 |
< |
if (support->options != NULL) |
763 |
> |
if (has_member_flags(member, CHFL_HALFOP)) |
764 |
|
{ |
765 |
< |
p += (n = ircsprintf(p, "=%s", support->options)); |
766 |
< |
len += n; |
765 |
> |
*p++ = 'h'; |
766 |
> |
len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", client_p->name); |
767 |
|
} |
768 |
|
|
769 |
< |
if (support->number > 0) |
769 |
> |
if (has_member_flags(member, CHFL_VOICE)) |
770 |
|
{ |
771 |
< |
p += (n = ircsprintf(p, "=%d", support->number)); |
772 |
< |
len += n; |
771 |
> |
*p++ = 'v'; |
772 |
> |
len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", client_p->name); |
773 |
|
} |
774 |
|
|
1536 |
– |
*p++ = ' '; |
1537 |
– |
len++; |
775 |
|
*p = '\0'; |
776 |
|
|
777 |
< |
if (++tokens == (MAXPARA-2) || len >= (sizeof(isupportbuffer)-reserve)) |
778 |
< |
{ /* arbritrary for now */ |
779 |
< |
if (*--p == ' ') |
780 |
< |
*p = '\0'; |
781 |
< |
|
782 |
< |
addto_MessageLine(isupportFile, isupportbuffer); |
783 |
< |
p = isupportbuffer; |
784 |
< |
len = 0; |
785 |
< |
n = tokens = 0; |
786 |
< |
} |
787 |
< |
} |
788 |
< |
|
789 |
< |
if (len != 0) |
790 |
< |
{ |
791 |
< |
if (*--p == ' ') |
792 |
< |
*p = '\0'; |
793 |
< |
addto_MessageLine(isupportFile, isupportbuffer); |
794 |
< |
} |
777 |
> |
sendto_channel_local(client_p, member->chptr, 0, CAP_EXTENDED_JOIN, CAP_CHGHOST, ":%s!%s@%s JOIN %s %s :%s", |
778 |
> |
client_p->name, client_p->username, |
779 |
> |
client_p->host, member->chptr->name, |
780 |
> |
client_p->account, client_p->info); |
781 |
> |
sendto_channel_local(client_p, member->chptr, 0, 0, CAP_EXTENDED_JOIN | CAP_CHGHOST, ":%s!%s@%s JOIN :%s", |
782 |
> |
client_p->name, client_p->username, |
783 |
> |
client_p->host, member->chptr->name); |
784 |
> |
|
785 |
> |
if (nickbuf[0]) |
786 |
> |
sendto_channel_local(client_p, member->chptr, 0, 0, CAP_CHGHOST, ":%s MODE %s +%s %s", |
787 |
> |
client_p->servptr->name, member->chptr->name, |
788 |
> |
modebuf, nickbuf); |
789 |
> |
} |
790 |
> |
|
791 |
> |
if (client_p->away[0]) |
792 |
> |
sendto_common_channels_local(client_p, 0, CAP_AWAY_NOTIFY, CAP_CHGHOST, |
793 |
> |
":%s!%s@%s AWAY :%s", |
794 |
> |
client_p->name, client_p->username, |
795 |
> |
client_p->host, client_p->away); |
796 |
|
} |