/[svn]/hybrid.c
ViewVC logotype

Contents of /hybrid.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1583 - (show annotations)
Mon Oct 22 19:04:03 2012 UTC (9 years, 8 months ago) by michael
File MIME type: text/x-chdr
File size: 29115 byte(s)
- Add denora protocol module as of the latest git on October 22th
1 /* Hybrid IRCD functions
2 *
3 * (c) 2004-2012 Denora Team
4 * Contact us at info@denorastats.org
5 *
6 * Please read COPYING and README for furhter details.
7 *
8 * Based on the original code of Anope by Anope Team.
9 * Based on the original code of Thales by Lucas.
10 *
11 *
12 *
13 */
14
15 #include "denora.h"
16 #include "hybrid.h"
17
18 IRCDVar myIrcd[] =
19 {
20 {
21 "HybridIRCd 7.*", /* ircd name */
22 "+o", /* StatServ mode */
23 IRCD_ENABLE, /* Vhost */
24 IRCD_ENABLE, /* Supports SGlines */
25 IRCD_ENABLE, /* sgline sql table */
26 IRCD_DISABLE, /* Supports SQlines */
27 IRCD_DISABLE, /* sqline sql table */
28 IRCD_DISABLE, /* Supports SZlines */
29 IRCD_ENABLE, /* Has exceptions +e */
30 IRCD_ENABLE, /* vidents */
31 IRCD_ENABLE, /* NICKIP */
32 IRCD_DISABLE, /* VHOST ON NICK */
33 IRCD_DISABLE, /* +f */
34 IRCD_DISABLE, /* +j */
35 IRCD_DISABLE, /* +L */
36 IRCD_DISABLE, /* +f Mode */
37 IRCD_DISABLE, /* +j */
38 IRCD_DISABLE, /* +L Mode */
39 NULL, /* CAPAB Chan Modes */
40 IRCD_DISABLE, /* We support TOKENS */
41 IRCD_ENABLE, /* TOKENS are CASE Sensitive */
42 IRCD_DISABLE, /* TIME STAMPS are BASE64 */
43 IRCD_ENABLE, /* +I support */
44 IRCD_DISABLE, /* SJOIN ban char */
45 IRCD_DISABLE, /* SJOIN except char */
46 IRCD_DISABLE, /* SJOIN invite char */
47 UMODE_h, /* umode for vhost */
48 IRCD_DISABLE, /* owner */
49 IRCD_DISABLE, /* protect */
50 IRCD_ENABLE, /* halfop */
51 NULL, /* User modes */
52 NULL, /* channel modes */
53 IRCD_DISABLE, /* flood */
54 IRCD_DISABLE, /* flood other */
55 IRCD_DISABLE, /* join throttle */
56 IRCD_DISABLE, /* nick change flood */
57 'h', /* vhost */
58 IRCD_DISABLE, /* vhost other */
59 IRCD_DISABLE, /* channek linking */
60 IRCD_DISABLE, /* p10 */
61 IRCD_ENABLE, /* TS6 */
62 IRCD_ENABLE, /* numeric ie.. 350 etc */
63 IRCD_DISABLE, /* channel mode gagged */
64 IRCD_DISABLE, /* spamfilter */
65 'b', /* ban char */
66 'e', /* except char */
67 'I', /* invite char */
68 IRCD_DISABLE, /* zip */
69 IRCD_DISABLE, /* ssl */
70 IRCD_ENABLE, /* uline */
71 NULL, /* nickchar */
72 IRCD_DISABLE, /* svid */
73 IRCD_DISABLE, /* hidden oper */
74 IRCD_ENABLE, /* extra warning */
75 IRCD_ENABLE, /* Report sync state */
76 IRCD_DISABLE /* Persistent channel mode */
77 }
78 ,
79 };
80
81 IRCDCAPAB myIrcdcap[] =
82 {
83 {
84 CAPAB_NOQUIT, /* NOQUIT */
85 0, /* TSMODE */
86 0, /* UNCONNECT */
87 0, /* NICKIP */
88 0, /* SJOIN */
89 CAPAB_ZIP, /* ZIP */
90 0, /* BURST */
91 CAPAB_TS5, /* TS5 */
92 0, /* TS3 */
93 0, /* DKEY */
94 0, /* PT4 */
95 0, /* SCS */
96 CAPAB_QS, /* QS */
97 CAPAB_UID, /* UID */
98 CAPAB_KNOCK, /* KNOCK */
99 0, /* CLIENT */
100 0, /* IPV6 */
101 0, /* SSJ5 */
102 0, /* SN2 */
103 0, /* TOKEN */
104 0, /* VHOST */
105 0, /* SSJ3 */
106 0, /* NICK2 */
107 0, /* UMODE2 */
108 0, /* VL */
109 0, /* TLKEXT */
110 0, /* DODKEY */
111 0, /* DOZIP */
112 0, 0, 0
113 }
114 };
115
116 /*************************************************************************/
117
118 void IRCDModeInit(void)
119 {
120 ModuleSetUserMode(UMODE_a, IRCD_ENABLE);
121 ModuleSetUserMode(UMODE_b, IRCD_ENABLE);
122 ModuleSetUserMode(UMODE_c, IRCD_ENABLE);
123 ModuleSetUserMode(UMODE_d, IRCD_ENABLE);
124 ModuleSetUserMode(UMODE_f, IRCD_ENABLE);
125 ModuleSetUserMode(UMODE_g, IRCD_ENABLE);
126 ModuleSetUserMode(UMODE_i, IRCD_ENABLE);
127 ModuleSetUserMode(UMODE_k, IRCD_ENABLE);
128 ModuleSetUserMode(UMODE_l, IRCD_ENABLE);
129 ModuleSetUserMode(UMODE_n, IRCD_ENABLE);
130 ModuleSetUserMode(UMODE_o, IRCD_ENABLE);
131 ModuleSetUserMode(UMODE_r, IRCD_ENABLE);
132 ModuleSetUserMode(UMODE_s, IRCD_ENABLE);
133 ModuleSetUserMode(UMODE_u, IRCD_ENABLE);
134 ModuleSetUserMode(UMODE_w, IRCD_ENABLE);
135 ModuleSetUserMode(UMODE_x, IRCD_ENABLE);
136 ModuleSetUserMode(UMODE_y, IRCD_ENABLE);
137 ModuleSetUserMode(UMODE_z, IRCD_ENABLE);
138 ModuleSetUserMode(UMODE_D, IRCD_ENABLE);
139 ModuleSetUserMode(UMODE_G, IRCD_ENABLE);
140 ModuleUpdateSQLUserMode();
141 CreateChanBanMode(CMODE_b, add_ban, del_ban);
142 CreateChanBanMode(CMODE_e, add_exception, del_exception);
143 CreateChanBanMode(CMODE_I, add_invite, del_invite);
144
145 /* Channel Modes */
146 CreateChanMode(CMODE_a, NULL, NULL);
147 CreateChanMode(CMODE_i, NULL, NULL);
148 CreateChanMode(CMODE_k, set_key, get_key);
149 CreateChanMode(CMODE_l, set_limit, get_limit);
150 CreateChanMode(CMODE_m, NULL, NULL);
151 CreateChanMode(CMODE_n, NULL, NULL);
152 CreateChanMode(CMODE_p, NULL, NULL);
153 CreateChanMode(CMODE_r, NULL, NULL);
154 CreateChanMode(CMODE_s, NULL, NULL);
155 CreateChanMode(CMODE_t, NULL, NULL);
156
157 ModuleSetChanUMode('%', 'h', STATUS_HALFOP);
158 ModuleSetChanUMode('+', 'v', STATUS_VOICE);
159 ModuleSetChanUMode('@', 'o', STATUS_OP);
160 ModuleSetChanUMode('!', 'a', STATUS_PROTECTED);
161
162 ModuleUpdateSQLChanMode();
163
164 }
165
166 void hybrid_cmd_notice(char *source, char *dest, char *buf)
167 {
168 Uid *ud;
169 User *u;
170
171 ud = find_uid(source);
172 u = finduser(dest);
173 send_cmd((UseTS6 ? (ud ? ud->uid : source) : source),
174 "NOTICE %s :%s", (UseTS6 ? (u ? u->uid : dest) : dest), buf);
175 }
176
177 void hybrid_cmd_privmsg(char *source, char *dest, char *buf)
178 {
179 Uid *ud, *ud2;
180
181 ud = find_uid(source);
182 ud2 = find_uid(dest);
183
184 send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "PRIVMSG %s :%s",
185 (UseTS6 ? (ud2 ? ud2->uid : dest) : dest), buf);
186 }
187
188 void hybrid_cmd_serv_notice(char *source, char *dest, char *msg)
189 {
190 send_cmd(source, "NOTICE $$%s :%s", dest, msg);
191 }
192
193 void hybrid_cmd_serv_privmsg(char *source, char *dest, char *msg)
194 {
195 send_cmd(source, "PRIVMSG $$%s :%s", dest, msg);
196 }
197
198 void hybrid_cmd_global(char *source, char *buf)
199 {
200 Uid *u;
201
202 if (source)
203 {
204 u = find_uid(source);
205 if (u)
206 {
207 send_cmd((UseTS6 ? u->uid : source), "OPERWALL :%s", buf);
208 }
209 else
210 {
211 send_cmd((UseTS6 ? TS6SID : ServerName), "OPERWALL :%s", buf);
212 }
213 }
214 else
215 {
216 send_cmd((UseTS6 ? TS6SID : ServerName), "OPERWALL :%s", buf);
217 }
218 }
219
220 int denora_event_sjoin(char *source, int ac, char **av)
221 {
222 if (denora->protocoldebug)
223 {
224 protocol_debug(source, ac, av);
225 }
226 do_sjoin(source, ac, av);
227 return MOD_CONT;
228 }
229
230 /*
231 1 : const char *source
232 2 : char *nick
233 3 : char *username
234 4 : char *host,
235 5 : char *server
236 6 : char *realname
237 7 : time_t ts
238 8 : uint32 svid
239 9 : uint32 ip
240 10 : char *vhost
241 11 : char *uid
242 12 : int hopcount
243 13 : char *modes
244 */
245 int denora_event_nick(char *source, int ac, char **av)
246 {
247 Server *s;
248 User *user;
249 char *ipchar = NULL;
250
251 if (denora->protocoldebug)
252 {
253 protocol_debug(source, ac, av);
254 }
255
256 if (UseTS6)
257 {
258 if (ac == 9)
259 {
260 s = server_find(source);
261 ipchar = host_resolve(av[5]);
262 /* Source is always the server */
263 *source = '\0';
264 user = do_nick(source, av[0], av[4], av[5], s->name, av[8],
265 strtoul(av[2], NULL, 10), 0, ipchar, NULL,
266 av[7], strtoul(av[1], NULL, 10), av[3], NULL);
267 free(ipchar);
268 }
269 else if (ac == 8)
270 {
271 ipchar = host_resolve(av[5]);
272 user = do_nick(source, av[0], av[4], av[5], av[6], av[7],
273 strtoul(av[2], NULL, 10), 0, ipchar, NULL, NULL,
274 strtoul(av[1], NULL, 10), av[3], NULL);
275 free(ipchar);
276 }
277 else
278 {
279 user = find_byuid(source);
280 do_nick((user ? user->nick : source), av[0], NULL, NULL, NULL,
281 NULL, strtoul(av[1], NULL, 10), 0, NULL, NULL, NULL, 0,
282 NULL, NULL);
283 }
284 }
285 else
286 {
287 if (ac != 2)
288 {
289 ipchar = host_resolve(av[5]);
290 user = do_nick(source, av[0], av[4], av[5], av[6], av[7],
291 strtoul(av[2], NULL, 10), 0, ipchar, NULL, NULL,
292 strtoul(av[1], NULL, 10), av[3], NULL);
293 free(ipchar);
294 }
295 else
296 {
297 do_nick(source, av[0], NULL, NULL, NULL, NULL,
298 strtoul(av[1], NULL, 10), 0, NULL, NULL, NULL, 0,
299 NULL, NULL);
300 }
301 }
302 return MOD_CONT;
303 }
304
305 /*
306 [Jan 07 11:54:45.605915 2006] Source 42DAAAAAA
307 [Jan 07 11:54:45.605972 2006] av[0] = #test
308 [Jan 07 11:54:45.606028 2006] av[1] = test test topic test test
309 */
310 int denora_event_topic(char *source, int ac, char **av)
311 {
312 char *temp[5];
313
314 if (denora->protocoldebug)
315 {
316 protocol_debug(source, ac, av);
317 }
318
319 temp[0] = av[0];
320 temp[1] = source;
321 temp[2] = itostr((int) time(NULL));
322 temp[3] = av[1];
323 do_topic(4, temp);
324 return MOD_CONT;
325 }
326
327 int denora_event_tburst(char *source, int ac, char **av)
328 {
329 if (denora->protocoldebug)
330 {
331 protocol_debug(source, ac, av);
332 }
333 if (ac != 5)
334 return MOD_CONT;
335
336 av[0] = av[1];
337 av[1] = av[3];
338 av[3] = av[4];
339 do_topic(4, av);
340 return MOD_CONT;
341 }
342
343 int denora_event_436(char *source, int ac, char **av)
344 {
345 if (denora->protocoldebug)
346 {
347 protocol_debug(source, ac, av);
348 }
349 if (ac < 1)
350 return MOD_CONT;
351
352 m_nickcoll(av[0]);
353 return MOD_CONT;
354 }
355
356 int denora_event_pong(char *source, int ac, char **av)
357 {
358 if (denora->protocoldebug)
359 {
360 protocol_debug(source, ac, av);
361 }
362 server_store_pong(source, time(NULL));
363 return MOD_CONT;
364 }
365
366 /* *INDENT-OFF* */
367 void moduleAddIRCDMsgs(void)
368 {
369 Message *m;
370
371 if (UseTS6)
372 {
373 if (!BadPtr(Numeric))
374 {
375 TS6SID = sstrdup(Numeric);
376 UseTSMODE = 1; /* TMODE */
377 }
378 else
379 {
380 alog(LOG_NORMAL, "TS6 requires the use of Numeric - exiting");
381 exit(1);
382 }
383 }
384
385 m = createMessage("436", denora_event_436);
386 addCoreMessage(IRCD,m);
387 m = createMessage("AWAY", denora_event_away);
388 addCoreMessage(IRCD,m);
389 m = createMessage("INVITE", denora_event_null);
390 addCoreMessage(IRCD,m);
391 m = createMessage("JOIN", denora_event_join);
392 addCoreMessage(IRCD,m);
393 m = createMessage("KICK", denora_event_kick);
394 addCoreMessage(IRCD,m);
395 m = createMessage("KILL", denora_event_kill);
396 addCoreMessage(IRCD,m);
397 m = createMessage("MODE", denora_event_mode);
398 addCoreMessage(IRCD,m);
399 m = createMessage("PONG", denora_event_pong);
400 addCoreMessage(IRCD,m);
401 m = createMessage("MOTD", denora_event_motd);
402 addCoreMessage(IRCD,m);
403 m = createMessage("NICK", denora_event_nick);
404 addCoreMessage(IRCD,m);
405 m = createMessage("NOTICE", denora_event_notice);
406 addCoreMessage(IRCD,m);
407 m = createMessage("PART", denora_event_part);
408 addCoreMessage(IRCD,m);
409 m = createMessage("PASS", denora_event_pass);
410 addCoreMessage(IRCD,m);
411 m = createMessage("PING", denora_event_ping);
412 addCoreMessage(IRCD,m);
413 m = createMessage("PRIVMSG", denora_event_privmsg);
414 addCoreMessage(IRCD,m);
415 m = createMessage("QUIT", denora_event_quit);
416 addCoreMessage(IRCD,m);
417 m = createMessage("SERVER", denora_event_server);
418 addCoreMessage(IRCD,m);
419 m = createMessage("SQUIT", denora_event_squit);
420 addCoreMessage(IRCD,m);
421 m = createMessage("TOPIC", denora_event_topic);
422 addCoreMessage(IRCD,m);
423 m = createMessage("USER", denora_event_null);
424 addCoreMessage(IRCD,m);
425 m = createMessage("WALLOPS", denora_event_null);
426 addCoreMessage(IRCD,m);
427 m = createMessage("WHOIS", denora_event_whois);
428 addCoreMessage(IRCD,m);
429 m = createMessage("AKILL", denora_event_null);
430 addCoreMessage(IRCD,m);
431 m = createMessage("GLOBOPS", denora_event_null);
432 addCoreMessage(IRCD,m);
433 m = createMessage("GNOTICE", denora_event_null);
434 addCoreMessage(IRCD,m);
435 m = createMessage("GOPER", denora_event_null);
436 addCoreMessage(IRCD,m);
437 m = createMessage("RAKILL", denora_event_null);
438 addCoreMessage(IRCD,m);
439 m = createMessage("SILENCE", denora_event_null);
440 addCoreMessage(IRCD,m);
441 m = createMessage("SQLINE", denora_event_null);
442 addCoreMessage(IRCD,m);
443 m = createMessage("UNSQLINE", denora_event_null);
444 addCoreMessage(IRCD,m);
445 m = createMessage("CAPAB", denora_event_capab);
446 addCoreMessage(IRCD,m);
447 m = createMessage("SJOIN", denora_event_sjoin);
448 addCoreMessage(IRCD,m);
449 m = createMessage("SVINFO", denora_event_svinfo);
450 addCoreMessage(IRCD,m);
451 m = createMessage("EOB", denora_event_eob);
452 addCoreMessage(IRCD,m);
453 m = createMessage("ADMIN", denora_event_null);
454 addCoreMessage(IRCD,m);
455 m = createMessage("ERROR", denora_event_error);
456 addCoreMessage(IRCD,m);
457 m = createMessage("SID", denora_event_sid);
458 addCoreMessage(IRCD,m);
459 m = createMessage("BMASK", denora_event_bmask);
460 addCoreMessage(IRCD,m);
461 m = createMessage("UID", denora_event_nick);
462 addCoreMessage(IRCD,m);
463 m = createMessage("TMODE", denora_event_tmode);
464 addCoreMessage(IRCD,m);
465 m = createMessage("ENCAP", denora_event_encap);
466 addCoreMessage(IRCD,m);
467 m = createMessage("KLINE", denora_event_kline);
468 addCoreMessage(IRCD,m);
469 m = createMessage("UNKLINE", denora_event_unkline);
470 addCoreMessage(IRCD,m);
471 m = createMessage("RKLINE", denora_event_kline);
472 addCoreMessage(IRCD,m);
473 m = createMessage("UNRKLINE", denora_event_unkline);
474 addCoreMessage(IRCD,m);
475 m = createMessage("XLINE", denora_event_xline);
476 addCoreMessage(IRCD,m);
477 m = createMessage("RXLINE", denora_event_xline);
478 addCoreMessage(IRCD,m);
479 m = createMessage("UNXLINE", denora_event_unxline);
480 addCoreMessage(IRCD,m);
481 m = createMessage("UNRXLINE", denora_event_unxline);
482 addCoreMessage(IRCD,m);
483 }
484
485 /* *INDENT-ON* */
486
487 int denora_event_kline(char *source, int ac, char **av)
488 {
489 char buf[BUFSIZE];
490 *buf = '\0';
491
492 if (denora->protocoldebug)
493 {
494 protocol_debug(source, ac, av);
495 }
496 ircsnprintf(buf, BUFSIZE, "%ld", (long int) time(NULL));
497 sql_do_server_bans_add(NULL, av[2], av[3], source, buf, av[1], av[4]);
498 return MOD_CONT;
499 }
500
501 int denora_event_unkline(char *source, int ac, char **av)
502 {
503 if (denora->protocoldebug)
504 {
505 protocol_debug(source, ac, av);
506 }
507 sql_do_server_bans_remove(NULL, av[1], av[2]);
508 return MOD_CONT;
509 }
510
511 int denora_event_xline(char *source, int ac, char **av)
512 {
513 if (denora->protocoldebug)
514 {
515 protocol_debug(source, ac, av);
516 }
517 sql_do_xline(av[1], av[3]);
518 return MOD_CONT;
519 }
520
521 int denora_event_unxline(char *source, int ac, char **av)
522 {
523 if (denora->protocoldebug)
524 {
525 protocol_debug(source, ac, av);
526 }
527 sql_do_unxline(av[1]);
528 return MOD_CONT;
529 }
530
531 int denora_event_encap(char *source, int ac, char **av)
532 {
533 if (denora->protocoldebug)
534 {
535 protocol_debug(source, ac, av);
536 }
537 if (!stricmp(av[1], "CHGNAME"))
538 {
539 change_user_realname(av[2], av[3]);
540 }
541 if (!stricmp(av[1], "CHGHOST"))
542 {
543 change_user_host(av[2], av[3]);
544 }
545 if (!stricmp(av[1], "CHGIDENT"))
546 {
547 change_user_username(av[2], av[3]);
548 }
549 if (!stricmp(av[1], "XLINE"))
550 {
551 sql_do_xline(av[3], av[5]);
552 }
553 if (!stricmp(av[1], "SVSNICK"))
554 {
555 do_nick(av[2], av[3], NULL, NULL, NULL, NULL,
556 time(NULL), 0, NULL, NULL, NULL, 0, NULL, NULL);
557 }
558 return MOD_CONT;
559 }
560
561 void hybrid_cmd_join(char *user, char *channel, time_t chantime)
562 {
563 Uid *ud;
564
565 ud = find_uid(user);
566 send_cmd(NULL, "SJOIN %ld %s + :%s", (long int) chantime,
567 channel, (UseTS6 ? (ud ? ud->uid : user) : user));
568 if (AutoOp && AutoMode && LogChannel == channel)
569 denora_automode(channel);
570 }
571
572 void hybrid_cmd_version(char *server)
573 {
574 Uid *ud;
575 ud = find_uid(s_StatServ);
576
577 send_cmd((ud ? ud->uid : s_StatServ), "VERSION %s", server);
578 }
579
580 void hybrid_cmd_motd(char *sender, char *server)
581 {
582 Uid *ud;
583 ud = find_uid(sender);
584
585 send_cmd((ud ? ud->uid : sender), "MOTD %s", server);
586 }
587
588 /*
589 * SVINFO
590 * parv[0] = sender prefix
591 * parv[1] = TS_CURRENT for the server
592 * parv[2] = TS_MIN for the server
593 * parv[3] = server is standalone or connected to non-TS only
594 * parv[4] = server's idea of UTC time
595 */
596 void hybrid_cmd_svinfo(void)
597 {
598 if (UseTS6)
599 {
600 send_cmd(NULL, "SVINFO 6 3 0 :%ld", (long int) time(NULL));
601 }
602 else
603 {
604 send_cmd(NULL, "SVINFO 5 5 0 :%ld", (long int) time(NULL));
605 }
606 }
607
608 /* CAPAB */
609 /*
610 QS - Can handle quit storm removal
611 EX - Can do channel +e exemptions
612 CHW - Can do channel wall @#
613 LL - Can do lazy links
614 IE - Can do invite exceptions
615 EOB - Can do EOB message
616 KLN - Can do KLINE message
617 GLN - Can do GLINE message
618 HOPS - can do half ops (+h)
619 HUB - This server is a HUB
620 AOPS - Can do anon ops (+a)
621 UID - Can do UIDs
622 ZIP - Can do ZIPlinks
623 ENC - Can do ENCrypted links
624 KNOCK - supports KNOCK
625 TBURST - supports TBURST
626 PARA - supports invite broadcasting for +p
627 ENCAP - ?
628 */
629 void hybrid_cmd_capab(void)
630 {
631 send_cmd(NULL,
632 "CAPAB :TB KNOCK UNKLN KLN GLN ENCAP CHW IE HOPS CLUSTER EOB LL QS HUB EX");
633 }
634
635 void hybrid_cmd_stats(char *sender, const char *letter, char *server)
636 {
637 Uid *ud;
638 ud = find_uid(sender);
639
640 send_cmd((ud ? ud->uid : sender), "STATS %s %s", letter, server);
641 }
642
643 /* PASS */
644 void hybrid_cmd_pass(char *pass)
645 {
646 if (UseTS6)
647 {
648 send_cmd(NULL, "PASS %s TS 6 :%s", pass, TS6SID);
649 }
650 else
651 {
652 send_cmd(NULL, "PASS %s :TS", pass);
653 }
654 }
655
656 /* SERVER name hop descript */
657 void hybrid_cmd_server(char *servname, int hop, char *descript)
658 {
659 send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
660 }
661
662 void hybrid_cmd_connect(void)
663 {
664 /* Make myself known to myself in the serverlist */
665 if (UseTS6 && Numeric)
666 {
667 me_server =
668 do_server(NULL, ServerName, (char *) "0", ServerDesc, TS6SID);
669 }
670 else
671 {
672 me_server =
673 do_server(NULL, ServerName, (char *) "0", ServerDesc, NULL);
674 }
675
676 hybrid_cmd_pass(RemotePassword);
677 hybrid_cmd_capab();
678 hybrid_cmd_server(ServerName, 1, ServerDesc);
679 hybrid_cmd_svinfo();
680 }
681
682 void hybrid_cmd_bot_nick(char *nick, char *user, char *host, char *real,
683 char *modes)
684 {
685 char *nicknumbuf = ts6_uid_retrieve();
686
687 if (UseTS6)
688 {
689 send_cmd(TS6SID, "UID %s 1 %ld %s %s %s 0 %s :%s", nick,
690 (long int) time(NULL), modes, user, host, nicknumbuf,
691 real);
692
693 new_uid(nick, nicknumbuf);
694 }
695 else
696 {
697 send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick,
698 (long int) time(NULL), modes, user, host, ServerName,
699 real);
700 }
701 }
702
703 void hybrid_cmd_part(char *nick, char *chan, char *buf)
704 {
705 Uid *ud;
706
707 ud = find_uid(nick);
708
709 if (buf)
710 {
711 send_cmd((UseTS6 ? ud->uid : nick), "PART %s :%s", chan, buf);
712 }
713 else
714 {
715 send_cmd((UseTS6 ? ud->uid : nick), "PART %s", chan);
716 }
717 }
718
719 int denora_event_ping(char *source, int ac, char **av)
720 {
721 char buf[BUFSIZE];
722 int i;
723
724 *buf = '\0';
725 if (denora->protocoldebug)
726 {
727 protocol_debug(source, ac, av);
728 }
729 if (ac < 1)
730 return MOD_CONT;
731
732 *buf = '\0';
733 for (i=0; i < ac; i++)
734 ircsnprintf(buf, BUFSIZE, "%s %s", buf, av[i]);
735
736 hybrid_cmd_pong(source, buf);
737 return MOD_CONT;
738 }
739
740 int denora_event_away(char *source, int ac, char **av)
741 {
742 if (denora->protocoldebug)
743 {
744 protocol_debug(source, ac, av);
745 }
746 m_away(source, (ac ? av[0] : NULL));
747 return MOD_CONT;
748 }
749
750 int denora_event_kill(char *source, int ac, char **av)
751 {
752 if (denora->protocoldebug)
753 {
754 protocol_debug(source, ac, av);
755 }
756 if (ac != 2)
757 return MOD_CONT;
758
759 m_kill(source, av[0], av[1]);
760 return MOD_CONT;
761 }
762
763 int denora_event_kick(char *source, int ac, char **av)
764 {
765 if (denora->protocoldebug)
766 {
767 protocol_debug(source, ac, av);
768 }
769 if (ac != 3)
770 return MOD_CONT;
771 do_kick(source, ac, av);
772 return MOD_CONT;
773 }
774
775 int denora_event_eob(char *source, int ac, char **av)
776 {
777 if (denora->protocoldebug)
778 {
779 protocol_debug(source, ac, av);
780 }
781 update_sync_state(source, SYNC_COMPLETE);
782 return MOD_CONT;
783 }
784
785 void hybrid_cmd_eob(void)
786 {
787 send_cmd(ServerName, "EOB");
788 }
789
790 void hybrid_cmd_ping(char *server)
791 {
792 send_cmd(ServerName, "PING %s :%s", ServerName, server);
793 }
794
795 int denora_event_join(char *source, int ac, char **av)
796 {
797 if (denora->protocoldebug)
798 {
799 protocol_debug(source, ac, av);
800 }
801 if (ac != 1)
802 return MOD_CONT;
803 do_join(source, ac, av);
804 return MOD_CONT;
805 }
806
807 int denora_event_motd(char *source, int ac, char **av)
808 {
809 if (denora->protocoldebug)
810 {
811 protocol_debug(source, ac, av);
812 }
813 m_motd(source);
814 return MOD_CONT;
815 }
816
817 int denora_event_privmsg(char *source, int ac, char **av)
818 {
819 User *u = NULL;
820 Uid *ud = NULL;
821
822 if (denora->protocoldebug)
823 {
824 protocol_debug(source, ac, av);
825 }
826 if (ac != 2)
827 {
828 return MOD_CONT;
829 }
830
831 if (UseTS6)
832 {
833 u = find_byuid(source);
834 ud = find_nickuid(av[0]);
835 }
836 m_privmsg((UseTS6 ? (u ? u->nick : source) : source),
837 (UseTS6 ? (ud ? ud->nick : av[0]) : av[0]), av[1]);
838 return MOD_CONT;
839 }
840
841 int denora_event_part(char *source, int ac, char **av)
842 {
843 if (denora->protocoldebug)
844 {
845 protocol_debug(source, ac, av);
846 }
847 do_part(source, ac, av);
848 return MOD_CONT;
849 }
850
851 int denora_event_whois(char *source, int ac, char **av)
852 {
853 Uid *ud;
854
855 if (denora->protocoldebug)
856 {
857 protocol_debug(source, ac, av);
858 }
859
860 if (source && ac >= 1)
861 {
862 ud = find_nickuid(av[0]);
863 m_whois(source, (UseTS6 ? (ud ? ud->nick : av[0]) : av[0]));
864 }
865 return MOD_CONT;
866 }
867
868 /* EVENT: SERVER */
869 int denora_event_server(char *source, int ac, char **av)
870 {
871 if (denora->protocoldebug)
872 {
873 protocol_debug(source, ac, av);
874 }
875 if (!denora->uplink)
876 {
877 denora->uplink = sstrdup(av[0]);
878 }
879 do_server(source, av[0], av[1], av[2],(!stricmp(av[1], "1") && UseTS6 && TS6UPLINK ? TS6UPLINK : NULL));
880 return MOD_CONT;
881 }
882
883 int denora_event_sid(char *source, int ac, char **av)
884 {
885 Server *s;
886
887 /* :42X SID trystan.nomadirc.net 2 43X :ircd-ratbox test server */
888
889 if (denora->protocoldebug)
890 {
891 protocol_debug(source, ac, av);
892 }
893
894 s = server_find(source);
895
896 do_server(s->name, av[0], av[1], av[3], av[2]);
897 return MOD_CONT;
898 }
899
900 int denora_event_squit(char *source, int ac, char **av)
901 {
902 if (denora->protocoldebug)
903 {
904 protocol_debug(source, ac, av);
905 }
906 if (ac != 2)
907 return MOD_CONT;
908 do_squit(av[0]);
909 return MOD_CONT;
910 }
911
912 int denora_event_quit(char *source, int ac, char **av)
913 {
914 if (denora->protocoldebug)
915 {
916 protocol_debug(source, ac, av);
917 }
918 if (ac != 1)
919 return MOD_CONT;
920 do_quit(source, ac, av);
921 return MOD_CONT;
922 }
923
924 void hybrid_cmd_mode(char *source, char *dest, char *buf)
925 {
926 Uid *ud;
927
928 if (source)
929 {
930 ud = find_uid(source);
931 send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "MODE %s %s",
932 dest, buf);
933 }
934 else
935 {
936 send_cmd(source, "MODE %s %s", dest, buf);
937 }
938 }
939
940 void hybrid_cmd_nick(char *nick, char *name, const char *mode)
941 {
942 char *nicknumbuf = ts6_uid_retrieve();
943 if (UseTS6)
944 {
945 send_cmd(TS6SID, "UID %s 1 %ld %s %s %s 0 %s :%s", nick,
946 (long int) time(NULL), mode, ServiceUser, ServiceHost,
947 nicknumbuf, name);
948
949 new_uid(nick, nicknumbuf);
950 }
951 else
952 {
953 send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick,
954 (long int) time(NULL), mode, ServiceUser, ServiceHost,
955 ServerName, name);
956 }
957 }
958
959 /* QUIT */
960 void hybrid_cmd_quit(char *source, char *buf)
961 {
962 Uid *ud;
963 ud = find_uid(source);
964
965 if (buf)
966 {
967 send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "QUIT :%s",
968 buf);
969 }
970 else
971 {
972 send_cmd((UseTS6 ? (ud ? ud->uid : source) : source), "QUIT");
973 }
974 }
975
976 int denora_event_pass(char *source, int ac, char **av)
977 {
978 if (denora->protocoldebug)
979 {
980 protocol_debug(source, ac, av);
981 }
982 if (UseTS6)
983 {
984 if (av[3])
985 {
986 TS6UPLINK = sstrdup(av[3]);
987 }
988 }
989 return MOD_CONT;
990 }
991
992 /* :42X BMASK 1106409026 #ircops b :*!*@*.aol.com */
993 int denora_event_bmask(char *source, int ac, char **av)
994 {
995 if (denora->protocoldebug)
996 {
997 protocol_debug(source, ac, av);
998 }
999 do_bmask(av);
1000 return MOD_CONT;
1001 }
1002
1003 /* PONG */
1004 void hybrid_cmd_pong(char *source, char *buf)
1005 {
1006 int ac;
1007 char **av;
1008 ac = split_buf(buf, &av);
1009
1010 if (UseTS6)
1011 {
1012 send_cmd(TS6SID, "PONG %s :%s", av[2] ? av[2] : TS6SID, av[1]);
1013 }
1014 else
1015 {
1016 send_cmd(source, "PONG %s :%s", av[2] ? av[2] : source, av[1]);
1017 }
1018 }
1019
1020 /* SQUIT */
1021 void hybrid_cmd_squit(char *servname, char *message)
1022 {
1023 send_cmd(NULL, "SQUIT %s :%s", servname, message);
1024 }
1025
1026 int denora_event_mode(char *source, int ac, char **av)
1027 {
1028 User *u, *u2;
1029
1030 if (denora->protocoldebug)
1031 {
1032 protocol_debug(source, ac, av);
1033 }
1034
1035 if (ac < 2)
1036 {
1037 return MOD_CONT;
1038 }
1039
1040 if (*av[0] == '#' || *av[0] == '&')
1041 {
1042 do_cmode(source, ac, av);
1043 }
1044 else
1045 {
1046 if (UseTS6)
1047 {
1048 u = find_byuid(source);
1049 u2 = find_byuid(av[0]);
1050 av[0] = u2->nick;
1051 do_umode(u->nick, ac, av);
1052 }
1053 else
1054 {
1055 do_umode(source, ac, av);
1056 }
1057 }
1058 return MOD_CONT;
1059 }
1060
1061 int denora_event_tmode(char *source, int ac, char **av)
1062 {
1063 if (denora->protocoldebug)
1064 {
1065 protocol_debug(source, ac, av);
1066 }
1067 if (*av[1] == '#' || *av[1] == '&')
1068 {
1069 do_cmode(source, ac, av);
1070 }
1071 return MOD_CONT;
1072 }
1073
1074 /* Event: PROTOCTL */
1075 int denora_event_capab(char *source, int ac, char **av)
1076 {
1077 if (denora->protocoldebug)
1078 {
1079 protocol_debug(source, ac, av);
1080 }
1081 capab_parse(ac, av);
1082 return MOD_CONT;
1083 }
1084
1085 /*
1086 * SVINFO
1087 * parv[0] = sender prefix
1088 * parv[1] = TS_CURRENT for the server
1089 * parv[2] = TS_MIN for the server
1090 * parv[3] = server is standalone or connected to non-TS only
1091 * parv[4] = server's idea of UTC time
1092 */
1093 int denora_event_svinfo(char *source, int ac, char **av)
1094 {
1095 if (denora->protocoldebug)
1096 {
1097 protocol_debug(source, ac, av);
1098 }
1099 /* currently not used but removes the message : unknown message from server */
1100 return MOD_CONT;
1101 }
1102
1103 int denora_event_error(char *source, int ac, char **av)
1104 {
1105 if (denora->protocoldebug)
1106 {
1107 protocol_debug(source, ac, av);
1108 }
1109 if (ac >= 1)
1110 {
1111 alog(LOG_ERROR, "ERROR: %s", av[0]);
1112 }
1113 return MOD_CONT;
1114 }
1115
1116 void hybrid_cmd_ctcp(char *source, char *dest, char *buf)
1117 {
1118 send_cmd(source, "NOTICE %s :\1%s \1", dest, buf);
1119 }
1120
1121 int denora_event_notice(char *source, int ac, char **av)
1122 {
1123 if (denora->protocoldebug)
1124 {
1125 protocol_debug(source, ac, av);
1126 }
1127 if (ac != 2)
1128 {
1129 return MOD_CONT;
1130 }
1131 m_notice(source, av[0], av[1]);
1132 return MOD_CONT;
1133 }
1134
1135 void moduleAddIRCDCmds()
1136 {
1137 pmodule_cmd_nick(hybrid_cmd_nick);
1138 pmodule_cmd_mode(hybrid_cmd_mode);
1139 pmodule_cmd_bot_nick(hybrid_cmd_bot_nick);
1140 pmodule_cmd_notice(hybrid_cmd_notice);
1141 pmodule_cmd_privmsg(hybrid_cmd_privmsg);
1142 pmodule_cmd_serv_notice(hybrid_cmd_serv_notice);
1143 pmodule_cmd_serv_privmsg(hybrid_cmd_serv_privmsg);
1144 pmodule_cmd_quit(hybrid_cmd_quit);
1145 pmodule_cmd_pong(hybrid_cmd_pong);
1146 pmodule_cmd_join(hybrid_cmd_join);
1147 pmodule_cmd_part(hybrid_cmd_part);
1148 pmodule_cmd_global(hybrid_cmd_global);
1149 pmodule_cmd_squit(hybrid_cmd_squit);
1150 pmodule_cmd_connect(hybrid_cmd_connect);
1151 pmodule_cmd_eob(hybrid_cmd_eob);
1152 pmodule_cmd_ctcp(hybrid_cmd_ctcp);
1153 pmodule_cmd_version(hybrid_cmd_version);
1154 pmodule_cmd_stats(hybrid_cmd_stats);
1155 pmodule_cmd_motd(hybrid_cmd_motd);
1156 pmodule_cmd_ping(hybrid_cmd_ping);
1157 }
1158
1159 int DenoraInit(int argc, char **argv)
1160 {
1161 if (denora->protocoldebug)
1162 {
1163 protocol_debug(NULL, argc, argv);
1164 }
1165 /* Only 1 protocol module may be loaded */
1166 if (protocolModuleLoaded())
1167 {
1168 alog(LOG_NORMAL, langstr(ALOG_MOD_BE_ONLY_ONE));
1169 return MOD_STOP;
1170 }
1171
1172 moduleAddAuthor("Denora");
1173 moduleAddVersion("");
1174 moduleSetType(PROTOCOL);
1175
1176 if (!UseTS6)
1177 {
1178 alog(LOG_ERROR,
1179 "You need to enable TS6 in config for the hybrid module to work");
1180 denora->quitting = 1;
1181 return MOD_STOP;
1182 }
1183
1184 if (!Numeric)
1185 {
1186 alog(LOG_ERROR,
1187 "You need to specify a valid numeric in config for the hybrid module to work");
1188 denora->quitting = 1;
1189 return MOD_STOP;
1190 }
1191
1192 pmodule_ircd_version("Hybrid IRCd 7.x");
1193 pmodule_ircd_cap(myIrcdcap);
1194 pmodule_ircd_var(myIrcd);
1195 pmodule_ircd_useTSMode(0);
1196 IRCDModeInit();
1197 pmodule_oper_umode(UMODE_o);
1198 pmodule_irc_var(IRC_HYBRID);
1199 moduleAddIRCDCmds();
1200 moduleAddIRCDMsgs();
1201
1202 return MOD_CONT;
1203 }

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28