8 |
* Based on the original code of Epona by Lara. |
* Based on the original code of Epona by Lara. |
9 |
* Based on the original code of Services by Andy Church. |
* Based on the original code of Services by Andy Church. |
10 |
* |
* |
|
* $Id$ |
|
11 |
*/ |
*/ |
12 |
|
|
13 |
#include "module.h" |
#include "module.h" |
16 |
|
|
17 |
class HybridProto : public IRCDProto |
class HybridProto : public IRCDProto |
18 |
{ |
{ |
19 |
public: |
public: |
20 |
HybridProto() : IRCDProto("Hybrid 8.0.0") |
HybridProto() : IRCDProto("Hybrid 8.0.0") |
21 |
{ |
{ |
22 |
DefaultPseudoclientModes = "+oi"; |
DefaultPseudoclientModes = "+oi"; |
23 |
CanSNLine = true; |
CanSNLine = true; |
24 |
CanSQLine = true; |
CanSQLine = true; |
25 |
CanSZLine = true; |
CanSZLine = true; |
26 |
RequiresID = true; |
RequiresID = true; |
27 |
MaxModes = 4; |
MaxModes = 4; |
28 |
} |
} |
29 |
|
|
30 |
void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override |
void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override |
31 |
{ |
{ |
32 |
UplinkSocket::Message(bi) << "NOTICE $$" << dest->GetName() << " :" << msg; |
UplinkSocket::Message(bi) << "NOTICE $$" << dest->GetName() << " :" << msg; |
33 |
} |
} |
34 |
|
|
35 |
void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override |
void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override |
36 |
{ |
{ |
37 |
UplinkSocket::Message(bi) << "PRIVMSG $$" << dest->GetName() << " :" << msg; |
UplinkSocket::Message(bi) << "PRIVMSG $$" << dest->GetName() << " :" << msg; |
38 |
} |
} |
39 |
|
|
40 |
void SendGlobopsInternal(const BotInfo *bi, const Anope::string &buf) anope_override |
void SendGlobopsInternal(const BotInfo *bi, const Anope::string &buf) anope_override |
41 |
{ |
{ |
42 |
UplinkSocket::Message(bi) << "GLOBOPS :" << buf; |
UplinkSocket::Message(bi) << "GLOBOPS :" << buf; |
43 |
} |
} |
44 |
|
|
45 |
void SendSQLine(User *, const XLine *x) anope_override |
void SendSQLine(User *, const XLine *x) anope_override |
46 |
{ |
{ |
47 |
const BotInfo *bi = findbot(Config->OperServ); |
const BotInfo *bi = findbot(Config->OperServ); |
48 |
|
|
49 |
UplinkSocket::Message(bi) << "RESV * " << x->Mask << " :" << x->GetReason(); |
UplinkSocket::Message(bi) << "RESV * " << x->Mask << " :" << x->GetReason(); |
50 |
} |
} |
51 |
|
|
52 |
void SendSGLineDel(const XLine *x) anope_override |
void SendSGLineDel(const XLine *x) anope_override |
53 |
{ |
{ |
54 |
const BotInfo *bi = findbot(Config->OperServ); |
const BotInfo *bi = findbot(Config->OperServ); |
55 |
|
|
56 |
UplinkSocket::Message(bi) << "UNXLINE * " << x->Mask; |
UplinkSocket::Message(bi) << "UNXLINE * " << x->Mask; |
57 |
} |
} |
58 |
|
|
59 |
void SendSGLine(User *, const XLine *x) anope_override |
void SendSGLine(User *, const XLine *x) anope_override |
60 |
{ |
{ |
61 |
const BotInfo *bi = findbot(Config->OperServ); |
const BotInfo *bi = findbot(Config->OperServ); |
62 |
|
|
63 |
UplinkSocket::Message(bi) << "XLINE * " << x->Mask << " 0 :" << x->GetReason(); |
UplinkSocket::Message(bi) << "XLINE * " << x->Mask << " 0 :" << x->GetReason(); |
64 |
} |
} |
65 |
|
|
66 |
void SendSZLineDel(const XLine *x) anope_override |
void SendSZLineDel(const XLine *x) anope_override |
67 |
{ |
{ |
68 |
const BotInfo *bi = findbot(Config->OperServ); |
const BotInfo *bi = findbot(Config->OperServ); |
69 |
|
|
70 |
UplinkSocket::Message(bi) << "UNDLINE * " << x->GetHost(); |
UplinkSocket::Message(bi) << "UNDLINE * " << x->GetHost(); |
71 |
} |
} |
72 |
|
|
73 |
void SendSZLine(User *, const XLine *x) anope_override |
void SendSZLine(User *, const XLine *x) anope_override |
74 |
{ |
{ |
75 |
const BotInfo *bi = findbot(Config->OperServ); |
const BotInfo *bi = findbot(Config->OperServ); |
76 |
/* Calculate the time left before this would expire, capping it at 2 days */ |
/* Calculate the time left before this would expire, capping it at 2 days */ |
77 |
time_t timeleft = x->Expires - Anope::CurTime; |
time_t timeleft = x->Expires - Anope::CurTime; |
78 |
|
|
79 |
if (timeleft > 172800 || !x->Expires) |
if (timeleft > 172800 || !x->Expires) |
80 |
timeleft = 172800; |
timeleft = 172800; |
81 |
|
|
82 |
UplinkSocket::Message(bi) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason(); |
UplinkSocket::Message(bi) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason(); |
83 |
} |
} |
84 |
|
|
85 |
void SendAkillDel(const XLine *x) anope_override |
void SendAkillDel(const XLine *x) anope_override |
86 |
{ |
{ |
87 |
if (x->IsRegex() || x->HasNickOrReal()) |
if (x->IsRegex() || x->HasNickOrReal()) |
88 |
return; |
return; |
89 |
|
|
90 |
const BotInfo *bi = findbot(Config->OperServ); |
const BotInfo *bi = findbot(Config->OperServ); |
91 |
|
|
92 |
UplinkSocket::Message(bi) << "UNKLINE * " << x->GetUser() << " " << x->GetHost(); |
UplinkSocket::Message(bi) << "UNKLINE * " << x->GetUser() << " " << x->GetHost(); |
93 |
} |
} |
94 |
|
|
95 |
void SendSQLineDel(const XLine *x) anope_override |
void SendSQLineDel(const XLine *x) anope_override |
96 |
{ |
{ |
97 |
const BotInfo *bi = findbot(Config->OperServ); |
const BotInfo *bi = findbot(Config->OperServ); |
98 |
|
|
99 |
UplinkSocket::Message(bi) << "UNRESV * " << x->Mask; |
UplinkSocket::Message(bi) << "UNRESV * " << x->Mask; |
100 |
} |
} |
101 |
|
|
102 |
void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override |
void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override |
103 |
{ |
{ |
104 |
/* |
/* |
105 |
* Note that we must send our modes with the SJOIN and |
* Note that we must send our modes with the SJOIN and |
106 |
* can not add them to the mode stacker because ircd-hybrid |
* can not add them to the mode stacker because ircd-hybrid |
107 |
* does not allow *any* client to op itself |
* does not allow *any* client to op itself |
108 |
*/ |
*/ |
109 |
UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " +" |
UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " +" |
110 |
<< c->GetModes(true, true) << " :" |
<< c->GetModes(true, true) << " :" |
111 |
<< (status != NULL ? status->BuildModePrefixList() : "") << user->GetUID(); |
<< (status != NULL ? status->BuildModePrefixList() : "") << user->GetUID(); |
112 |
|
|
113 |
/* And update our internal status for this user since this is not going through our mode handling system */ |
/* And update our internal status for this user since this is not going through our mode handling system */ |
114 |
if (status != NULL) |
if (status != NULL) |
115 |
{ |
{ |
116 |
UserContainer *uc = c->FindUser(user); |
UserContainer *uc = c->FindUser(user); |
117 |
|
|
118 |
if (uc != NULL) |
if (uc != NULL) |
119 |
*uc->Status = *status; |
*uc->Status = *status; |
120 |
} |
} |
121 |
} |
} |
122 |
|
|
123 |
void SendAkill(User *u, XLine *x) anope_override |
void SendAkill(User *u, XLine *x) anope_override |
124 |
{ |
{ |
125 |
const BotInfo *bi = findbot(Config->OperServ); |
const BotInfo *bi = findbot(Config->OperServ); |
126 |
|
|
127 |
if (x->IsRegex() || x->HasNickOrReal()) |
if (x->IsRegex() || x->HasNickOrReal()) |
128 |
{ |
{ |
129 |
if (!u) |
if (!u) |
130 |
{ |
{ |
131 |
/* |
/* |
132 |
* No user (this akill was just added), and contains nick and/or realname. |
* No user (this akill was just added), and contains nick and/or realname. |
133 |
* Find users that match and ban them. |
* Find users that match and ban them. |
134 |
*/ |
*/ |
135 |
for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) |
for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) |
136 |
if (x->manager->Check(it->second, x)) |
if (x->manager->Check(it->second, x)) |
137 |
this->SendAkill(it->second, x); |
this->SendAkill(it->second, x); |
138 |
|
|
139 |
return; |
return; |
140 |
} |
} |
141 |
|
|
142 |
const XLine *old = x; |
const XLine *old = x; |
143 |
|
|
144 |
if (old->manager->HasEntry("*@" + u->host)) |
if (old->manager->HasEntry("*@" + u->host)) |
145 |
return; |
return; |
146 |
|
|
147 |
/* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ |
/* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ |
148 |
XLine *xline = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID); |
XLine *xline = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID); |
149 |
|
|
150 |
old->manager->AddXLine(xline); |
old->manager->AddXLine(xline); |
151 |
x = xline; |
x = xline; |
152 |
|
|
153 |
Log(bi, "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" |
Log(bi, "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" |
154 |
<< u->realname << " matches " << old->Mask; |
<< u->realname << " matches " << old->Mask; |
155 |
} |
} |
156 |
|
|
157 |
/* Calculate the time left before this would expire, capping it at 2 days */ |
/* Calculate the time left before this would expire, capping it at 2 days */ |
158 |
time_t timeleft = x->Expires - Anope::CurTime; |
time_t timeleft = x->Expires - Anope::CurTime; |
159 |
|
|
160 |
if (timeleft > 172800 || !x->Expires) |
if (timeleft > 172800 || !x->Expires) |
161 |
timeleft = 172800; |
timeleft = 172800; |
162 |
|
|
163 |
UplinkSocket::Message(bi) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason(); |
UplinkSocket::Message(bi) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason(); |
164 |
} |
} |
165 |
|
|
166 |
void SendServer(const Server *server) anope_override |
void SendServer(const Server *server) anope_override |
167 |
{ |
{ |
168 |
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription(); |
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription(); |
169 |
} |
} |
170 |
|
|
171 |
void SendConnect() anope_override |
void SendConnect() anope_override |
172 |
{ |
{ |
173 |
UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " TS 6 :" << Me->GetSID(); |
UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " TS 6 :" << Me->GetSID(); |
174 |
|
|
175 |
/* |
/* |
176 |
* As of October 13, 2012, ircd-hybrid-8 does support the following capabilities |
* As of October 13, 2012, ircd-hybrid-8 does support the following capabilities |
177 |
* which are required to work with IRC-services: |
* which are required to work with IRC-services: |
178 |
* |
* |
179 |
* QS - Can handle quit storm removal |
* QS - Can handle quit storm removal |
180 |
* EX - Can do channel +e exemptions |
* EX - Can do channel +e exemptions |
181 |
* CHW - Can do channel wall @# |
* CHW - Can do channel wall @# |
182 |
* IE - Can do invite exceptions |
* IE - Can do invite exceptions |
183 |
* KNOCK - Supports KNOCK |
* KNOCK - Supports KNOCK |
184 |
* TBURST - Supports topic burst |
* TBURST - Supports topic burst |
185 |
* ENCAP - Supports ENCAP |
* ENCAP - Supports ENCAP |
186 |
* HOPS - Supports HalfOps |
* HOPS - Supports HalfOps |
187 |
* SVS - Supports services |
* SVS - Supports services |
188 |
* EOB - Supports End Of Burst message |
* EOB - Supports End Of Burst message |
189 |
* TS6 - Capable of TS6 support |
* TS6 - Capable of TS6 support |
190 |
*/ |
*/ |
191 |
UplinkSocket::Message() << "CAPAB :QS EX CHW IE ENCAP TBURST SVS HOPS EOB TS6"; |
UplinkSocket::Message() << "CAPAB :QS EX CHW IE ENCAP TBURST SVS HOPS EOB TS6"; |
192 |
|
|
193 |
SendServer(Me); |
SendServer(Me); |
194 |
|
|
195 |
UplinkSocket::Message() << "SVINFO 6 5 0 :" << Anope::CurTime; |
UplinkSocket::Message() << "SVINFO 6 5 0 :" << Anope::CurTime; |
196 |
} |
} |
197 |
|
|
198 |
void SendClientIntroduction(const User *u) anope_override |
void SendClientIntroduction(const User *u) anope_override |
199 |
{ |
{ |
200 |
Anope::string modes = "+" + u->GetModes(); |
Anope::string modes = "+" + u->GetModes(); |
201 |
|
|
202 |
UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " |
UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " |
203 |
<< u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " 0 :" << u->realname; |
<< u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " 0 :" << u->realname; |
204 |
} |
} |
205 |
|
|
206 |
void SendEOB() anope_override |
void SendEOB() anope_override |
207 |
{ |
{ |
208 |
UplinkSocket::Message(Me) << "EOB"; |
UplinkSocket::Message(Me) << "EOB"; |
209 |
} |
} |
210 |
|
|
211 |
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override |
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override |
212 |
{ |
{ |
213 |
if (bi) |
if (bi) |
214 |
UplinkSocket::Message(bi) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf; |
UplinkSocket::Message(bi) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf; |
215 |
else |
else |
216 |
UplinkSocket::Message(Me) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf; |
UplinkSocket::Message(Me) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf; |
217 |
} |
} |
218 |
|
|
219 |
void SendLogin(User *u) anope_override |
void SendLogin(User *u) anope_override |
220 |
{ |
{ |
221 |
const BotInfo *ns = findbot(Config->NickServ); |
const BotInfo *ns = findbot(Config->NickServ); |
222 |
|
|
223 |
ircdproto->SendMode(ns, u, "+d %s" u->Account()->display.c_str()); |
ircdproto->SendMode(ns, u, "+d %s", u->Account()->display.c_str()); |
224 |
} |
} |
225 |
|
|
226 |
void SendLogout(User *u) anope_override |
void SendLogout(User *u) anope_override |
227 |
{ |
{ |
228 |
const BotInfo *ns = findbot(Config->NickServ); |
const BotInfo *ns = findbot(Config->NickServ); |
229 |
|
|
230 |
ircdproto->SendMode(ns, u, "+d 0"); |
ircdproto->SendMode(ns, u, "+d 0"); |
231 |
} |
} |
232 |
|
|
233 |
void SendChannel(Channel *c) anope_override |
void SendChannel(Channel *c) anope_override |
234 |
{ |
{ |
235 |
Anope::string modes = c->GetModes(true, true); |
Anope::string modes = c->GetModes(true, true); |
236 |
|
|
237 |
if (modes.empty()) |
if (modes.empty()) |
238 |
modes = "+"; |
modes = "+"; |
239 |
|
|
240 |
UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :"; |
UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :"; |
241 |
} |
} |
242 |
|
|
243 |
void SendTopic(BotInfo *bi, Channel *c) anope_override |
void SendTopic(BotInfo *bi, Channel *c) anope_override |
244 |
{ |
{ |
245 |
bool needjoin = c->FindUser(bi) == NULL; |
bool needjoin = c->FindUser(bi) == NULL; |
246 |
|
|
247 |
if (needjoin) |
if (needjoin) |
248 |
{ |
{ |
249 |
ChannelStatus status; |
ChannelStatus status; |
250 |
|
|
251 |
status.SetFlag(CMODE_OP); |
status.SetFlag(CMODE_OP); |
252 |
bi->Join(c, &status); |
bi->Join(c, &status); |
253 |
} |
} |
254 |
|
|
255 |
IRCDProto::SendTopic(bi, c); |
IRCDProto::SendTopic(bi, c); |
256 |
|
|
257 |
if (needjoin) |
if (needjoin) |
258 |
bi->Part(c); |
bi->Part(c); |
259 |
} |
} |
260 |
}; |
}; |
261 |
|
|
262 |
struct IRCDMessageBMask : IRCDMessage |
struct IRCDMessageBMask : IRCDMessage |
263 |
{ |
{ |
264 |
IRCDMessageBMask() : IRCDMessage("BMASK", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
IRCDMessageBMask() : IRCDMessage("BMASK", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
265 |
|
|
266 |
/* 0 1 2 3 */ |
/* 0 1 2 3 */ |
267 |
/* :0MC BMASK 1350157102 #channel b :*!*@*.test.com */ |
/* :0MC BMASK 1350157102 #channel b :*!*@*.test.com */ |
268 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
269 |
{ |
{ |
270 |
Channel *c = findchan(params[1]); |
Channel *c = findchan(params[1]); |
271 |
|
|
272 |
if (c) |
if (c) |
273 |
{ |
{ |
274 |
ChannelMode *ban = ModeManager::FindChannelModeByName(CMODE_BAN), |
ChannelMode *ban = ModeManager::FindChannelModeByName(CMODE_BAN), |
275 |
*except = ModeManager::FindChannelModeByName(CMODE_EXCEPT), |
*except = ModeManager::FindChannelModeByName(CMODE_EXCEPT), |
276 |
*invex = ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE); |
*invex = ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE); |
277 |
|
|
278 |
Anope::string bans = params[3]; |
Anope::string bans = params[3]; |
279 |
|
|
280 |
int count = myNumToken(bans, ' '), i; |
int count = myNumToken(bans, ' '), i; |
281 |
|
|
282 |
for (i = 0; i < count; ++i) |
for (i = 0; i < count; ++i) |
283 |
{ |
{ |
284 |
Anope::string b = myStrGetToken(bans, ' ', i); |
Anope::string b = myStrGetToken(bans, ' ', i); |
285 |
|
|
286 |
if (ban && params[2].equals_cs("b")) |
if (ban && params[2].equals_cs("b")) |
287 |
c->SetModeInternal(source, ban, b); |
c->SetModeInternal(source, ban, b); |
288 |
else if (except && params[2].equals_cs("e")) |
else if (except && params[2].equals_cs("e")) |
289 |
c->SetModeInternal(source, except, b); |
c->SetModeInternal(source, except, b); |
290 |
else if (invex && params[2].equals_cs("I")) |
else if (invex && params[2].equals_cs("I")) |
291 |
c->SetModeInternal(source, invex, b); |
c->SetModeInternal(source, invex, b); |
292 |
} |
} |
293 |
} |
} |
294 |
|
|
295 |
return true; |
return true; |
296 |
} |
} |
297 |
}; |
}; |
298 |
|
|
299 |
struct IRCDMessageJoin : CoreIRCDMessageJoin |
struct IRCDMessageJoin : CoreIRCDMessageJoin |
300 |
{ |
{ |
301 |
IRCDMessageJoin() : CoreIRCDMessageJoin("JOIN") { } |
IRCDMessageJoin() : CoreIRCDMessageJoin("JOIN") { } |
302 |
|
|
303 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
304 |
{ |
{ |
305 |
if (params.size() < 2) |
if (params.size() < 2) |
306 |
return true; |
return true; |
307 |
|
|
308 |
std::vector<Anope::string> p = params; |
std::vector<Anope::string> p = params; |
309 |
p.erase(p.begin()); |
p.erase(p.begin()); |
310 |
|
|
311 |
return CoreIRCDMessageJoin::Run(source, p); |
return CoreIRCDMessageJoin::Run(source, p); |
312 |
} |
} |
313 |
}; |
}; |
314 |
|
|
315 |
struct IRCDMessageMode : IRCDMessage |
struct IRCDMessageMode : IRCDMessage |
316 |
{ |
{ |
317 |
IRCDMessageMode(const Anope::string &n) : IRCDMessage(n, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } |
IRCDMessageMode(const Anope::string &n) : IRCDMessage(n, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } |
318 |
|
|
319 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
320 |
{ |
{ |
321 |
if (params.size() > 2 && ircdproto->IsChannelValid(params[0])) |
if (params.size() > 2 && ircdproto->IsChannelValid(params[0])) |
322 |
{ |
{ |
323 |
Channel *c = findchan(params[0]); |
Channel *c = findchan(params[0]); |
324 |
time_t ts = Anope::CurTime; |
time_t ts = Anope::CurTime; |
325 |
|
|
326 |
try |
try |
327 |
{ |
{ |
328 |
ts = convertTo<time_t>(params[1]); |
ts = convertTo<time_t>(params[1]); |
329 |
} |
} |
330 |
catch (const ConvertException &) { } |
catch (const ConvertException &) { } |
331 |
|
|
332 |
if (c) |
if (c) |
333 |
c->SetModesInternal(source, params[2], ts); |
c->SetModesInternal(source, params[2], ts); |
334 |
} |
} |
335 |
else |
else |
336 |
{ |
{ |
337 |
User *u = finduser(params[0]); |
User *u = finduser(params[0]); |
338 |
|
|
339 |
if (u) |
if (u) |
340 |
u->SetModesInternal("%s", params[1].c_str()); |
u->SetModesInternal("%s", params[1].c_str()); |
341 |
} |
} |
342 |
|
|
343 |
return true; |
return true; |
344 |
} |
} |
345 |
}; |
}; |
346 |
|
|
347 |
struct IRCDMessageNick : IRCDMessage |
struct IRCDMessageNick : IRCDMessage |
348 |
{ |
{ |
349 |
IRCDMessageNick() : IRCDMessage("NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } |
IRCDMessageNick() : IRCDMessage("NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } |
350 |
|
|
351 |
/* 0 1 */ |
/* 0 1 */ |
352 |
/* :0MCAAAAAB NICK newnick 1350157102 */ |
/* :0MCAAAAAB NICK newnick 1350157102 */ |
353 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
354 |
{ |
{ |
355 |
source.GetUser()->ChangeNick(params[0]); |
source.GetUser()->ChangeNick(params[0], convertTo<time_t>(params[1])); |
356 |
return true; |
return true; |
357 |
} |
} |
358 |
}; |
}; |
359 |
|
|
360 |
struct IRCDMessagePass : IRCDMessage |
struct IRCDMessagePass : IRCDMessage |
361 |
{ |
{ |
362 |
IRCDMessagePass() : IRCDMessage("PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
IRCDMessagePass() : IRCDMessage("PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
363 |
|
|
364 |
/* 0 1 2 3 */ |
/* 0 1 2 3 */ |
365 |
/* PASS password TS 6 0MC */ |
/* PASS password TS 6 0MC */ |
366 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
367 |
{ |
{ |
368 |
UplinkSID = params[3]; |
UplinkSID = params[3]; |
369 |
return true; |
return true; |
370 |
} |
} |
371 |
}; |
}; |
372 |
|
|
373 |
struct IRCDMessagePong : IRCDMessage |
struct IRCDMessagePong : IRCDMessage |
374 |
{ |
{ |
375 |
IRCDMessagePong() : IRCDMessage("PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
IRCDMessagePong() : IRCDMessage("PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
376 |
|
|
377 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
378 |
{ |
{ |
379 |
source.GetServer()->Sync(false); |
source.GetServer()->Sync(false); |
380 |
return true; |
return true; |
381 |
} |
} |
382 |
}; |
}; |
383 |
|
|
384 |
struct IRCDMessageServer : IRCDMessage |
struct IRCDMessageServer : IRCDMessage |
385 |
{ |
{ |
386 |
IRCDMessageServer() : IRCDMessage("SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
IRCDMessageServer() : IRCDMessage("SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
387 |
|
|
388 |
/* 0 1 2 */ |
/* 0 1 2 */ |
389 |
/* SERVER hades.arpa 1 :ircd-hybrid test server */ |
/* SERVER hades.arpa 1 :ircd-hybrid test server */ |
390 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
391 |
{ |
{ |
392 |
/* Servers other than our immediate uplink are introduced via SID */ |
/* Servers other than our immediate uplink are introduced via SID */ |
393 |
if (params[1] != "1") |
if (params[1] != "1") |
394 |
return true; |
return true; |
395 |
|
|
396 |
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); |
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); |
397 |
|
|
398 |
ircdproto->SendPing(Config->ServerName, params[0]); |
ircdproto->SendPing(Config->ServerName, params[0]); |
399 |
return true; |
return true; |
400 |
} |
} |
401 |
}; |
}; |
402 |
|
|
403 |
struct IRCDMessageSID : IRCDMessage |
struct IRCDMessageSID : IRCDMessage |
404 |
{ |
{ |
405 |
IRCDMessageSID() : IRCDMessage("SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
IRCDMessageSID() : IRCDMessage("SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
406 |
|
|
407 |
/* 0 1 2 3 */ |
/* 0 1 2 3 */ |
408 |
/* :0MC SID hades.arpa 2 4XY :ircd-hybrid test server */ |
/* :0MC SID hades.arpa 2 4XY :ircd-hybrid test server */ |
409 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
410 |
{ |
{ |
411 |
unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0; |
unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0; |
412 |
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]); |
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]); |
413 |
|
|
414 |
ircdproto->SendPing(Config->ServerName, params[0]); |
ircdproto->SendPing(Config->ServerName, params[0]); |
415 |
return true; |
return true; |
416 |
} |
} |
417 |
}; |
}; |
418 |
|
|
419 |
struct IRCDMessageSjoin : IRCDMessage |
struct IRCDMessageSjoin : IRCDMessage |
420 |
{ |
{ |
421 |
IRCDMessageSjoin() : IRCDMessage("SJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } |
IRCDMessageSjoin() : IRCDMessage("SJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } |
422 |
|
|
423 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
424 |
{ |
{ |
425 |
Channel *c = findchan(params[1]); |
Channel *c = findchan(params[1]); |
426 |
time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0; |
time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0; |
427 |
bool keep_their_modes = true; |
bool keep_their_modes = true; |
428 |
|
|
429 |
if (!c) |
if (!c) |
430 |
{ |
{ |
431 |
c = new Channel(params[1], ts); |
c = new Channel(params[1], ts); |
432 |
c->SetFlag(CH_SYNCING); |
c->SetFlag(CH_SYNCING); |
433 |
} |
} |
434 |
/* Our creation time is newer than what the server gave us */ |
/* Our creation time is newer than what the server gave us */ |
435 |
else if (c->creation_time > ts) |
else if (c->creation_time > ts) |
436 |
{ |
{ |
437 |
c->creation_time = ts; |
c->creation_time = ts; |
438 |
c->Reset(); |
c->Reset(); |
439 |
} |
} |
440 |
/* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ |
/* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ |
441 |
else if (ts > c->creation_time) |
else if (ts > c->creation_time) |
442 |
keep_their_modes = false; |
keep_their_modes = false; |
443 |
|
|
444 |
/* If we need to keep their modes, and this SJOIN string contains modes */ |
/* If we need to keep their modes, and this SJOIN string contains modes */ |
445 |
if (keep_their_modes && params.size() >= 3) |
if (keep_their_modes && params.size() >= 3) |
446 |
{ |
{ |
447 |
Anope::string modes; |
Anope::string modes; |
448 |
|
|
449 |
for (unsigned i = 2; i < params.size() - 1; ++i) |
for (unsigned i = 2; i < params.size() - 1; ++i) |
450 |
modes += " " + params[i]; |
modes += " " + params[i]; |
451 |
|
|
452 |
if (!modes.empty()) |
if (!modes.empty()) |
453 |
modes.erase(modes.begin()); |
modes.erase(modes.begin()); |
454 |
|
|
455 |
/* Set the modes internally */ |
/* Set the modes internally */ |
456 |
c->SetModesInternal(source, modes); |
c->SetModesInternal(source, modes); |
457 |
} |
} |
458 |
|
|
459 |
spacesepstream sep(params[params.size() - 1]); |
spacesepstream sep(params[params.size() - 1]); |
460 |
Anope::string buf; |
Anope::string buf; |
461 |
|
|
462 |
while (sep.GetToken(buf)) |
while (sep.GetToken(buf)) |
463 |
{ |
{ |
464 |
std::list<ChannelMode *> Status; |
std::list<ChannelMode *> Status; |
465 |
char ch; |
char ch; |
466 |
|
|
467 |
/* Get prefixes from the nick */ |
/* Get prefixes from the nick */ |
468 |
while ((ch = ModeManager::GetStatusChar(buf[0]))) |
while ((ch = ModeManager::GetStatusChar(buf[0]))) |
469 |
{ |
{ |
470 |
buf.erase(buf.begin()); |
buf.erase(buf.begin()); |
471 |
|
|
472 |
ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); |
ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); |
473 |
|
|
474 |
if (!cm) |
if (!cm) |
475 |
{ |
{ |
476 |
Log() << "Received unknown mode prefix " << ch << " in SJOIN string"; |
Log() << "Received unknown mode prefix " << ch << " in SJOIN string"; |
477 |
continue; |
continue; |
478 |
} |
} |
479 |
|
|
480 |
if (keep_their_modes) |
if (keep_their_modes) |
481 |
Status.push_back(cm); |
Status.push_back(cm); |
482 |
} |
} |
483 |
|
|
484 |
User *u = finduser(buf); |
User *u = finduser(buf); |
485 |
|
|
486 |
if (!u) |
if (!u) |
487 |
{ |
{ |
488 |
Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; |
Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; |
489 |
continue; |
continue; |
490 |
} |
} |
491 |
|
|
492 |
EventReturn MOD_RESULT; |
EventReturn MOD_RESULT; |
493 |
FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); |
FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); |
494 |
|
|
495 |
/* Add the user to the channel */ |
/* Add the user to the channel */ |
496 |
c->JoinUser(u); |
c->JoinUser(u); |
497 |
|
|
498 |
/* |
/* |
499 |
* Update their status internally on the channel |
* Update their status internally on the channel |
500 |
* This will enforce secureops etc on the user |
* This will enforce secureops etc on the user |
501 |
*/ |
*/ |
502 |
for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) |
for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) |
503 |
c->SetModeInternal(source, *it, buf); |
c->SetModeInternal(source, *it, buf); |
504 |
|
|
505 |
/* Now set whatever modes this user is allowed to have on the channel */ |
/* Now set whatever modes this user is allowed to have on the channel */ |
506 |
chan_set_correct_modes(u, c, 1, true); |
chan_set_correct_modes(u, c, 1, true); |
507 |
|
|
508 |
/* |
/* |
509 |
* Check to see if modules want the user to join, if they do |
* Check to see if modules want the user to join, if they do |
510 |
* check to see if they are allowed to join (CheckKick will kick/ban them) |
* check to see if they are allowed to join (CheckKick will kick/ban them) |
511 |
* Don't trigger OnJoinChannel event then as the user will be destroyed |
* Don't trigger OnJoinChannel event then as the user will be destroyed |
512 |
*/ |
*/ |
513 |
if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) |
if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) |
514 |
continue; |
continue; |
515 |
|
|
516 |
FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); |
FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); |
517 |
} |
} |
518 |
|
|
519 |
/* Channel is done syncing */ |
/* Channel is done syncing */ |
520 |
if (c->HasFlag(CH_SYNCING)) |
if (c->HasFlag(CH_SYNCING)) |
521 |
{ |
{ |
522 |
/* Unset the syncing flag */ |
/* Unset the syncing flag */ |
523 |
c->UnsetFlag(CH_SYNCING); |
c->UnsetFlag(CH_SYNCING); |
524 |
c->Sync(); |
c->Sync(); |
525 |
} |
} |
526 |
|
|
527 |
return true; |
return true; |
528 |
} |
} |
529 |
}; |
}; |
530 |
|
|
531 |
struct IRCDMessageTBurst : IRCDMessage |
struct IRCDMessageTBurst : IRCDMessage |
532 |
{ |
{ |
533 |
IRCDMessageTBurst() : IRCDMessage("TBURST", 5) { } |
IRCDMessageTBurst() : IRCDMessage("TBURST", 5) { } |
534 |
|
|
535 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
536 |
{ |
{ |
537 |
Anope::string setter = myStrGetToken(params[3], '!', 0); |
Anope::string setter = myStrGetToken(params[3], '!', 0); |
538 |
time_t topic_time = Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime; |
time_t topic_time = Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime; |
539 |
Channel *c = findchan(params[1]); |
Channel *c = findchan(params[1]); |
540 |
|
|
541 |
if (c) |
if (c) |
542 |
c->ChangeTopicInternal(setter, params[4], topic_time); |
c->ChangeTopicInternal(setter, params[4], topic_time); |
543 |
|
|
544 |
return true; |
return true; |
545 |
} |
} |
546 |
}; |
}; |
547 |
|
|
548 |
struct IRCDMessageTMode : IRCDMessage |
struct IRCDMessageTMode : IRCDMessage |
549 |
{ |
{ |
550 |
IRCDMessageTMode() : IRCDMessage("TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } |
IRCDMessageTMode() : IRCDMessage("TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } |
551 |
|
|
552 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
553 |
{ |
{ |
554 |
time_t ts = Anope::CurTime; |
time_t ts = Anope::CurTime; |
555 |
|
|
556 |
try |
try |
557 |
{ |
{ |
558 |
ts = convertTo<time_t>(params[0]); |
ts = convertTo<time_t>(params[0]); |
559 |
} |
} |
560 |
catch (const ConvertException &) { } |
catch (const ConvertException &) { } |
561 |
|
|
562 |
Channel *c = findchan(params[1]); |
Channel *c = findchan(params[1]); |
563 |
Anope::string modes = params[2]; |
Anope::string modes = params[2]; |
564 |
|
|
565 |
for (unsigned i = 3; i < params.size(); ++i) |
for (unsigned i = 3; i < params.size(); ++i) |
566 |
modes += " " + params[i]; |
modes += " " + params[i]; |
567 |
|
|
568 |
if (c) |
if (c) |
569 |
c->SetModesInternal(source, modes, ts); |
c->SetModesInternal(source, modes, ts); |
570 |
|
|
571 |
return true; |
return true; |
572 |
} |
} |
573 |
}; |
}; |
574 |
|
|
575 |
struct IRCDMessageUID : IRCDMessage |
struct IRCDMessageUID : IRCDMessage |
576 |
{ |
{ |
577 |
IRCDMessageUID() : IRCDMessage("UID", 10) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
IRCDMessageUID() : IRCDMessage("UID", 10) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } |
578 |
|
|
579 |
/* 0 1 2 3 4 5 6 7 8 9 */ |
/* 0 1 2 3 4 5 6 7 8 9 */ |
580 |
/* :0MC UID Steve 1 1350157102 +oi ~steve resolved.host 10.0.0.1 0MCAAAAAB 1350157108 :Mining all the time */ |
/* :0MC UID Steve 1 1350157102 +oi ~steve resolved.host 10.0.0.1 0MCAAAAAB 1350157108 :Mining all the time */ |
581 |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override |
582 |
{ |
{ |
583 |
/* Source is always the server */ |
/* Source is always the server */ |
584 |
User *user = new User(params[0], params[4], params[5], "", |
User *user = new User(params[0], params[4], params[5], "", |
585 |
params[6], source.GetServer(), |
params[6], source.GetServer(), |
586 |
params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, |
params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, |
587 |
params[3], params[7]); |
params[3], params[7]); |
588 |
|
|
589 |
|
if (user && nickserv) |
590 |
if (user && nickserv) |
{ |
591 |
{ |
const NickAlias *na = NULL; |
592 |
const NickAlias *na = NULL; |
|
593 |
|
if (params[8] != "0") |
594 |
if (params[8] != "0") |
na = findnick(params[8]); |
595 |
na = findnick(params[8]); |
|
596 |
|
if (na) |
597 |
if (na) |
{ |
598 |
{ |
user->Login(na->nc); |
599 |
user->Login(na->nc); |
|
600 |
|
if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false) |
601 |
if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false) |
user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); |
602 |
user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); |
} |
603 |
} |
else |
604 |
else |
nickserv->Validate(user); |
605 |
nickserv->Validate(user); |
} |
|
} |
|
606 |
|
|
607 |
return true; |
return true; |
608 |
} |
} |
609 |
}; |
}; |
610 |
|
|
611 |
class ProtoHybrid : public Module |
class ProtoHybrid : public Module |
612 |
{ |
{ |
613 |
HybridProto ircd_proto; |
HybridProto ircd_proto; |
614 |
|
|
615 |
/* Core message handlers */ |
/* Core message handlers */ |
616 |
CoreIRCDMessageAway core_message_away; |
CoreIRCDMessageAway core_message_away; |
617 |
CoreIRCDMessageCapab core_message_capab; |
CoreIRCDMessageCapab core_message_capab; |
618 |
CoreIRCDMessageError core_message_error; |
CoreIRCDMessageError core_message_error; |
619 |
CoreIRCDMessageKick core_message_kick; |
CoreIRCDMessageKick core_message_kick; |
620 |
CoreIRCDMessageKill core_message_kill; |
CoreIRCDMessageKill core_message_kill; |
621 |
CoreIRCDMessageMOTD core_message_motd; |
CoreIRCDMessageMOTD core_message_motd; |
622 |
CoreIRCDMessagePart core_message_part; |
CoreIRCDMessagePart core_message_part; |
623 |
CoreIRCDMessagePing core_message_ping; |
CoreIRCDMessagePing core_message_ping; |
624 |
CoreIRCDMessagePrivmsg core_message_privmsg; |
CoreIRCDMessagePrivmsg core_message_privmsg; |
625 |
CoreIRCDMessageQuit core_message_quit; |
CoreIRCDMessageQuit core_message_quit; |
626 |
CoreIRCDMessageSQuit core_message_squit; |
CoreIRCDMessageSQuit core_message_squit; |
627 |
CoreIRCDMessageStats core_message_stats; |
CoreIRCDMessageStats core_message_stats; |
628 |
CoreIRCDMessageTime core_message_time; |
CoreIRCDMessageTime core_message_time; |
629 |
CoreIRCDMessageTopic core_message_topic; |
CoreIRCDMessageTopic core_message_topic; |
630 |
CoreIRCDMessageVersion core_message_version; |
CoreIRCDMessageVersion core_message_version; |
631 |
|
CoreIRCDMessageWhois core_message_whois; |
632 |
/* Our message handlers */ |
|
633 |
IRCDMessageBMask message_bmask; |
/* Our message handlers */ |
634 |
IRCDMessageJoin message_join; |
IRCDMessageBMask message_bmask; |
635 |
IRCDMessageMode message_mode, message_svsmode; |
IRCDMessageJoin message_join; |
636 |
IRCDMessageNick message_nick; |
IRCDMessageMode message_mode, message_svsmode; |
637 |
IRCDMessagePass message_pass; |
IRCDMessageNick message_nick; |
638 |
IRCDMessagePong message_pong; |
IRCDMessagePass message_pass; |
639 |
IRCDMessageServer message_server; |
IRCDMessagePong message_pong; |
640 |
IRCDMessageSID message_sid; |
IRCDMessageServer message_server; |
641 |
IRCDMessageSjoin message_sjoin; |
IRCDMessageSID message_sid; |
642 |
IRCDMessageTBurst message_tburst; |
IRCDMessageSjoin message_sjoin; |
643 |
IRCDMessageTMode message_tmode; |
IRCDMessageTBurst message_tburst; |
644 |
IRCDMessageUID message_uid; |
IRCDMessageTMode message_tmode; |
645 |
|
IRCDMessageUID message_uid; |
646 |
void AddModes() |
|
647 |
{ |
void AddModes() |
648 |
/* Add user modes */ |
{ |
649 |
ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, 'a')); |
/* Add user modes */ |
650 |
ModeManager::AddUserMode(new UserMode(UMODE_INVIS, 'i')); |
ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, 'a')); |
651 |
ModeManager::AddUserMode(new UserMode(UMODE_OPER, 'o')); |
ModeManager::AddUserMode(new UserMode(UMODE_INVIS, 'i')); |
652 |
ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, 'r')); |
ModeManager::AddUserMode(new UserMode(UMODE_OPER, 'o')); |
653 |
ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, 's')); |
ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, 'r')); |
654 |
ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, 'w')); |
ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, 's')); |
655 |
ModeManager::AddUserMode(new UserMode(UMODE_HIDEOPER, 'H')); |
ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, 'w')); |
656 |
ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, 'R')); |
ModeManager::AddUserMode(new UserMode(UMODE_HIDEOPER, 'H')); |
657 |
|
ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, 'R')); |
658 |
/* b/e/I */ |
|
659 |
ModeManager::AddChannelMode(new ChannelModeList(CMODE_BAN, 'b')); |
/* b/e/I */ |
660 |
ModeManager::AddChannelMode(new ChannelModeList(CMODE_EXCEPT, 'e')); |
ModeManager::AddChannelMode(new ChannelModeList(CMODE_BAN, 'b')); |
661 |
ModeManager::AddChannelMode(new ChannelModeList(CMODE_INVITEOVERRIDE, 'I')); |
ModeManager::AddChannelMode(new ChannelModeList(CMODE_EXCEPT, 'e')); |
662 |
|
ModeManager::AddChannelMode(new ChannelModeList(CMODE_INVITEOVERRIDE, 'I')); |
663 |
/* v/h/o/a/q */ |
|
664 |
ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, 'v', '+', 0)); |
/* v/h/o/a/q */ |
665 |
ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, 'o', '@', 1)); |
ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, 'v', '+', 0)); |
666 |
|
ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, 'o', '@', 1)); |
667 |
/* Add channel modes */ |
|
668 |
ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, 'i')); |
/* Add channel modes */ |
669 |
ModeManager::AddChannelMode(new ChannelModeKey('k')); |
ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, 'i')); |
670 |
ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, 'l')); |
ModeManager::AddChannelMode(new ChannelModeKey('k')); |
671 |
ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, 'm')); |
ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, 'l')); |
672 |
ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, 'n')); |
ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, 'm')); |
673 |
ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, 'p')); |
ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, 'n')); |
674 |
ModeManager::AddChannelMode(new ChannelModeRegistered('r')); |
ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, 'p')); |
675 |
ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, 's')); |
ModeManager::AddChannelMode(new ChannelModeRegistered('r')); |
676 |
ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, 't')); |
ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, 's')); |
677 |
ModeManager::AddChannelMode(new ChannelModeOper('O')); |
ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, 't')); |
678 |
ModeManager::AddChannelMode(new ChannelMode(CMODE_REGISTEREDONLY, 'R')); |
ModeManager::AddChannelMode(new ChannelModeOper('O')); |
679 |
ModeManager::AddChannelMode(new ChannelMode(CMODE_SSL, 'S')); |
ModeManager::AddChannelMode(new ChannelMode(CMODE_REGISTEREDONLY, 'R')); |
680 |
} |
ModeManager::AddChannelMode(new ChannelMode(CMODE_SSL, 'S')); |
681 |
|
} |
682 |
|
|
683 |
public: |
public: |
684 |
ProtoHybrid(const Anope::string &modname, const Anope::string &creator) : |
ProtoHybrid(const Anope::string &modname, const Anope::string &creator) : |
685 |
Module(modname, creator, PROTOCOL), message_mode("MODE"), message_svsmode("SVSMODE") |
Module(modname, creator, PROTOCOL), message_mode("MODE"), message_svsmode("SVSMODE") |
686 |
{ |
{ |
687 |
this->SetAuthor("Anope"); |
this->SetAuthor("Anope"); |
688 |
this->AddModes(); |
this->AddModes(); |
689 |
|
|
690 |
ModuleManager::Attach(I_OnUserNickChange, this); |
ModuleManager::Attach(I_OnUserNickChange, this); |
691 |
|
|
692 |
if (Config->Numeric.empty()) |
if (Config->Numeric.empty()) |
693 |
{ |
{ |
694 |
Anope::string numeric = ts6_sid_retrieve(); |
Anope::string numeric = ts6_sid_retrieve(); |
695 |
Me->SetSID(numeric); |
Me->SetSID(numeric); |
696 |
Config->Numeric = numeric; |
Config->Numeric = numeric; |
697 |
} |
} |
698 |
|
|
699 |
for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) |
for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) |
700 |
it->second->GenerateUID(); |
it->second->GenerateUID(); |
701 |
} |
} |
702 |
|
|
703 |
void OnUserNickChange(User *u, const Anope::string &) anope_override |
void OnUserNickChange(User *u, const Anope::string &) anope_override |
704 |
{ |
{ |
705 |
u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED)); |
u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED)); |
706 |
ircdproto->SendLogout(u); |
ircdproto->SendLogout(u); |
707 |
} |
} |
708 |
}; |
}; |
709 |
|
|
710 |
MODULE_INIT(ProtoHybrid) |
MODULE_INIT(ProtoHybrid) |