Guest User

Untitled

a guest
Jun 23rd, 2018
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 67.98 KB | None | 0 0
  1. /* Unreal IRCD 3.2.x functions
  2. *
  3. * (C) 2003-2011 Anope Team
  4. * Contact us at team@anope.org
  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.  
  14. /*************************************************************************/
  15.  
  16. #include "services.h"
  17. #include "pseudo.h"
  18. #include "unreal32.h"
  19. #include "version.h"
  20.  
  21. IRCDVar myIrcd[] = {
  22. {"UnrealIRCd 3.2.x", /* ircd name */
  23. "+oSH", /* nickserv mode */
  24. "+oSH", /* chanserv mode */
  25. "+oSH", /* memoserv mode */
  26. "+oSH", /* hostserv mode */
  27. "+ioSH", /* operserv mode */
  28. "+oSH", /* botserv mode */
  29. "+oSH", /* helpserv mode */
  30. "+iSH", /* Dev/Null mode */
  31. "+ioSH", /* Global mode */
  32. "+oSH", /* nickserv alias mode */
  33. "+oSH", /* chanserv alias mode */
  34. "+oSH", /* memoserv alias mode */
  35. "+ioSH", /* hostserv alias mode */
  36. "+ioSH", /* operserv alias mode */
  37. "+oSH", /* botserv alias mode */
  38. "+oSH", /* helpserv alias mode */
  39. "+iSH", /* Dev/Null alias mode */
  40. "+ioSH", /* Global alias mode */
  41. "+SH", /* Used by BotServ Bots */
  42. 5, /* Chan Max Symbols */
  43. "-cijlmnpstuzACGKMNOQRSTV", /* Modes to Remove */
  44. # "+ao", /* Channel Umode used by Botserv bots */
  45. 1, /* SVSNICK */
  46. 1, /* Vhost */
  47. 1, /* Has Owner */
  48. "+q", /* Mode to set for an owner */
  49. "-q", /* Mode to unset for an owner */
  50. "+a", /* Mode to set for channel admin */
  51. "-a", /* Mode to unset for channel admin */
  52. "+rd", /* Mode On Reg */
  53. NULL, /* Mode on ID for Roots */
  54. NULL, /* Mode on ID for Admins */
  55. NULL, /* Mode on ID for Opers */
  56. "-r+d", /* Mode on UnReg */
  57. "-r+d", /* Mode on Nick Change */
  58. 1, /* Supports SGlines */
  59. 1, /* Supports SQlines */
  60. 1, /* Supports SZlines */
  61. 1, /* Supports Halfop +h */
  62. 3, /* Number of server args */
  63. 0, /* Join 2 Set */
  64. 0, /* Join 2 Message */
  65. 1, /* Has exceptions +e */
  66. 1, /* TS Topic Forward */
  67. 0, /* TS Topci Backward */
  68. UMODE_S, /* Protected Umode */
  69. 0, /* Has Admin */
  70. 0, /* Chan SQlines */
  71. 0, /* Quit on Kill */
  72. 1, /* SVSMODE unban */
  73. 1, /* Has Protect */
  74. 1, /* Reverse */
  75. 1, /* Chan Reg */
  76. CMODE_r, /* Channel Mode */
  77. 1, /* vidents */
  78. 1, /* svshold */
  79. 1, /* time stamp on mode */
  80. 1, /* NICKIP */
  81. 1, /* O:LINE */
  82. 1, /* UMODE */
  83. 1, /* VHOST ON NICK */
  84. 1, /* Change RealName */
  85. CMODE_K, /* No Knock */
  86. CMODE_A, /* Admin Only */
  87. DEFAULT_MLOCK, /* Default MLOCK */
  88. UMODE_x, /* Vhost Mode */
  89. 1, /* +f */
  90. 1, /* +L */
  91. CMODE_f, /* +f Mode */
  92. CMODE_L, /* +L Mode */
  93. 0, /* On nick change check if they could be identified */
  94. 1, /* No Knock requires +i */
  95. NULL, /* CAPAB Chan Modes */
  96. 1, /* We support Unreal TOKENS */
  97. 0, /* TOKENS are CASE Sensitive */
  98. 1, /* TIME STAMPS are BASE64 */
  99. 1, /* +I support */
  100. '&', /* SJOIN ban char */
  101. '\"', /* SJOIN except char */
  102. '\'', /* SJOIN invite char */
  103. 1, /* Can remove User Channel Modes with SVSMODE */
  104. 0, /* Sglines are not enforced until user reconnects */
  105. "x", /* vhost char */
  106. 0, /* ts6 */
  107. 1, /* support helper umode */
  108. 0, /* p10 */
  109. NULL, /* character set */
  110. 1, /* reports sync state */
  111. 0, /* CIDR channelbans */
  112. 1, /* +j */
  113. CMODE_j, /* +j Mode */
  114. 0, /* Use delayed client introduction. */
  115. }
  116. ,
  117. {NULL}
  118. };
  119.  
  120. IRCDCAPAB myIrcdcap[] = {
  121. {
  122. CAPAB_NOQUIT, /* NOQUIT */
  123. 0, /* TSMODE */
  124. 0, /* UNCONNECT */
  125. CAPAB_NICKIP, /* NICKIP */
  126. 0, /* SJOIN */
  127. CAPAB_ZIP, /* ZIP */
  128. 0, /* BURST */
  129. 0, /* TS5 */
  130. 0, /* TS3 */
  131. 0, /* DKEY */
  132. 0, /* PT4 */
  133. 0, /* SCS */
  134. 0, /* QS */
  135. 0, /* UID */
  136. 0, /* KNOCK */
  137. 0, /* CLIENT */
  138. 0, /* IPV6 */
  139. 0, /* SSJ5 */
  140. 0, /* SN2 */
  141. CAPAB_TOKEN, /* TOKEN */
  142. 0, /* VHOST */
  143. CAPAB_SSJ3, /* SSJ3 */
  144. CAPAB_NICK2, /* NICK2 */
  145. CAPAB_UMODE2, /* UMODE2 */
  146. CAPAB_VL, /* VL */
  147. CAPAB_TLKEXT, /* TLKEXT */
  148. 0, /* DODKEY */
  149. 0, /* DOZIP */
  150. CAPAB_CHANMODE, /* CHANMODE */
  151. CAPAB_SJB64,
  152. CAPAB_NICKCHARS,
  153. }
  154. };
  155.  
  156.  
  157. unsigned long umodes[128] = {
  158. 0, 0, 0, /* Unused */
  159. 0, 0, 0, /* Unused */
  160. 0, 0, 0, /* Unused, Unused, Horzontal Tab */
  161. 0, 0, 0, /* Line Feed, Unused, Unused */
  162. 0, 0, 0, /* Carriage Return, Unused, Unused */
  163. 0, 0, 0, /* Unused */
  164. 0, 0, 0, /* Unused */
  165. 0, 0, 0, /* Unused */
  166. 0, 0, 0, /* Unused */
  167. 0, 0, 0, /* Unused */
  168. 0, 0, 0, /* Unused, Unused, Space */
  169. 0, 0, 0, /* ! " # */
  170. 0, 0, 0, /* $ % & */
  171. 0, 0, 0, /* ! ( ) */
  172. 0, 0, 0, /* * + , */
  173. 0, 0, 0, /* - . / */
  174. 0, 0, /* 0 1 */
  175. 0, 0, /* 2 3 */
  176. 0, 0, /* 4 5 */
  177. 0, 0, /* 6 7 */
  178. 0, 0, /* 8 9 */
  179. 0, 0, /* : ; */
  180. 0, 0, 0, /* < = > */
  181. 0, 0, /* ? @ */
  182. UMODE_A, UMODE_B, UMODE_C, /* A B C */
  183. 0, 0, 0, /* D E F */
  184. UMODE_G, UMODE_H, 0, /* G H I */
  185. 0, 0, 0, /* J K L */
  186. 0, UMODE_N, UMODE_O, /* M N O */
  187. 0, 0, UMODE_R, /* P Q R */
  188. UMODE_S, UMODE_T, 0, /* S T U */
  189. UMODE_V, UMODE_W, 0, /* V W X */
  190. 0, /* Y */
  191. 0, /* Z */
  192. 0, 0, 0, /* [ \ ] */
  193. 0, 0, 0, /* ^ _ ` */
  194. UMODE_a, 0, 0, /* a b c */
  195. UMODE_d, 0, 0, /* d e f */
  196. UMODE_g, UMODE_h, UMODE_i, /* g h i */
  197. 0, 0, 0, /* j k l */
  198. 0, 0, UMODE_o, /* m n o */
  199. UMODE_p, UMODE_q, UMODE_r, /* p q r */
  200. UMODE_s, UMODE_t, 0, /* s t u */
  201. UMODE_v, UMODE_w, UMODE_x, /* v w x */
  202. 0, /* y */
  203. UMODE_z, /* z */
  204. 0, 0, 0, /* { | } */
  205. 0, 0 /* ~ ΠΏΡ—Π… */
  206. };
  207.  
  208. char myCsmodes[128] = {
  209. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  210. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  211.  
  212. 0,
  213. 0,
  214. 0, 0, 0,
  215. 'h', /* (37) % Channel halfops */
  216. 'b', /* (38) & bans */
  217. 0, 0, 0,
  218. 'q',
  219.  
  220. 'v', 0, 0, 0, 0,
  221. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  222.  
  223. 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  224. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  225.  
  226. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  227. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0
  228. };
  229.  
  230. CMMode myCmmodes[128] = {
  231. {NULL}, {NULL}, {NULL},
  232. {NULL}, {NULL}, {NULL},
  233. {NULL}, {NULL}, {NULL},
  234. {NULL}, {NULL}, {NULL},
  235. {NULL}, {NULL}, {NULL},
  236. {NULL}, {NULL}, {NULL},
  237. {NULL}, {NULL}, {NULL},
  238. {NULL}, {NULL}, {NULL},
  239. {NULL}, {NULL}, {NULL},
  240. {NULL}, {NULL}, {NULL},
  241. {NULL}, {NULL}, {NULL},
  242. {NULL}, {NULL}, {NULL},
  243. {NULL}, {NULL}, {NULL},
  244. {NULL}, {NULL}, {NULL},
  245. {NULL}, {NULL}, {NULL},
  246. {NULL}, {NULL}, {NULL},
  247. {NULL}, {NULL}, {NULL},
  248. {NULL}, {NULL}, {NULL},
  249. {NULL}, {NULL}, {NULL},
  250. {NULL}, {NULL}, {NULL},
  251. {NULL}, {NULL}, {NULL},
  252. {NULL}, {NULL}, {NULL},
  253. {NULL}, {NULL}, {NULL}, /* BCD */
  254. {NULL}, {NULL}, {NULL}, /* EFG */
  255. {NULL}, /* H */
  256. {add_invite, del_invite}, /* I */
  257. {NULL}, /* J */
  258. {NULL}, {NULL}, {NULL}, /* KLM */
  259. {NULL}, {NULL}, {NULL}, /* NOP */
  260. {NULL}, {NULL}, {NULL}, /* QRS */
  261. {NULL}, {NULL}, {NULL}, /* TUV */
  262. {NULL}, {NULL}, {NULL}, /* WXY */
  263. {NULL}, /* Z */
  264. {NULL}, {NULL}, /* (char 91 - 92) */
  265. {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */
  266. {NULL}, /* ` (char 96) */
  267. {NULL}, /* a (char 97) */
  268. {add_ban, del_ban}, /* b */
  269. {NULL}, {NULL}, /* cd */
  270. {add_exception, del_exception},
  271. {NULL}, {NULL},
  272. {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
  273. {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
  274. {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
  275. };
  276.  
  277. CBMode myCbmodes[128] = {
  278. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  279. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  280. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  281. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  282. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  283. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  284. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  285. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  286. {0},
  287. {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL},
  288. {0}, /* B */
  289. {CMODE_C, 0, NULL, NULL}, /* C */
  290. {0}, /* D */
  291. {0}, /* E */
  292. {0}, /* F */
  293. {CMODE_G, 0, NULL, NULL}, /* G */
  294. {0}, /* H */
  295. {0}, /* I */
  296. {0}, /* J */
  297. {CMODE_K, 0, NULL, NULL}, /* K */
  298. {CMODE_L, 0, set_redirect, cs_set_redirect},
  299. {CMODE_M, 0, NULL, NULL}, /* M */
  300. {CMODE_N, 0, NULL, NULL}, /* N */
  301. {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
  302. {0}, /* P */
  303. {CMODE_Q, 0, NULL, NULL}, /* Q */
  304. {CMODE_R, 0, NULL, NULL}, /* R */
  305. {CMODE_S, 0, NULL, NULL}, /* S */
  306. {CMODE_T, 0, NULL, NULL}, /* T */
  307. {0}, /* U */
  308. {CMODE_V, 0, NULL, NULL}, /* V */
  309. {0}, /* W */
  310. {0}, /* X */
  311. {0}, /* Y */
  312. {0}, /* Z */
  313. {0}, {0}, {0}, {0}, {0}, {0},
  314. {0}, /* a */
  315. {0}, /* b */
  316. {CMODE_c, 0, NULL, NULL},
  317. {0}, /* d */
  318. {0}, /* e */
  319. {CMODE_f, 0, set_flood, cs_set_flood},
  320. {0}, /* g */
  321. {0}, /* h */
  322. {CMODE_i, 0, NULL, NULL},
  323. {CMODE_j, CBM_MINUS_NO_ARG | CBM_NO_MLOCK, chan_set_throttle, cs_set_throttle}, /* j */
  324. {CMODE_k, 0, chan_set_key, cs_set_key},
  325. {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
  326. {CMODE_m, 0, NULL, NULL},
  327. {CMODE_n, 0, NULL, NULL},
  328. {0}, /* o */
  329. {CMODE_p, 0, NULL, NULL},
  330. {0}, /* q */
  331. {CMODE_r, CBM_NO_MLOCK, NULL, NULL},
  332. {CMODE_s, 0, NULL, NULL},
  333. {CMODE_t, 0, NULL, NULL},
  334. {CMODE_u, 0, NULL, NULL},
  335. {0}, /* v */
  336. {0}, /* w */
  337. {0}, /* x */
  338. {0}, /* y */
  339. {CMODE_z, 0, NULL, NULL},
  340. {0}, {0}, {0}, {0}
  341. };
  342.  
  343. CBModeInfo myCbmodeinfos[] = {
  344. {'c', CMODE_c, 0, NULL, NULL},
  345. {'f', CMODE_f, 0, get_flood, cs_get_flood},
  346. {'i', CMODE_i, 0, NULL, NULL},
  347. {'j', CMODE_j, 0, get_throttle, cs_get_throttle},
  348. {'k', CMODE_k, 0, get_key, cs_get_key},
  349. {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
  350. {'m', CMODE_m, 0, NULL, NULL},
  351. {'n', CMODE_n, 0, NULL, NULL},
  352. {'p', CMODE_p, 0, NULL, NULL},
  353. {'r', CMODE_r, 0, NULL, NULL},
  354. {'s', CMODE_s, 0, NULL, NULL},
  355. {'t', CMODE_t, 0, NULL, NULL},
  356. {'u', CMODE_u, 0, NULL, NULL},
  357. {'z', CMODE_z, 0, NULL, NULL},
  358. {'A', CMODE_A, 0, NULL, NULL},
  359. {'C', CMODE_C, 0, NULL, NULL},
  360. {'G', CMODE_G, 0, NULL, NULL},
  361. {'K', CMODE_K, 0, NULL, NULL},
  362. {'L', CMODE_L, 0, get_redirect, cs_get_redirect},
  363. {'M', CMODE_M, 0, NULL, NULL},
  364. {'N', CMODE_N, 0, NULL, NULL},
  365. {'O', CMODE_O, 0, NULL, NULL},
  366. {'Q', CMODE_Q, 0, NULL, NULL},
  367. {'R', CMODE_R, 0, NULL, NULL},
  368. {'S', CMODE_S, 0, NULL, NULL},
  369. {'T', CMODE_T, 0, NULL, NULL},
  370. {'V', CMODE_V, 0, NULL, NULL},
  371. {0}
  372. };
  373.  
  374. CUMode myCumodes[128] = {
  375. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  376. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  377. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  378. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  379.  
  380. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  381. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  382. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  383. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  384.  
  385. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  386. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  387. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  388. {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
  389.  
  390. {0},
  391.  
  392. {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op},
  393. {0}, /* b */
  394. {0}, /* c */
  395. {0}, /* d */
  396. {0}, /* e */
  397. {0}, /* f */
  398. {0}, /* g */
  399. {CUS_HALFOP, 0, check_valid_op},
  400. {0}, /* i */
  401. {0}, /* j */
  402. {0}, /* k */
  403. {0}, /* l */
  404. {0}, /* m */
  405. {0}, /* n */
  406. {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
  407. {0}, /* p */
  408. {CUS_OWNER, 0, check_valid_op},
  409. {0}, /* r */
  410. {0}, /* s */
  411. {0}, /* t */
  412. {0}, /* u */
  413. {CUS_VOICE, 0, NULL},
  414. {0}, /* w */
  415. {0}, /* x */
  416. {0}, /* y */
  417. {0}, /* z */
  418. {0}, {0}, {0}, {0}, {0}
  419. };
  420.  
  421.  
  422. void unreal_set_umode(User * user, int ac, char **av)
  423. {
  424. int add = 1; /* 1 if adding modes, 0 if deleting */
  425. char *modes = av[0];
  426.  
  427. ac--;
  428.  
  429. if (!user || !modes) {
  430. /* Prevent NULLs from doing bad things */
  431. return;
  432. }
  433.  
  434. if (debug)
  435. alog("debug: Changing mode for %s to %s", user->nick, modes);
  436.  
  437. while (*modes) {
  438. uint32 backup = user->mode;
  439.  
  440. /* This looks better, much better than "add ? (do_add) : (do_remove)".
  441. * At least this is readable without paying much attention :) -GD
  442. */
  443. if (add)
  444. user->mode |= umodes[(int) *modes];
  445. else
  446. user->mode &= ~umodes[(int) *modes];
  447.  
  448. switch (*modes++) {
  449. case '+':
  450. add = 1;
  451. break;
  452. case '-':
  453. add = 0;
  454. break;
  455. case 'd':
  456. if (ac <= 0) {
  457. break;
  458. }
  459. if (isdigit(*av[1])) {
  460. user->svid = strtoul(av[1], NULL, 0);
  461. user->mode = backup; /* Ugly fix, but should do the job ~ Viper */
  462. }
  463. break;
  464. case 'o':
  465. if (add) {
  466. opcnt++;
  467. if (WallOper) {
  468. anope_cmd_global(s_OperServ,
  469. "\2%s\2 is now an IRC operator.",
  470. user->nick);
  471. }
  472. display_news(user, NEWS_OPER);
  473. } else {
  474. opcnt--;
  475. }
  476. break;
  477. case 'a':
  478. if (UnRestrictSAdmin) {
  479. break;
  480. }
  481. if (add && !is_services_admin(user)) {
  482. common_svsmode(user, "-a", NULL);
  483. user->mode &= ~UMODE_a;
  484. }
  485. break;
  486. case 'r':
  487. if (add && !nick_identified(user)) {
  488. common_svsmode(user, "-r", NULL);
  489. user->mode &= ~UMODE_r;
  490. }
  491. break;
  492. case 'x':
  493. if (!add) {
  494. if (user->vhost)
  495. free(user->vhost);
  496. user->vhost = NULL;
  497. }
  498. update_host(user);
  499. break;
  500. }
  501. }
  502. }
  503.  
  504.  
  505.  
  506.  
  507. /* Event: PROTOCTL */
  508. int anope_event_capab(char *source, int ac, char **av)
  509. {
  510. capab_parse(ac, av);
  511. return MOD_CONT;
  512. }
  513.  
  514. /* SVSNOOP */
  515. void unreal_cmd_svsnoop(char *server, int set)
  516. {
  517. send_cmd(NULL, "%s %s %s", send_token("SVSNOOP", "f"), server,
  518. (set ? "+" : "-"));
  519. }
  520.  
  521. void unreal_cmd_svsadmin(char *server, int set)
  522. {
  523. unreal_cmd_svsnoop(server, set);
  524. }
  525.  
  526. void unreal_cmd_remove_akill(char *user, char *host)
  527. {
  528. send_cmd(NULL, "%s - G %s %s %s", send_token("TKL", "BD"), user, host,
  529. s_OperServ);
  530. }
  531.  
  532. void unreal_cmd_topic(char *whosets, char *chan, char *whosetit,
  533. char *topic, time_t when)
  534. {
  535. send_cmd(whosets, "%s %s %s %lu :%s", send_token("TOPIC", ")"), chan,
  536. whosetit, (unsigned long int) when, topic);
  537. }
  538.  
  539. void unreal_cmd_vhost_off(User * u)
  540. {
  541. common_svsmode(u, "-xt", NULL);
  542. common_svsmode(u, "+x", NULL);
  543.  
  544. notice_lang(s_HostServ, u, HOST_OFF);
  545. }
  546.  
  547. void unreal_cmd_akill(char *user, char *host, char *who, time_t when,
  548. time_t expires, char *reason)
  549. {
  550. send_cmd(NULL, "%s + G %s %s %s %ld %ld :%s", send_token("TKL", "BD"),
  551. user, host, who, (long int) time(NULL) + 86400 * 2,
  552. (long int) when, reason);
  553. }
  554.  
  555. /*
  556. ** svskill
  557. ** parv[0] = servername
  558. ** parv[1] = client
  559. ** parv[2] = kill message
  560. */
  561. void unreal_cmd_svskill(char *source, char *user, char *buf)
  562. {
  563. if (!source || !user || !buf) {
  564. return;
  565. }
  566. send_cmd(source, "%s %s :%s", send_token("SVSKILL", "h"), user, buf);
  567. }
  568.  
  569. /*
  570. * m_svsmode() added by taz
  571. * parv[0] - sender
  572. * parv[1] - username to change mode for
  573. * parv[2] - modes to change
  574. * parv[3] - Service Stamp (if mode == d)
  575. */
  576. void unreal_cmd_svsmode(User * u, int ac, char **av)
  577. {
  578. if (ac >= 1) {
  579. if (!u || !av[0]) {
  580. return;
  581. }
  582. if (UseSVS2MODE) {
  583. send_cmd(ServerName, "%s %s %s%s%s",
  584. send_token("SVS2MODE", "v"), u->nick, av[0],
  585. (ac == 2 ? " " : ""), (ac == 2 ? av[1] : ""));
  586. } else {
  587. send_cmd(ServerName, "%s %s %s%s%s",
  588. send_token("SVSMODE", "n"), u->nick, av[0],
  589. (ac == 2 ? " " : ""), (ac == 2 ? av[1] : ""));
  590. }
  591. }
  592. }
  593.  
  594. /* 372 */
  595. void unreal_cmd_372(char *source, char *msg)
  596. {
  597. send_cmd(ServerName, "372 %s :- %s", source, msg);
  598. }
  599.  
  600. void unreal_cmd_372_error(char *source)
  601. {
  602. send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
  603. "contact your IRC administrator.", source);
  604. }
  605.  
  606. void unreal_cmd_375(char *source)
  607. {
  608. send_cmd(ServerName, "375 %s :- %s Message of the Day",
  609. source, ServerName);
  610. }
  611.  
  612. void unreal_cmd_376(char *source)
  613. {
  614. send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
  615. }
  616.  
  617. void unreal_cmd_nick(char *nick, char *name, char *modes)
  618. {
  619. EnforceQlinedNick(nick, NULL);
  620. send_cmd(NULL, "%s %s 1 %ld %s %s %s 0 %s %s%s :%s",
  621. send_token("NICK", "&"), nick, (long int) time(NULL),
  622. ServiceUser, ServiceHost, ServerName, modes, ServiceHost,
  623. (myIrcd->nickip ? " *" : " "), name);
  624. unreal_cmd_sqline(nick, "Reserved for services");
  625. }
  626.  
  627. void unreal_cmd_guest_nick(char *nick, char *user, char *host, char *real,
  628. char *modes)
  629. {
  630. send_cmd(NULL, "%s %s 1 %ld %s %s %s 0 %s %s%s :%s",
  631. send_token("NICK", "&"), nick, (long int) time(NULL), user,
  632. host, ServerName, modes, host, (myIrcd->nickip ? " *" : " "),
  633. real);
  634. }
  635.  
  636. void unreal_cmd_mode(char *source, char *dest, char *buf)
  637. {
  638. if (!buf) {
  639. return;
  640. }
  641.  
  642. send_cmd(source, "%s %s %s", send_token("MODE", "G"), dest, buf);
  643. }
  644.  
  645. void unreal_cmd_bot_nick(char *nick, char *user, char *host, char *real,
  646. char *modes)
  647. {
  648. EnforceQlinedNick(nick, s_BotServ);
  649. send_cmd(NULL, "%s %s 1 %ld %s %s %s 0 %s %s%s :%s",
  650. send_token("NICK", "&"), nick, (long int) time(NULL), user,
  651. host, ServerName, modes, host, (myIrcd->nickip ? " *" : " "),
  652. real);
  653. unreal_cmd_sqline(nick, "Reserved for services");
  654. }
  655.  
  656. void unreal_cmd_kick(char *source, char *chan, char *user, char *buf)
  657. {
  658. if (buf) {
  659. send_cmd(source, "%s %s %s :%s", send_token("KICK", "H"), chan,
  660. user, buf);
  661. } else {
  662. send_cmd(source, "%s %s %s", send_token("KICK", "H"), chan, user);
  663. }
  664. }
  665.  
  666. void unreal_cmd_notice_ops(char *source, char *dest, char *buf)
  667. {
  668. if (!buf) {
  669. return;
  670. }
  671.  
  672. send_cmd(source, "%s @%s :%s", send_token("NOTICE", "B"), dest, buf);
  673. }
  674.  
  675.  
  676. void unreal_cmd_notice(char *source, char *dest, char *buf)
  677. {
  678. if (!buf) {
  679. return;
  680. }
  681.  
  682. if (NSDefFlags & NI_MSG) {
  683. unreal_cmd_privmsg2(source, dest, buf);
  684. } else {
  685. send_cmd(source, "%s %s :%s", send_token("NOTICE", "B"), dest,
  686. buf);
  687. }
  688. }
  689.  
  690. void unreal_cmd_notice2(char *source, char *dest, char *msg)
  691. {
  692. send_cmd(source, "%s %s :%s", send_token("NOTICE", "B"), dest, msg);
  693. }
  694.  
  695. void unreal_cmd_privmsg(char *source, char *dest, char *buf)
  696. {
  697. if (!buf) {
  698. return;
  699. }
  700.  
  701. send_cmd(source, "%s %s :%s", send_token("PRIVMSG", "!"), dest, buf);
  702. }
  703.  
  704. void unreal_cmd_privmsg2(char *source, char *dest, char *msg)
  705. {
  706. send_cmd(source, "%s %s :%s", send_token("PRIVMSG", "!"), dest, msg);
  707. }
  708.  
  709. void unreal_cmd_serv_notice(char *source, char *dest, char *msg)
  710. {
  711. send_cmd(source, "%s $%s :%s", send_token("NOTICE", "B"), dest, msg);
  712. }
  713.  
  714. void unreal_cmd_serv_privmsg(char *source, char *dest, char *msg)
  715. {
  716. send_cmd(source, "%s $%s :%s", send_token("PRIVMSG", "!"), dest, msg);
  717. }
  718.  
  719. void unreal_cmd_bot_chan_mode(char *nick, char *chan)
  720. {
  721. anope_cmd_mode(nick, chan, "%s %s %s", myIrcd->botchanumode, nick,
  722. nick);
  723. }
  724.  
  725. void unreal_cmd_351(char *source)
  726. {
  727. send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s",
  728. source, version_number, ServerName, myIrcd->name,
  729. version_flags, EncModule, version_build);
  730. }
  731.  
  732. /* QUIT */
  733. void unreal_cmd_quit(char *source, char *buf)
  734. {
  735. if (buf) {
  736. send_cmd(source, "%s :%s", send_token("QUIT", ","), buf);
  737. } else {
  738. send_cmd(source, "%s", send_token("QUIT", ","));
  739. }
  740. }
  741.  
  742. /* PROTOCTL */
  743. /*
  744. NICKv2 = Nick Version 2
  745. VHP = Sends hidden host
  746. UMODE2 = sends UMODE2 on user modes
  747. NICKIP = Sends IP on NICK
  748. TOKEN = Use tokens to talk
  749. SJ3 = Supports SJOIN
  750. NOQUIT = No Quit
  751. TKLEXT = Extended TKL we don't use it but best to have it
  752. SJB64 = Base64 encoded time stamps
  753. VL = Version Info
  754. NS = Numeric Server
  755.  
  756. */
  757. void unreal_cmd_capab()
  758. {
  759. if (UseTokens) {
  760. if (Numeric) {
  761. send_cmd(NULL,
  762. "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT SJB64 VL");
  763. } else {
  764. send_cmd(NULL,
  765. "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT SJB64");
  766. }
  767. } else {
  768. if (Numeric) {
  769. send_cmd(NULL,
  770. "PROTOCTL NICKv2 VHP UMODE2 NICKIP SJOIN SJOIN2 SJ3 NOQUIT TKLEXT SJB64 VL");
  771. } else {
  772. send_cmd(NULL,
  773. "PROTOCTL NICKv2 VHP UMODE2 NICKIP SJOIN SJOIN2 SJ3 NOQUIT TKLEXT SJB64");
  774. }
  775. }
  776. }
  777.  
  778. /* PASS */
  779. void unreal_cmd_pass(char *pass)
  780. {
  781. send_cmd(NULL, "PASS :%s", pass);
  782. }
  783.  
  784. /* SERVER name hop descript */
  785. /* Unreal 3.2 actually sends some info about itself in the descript area */
  786. void unreal_cmd_server(char *servname, int hop, char *descript)
  787. {
  788. if (Numeric) {
  789. send_cmd(NULL, "SERVER %s %d :U0-*-%s %s", servname, hop, Numeric,
  790. descript);
  791. } else {
  792. send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
  793. }
  794. }
  795.  
  796. /* PONG */
  797. void unreal_cmd_pong(char *servname, char *who)
  798. {
  799. send_cmd(servname, "%s %s", send_token("PONG", "9"), who);
  800. }
  801.  
  802. /* JOIN */
  803. void unreal_cmd_join(char *user, char *channel, time_t chantime)
  804. {
  805. send_cmd(ServerName, "%s !%s %s :%s",
  806. send_token("SJOIN", "~"), base64enc((long int) chantime),
  807. channel, user);
  808. /* send_cmd(user, "%s %s", send_token("JOIN", "C"), channel); */
  809. }
  810.  
  811. /* unsqline
  812. ** parv[0] = sender
  813. ** parv[1] = nickmask
  814. */
  815. void unreal_cmd_unsqline(char *user)
  816. {
  817. if (!user) {
  818. return;
  819. }
  820. send_cmd(NULL, "%s %s", send_token("UNSQLINE", "d"), user);
  821. }
  822.  
  823. /* CHGHOST */
  824. void unreal_cmd_chghost(char *nick, char *vhost)
  825. {
  826. if (!nick || !vhost) {
  827. return;
  828. }
  829. send_cmd(ServerName, "%s %s %s", send_token("CHGHOST", "AL"), nick,
  830. vhost);
  831. }
  832.  
  833. /* CHGIDENT */
  834. void unreal_cmd_chgident(char *nick, char *vIdent)
  835. {
  836. if (!nick || !vIdent) {
  837. return;
  838. }
  839. send_cmd(ServerName, "%s %s %s", send_token("CHGIDENT", "AZ"), nick,
  840. vIdent);
  841. }
  842.  
  843. /* INVITE */
  844. void unreal_cmd_invite(char *source, char *chan, char *nick)
  845. {
  846. if (!source || !chan || !nick) {
  847. return;
  848. }
  849.  
  850. send_cmd(source, "%s %s %s", send_token("INVITE", "*"), nick, chan);
  851. }
  852.  
  853. /* PART */
  854. void unreal_cmd_part(char *nick, char *chan, char *buf)
  855. {
  856. if (!nick || !chan) {
  857. return;
  858. }
  859.  
  860. if (buf) {
  861. send_cmd(nick, "%s %s :%s", send_token("PART", "D"), chan, buf);
  862. } else {
  863. send_cmd(nick, "%s %s", send_token("PART", "D"), chan);
  864. }
  865. }
  866.  
  867. /* 391 RPL_TIME ":%s 391 %s %s :%s" */
  868. void unreal_cmd_391(char *source, char *timestr)
  869. {
  870. if (!timestr) {
  871. return;
  872. }
  873. send_cmd(ServerName, "391 %s %s :%s", source, ServerName, timestr);
  874. }
  875.  
  876. /* 250 */
  877. void unreal_cmd_250(char *buf)
  878. {
  879. if (!buf) {
  880. return;
  881. }
  882.  
  883. send_cmd(NULL, "250 %s", buf);
  884. }
  885.  
  886. /* 307 */
  887. void unreal_cmd_307(char *buf)
  888. {
  889. if (!buf) {
  890. return;
  891. }
  892.  
  893. send_cmd(ServerName, "307 %s", buf);
  894. }
  895.  
  896. /* 311 */
  897. void unreal_cmd_311(char *buf)
  898. {
  899. if (!buf) {
  900. return;
  901. }
  902.  
  903. send_cmd(ServerName, "311 %s", buf);
  904. }
  905.  
  906. /* 312 */
  907. void unreal_cmd_312(char *buf)
  908. {
  909. if (!buf) {
  910. return;
  911. }
  912.  
  913. send_cmd(ServerName, "312 %s", buf);
  914. }
  915.  
  916. /* 317 */
  917. void unreal_cmd_317(char *buf)
  918. {
  919. if (!buf) {
  920. return;
  921. }
  922.  
  923. send_cmd(ServerName, "317 %s", buf);
  924. }
  925.  
  926. /* 219 */
  927. void unreal_cmd_219(char *source, char *letter)
  928. {
  929. if (!source) {
  930. return;
  931. }
  932.  
  933. if (letter) {
  934. send_cmd(NULL, "219 %s %c :End of /STATS report.", source,
  935. *letter);
  936. } else {
  937. send_cmd(NULL, "219 %s l :End of /STATS report.", source);
  938. }
  939. }
  940.  
  941. /* 401 */
  942. void unreal_cmd_401(char *source, char *who)
  943. {
  944. if (!source || !who) {
  945. return;
  946. }
  947. send_cmd(ServerName, "401 %s %s :No such service.", source, who);
  948. }
  949.  
  950. /* 318 */
  951. void unreal_cmd_318(char *source, char *who)
  952. {
  953. if (!source || !who) {
  954. return;
  955. }
  956.  
  957. send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who);
  958. }
  959.  
  960. /* 242 */
  961. void unreal_cmd_242(char *buf)
  962. {
  963. if (!buf) {
  964. return;
  965. }
  966.  
  967. send_cmd(NULL, "242 %s", buf);
  968. }
  969.  
  970. /* 243 */
  971. void unreal_cmd_243(char *buf)
  972. {
  973. if (!buf) {
  974. return;
  975. }
  976.  
  977. send_cmd(NULL, "243 %s", buf);
  978. }
  979.  
  980. /* 211 */
  981. void unreal_cmd_211(char *buf)
  982. {
  983. if (!buf) {
  984. return;
  985. }
  986.  
  987. send_cmd(NULL, "211 %s", buf);
  988. }
  989.  
  990. /* GLOBOPS */
  991. void unreal_cmd_global(char *source, char *buf)
  992. {
  993. if (!buf) {
  994. return;
  995. }
  996.  
  997. send_cmd(source ? source : ServerName, "%s :%s",
  998. send_token("GLOBOPS", "]"), buf);
  999. }
  1000.  
  1001. /* GLOBOPS - to handle old WALLOPS */
  1002. void unreal_cmd_global_legacy(char *source, char *fmt)
  1003. {
  1004. send_cmd(source ? source : ServerName, "%s :%s",
  1005. send_token("GLOBOPS", "]"), fmt);
  1006. }
  1007.  
  1008. /* SQLINE */
  1009. /*
  1010. ** parv[0] = sender
  1011. ** parv[1] = nickmask
  1012. ** parv[2] = reason
  1013. **
  1014. ** - Unreal will translate this to TKL for us
  1015. **
  1016. */
  1017. void unreal_cmd_sqline(char *mask, char *reason)
  1018. {
  1019. if (!mask || !reason) {
  1020. return;
  1021. }
  1022.  
  1023. send_cmd(NULL, "%s %s :%s", send_token("SQLINE", "c"), mask, reason);
  1024. }
  1025.  
  1026. /* SQUIT */
  1027. void unreal_cmd_squit(char *servname, char *message)
  1028. {
  1029. if (!servname || !message) {
  1030. return;
  1031. }
  1032.  
  1033. send_cmd(NULL, "%s %s :%s", send_token("SQUIT", "-"), servname,
  1034. message);
  1035. }
  1036.  
  1037. /*
  1038. ** svso
  1039. ** parv[0] = sender prefix
  1040. ** parv[1] = nick
  1041. ** parv[2] = options
  1042. */
  1043. void unreal_cmd_svso(char *source, char *nick, char *flag)
  1044. {
  1045. if (!source || !nick || !flag) {
  1046. return;
  1047. }
  1048.  
  1049. send_cmd(source, "%s %s %s", send_token("SVSO", "BB"), nick, flag);
  1050. }
  1051.  
  1052. /* NICK <newnick> */
  1053. void unreal_cmd_chg_nick(char *oldnick, char *newnick)
  1054. {
  1055. if (!oldnick || !newnick) {
  1056. return;
  1057. }
  1058.  
  1059. send_cmd(oldnick, "%s %s %ld", send_token("NICK", "&"), newnick,
  1060. (long int) time(NULL));
  1061. }
  1062.  
  1063. /* SVSNICK */
  1064. /*
  1065. ** parv[0] = sender
  1066. ** parv[1] = old nickname
  1067. ** parv[2] = new nickname
  1068. ** parv[3] = timestamp
  1069. */
  1070. void unreal_cmd_svsnick(char *source, char *guest, time_t when)
  1071. {
  1072. if (!source || !guest) {
  1073. return;
  1074. }
  1075. send_cmd(NULL, "%s %s %s :%ld", send_token("SVSNICK", "e"), source,
  1076. guest, (long int) when);
  1077. }
  1078.  
  1079. /* Functions that use serval cmd functions */
  1080.  
  1081. void unreal_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
  1082. {
  1083. if (!nick) {
  1084. return;
  1085. }
  1086. if (vIdent) {
  1087. unreal_cmd_chgident(nick, vIdent);
  1088. }
  1089. unreal_cmd_chghost(nick, vhost);
  1090. }
  1091.  
  1092. void unreal_cmd_connect(int servernum)
  1093. {
  1094. if (Numeric) {
  1095. me_server =
  1096. new_server(NULL, ServerName, ServerDesc, SERVER_ISME, Numeric);
  1097. } else {
  1098. me_server =
  1099. new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
  1100. }
  1101.  
  1102. unreal_cmd_capab();
  1103. if (servernum == 1) {
  1104. unreal_cmd_pass(RemotePassword);
  1105. }
  1106. if (servernum == 2) {
  1107. unreal_cmd_pass(RemotePassword2);
  1108. }
  1109. if (servernum == 3) {
  1110. unreal_cmd_pass(RemotePassword3);
  1111. }
  1112. unreal_cmd_server(ServerName, 1, ServerDesc);
  1113. }
  1114.  
  1115. void unreal_cmd_bob()
  1116. {
  1117. /* Not used */
  1118. }
  1119.  
  1120. /* Events */
  1121.  
  1122. int anope_event_ping(char *source, int ac, char **av)
  1123. {
  1124. if (ac < 1)
  1125. return MOD_CONT;
  1126. unreal_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
  1127. return MOD_CONT;
  1128. }
  1129.  
  1130. void unreal_cmd_netinfo(int ac, char **av)
  1131. {
  1132. send_cmd(NULL, "%s %ld %ld %d %s 0 0 0 :%s",
  1133. send_token("NETINFO", "AO"), (long int) maxusercnt,
  1134. (long int) time(NULL), atoi(av[2]), av[3], av[7]);
  1135. }
  1136.  
  1137. /* netinfo
  1138. * argv[0] = max global count
  1139. * argv[1] = time of end sync
  1140. * argv[2] = unreal protocol using (numeric)
  1141. * argv[3] = cloak-crc (> u2302)
  1142. * argv[4] = free(**)
  1143. * argv[5] = free(**)
  1144. * argv[6] = free(**)
  1145. * argv[7] = ircnet
  1146. */
  1147. int anope_event_netinfo(char *source, int ac, char **av)
  1148. {
  1149. unreal_cmd_netinfo(ac, av);
  1150. return MOD_CONT;
  1151. }
  1152.  
  1153.  
  1154. /* TKL
  1155. * add: remove: spamfilter: spamfilter+TKLEXT sqline:
  1156. * parv[ 1]: + - +/- + +/-
  1157. * parv[ 2]: type type type type type
  1158. * parv[ 3]: user user target target hold
  1159. * parv[ 4]: host host action action host
  1160. * parv[ 5]: setby removedby (un)setby setby setby
  1161. * parv[ 6]: expire_at expire_at (0) expire_at (0) expire_at
  1162. * parv[ 7]: set_at set_at set_at set_at
  1163. * parv[ 8]: reason regex tkl duration reason
  1164. * parv[ 9]: tkl reason [A]
  1165. * parv[10]: regex
  1166. *
  1167. */
  1168. int anope_event_tkl(char *source, int ac, char **av)
  1169. {
  1170. return MOD_CONT;
  1171. }
  1172.  
  1173. int anope_event_eos(char *source, int ac, char **av)
  1174. {
  1175. Server *s;
  1176. s = findserver(servlist, source);
  1177. /* If we found a server with the given source, that one just
  1178. * finished bursting. If there was no source, then our uplink
  1179. * server finished bursting. -GD
  1180. */
  1181. if (!s && serv_uplink)
  1182. s = serv_uplink;
  1183. finish_sync(s, 1);
  1184. return MOD_CONT;
  1185. }
  1186.  
  1187. int anope_event_436(char *source, int ac, char **av)
  1188. {
  1189. if (ac < 1)
  1190. return MOD_CONT;
  1191.  
  1192. m_nickcoll(av[0]);
  1193. return MOD_CONT;
  1194. }
  1195.  
  1196. /*
  1197. ** away
  1198. ** parv[0] = sender prefix
  1199. ** parv[1] = away message
  1200. */
  1201. int anope_event_away(char *source, int ac, char **av)
  1202. {
  1203. if (!source) {
  1204. return MOD_CONT;
  1205. }
  1206. m_away(source, (ac ? av[0] : NULL));
  1207. return MOD_CONT;
  1208. }
  1209.  
  1210. /*
  1211. ** m_topic
  1212. ** parv[0] = sender prefix
  1213. ** parv[1] = topic text
  1214. **
  1215. ** For servers using TS:
  1216. ** parv[0] = sender prefix
  1217. ** parv[1] = channel name
  1218. ** parv[2] = topic nickname
  1219. ** parv[3] = topic time
  1220. ** parv[4] = topic text
  1221. */
  1222. int anope_event_topic(char *source, int ac, char **av)
  1223. {
  1224. if (ac != 4)
  1225. return MOD_CONT;
  1226. do_topic(source, ac, av);
  1227. return MOD_CONT;
  1228. }
  1229.  
  1230. int anope_event_squit(char *source, int ac, char **av)
  1231. {
  1232. if (ac != 2)
  1233. return MOD_CONT;
  1234. do_squit(source, ac, av);
  1235. return MOD_CONT;
  1236. }
  1237.  
  1238. int anope_event_quit(char *source, int ac, char **av)
  1239. {
  1240. if (ac != 1)
  1241. return MOD_CONT;
  1242. do_quit(source, ac, av);
  1243. return MOD_CONT;
  1244. }
  1245.  
  1246. int anope_event_pass(char *source, int ac, char **av)
  1247. {
  1248. return MOD_CONT;
  1249. }
  1250.  
  1251.  
  1252. int anope_event_mode(char *source, int ac, char **av)
  1253. {
  1254. if (ac < 2)
  1255. return MOD_CONT;
  1256.  
  1257. if (*av[0] == '#' || *av[0] == '&') {
  1258. do_cmode(source, ac, av);
  1259. } else {
  1260. do_umode(source, ac, av);
  1261. }
  1262. return MOD_CONT;
  1263. }
  1264.  
  1265. /* Unreal sends USER modes with this */
  1266. /*
  1267. umode2
  1268. parv[0] - sender
  1269. parv[1] - modes to change
  1270. */
  1271. int anope_event_umode2(char *source, int ac, char **av)
  1272. {
  1273. if (ac < 1)
  1274. return MOD_CONT;
  1275.  
  1276. do_umode2(source, ac, av);
  1277. return MOD_CONT;
  1278. }
  1279.  
  1280. int anope_event_kill(char *source, int ac, char **av)
  1281. {
  1282. if (ac != 2)
  1283. return MOD_CONT;
  1284.  
  1285. m_kill(av[0], av[1]);
  1286. return MOD_CONT;
  1287. }
  1288.  
  1289. int anope_event_kick(char *source, int ac, char **av)
  1290. {
  1291. if (ac != 3)
  1292. return MOD_CONT;
  1293. do_kick(source, ac, av);
  1294. return MOD_CONT;
  1295. }
  1296.  
  1297.  
  1298. int anope_event_join(char *source, int ac, char **av)
  1299. {
  1300. if (ac != 1)
  1301. return MOD_CONT;
  1302. do_join(source, ac, av);
  1303. return MOD_CONT;
  1304. }
  1305.  
  1306. int anope_event_motd(char *source, int ac, char **av)
  1307. {
  1308. if (!source) {
  1309. return MOD_CONT;
  1310. }
  1311.  
  1312. m_motd(source);
  1313. return MOD_CONT;
  1314. }
  1315.  
  1316. int anope_event_setname(char *source, int ac, char **av)
  1317. {
  1318. User *u;
  1319.  
  1320. if (ac != 1)
  1321. return MOD_CONT;
  1322.  
  1323. u = finduser(source);
  1324. if (!u) {
  1325. if (debug) {
  1326. alog("debug: SETNAME for nonexistent user %s", source);
  1327. }
  1328. return MOD_CONT;
  1329. }
  1330.  
  1331. change_user_realname(u, av[0]);
  1332. return MOD_CONT;
  1333. }
  1334.  
  1335. int anope_event_chgname(char *source, int ac, char **av)
  1336. {
  1337. User *u;
  1338.  
  1339. if (ac != 2)
  1340. return MOD_CONT;
  1341.  
  1342. u = finduser(av[0]);
  1343. if (!u) {
  1344. if (debug) {
  1345. alog("debug: CHGNAME for nonexistent user %s", av[0]);
  1346. }
  1347. return MOD_CONT;
  1348. }
  1349.  
  1350. change_user_realname(u, av[1]);
  1351. return MOD_CONT;
  1352. }
  1353.  
  1354. int anope_event_setident(char *source, int ac, char **av)
  1355. {
  1356. User *u;
  1357.  
  1358. if (ac != 1)
  1359. return MOD_CONT;
  1360.  
  1361. u = finduser(source);
  1362. if (!u) {
  1363. if (debug) {
  1364. alog("debug: SETIDENT for nonexistent user %s", source);
  1365. }
  1366. return MOD_CONT;
  1367. }
  1368.  
  1369. change_user_username(u, av[0]);
  1370. return MOD_CONT;
  1371. }
  1372. int anope_event_chgident(char *source, int ac, char **av)
  1373. {
  1374. User *u;
  1375.  
  1376. if (ac != 2)
  1377. return MOD_CONT;
  1378.  
  1379. u = finduser(av[0]);
  1380. if (!u) {
  1381. if (debug) {
  1382. alog("debug: CHGIDENT for nonexistent user %s", av[0]);
  1383. }
  1384. return MOD_CONT;
  1385. }
  1386.  
  1387. change_user_username(u, av[1]);
  1388. return MOD_CONT;
  1389. }
  1390.  
  1391. int anope_event_sethost(char *source, int ac, char **av)
  1392. {
  1393. User *u;
  1394.  
  1395. if (ac != 1)
  1396. return MOD_CONT;
  1397.  
  1398. u = finduser(source);
  1399. if (!u) {
  1400. if (debug) {
  1401. alog("debug: SETHOST for nonexistent user %s", source);
  1402. }
  1403. return MOD_CONT;
  1404. }
  1405.  
  1406. if (u->mode & UMODE_x)
  1407. change_user_host(u, av[0]);
  1408. else {
  1409. if (u->chost)
  1410. free(u->chost);
  1411. u->chost = sstrdup(av[0]);
  1412. }
  1413. return MOD_CONT;
  1414. }
  1415.  
  1416. /*
  1417. ** NICK - new
  1418. ** source = NULL
  1419. ** parv[0] = nickname
  1420. ** parv[1] = hopcount
  1421. ** parv[2] = timestamp
  1422. ** parv[3] = username
  1423. ** parv[4] = hostname
  1424. ** parv[5] = servername
  1425. ** if NICK version 1:
  1426. ** parv[6] = servicestamp
  1427. ** parv[7] = info
  1428. ** if NICK version 2:
  1429. ** parv[6] = servicestamp
  1430. ** parv[7] = umodes
  1431. ** parv[8] = virthost, * if none
  1432. ** parv[9] = info
  1433. ** if NICKIP:
  1434. ** parv[9] = ip
  1435. ** parv[10] = info
  1436. **
  1437. ** NICK - change
  1438. ** source = oldnick
  1439. ** parv[0] = new nickname
  1440. ** parv[1] = hopcount
  1441. */
  1442. /*
  1443. do_nick(const char *source, char *nick, char *username, char *host,
  1444. char *server, char *realname, time_t ts, uint32 svid,
  1445. uint32 ip, char *vhost, char *uid)
  1446. */
  1447. int anope_event_nick(char *source, int ac, char **av)
  1448. {
  1449. User *user;
  1450.  
  1451. if (ac != 2) {
  1452. if (ac == 7) {
  1453. /*
  1454. <codemastr> that was a bug that is now fixed in 3.2.1
  1455. <codemastr> in some instances it would use the non-nickv2 format
  1456. <codemastr> it's sent when a nick collision occurs
  1457. - so we have to leave it around for now -TSL
  1458. */
  1459. do_nick(source, av[0], av[3], av[4], av[5], av[6],
  1460. strtoul(av[2], NULL, 10), 0, 0, "*", NULL);
  1461.  
  1462. } else if (ac == 11) {
  1463. user = do_nick(source, av[0], av[3], av[4], av[5], av[10],
  1464. strtoul(av[2], NULL, 10), strtoul(av[6], NULL,
  1465. 0),
  1466. ntohl(decode_ip(av[9])), av[8], NULL);
  1467. if (user)
  1468. anope_set_umode(user, 1, &av[7]);
  1469.  
  1470. } else {
  1471. /* NON NICKIP */
  1472. user = do_nick(source, av[0], av[3], av[4], av[5], av[9],
  1473. strtoul(av[2], NULL, 10), strtoul(av[6], NULL,
  1474. 0), 0, av[8],
  1475. NULL);
  1476. if (user)
  1477. anope_set_umode(user, 1, &av[7]);
  1478. }
  1479. } else {
  1480. do_nick(source, av[0], NULL, NULL, NULL, NULL,
  1481. strtoul(av[1], NULL, 10), 0, 0, NULL, NULL);
  1482. }
  1483. return MOD_CONT;
  1484. }
  1485.  
  1486.  
  1487. int anope_event_chghost(char *source, int ac, char **av)
  1488. {
  1489. User *u;
  1490.  
  1491. if (ac != 2)
  1492. return MOD_CONT;
  1493.  
  1494. u = finduser(av[0]);
  1495. if (!u) {
  1496. if (debug) {
  1497. alog("debug: CHGHOST for nonexistent user %s", av[0]);
  1498. }
  1499. return MOD_CONT;
  1500. }
  1501.  
  1502. change_user_host(u, av[1]);
  1503. return MOD_CONT;
  1504. }
  1505.  
  1506. /* EVENT: SERVER */
  1507. int anope_event_server(char *source, int ac, char **av)
  1508. {
  1509. char *desc;
  1510. char *vl;
  1511. char *upnumeric;
  1512.  
  1513. if (!stricmp(av[1], "1")) {
  1514. uplink = sstrdup(av[0]);
  1515. vl = myStrGetToken(av[2], ' ', 0);
  1516. upnumeric = myStrGetToken(vl, '-', 2);
  1517. desc = myStrGetTokenRemainder(av[2], ' ', 1);
  1518. do_server(source, av[0], av[1], desc, upnumeric);
  1519. Anope_Free(vl);
  1520. Anope_Free(desc);
  1521. Anope_Free(upnumeric);
  1522. } else {
  1523. do_server(source, av[0], av[1], av[2], NULL);
  1524. }
  1525.  
  1526. return MOD_CONT;
  1527. }
  1528.  
  1529. int anope_event_privmsg(char *source, int ac, char **av)
  1530. {
  1531. if (ac != 2)
  1532. return MOD_CONT;
  1533. m_privmsg(source, av[0], av[1]);
  1534. return MOD_CONT;
  1535. }
  1536.  
  1537. int anope_event_part(char *source, int ac, char **av)
  1538. {
  1539. if (ac < 1 || ac > 2)
  1540. return MOD_CONT;
  1541. do_part(source, ac, av);
  1542. return MOD_CONT;
  1543. }
  1544.  
  1545. int anope_event_whois(char *source, int ac, char **av)
  1546. {
  1547. if (source && ac >= 1) {
  1548. m_whois(source, av[0]);
  1549. }
  1550. return MOD_CONT;
  1551. }
  1552.  
  1553. /* SVSHOLD - set */
  1554. void unreal_cmd_svshold(char *nick)
  1555. {
  1556. send_cmd(NULL, "%s + Q H %s %s %ld %ld :%s", send_token("TKL", "BD"),
  1557. nick, ServerName, (long int) time(NULL) + NSReleaseTimeout,
  1558. (long int) time(NULL), "Being held for registered user");
  1559. }
  1560.  
  1561. /* SVSHOLD - release */
  1562. void unreal_cmd_release_svshold(char *nick)
  1563. {
  1564. send_cmd(NULL, "%s - Q * %s %s", send_token("TKL", "BD"), nick,
  1565. ServerName);
  1566. }
  1567.  
  1568. /* UNSGLINE */
  1569. /*
  1570. * SVSNLINE - :realname mask
  1571. */
  1572. void unreal_cmd_unsgline(char *mask)
  1573. {
  1574. send_cmd(NULL, "%s - :%s", send_token("SVSNLINE", "BR"), mask);
  1575. }
  1576.  
  1577. /* UNSZLINE */
  1578. void unreal_cmd_unszline(char *mask)
  1579. {
  1580. send_cmd(NULL, "%s - Z * %s %s", send_token("TKL", "BD"), mask,
  1581. s_OperServ);
  1582. }
  1583.  
  1584. /* SZLINE */
  1585. void unreal_cmd_szline(char *mask, char *reason, char *whom)
  1586. {
  1587. send_cmd(NULL, "%s + Z * %s %s %ld %ld :%s", send_token("TKL", "BD"),
  1588. mask, whom, (long int) time(NULL) + 86400 * 2,
  1589. (long int) time(NULL), reason);
  1590. }
  1591.  
  1592. /* SGLINE */
  1593. /*
  1594. * SVSNLINE + reason_where_is_space :realname mask with spaces
  1595. */
  1596. void unreal_cmd_sgline(char *mask, char *reason)
  1597. {
  1598. strnrepl(reason, BUFSIZE, " ", "_");
  1599. send_cmd(NULL, "%s + %s :%s", send_token("SVSNLINE", "BR"), reason,
  1600. mask);
  1601. }
  1602.  
  1603. /* SVSMODE -b */
  1604. void unreal_cmd_unban(char *name, char *nick)
  1605. {
  1606. unreal_cmd_svsmode_chan(name, "-b", nick);
  1607. }
  1608.  
  1609.  
  1610. /* SVSMODE channel modes */
  1611.  
  1612. void unreal_cmd_svsmode_chan(char *name, char *mode, char *nick)
  1613. {
  1614. if (nick) {
  1615. send_cmd(ServerName, "%s %s %s %s", send_token("SVSMODE", "n"),
  1616. name, mode, nick);
  1617. } else {
  1618. send_cmd(ServerName, "%s %s %s", send_token("SVSMODE", "n"), name,
  1619. mode);
  1620. }
  1621. }
  1622.  
  1623.  
  1624. /* SVSMODE +d */
  1625. /* sent if svid is something weird */
  1626. void unreal_cmd_svid_umode(char *nick, time_t ts)
  1627. {
  1628. if (UseSVS2MODE) {
  1629. send_cmd(ServerName, "%s %s +d 1", send_token("SVS2MODE", "v"),
  1630. nick);
  1631. } else {
  1632. send_cmd(ServerName, "%s %s +d 1", send_token("SVSMODE", "n"),
  1633. nick);
  1634. }
  1635. }
  1636.  
  1637. /* SVSMODE +d */
  1638. /* nc_change was = 1, and there is no na->status */
  1639. void unreal_cmd_nc_change(User * u)
  1640. {
  1641. common_svsmode(u, "-r+d", "1");
  1642. }
  1643.  
  1644. /* SVSMODE +r */
  1645. void unreal_cmd_svid_umode2(User * u, char *ts)
  1646. {
  1647. if (u->svid != u->timestamp) {
  1648. common_svsmode(u, "+rd", ts);
  1649. } else {
  1650. common_svsmode(u, "+r", NULL);
  1651. }
  1652. }
  1653.  
  1654. void unreal_cmd_svid_umode3(User * u, char *ts)
  1655. {
  1656. /* not used */
  1657. }
  1658.  
  1659. int anope_event_error(char *source, int ac, char **av)
  1660. {
  1661. if (av[0]) {
  1662. if (debug) {
  1663. alog("debug: %s", av[0]);
  1664. }
  1665. if(strstr(av[0],"No matching link configuration")!=0) {
  1666. alog("Error: Your IRCD's link block may not be setup correctly, please check unrealircd.conf");
  1667. }
  1668. }
  1669. return MOD_CONT;
  1670. }
  1671.  
  1672. int anope_event_notice(char *source, int ac, char **av)
  1673. {
  1674. return MOD_CONT;
  1675. }
  1676.  
  1677. int anope_event_smo(char *source, int ac, char **av)
  1678. {
  1679. return MOD_CONT;
  1680. }
  1681.  
  1682. /* svsjoin
  1683. parv[0] - sender
  1684. parv[1] - nick to make join
  1685. parv[2] - channel to join
  1686. parv[3] - (optional) channel key(s)
  1687. */
  1688. /* In older Unreal SVSJOIN and SVSNLINE tokens were mixed so SVSJOIN and SVSNLINE are broken
  1689. when coming from a none TOKEN'd server
  1690. */
  1691. void unreal_cmd_svsjoin(char *source, char *nick, char *chan, char *param)
  1692. {
  1693. if (param) {
  1694. send_cmd(source, "%s %s %s :%s", send_token("SVSJOIN", "BX"), nick, chan, param);
  1695. } else {
  1696. send_cmd(source, "%s %s :%s", send_token("SVSJOIN", "BX"), nick, chan);
  1697. }
  1698. }
  1699.  
  1700. /* svspart
  1701. parv[0] - sender
  1702. parv[1] - nick to make part
  1703. parv[2] - channel(s) to part
  1704. */
  1705. void unreal_cmd_svspart(char *source, char *nick, char *chan)
  1706. {
  1707. send_cmd(source, "%s %s :%s", send_token("SVSPART", "BT"), nick, chan);
  1708. }
  1709.  
  1710. int anope_event_globops(char *source, int ac, char **av)
  1711. {
  1712. return MOD_CONT;
  1713. }
  1714.  
  1715. int anope_event_swhois(char *source, int ac, char **av)
  1716. {
  1717. return MOD_CONT;
  1718. }
  1719.  
  1720. int anope_event_rehash(char *source, int ac, char **av)
  1721. {
  1722. return MOD_CONT;
  1723. }
  1724.  
  1725. int anope_event_credits(char *source, int ac, char **av)
  1726. {
  1727. return MOD_CONT;
  1728. }
  1729.  
  1730. int anope_event_admin(char *source, int ac, char **av)
  1731. {
  1732. return MOD_CONT;
  1733. }
  1734.  
  1735. int anope_event_sdesc(char *source, int ac, char **av)
  1736. {
  1737. Server *s;
  1738. s = findserver(servlist, source);
  1739.  
  1740. if (s) {
  1741. s->desc = av[0];
  1742. }
  1743.  
  1744. return MOD_CONT;
  1745. }
  1746.  
  1747. int anope_event_sjoin(char *source, int ac, char **av)
  1748. {
  1749. do_sjoin(source, ac, av);
  1750. return MOD_CONT;
  1751. }
  1752.  
  1753. void unreal_cmd_swhois(char *source, char *who, char *mask)
  1754. {
  1755. send_cmd(source, "%s %s :%s", send_token("SWHOIS", "BA"), who, mask);
  1756. }
  1757.  
  1758. void unreal_cmd_eob()
  1759. {
  1760. send_cmd(ServerName, "%s", send_token("EOS", "ES"));
  1761. }
  1762.  
  1763. /* svswatch
  1764. * parv[0] - sender
  1765. * parv[1] - target nick
  1766. * parv[2] - parameters
  1767. */
  1768. void unreal_cmd_svswatch(char *sender, char *nick, char *parm)
  1769. {
  1770. send_cmd(sender, "%s %s :%s", send_token("SVSWATCH", "Bw"), nick,
  1771. parm);
  1772. }
  1773.  
  1774. /* check if +f mode is valid for the ircd */
  1775. /* borrowed part of the new check from channels.c in Unreal */
  1776. int unreal_flood_mode_check(char *value)
  1777. {
  1778. char *dp, *end;
  1779. /* NEW +F */
  1780. char xbuf[256], *p, *p2, *x = xbuf + 1;
  1781. int v;
  1782.  
  1783. if (!value) {
  1784. return 0;
  1785. }
  1786.  
  1787. if (*value != ':'
  1788. && (strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0)
  1789. && (*dp == ':') && (*(++dp) != 0) && (strtoul(dp, &end, 10) > 0)
  1790. && (*end == 0)) {
  1791. return 1;
  1792. } else {
  1793. /* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
  1794. strncpy(xbuf, value, sizeof(xbuf));
  1795. p2 = strchr(xbuf + 1, ']');
  1796. if (!p2) {
  1797. return 0;
  1798. }
  1799. *p2 = '\0';
  1800. if (*(p2 + 1) != ':') {
  1801. return 0;
  1802. }
  1803. for (x = strtok(xbuf + 1, ","); x; x = strtok(NULL, ",")) {
  1804. /* <number><1 letter>[optional: '#'+1 letter] */
  1805. p = x;
  1806. while (isdigit(*p)) {
  1807. p++;
  1808. }
  1809. if ((*p == '\0')
  1810. || !((*p == 'c') || (*p == 'j') || (*p == 'k')
  1811. || (*p == 'm') || (*p == 'n') || (*p == 't'))) {
  1812. continue; /* continue instead of break for forward compatability. */
  1813. }
  1814. *p = '\0';
  1815. v = atoi(x);
  1816. if ((v < 1) || (v > 999)) {
  1817. return 0;
  1818. }
  1819. p++;
  1820. }
  1821. return 1;
  1822. }
  1823. }
  1824.  
  1825. void unreal_cmd_jupe(char *jserver, char *who, char *reason)
  1826. {
  1827. char rbuf[256];
  1828.  
  1829. snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
  1830. reason ? ": " : "", reason ? reason : "");
  1831.  
  1832. if (findserver(servlist, jserver))
  1833. unreal_cmd_squit(jserver, rbuf);
  1834. unreal_cmd_server(jserver, 2, rbuf);
  1835. new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
  1836. }
  1837.  
  1838. /*
  1839. 1 = valid nick
  1840. 0 = nick is in valid
  1841. */
  1842. int unreal_valid_nick(char *nick)
  1843. {
  1844. if (!stricmp("ircd", nick)) {
  1845. return 0;
  1846. }
  1847. if (!stricmp("irc", nick)) {
  1848. return 0;
  1849. }
  1850. return 1;
  1851. }
  1852.  
  1853. int unreal_valid_chan(char *chan) {
  1854. if (strchr(chan, ':')) {
  1855. return 0;
  1856. }
  1857. return 1;
  1858. }
  1859.  
  1860. void unreal_cmd_ctcp(char *source, char *dest, char *buf)
  1861. {
  1862. char *s;
  1863. if (!buf) {
  1864. return;
  1865. } else {
  1866. s = normalizeBuffer(buf);
  1867. }
  1868.  
  1869. send_cmd(source, "%s %s :\1%s \1", send_token("NOTICE", "B"), dest, s);
  1870. free(s);
  1871. }
  1872.  
  1873. int unreal_jointhrottle_mode_check(char *value)
  1874. {
  1875. char *tempValue, *one, *two;
  1876. int param1, param2;
  1877.  
  1878. if (!value)
  1879. return 0;
  1880.  
  1881. tempValue = sstrdup(value);
  1882. one = strtok(tempValue, ":");
  1883. two = strtok(NULL, "");
  1884. if (one && two) {
  1885. param1 = atoi(one);
  1886. param2 = atoi(two);
  1887. if ((param1 >= 1) && (param1 <= 255) && (param2 >= 1) && (param2 <= 999)) {
  1888. free(tempValue);
  1889. return 1;
  1890. }
  1891. }
  1892. free(tempValue);
  1893. return 0;
  1894. }
  1895.  
  1896. /* *INDENT-OFF* */
  1897. void moduleAddIRCDMsgs(void) {
  1898. Message *m;
  1899.  
  1900. updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a");
  1901.  
  1902. m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m);
  1903. m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m);
  1904. m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
  1905. m = createMessage("451", anope_event_null); addCoreMessage(IRCD,m);
  1906. m = createMessage("461", anope_event_null); addCoreMessage(IRCD,m);
  1907. m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
  1908. if (UseTokens) {
  1909. m = createMessage("6", anope_event_away); addCoreMessage(IRCD,m);
  1910. }
  1911. m = createMessage("INVITE", anope_event_null); addCoreMessage(IRCD,m);
  1912. if (UseTokens) {
  1913. m = createMessage("*", anope_event_null); addCoreMessage(IRCD,m);
  1914. }
  1915. m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m);
  1916. if (UseTokens) {
  1917. m = createMessage("C", anope_event_join); addCoreMessage(IRCD,m);
  1918. }
  1919. m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m);
  1920. if (UseTokens) {
  1921. m = createMessage("H", anope_event_kick); addCoreMessage(IRCD,m);
  1922. }
  1923. m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m);
  1924. if (UseTokens) {
  1925. m = createMessage(".", anope_event_kill); addCoreMessage(IRCD,m);
  1926. }
  1927. m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m);
  1928. if (UseTokens) {
  1929. m = createMessage("G", anope_event_mode); addCoreMessage(IRCD,m);
  1930. }
  1931. m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m);
  1932. if (UseTokens) {
  1933. m = createMessage("F", anope_event_motd); addCoreMessage(IRCD,m);
  1934. }
  1935. m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m);
  1936. if (UseTokens) {
  1937. m = createMessage("&", anope_event_nick); addCoreMessage(IRCD,m);
  1938. }
  1939. m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m);
  1940. if (UseTokens) {
  1941. m = createMessage("B", anope_event_notice); addCoreMessage(IRCD,m);
  1942. }
  1943. m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m);
  1944. if (UseTokens) {
  1945. m = createMessage("D", anope_event_part); addCoreMessage(IRCD,m);
  1946. }
  1947. m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m);
  1948. if (UseTokens) {
  1949. m = createMessage("8", anope_event_ping); addCoreMessage(IRCD,m);
  1950. }
  1951. m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m);
  1952. if (UseTokens) {
  1953. m = createMessage("!", anope_event_privmsg); addCoreMessage(IRCD,m);
  1954. }
  1955. m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m);
  1956. if (UseTokens) {
  1957. m = createMessage(",", anope_event_quit); addCoreMessage(IRCD,m);
  1958. }
  1959. m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m);
  1960. if (UseTokens) {
  1961. m = createMessage("'", anope_event_server); addCoreMessage(IRCD,m);
  1962. }
  1963. m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m);
  1964. if (UseTokens) {
  1965. m = createMessage("-", anope_event_squit); addCoreMessage(IRCD,m);
  1966. }
  1967. m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m);
  1968. if (UseTokens) {
  1969. m = createMessage(")", anope_event_topic); addCoreMessage(IRCD,m);
  1970. }
  1971. m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m);
  1972. if (UseTokens) {
  1973. m = createMessage("n", anope_event_mode); addCoreMessage(IRCD,m);
  1974. }
  1975. m = createMessage("SVS2MODE", anope_event_mode); addCoreMessage(IRCD,m);
  1976. if (UseTokens) {
  1977. m = createMessage("v", anope_event_mode); addCoreMessage(IRCD,m);
  1978. }
  1979. m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m);
  1980. if (UseTokens) {
  1981. m = createMessage("%", anope_event_null); addCoreMessage(IRCD,m);
  1982. }
  1983. m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m);
  1984. if (UseTokens) {
  1985. m = createMessage("=", anope_event_null); addCoreMessage(IRCD,m);
  1986. }
  1987. m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m);
  1988. if (UseTokens) {
  1989. m = createMessage("#", anope_event_whois); addCoreMessage(IRCD,m);
  1990. }
  1991. m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m);
  1992. if (UseTokens) {
  1993. m = createMessage("V", anope_event_null); addCoreMessage(IRCD,m);
  1994. }
  1995. m = createMessage("GLOBOPS", anope_event_globops); addCoreMessage(IRCD,m);
  1996. if (UseTokens) {
  1997. m = createMessage("]", anope_event_globops); addCoreMessage(IRCD,m);
  1998. }
  1999. m = createMessage("GNOTICE", anope_event_null); addCoreMessage(IRCD,m);
  2000. if (UseTokens) {
  2001. m = createMessage("Z", anope_event_null); addCoreMessage(IRCD,m);
  2002. }
  2003. m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m);
  2004. if (UseTokens) {
  2005. m = createMessage("[", anope_event_null); addCoreMessage(IRCD,m);
  2006. }
  2007. m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m);
  2008. if (UseTokens) {
  2009. m = createMessage("Y", anope_event_null); addCoreMessage(IRCD,m);
  2010. }
  2011. m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m);
  2012. if (UseTokens) {
  2013. m = createMessage("U", anope_event_null); addCoreMessage(IRCD,m);
  2014. }
  2015. m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m);
  2016. if (UseTokens) {
  2017. m = createMessage("h", anope_event_null); addCoreMessage(IRCD,m);
  2018. }
  2019. m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m);
  2020. if (UseTokens) {
  2021. m = createMessage("e", anope_event_null); addCoreMessage(IRCD,m);
  2022. }
  2023. m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m);
  2024. if (UseTokens) {
  2025. m = createMessage("f", anope_event_null); addCoreMessage(IRCD,m);
  2026. }
  2027. m = createMessage("SQLINE", anope_event_null); addCoreMessage(IRCD,m);
  2028. if (UseTokens) {
  2029. m = createMessage("c", anope_event_null); addCoreMessage(IRCD,m);
  2030. }
  2031. m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m);
  2032. if (UseTokens) {
  2033. m = createMessage("d", anope_event_null); addCoreMessage(IRCD,m);
  2034. }
  2035. m = createMessage("PROTOCTL", anope_event_capab); addCoreMessage(IRCD,m);
  2036. if (UseTokens) {
  2037. m = createMessage("_", anope_event_capab); addCoreMessage(IRCD,m);
  2038. }
  2039. m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m);
  2040. if (UseTokens) {
  2041. m = createMessage("AL", anope_event_chghost); addCoreMessage(IRCD,m);
  2042. }
  2043. m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m);
  2044. if (UseTokens) {
  2045. m = createMessage("AZ", anope_event_chgident); addCoreMessage(IRCD,m);
  2046. }
  2047. m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m);
  2048. if (UseTokens) {
  2049. m = createMessage("BK", anope_event_chgname); addCoreMessage(IRCD,m);
  2050. }
  2051. m = createMessage("NETINFO", anope_event_netinfo); addCoreMessage(IRCD,m);
  2052. if (UseTokens) {
  2053. m = createMessage("AO", anope_event_netinfo); addCoreMessage(IRCD,m);
  2054. }
  2055. m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m);
  2056. if (UseTokens) {
  2057. m = createMessage("AA", anope_event_sethost); addCoreMessage(IRCD,m);
  2058. }
  2059. m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m);
  2060. if (UseTokens) {
  2061. m = createMessage("AD", anope_event_setident); addCoreMessage(IRCD,m);
  2062. }
  2063. m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m);
  2064. if (UseTokens) {
  2065. m = createMessage("AE", anope_event_setname); addCoreMessage(IRCD,m);
  2066. }
  2067. m = createMessage("TKL", anope_event_tkl); addCoreMessage(IRCD,m);
  2068. if (UseTokens) {
  2069. m = createMessage("BD", anope_event_tkl); addCoreMessage(IRCD,m);
  2070. }
  2071. m = createMessage("EOS", anope_event_eos); addCoreMessage(IRCD,m);
  2072. if (UseTokens) {
  2073. m = createMessage("ES", anope_event_eos); addCoreMessage(IRCD,m);
  2074. }
  2075. m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m);
  2076. if (UseTokens) {
  2077. m = createMessage("<", anope_event_pass); addCoreMessage(IRCD,m);
  2078. }
  2079. m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m);
  2080. if (UseTokens) {
  2081. m = createMessage("5", anope_event_error); addCoreMessage(IRCD,m);
  2082. }
  2083. m = createMessage("SMO", anope_event_smo); addCoreMessage(IRCD,m);
  2084. if (UseTokens) {
  2085. m = createMessage("AU", anope_event_smo); addCoreMessage(IRCD,m);
  2086. }
  2087. m = createMessage("UMODE2", anope_event_umode2); addCoreMessage(IRCD,m);
  2088. if (UseTokens) {
  2089. m = createMessage("|", anope_event_umode2); addCoreMessage(IRCD,m);
  2090. }
  2091. m = createMessage("SWHOIS", anope_event_swhois); addCoreMessage(IRCD,m);
  2092. if (UseTokens) {
  2093. m = createMessage("BA", anope_event_swhois); addCoreMessage(IRCD,m);
  2094. }
  2095. m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m);
  2096. if (UseTokens) {
  2097. m = createMessage("~", anope_event_sjoin); addCoreMessage(IRCD,m);
  2098. }
  2099. m = createMessage("REHASH", anope_event_rehash); addCoreMessage(IRCD,m);
  2100. if (UseTokens) {
  2101. m = createMessage("O", anope_event_rehash); addCoreMessage(IRCD,m);
  2102. }
  2103. m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m);
  2104. if (UseTokens) {
  2105. m = createMessage("@", anope_event_admin); addCoreMessage(IRCD,m);
  2106. }
  2107. m = createMessage("CREDITS", anope_event_credits); addCoreMessage(IRCD,m);
  2108. if (UseTokens) {
  2109. m = createMessage("AJ", anope_event_credits); addCoreMessage(IRCD,m);
  2110. }
  2111. m = createMessage("SDESC", anope_event_sdesc); addCoreMessage(IRCD,m);
  2112. if (UseTokens) {
  2113. m = createMessage("AG", anope_event_sdesc); addCoreMessage(IRCD,m);
  2114. }
  2115. m = createMessage("HTM", anope_event_null); addCoreMessage(IRCD,m);
  2116. if (UseTokens) {
  2117. m = createMessage("BH", anope_event_null); addCoreMessage(IRCD,m);
  2118. }
  2119. m = createMessage("HELP", anope_event_null); addCoreMessage(IRCD,m);
  2120. if (UseTokens) {
  2121. m = createMessage("4", anope_event_null); addCoreMessage(IRCD,m);
  2122. }
  2123. m = createMessage("TRACE", anope_event_null); addCoreMessage(IRCD,m);
  2124. if (UseTokens) {
  2125. m = createMessage("b", anope_event_null); addCoreMessage(IRCD,m);
  2126. }
  2127. m = createMessage("LAG", anope_event_null); addCoreMessage(IRCD,m);
  2128. if (UseTokens) {
  2129. m = createMessage("AF", anope_event_null); addCoreMessage(IRCD,m);
  2130. }
  2131. m = createMessage("RPING", anope_event_null); addCoreMessage(IRCD,m);
  2132. if (UseTokens) {
  2133. m = createMessage("AM", anope_event_null); addCoreMessage(IRCD,m);
  2134. }
  2135. m = createMessage("SENDSNO", anope_event_null); addCoreMessage(IRCD,m);
  2136. if (UseTokens) {
  2137. m = createMessage("Ss", anope_event_null); addCoreMessage(IRCD,m);
  2138. }
  2139. m = createMessage("SENDUMODE", anope_event_null); addCoreMessage(IRCD,m);
  2140. if (UseTokens) {
  2141. m = createMessage("AP", anope_event_null); addCoreMessage(IRCD,m);
  2142. }
  2143.  
  2144. /* The none token version of these is in messages.c */
  2145. if (UseTokens) {
  2146. m = createMessage("2", m_stats); addCoreMessage(IRCD,m);
  2147. m = createMessage(">", m_time); addCoreMessage(IRCD,m);
  2148. m = createMessage("+", m_version); addCoreMessage(IRCD,m);
  2149. }
  2150. }
  2151.  
  2152. /* *INDENT-ON* */
  2153.  
  2154. /**
  2155. * Tell anope which function we want to perform each task inside of anope.
  2156. * These prototypes must match what anope expects.
  2157. **/
  2158. void moduleAddAnopeCmds()
  2159. {
  2160. pmodule_cmd_svsnoop(unreal_cmd_svsnoop);
  2161. pmodule_cmd_remove_akill(unreal_cmd_remove_akill);
  2162. pmodule_cmd_topic(unreal_cmd_topic);
  2163. pmodule_cmd_vhost_off(unreal_cmd_vhost_off);
  2164. pmodule_cmd_akill(unreal_cmd_akill);
  2165. pmodule_cmd_svskill(unreal_cmd_svskill);
  2166. pmodule_cmd_svsmode(unreal_cmd_svsmode);
  2167. pmodule_cmd_372(unreal_cmd_372);
  2168. pmodule_cmd_372_error(unreal_cmd_372_error);
  2169. pmodule_cmd_375(unreal_cmd_375);
  2170. pmodule_cmd_376(unreal_cmd_376);
  2171. pmodule_cmd_nick(unreal_cmd_nick);
  2172. pmodule_cmd_guest_nick(unreal_cmd_guest_nick);
  2173. pmodule_cmd_mode(unreal_cmd_mode);
  2174. pmodule_cmd_bot_nick(unreal_cmd_bot_nick);
  2175. pmodule_cmd_kick(unreal_cmd_kick);
  2176. pmodule_cmd_notice_ops(unreal_cmd_notice_ops);
  2177. pmodule_cmd_notice(unreal_cmd_notice);
  2178. pmodule_cmd_notice2(unreal_cmd_notice2);
  2179. pmodule_cmd_privmsg(unreal_cmd_privmsg);
  2180. pmodule_cmd_privmsg2(unreal_cmd_privmsg2);
  2181. pmodule_cmd_serv_notice(unreal_cmd_serv_notice);
  2182. pmodule_cmd_serv_privmsg(unreal_cmd_serv_privmsg);
  2183. pmodule_cmd_bot_chan_mode(unreal_cmd_bot_chan_mode);
  2184. pmodule_cmd_351(unreal_cmd_351);
  2185. pmodule_cmd_quit(unreal_cmd_quit);
  2186. pmodule_cmd_pong(unreal_cmd_pong);
  2187. pmodule_cmd_join(unreal_cmd_join);
  2188. pmodule_cmd_unsqline(unreal_cmd_unsqline);
  2189. pmodule_cmd_invite(unreal_cmd_invite);
  2190. pmodule_cmd_part(unreal_cmd_part);
  2191. pmodule_cmd_391(unreal_cmd_391);
  2192. pmodule_cmd_250(unreal_cmd_250);
  2193. pmodule_cmd_307(unreal_cmd_307);
  2194. pmodule_cmd_311(unreal_cmd_311);
  2195. pmodule_cmd_312(unreal_cmd_312);
  2196. pmodule_cmd_317(unreal_cmd_317);
  2197. pmodule_cmd_219(unreal_cmd_219);
  2198. pmodule_cmd_401(unreal_cmd_401);
  2199. pmodule_cmd_318(unreal_cmd_318);
  2200. pmodule_cmd_242(unreal_cmd_242);
  2201. pmodule_cmd_243(unreal_cmd_243);
  2202. pmodule_cmd_211(unreal_cmd_211);
  2203. pmodule_cmd_global(unreal_cmd_global);
  2204. pmodule_cmd_global_legacy(unreal_cmd_global_legacy);
  2205. pmodule_cmd_sqline(unreal_cmd_sqline);
  2206. pmodule_cmd_squit(unreal_cmd_squit);
  2207. pmodule_cmd_svso(unreal_cmd_svso);
  2208. pmodule_cmd_chg_nick(unreal_cmd_chg_nick);
  2209. pmodule_cmd_svsnick(unreal_cmd_svsnick);
  2210. pmodule_cmd_vhost_on(unreal_cmd_vhost_on);
  2211. pmodule_cmd_connect(unreal_cmd_connect);
  2212. pmodule_cmd_bob(unreal_cmd_bob);
  2213. pmodule_cmd_svshold(unreal_cmd_svshold);
  2214. pmodule_cmd_release_svshold(unreal_cmd_release_svshold);
  2215. pmodule_cmd_unsgline(unreal_cmd_unsgline);
  2216. pmodule_cmd_unszline(unreal_cmd_unszline);
  2217. pmodule_cmd_szline(unreal_cmd_szline);
  2218. pmodule_cmd_sgline(unreal_cmd_sgline);
  2219. pmodule_cmd_unban(unreal_cmd_unban);
  2220. pmodule_cmd_svsmode_chan(unreal_cmd_svsmode_chan);
  2221. pmodule_cmd_svid_umode(unreal_cmd_svid_umode);
  2222. pmodule_cmd_nc_change(unreal_cmd_nc_change);
  2223. pmodule_cmd_svid_umode2(unreal_cmd_svid_umode2);
  2224. pmodule_cmd_svid_umode3(unreal_cmd_svid_umode3);
  2225. pmodule_cmd_svsjoin(unreal_cmd_svsjoin);
  2226. pmodule_cmd_svspart(unreal_cmd_svspart);
  2227. pmodule_cmd_swhois(unreal_cmd_swhois);
  2228. pmodule_cmd_eob(unreal_cmd_eob);
  2229. pmodule_flood_mode_check(unreal_flood_mode_check);
  2230. pmodule_cmd_jupe(unreal_cmd_jupe);
  2231. pmodule_valid_nick(unreal_valid_nick);
  2232. pmodule_valid_chan(unreal_valid_chan);
  2233. pmodule_cmd_ctcp(unreal_cmd_ctcp);
  2234. pmodule_set_umode(unreal_set_umode);
  2235. pmodule_jointhrottle_mode_check(unreal_jointhrottle_mode_check);
  2236. }
  2237.  
  2238. /**
  2239. * Now tell anope how to use us.
  2240. **/
  2241. int AnopeInit(int argc, char **argv)
  2242. {
  2243.  
  2244. moduleAddAuthor("Anope");
  2245. moduleAddVersion(VERSION_STRING);
  2246. moduleSetType(PROTOCOL);
  2247.  
  2248. pmodule_ircd_version("UnrealIRCd 3.2+");
  2249. pmodule_ircd_cap(myIrcdcap);
  2250. pmodule_ircd_var(myIrcd);
  2251. pmodule_ircd_cbmodeinfos(myCbmodeinfos);
  2252. pmodule_ircd_cumodes(myCumodes);
  2253. pmodule_ircd_flood_mode_char_set("+f");
  2254. pmodule_ircd_flood_mode_char_remove("-f");
  2255. pmodule_ircd_cbmodes(myCbmodes);
  2256. pmodule_ircd_cmmodes(myCmmodes);
  2257. pmodule_ircd_csmodes(myCsmodes);
  2258. pmodule_ircd_useTSMode(0);
  2259.  
  2260. /** Deal with modes anope _needs_ to know **/
  2261. pmodule_invis_umode(UMODE_i);
  2262. pmodule_oper_umode(UMODE_o);
  2263. pmodule_invite_cmode(CMODE_i);
  2264. pmodule_secret_cmode(CMODE_s);
  2265. pmodule_private_cmode(CMODE_p);
  2266. pmodule_key_mode(CMODE_k);
  2267. pmodule_limit_mode(CMODE_l);
  2268. pmodule_permchan_mode(0);
  2269.  
  2270. moduleAddAnopeCmds();
  2271. moduleAddIRCDMsgs();
  2272.  
  2273. return MOD_CONT;
  2274. }
Add Comment
Please, Sign In to add comment