1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* m_knock.c: Requests to be invited to a channel. |
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) 1998-2014 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 |
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 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file m_knock.c |
23 |
> |
* \brief Includes required functions for processing the KNOCK command. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
31 |
|
#include "client.h" |
32 |
|
#include "hash.h" |
33 |
|
#include "irc_string.h" |
32 |
– |
#include "sprintf_irc.h" |
34 |
|
#include "ircd.h" |
35 |
|
#include "numeric.h" |
36 |
|
#include "send.h" |
42 |
|
|
43 |
|
|
44 |
|
/* m_knock |
45 |
< |
* parv[0] = sender prefix |
45 |
> |
* parv[0] = command |
46 |
|
* parv[1] = channel |
47 |
|
* |
48 |
|
* The KNOCK command has the following syntax: |
55 |
|
* of these conditions. Concept by Dianora <db@db.net> and written by |
56 |
|
* <anonymous> |
57 |
|
*/ |
58 |
< |
static void |
59 |
< |
m_knock(struct Client *client_p, struct Client *source_p, |
59 |
< |
int parc, char *parv[]) |
58 |
> |
static int |
59 |
> |
m_knock(struct Client *source_p, int parc, char *parv[]) |
60 |
|
{ |
61 |
|
struct Channel *chptr = NULL; |
62 |
|
|
63 |
|
if (EmptyString(parv[1])) |
64 |
|
{ |
65 |
< |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
66 |
< |
me.name, source_p->name, "KNOCK"); |
67 |
< |
return; |
68 |
< |
} |
69 |
< |
|
70 |
< |
if (!ConfigChannel.use_knock && MyClient(source_p)) |
71 |
< |
{ |
72 |
< |
sendto_one(source_p, form_str(ERR_KNOCKDISABLED), |
73 |
< |
me.name, source_p->name); |
74 |
< |
return; |
65 |
> |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "KNOCK"); |
66 |
> |
return 0; |
67 |
|
} |
68 |
|
|
69 |
|
if ((chptr = hash_find_channel(parv[1])) == NULL) |
70 |
|
{ |
71 |
< |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
72 |
< |
me.name, source_p->name, parv[1]); |
81 |
< |
return; |
71 |
> |
sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[1]); |
72 |
> |
return 0; |
73 |
|
} |
74 |
|
|
75 |
|
/* Normal channel, just be sure they aren't on it */ |
76 |
|
if (IsMember(source_p, chptr)) |
77 |
|
{ |
78 |
< |
sendto_one(source_p, form_str(ERR_KNOCKONCHAN), me.name, |
79 |
< |
source_p->name, chptr->chname); |
89 |
< |
return; |
78 |
> |
sendto_one_numeric(source_p, &me, ERR_KNOCKONCHAN, chptr->chname); |
79 |
> |
return 0; |
80 |
|
} |
81 |
|
|
82 |
|
if (!((chptr->mode.mode & MODE_INVITEONLY) || (*chptr->mode.key) || |
83 |
|
(chptr->mode.limit && dlink_list_length(&chptr->members) >= |
84 |
|
chptr->mode.limit))) |
85 |
|
{ |
86 |
< |
sendto_one(source_p, form_str(ERR_CHANOPEN), me.name, |
87 |
< |
source_p->name, chptr->chname); |
98 |
< |
return; |
86 |
> |
sendto_one_numeric(source_p, &me, ERR_CHANOPEN, chptr->chname); |
87 |
> |
return 0; |
88 |
|
} |
89 |
|
|
90 |
|
if (MyClient(source_p)) |
94 |
|
*/ |
95 |
|
if (PrivateChannel(chptr) || is_banned(chptr, source_p)) |
96 |
|
{ |
97 |
< |
sendto_one(source_p, form_str(ERR_CANNOTSENDTOCHAN), |
98 |
< |
me.name, source_p->name, chptr->chname); |
110 |
< |
return; |
97 |
> |
sendto_one_numeric(source_p, &me, ERR_CANNOTSENDTOCHAN, chptr->chname); |
98 |
> |
return 0; |
99 |
|
} |
100 |
|
|
101 |
|
/* |
108 |
|
if ((source_p->localClient->last_knock + ConfigChannel.knock_delay) > |
109 |
|
CurrentTime) |
110 |
|
{ |
111 |
< |
sendto_one(source_p, form_str(ERR_TOOMANYKNOCK), me.name, |
112 |
< |
source_p->name, chptr->chname, "user"); |
125 |
< |
return; |
111 |
> |
sendto_one_numeric(source_p, &me, ERR_TOOMANYKNOCK, chptr->chname, "user"); |
112 |
> |
return 0; |
113 |
|
} |
114 |
|
|
115 |
|
if ((chptr->last_knock + ConfigChannel.knock_delay_channel) > CurrentTime) |
116 |
|
{ |
117 |
< |
sendto_one(source_p, form_str(ERR_TOOMANYKNOCK), me.name, |
118 |
< |
source_p->name, chptr->chname, "channel"); |
132 |
< |
return; |
117 |
> |
sendto_one_numeric(source_p, &me, ERR_TOOMANYKNOCK, chptr->chname, "channel"); |
118 |
> |
return 0; |
119 |
|
} |
120 |
|
|
121 |
|
source_p->localClient->last_knock = CurrentTime; |
122 |
< |
|
137 |
< |
sendto_one(source_p, form_str(RPL_KNOCKDLVR), me.name, |
138 |
< |
source_p->name, chptr->chname); |
122 |
> |
sendto_one_numeric(source_p, &me, RPL_KNOCKDLVR, chptr->chname); |
123 |
|
} |
124 |
|
|
125 |
|
chptr->last_knock = CurrentTime; |
126 |
|
|
127 |
< |
if (ConfigChannel.use_knock) |
128 |
< |
sendto_channel_local(CHFL_CHANOP, 0, chptr, form_str(RPL_KNOCK), |
129 |
< |
me.name, chptr->chname, chptr->chname, |
130 |
< |
source_p->name, source_p->username, |
131 |
< |
source_p->host); |
132 |
< |
|
133 |
< |
sendto_server(client_p, chptr, CAP_KNOCK|CAP_TS6, NOCAPS, |
134 |
< |
":%s KNOCK %s", ID(source_p), chptr->chname); |
135 |
< |
sendto_server(client_p, chptr, CAP_KNOCK, CAP_TS6, |
136 |
< |
":%s KNOCK %s", source_p->name, chptr->chname); |
127 |
> |
sendto_channel_local(CHFL_CHANOP, 0, chptr, |
128 |
> |
":%s NOTICE @%s :KNOCK: %s (%s [%s@%s] has asked for an invite)", |
129 |
> |
me.name, chptr->chname, chptr->chname, |
130 |
> |
source_p->name, |
131 |
> |
source_p->username, |
132 |
> |
source_p->host); |
133 |
> |
|
134 |
> |
sendto_server(source_p, CAP_KNOCK, NOCAPS, ":%s KNOCK %s", |
135 |
> |
source_p->id, chptr->chname); |
136 |
> |
return 0; |
137 |
|
} |
138 |
|
|
139 |
< |
static struct Message knock_msgtab = { |
139 |
> |
static struct Message knock_msgtab = |
140 |
> |
{ |
141 |
|
"KNOCK", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
142 |
|
{ m_unregistered, m_knock, m_knock, m_ignore, m_knock, m_ignore } |
143 |
|
}; |
158 |
|
delete_isupport("KNOCK"); |
159 |
|
} |
160 |
|
|
161 |
< |
struct module module_entry = { |
161 |
> |
struct module module_entry = |
162 |
> |
{ |
163 |
|
.node = { NULL, NULL, NULL }, |
164 |
|
.name = NULL, |
165 |
|
.version = "$Revision$", |