ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/anope-protocol-module/hybrid.cpp
Revision: 1565
Committed: Sun Oct 14 14:01:43 2012 UTC (14 years ago) by michael
Content type: text/x-c++src
File size: 20231 byte(s)
Log Message:
- Change mode handler to use UIDs within SVSMODE messages

File Contents

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

Properties

Name Value
svn:keywords Id