00001 /*************************************************************************** 00002 shared.h - description 00003 ------------------- 00004 begin : Thu Dec 9 2004 00005 copyright : (C) 2004 by VooDooMan 00006 email : vdmfun@hotmail.com 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 00011 VooDoo cIRCle - an IRC (ro)bot 00012 Copyright (C) 2004 by Marian VooDooMan Meravy (vdmfun@hotmail.com) 00013 00014 This program is free software; you can redistribute it and/or 00015 modify it under the terms of the GNU General Public License 00016 as published by the Free Software Foundation; either version 2 00017 of the License, or (at your option) any later version. 00018 00019 This program is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with this program; if not, write to the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00027 00028 ****************************************************************************/ 00029 00030 #ifndef _SHARED_H_ 00031 #define _SHARED_H_ 00032 00033 /*! 00034 \file 00035 \brief Contains shared structures 00036 */ 00037 00038 #include <vector> 00039 #include <string> 00040 #include <map> 00041 #include <list> 00042 00043 #include "md5.h" 00044 00045 /*! 00046 \namespace std 00047 \brief Standard C++ Template Library (STL) 00048 */ 00049 using namespace std; 00050 00051 /*! 00052 \brief Stores flood limit 00053 \author VooDooMan 00054 \version 1 00055 \date 2004 00056 */ 00057 struct s_flood { 00058 uint32 lines; //!< Number of lines 00059 time_t seconds; //!< Number of seconds 00060 }; 00061 00062 /*! 00063 \brief Stores replication list 00064 \author VooDooMan 00065 \version 1 00066 \date 2004 00067 */ 00068 struct s_replication { 00069 string partner; //!< Name of replication partner 00070 /*! 00071 \def REPL_INVALID 00072 \brief Invalid replication parameter/mode 00073 */ 00074 #define REPL_INVALID 0 00075 /*! 00076 \def REPL_PUSH 00077 \brief Push replication 00078 */ 00079 #define REPL_PUSH 1 00080 /*! 00081 \def REPL_PULL 00082 \brief Pull replication 00083 */ 00084 #define REPL_PULL 2 00085 /*! 00086 \def REPL_PUSHPULL 00087 \brief Push/pull replication 00088 */ 00089 #define REPL_PUSHPULL 3 00090 00091 int type; //!< Type of replication 00092 00093 s_replication() 00094 { 00095 partner=""; 00096 type=REPL_INVALID; 00097 } 00098 }; 00099 00100 /*! 00101 \brief Stores host for DCC connection 00102 \author VooDooMan 00103 \version 1 00104 \date 2004 00105 */ 00106 struct s_dcc_host { 00107 int group; //!< "dcc_group" ID number 00108 string host; //!< DCC host 00109 00110 s_dcc_host() 00111 { 00112 group=0; 00113 host=""; 00114 } 00115 }; 00116 00117 /*! 00118 \brief Stores name of group 00119 \author VooDooMan 00120 \version 1 00121 \date 2004 00122 */ 00123 struct s_group { 00124 string name; //!< Name of group 00125 00126 s_group() 00127 { 00128 name=""; 00129 } 00130 }; 00131 00132 /*! 00133 \brief Stores user options 00134 \author VooDooMan 00135 \version 1 00136 \date 2004 00137 */ 00138 struct s_user { 00139 string name; //!< Name of user 00140 bool host_unknown; //!< Is this user "an unknown user"? (if true, this structure contains definition for user that is NOT rekognized - something like "guest" on channel) 00141 bool host_bot; //!< Is this user a bot? 00142 bool is_template; //!< Is this user a template? 00143 bool terminator; //!< Is this user terminated? 00144 vector<string> hostmask; //!< Host hasks ("nick!ident@host") 00145 vector<string> fullname; //!< Full name masks 00146 vector<string> access_to_group; //!< This user can modify properties of users of these groups 00147 vector<string> access_to_proc; //!< This user can modify procedure commands 00148 vector<string> access_grant_procedure; //!< This user can grant access to this procedure to other user 00149 vector<string> access_usage_procedure; //!< This user can assign events of user to these procedures 00150 vector<string> access_grant_group; //!< This user can add or exclude users to/from these groups 00151 vector<string> access_to_channel; //!< This user can modify properties of these channels 00152 vector<string> access_grant_channel; //!< This user can add or exclude users to/from these channels 00153 bool access_grant_partyline; //!< Can this user grant/deny access to partyline to other user? 00154 bool access_to_backup; //!< Can this user use .backup command? 00155 bool access_grant_backup; //!< Can this user grant/deny access to .backup command to other user? 00156 bool access_to_rehash; //!< Can this user use .rehash command? 00157 bool access_grant_rehash; //!< Can this user grant/deny access to .rehash command to other user? 00158 bool access_to_plususer; //!< Can this user (or bot) create new user? 00159 bool access_grant_plususer; //!< Can this user (or bot) grant creation of new user to other user? 00160 00161 bool access_to_can_send_all_users; //!< Can this user send message / file to all users? 00162 bool access_grant_can_send_all_users; //!< Can this user grant right to send message / file to all users? 00163 00164 bool access_to_plusproc; //!< Can this user (or bot) create new procedure? 00165 bool access_grant_plusproc; //!< Can this user (or bot) grant creation of new procedure to other user? 00166 00167 bool access_to_replication; //!< Can this user change replication parameters? 00168 bool access_grant_replication; //!< Can this user (or bot) grant to other user right to change replication parameters? 00169 00170 bool access_to_restart; //!< Has user access to .restart command? 00171 bool access_grant_restart; //!< Can this user grant accesst to .restart command to other user? 00172 bool access_to_die; //!< Has user access to .die command? 00173 bool access_grant_die; //!< Can this user grant accesst to .die command to other user? 00174 00175 bool access_to_filesystem; //!< Has user access to .filesystem command? 00176 bool access_grant_filesystem; //!< Can this user grant accesst to .filesystem command to other user? 00177 00178 bool access_to_can_send_unknown_users; //!< Can this user send message / file to unknown users on all bot's channels? 00179 bool access_grant_can_send_unknown_users; //!< Can this grant right to other user to send message / file to unknown users on all bot's channels? 00180 00181 bool access_to_partyline; //!< Has this user access to partyline? 00182 vector<s_group> groups; //!< List of groups that this user is member of 00183 vector<s_dcc_host> dcc_hosts; //!< Hosts for DCC connection for this user 00184 00185 bool access_to_private; //!< Has this user access to modufy private query definition? 00186 bool access_grant_private; //!< Can this user grant accesst to private definition to other user? 00187 00188 bool access_to_upgrade; //!< Has user access to .upgrade command? 00189 bool access_grant_upgrade; //!< Can this user grant accesst to .upgrade command to other user? 00190 00191 bool access_to_apply; //!< Has user access to .apply command? 00192 bool access_grant_apply; //!< Can this user grant accesst to .apply command to other user? 00193 00194 vector<s_replication> replication; //!< Informations of replication 00195 time_t last_changed; //!< Time of last change 00196 bool replication_partner; //!< Is this user a replication partner? (==bot?) 00197 00198 s_flood partyline_msg_flood; //!< Message flood limit on partyline channels 00199 00200 map<string,string> meta; 00201 00202 void clear() 00203 { 00204 name=""; 00205 host_unknown=false; 00206 is_template=false; 00207 hostmask.clear(); 00208 fullname.clear(); 00209 meta.clear(); 00210 access_to_can_send_all_users=false; 00211 access_grant_can_send_all_users=false; 00212 access_to_group.clear(); 00213 access_to_proc.clear(); 00214 access_usage_procedure.clear(); 00215 access_grant_procedure.clear(); 00216 access_grant_group.clear(); 00217 access_to_channel.clear(); 00218 access_grant_channel.clear(); 00219 access_grant_partyline=false; 00220 access_to_backup=false; 00221 access_grant_backup=false; 00222 access_to_rehash=false; 00223 access_grant_rehash=false; 00224 access_to_plususer=false; 00225 access_grant_plususer=false; 00226 access_to_plusproc=false; 00227 access_grant_plusproc=false; 00228 access_to_replication=false; 00229 access_grant_replication=false; 00230 access_to_restart=false; 00231 access_grant_restart=false; 00232 access_to_die=false; 00233 access_grant_die=false; 00234 access_to_partyline=false; 00235 groups.clear(); 00236 dcc_hosts.clear(); 00237 replication.clear(); 00238 last_changed=0; 00239 replication_partner=false; 00240 access_to_private=false; 00241 access_grant_private=false; 00242 terminator=false; 00243 access_to_can_send_unknown_users=false; 00244 access_grant_can_send_unknown_users=false; 00245 access_to_upgrade=access_grant_upgrade=false; 00246 } 00247 00248 s_user() 00249 { 00250 clear(); 00251 } 00252 }; 00253 00254 /*! 00255 \brief Stores statistics entry for flood detection 00256 \author VooDooMan 00257 \version 1 00258 \date 2004 00259 */ 00260 struct s_flood_history { 00261 time_t time; //!< Time of origin of this entry 00262 size_t bytes; //!< Number of bytes in the message 00263 string msg; //!< Received message (only used for repeat_flood) 00264 00265 s_flood_history() 00266 { 00267 time=0; 00268 bytes=0; 00269 msg=""; 00270 } 00271 }; 00272 00273 /*! 00274 \brief Stores user's dynamic modes rule 00275 \author VooDooMan 00276 \version 1 00277 \date 2004 00278 */ 00279 struct s_dynamic_rule { 00280 string group; //!< From which group are dynamic modes accepted? 00281 string plus_modes; //!< Wich modes accepted? ('+' for +v, '@' for +o) 00282 string minus_modes; //!< Wich modes accepted? ('+' for -v, '@' for -o) 00283 00284 s_dynamic_rule() 00285 { 00286 group=""; 00287 plus_modes=""; 00288 minus_modes=""; 00289 } 00290 }; 00291 00292 /*! 00293 \brief Stores definition of properties for user on specific channel 00294 \author VooDooMan 00295 \version 2 00296 \date 2005 00297 */ 00298 struct s_channel { 00299 string username; //!< Name of user 00300 string channel_name; //!< Name of channel 00301 bool host_unknown; //!< Is this user "an unknown user"? (if true, this structure contains definition for user that is NOT recognized - something like "guest" on channel) 00302 bool is_template; //!< Is this an user template? 00303 bool terminator; //!< Is this user terminated? 00304 00305 bool can_send_unknown_users; //!< Can user send messages / files to unknown users? 00306 00307 vector<s_group> groups; //!< List of groups that this user is member of 00308 string on_deop; //!< Procedure for on_deop event (-o) 00309 string on_ban; //!< Procedure for on_ban event (+b) 00310 string on_unban; //!< Procedure for on_unban event (-b) 00311 string on_kick; //!< Procedure for on_kick event 00312 string on_op; //!< Procedure for on_op event (+o) 00313 string on_voice; //!< Procedure for on_voice event (+v) 00314 string on_devoice; //!< Procedure for on_devoice event (-v) 00315 string on_creator; //!< Procedure for on_creator event (+O) 00316 string on_decreator; //!< Procedure for on_decreator event (-O) 00317 string on_join; //!< Procedure for on_join event 00318 string on_banned; //!< Procedure for on_banned event (if some ban mask on bot's JOIN match this user) 00319 string on_flood; //!< Procedure for on_flood event 00320 string on_privmsg; //!< Procedure for on_privmsg event (PRIVMSG) 00321 string on_notice; //!< Procedure for on_notice event (NOTICE) 00322 string on_except; //!< Procedure for on_except event 00323 string on_unexcept; //!< Procedure for on_unexcept event 00324 string on_invite; //!< Procedure for on_invite event 00325 string on_uninvite; //!< Procedure for on_uninvite event 00326 string on_not_invited; //!< Procedure for on_not_invited event 00327 string on_other_mode; //!< Procedure for on_other_mode event 00328 string on_not_in_reop; //!< Procedure for on_not_in_reop event 00329 string on_reop; //!< Procedure for on_reop event 00330 00331 s_flood msg_flood; //!< Contains msg_flood limitation for this user (PRIVMSG) 00332 s_flood notice_flood; //!< Contains notice_flood limitation for this user (NOTICE) 00333 s_flood repeat_flood; //!< Contains repeat_flood limitation for this user 00334 s_flood nick_flood; //!< Contains nick_flood limitation for this user (NICK) 00335 s_flood join_flood; //!< Contains join_flood limitation for this user (JOIN <-> PART/QUIT/benn KICK-ed) 00336 s_flood mode_flood; //!< Contains mode_flood limitation for this user (MODE) 00337 s_flood ctcp_flood; //!< Contains ctcp_flood limitation for this user (CTCP to all users in the channel) 00338 00339 vector<s_dynamic_rule> allow_dynamic; //!< List of dynamic rule that can be accepted 00340 00341 string dynamic_plus_modes; //!< Wich modes accepted? ('+' for +v, '@' for +o) 00342 string dynamic_minus_modes; //!< Wich modes accepted? ('+' for -v, '@' for -o) 00343 00344 bool configured; //!< Set to true if all has been configured (only valid for partyline) 00345 00346 s_channel() 00347 { 00348 clear(); 00349 } 00350 00351 void clear() 00352 { 00353 username=""; 00354 channel_name=""; 00355 host_unknown=false; 00356 is_template=false; 00357 groups.clear(); 00358 on_deop=""; 00359 on_ban=""; 00360 on_unban=""; 00361 on_kick=""; 00362 on_op=""; 00363 on_voice=""; 00364 on_devoice=""; 00365 on_creator=""; 00366 on_decreator=""; 00367 on_join=""; 00368 on_banned=""; 00369 on_flood=""; 00370 on_privmsg=""; 00371 on_notice=""; 00372 on_except=""; 00373 on_unexcept=""; 00374 on_invite=""; 00375 on_uninvite=""; 00376 on_not_invited=""; 00377 on_other_mode=""; 00378 on_reop=""; 00379 on_not_in_reop=""; 00380 allow_dynamic.clear(); 00381 dynamic_plus_modes=""; 00382 dynamic_minus_modes=""; 00383 configured=false; 00384 can_send_unknown_users=false; 00385 } 00386 }; 00387 00388 /*! 00389 \brief Stores helping data for compiling (if_XXX,...) 00390 \author VooDooMan 00391 \version 1 00392 \date 2004 00393 */ 00394 struct s_lines { 00395 string proc_name; //!< Name of procedure 00396 int line; //!< Number of line of _goto command 00397 00398 s_lines() 00399 { 00400 proc_name=""; 00401 line=0; 00402 } 00403 }; 00404 00405 /*! 00406 \brief Stores data for sending an e-mail via SMTP protocol 00407 \author VooDooMan 00408 \version 1 00409 \date 2004 00410 */ 00411 struct s_smtp { 00412 string server; //!< Server's host 00413 unsigned short port; //!< Port (usually 25) 00414 string helo; //!< "HELO xxx" string 00415 string mail_from; //!< "MAIL FROM: xxx" string 00416 string rcpt_to; //!< "RCPT TO: xxx" string 00417 string data; //!< Lines of message headers and body delimited with CR+LF 00418 list<string> data_lines; //!< Lines of message headers and body as array 00419 00420 s_smtp() 00421 { 00422 server=""; 00423 port=0; 00424 helo=""; 00425 mail_from=""; 00426 rcpt_to=""; 00427 data=""; 00428 data_lines.clear(); 00429 } 00430 }; 00431 00432 /*! 00433 \brief Stores one command in the procedure 00434 \author VooDooMan 00435 \version 1 00436 \date 2004 00437 */ 00438 struct s_command { 00439 int line; //!< In some cases, this contains line number (for _goto) 00440 00441 string whom; //!< In some cases, this contains "whom to send message" 00442 /*! 00443 \def _op 00444 \brief "op" command 00445 */ 00446 #define _op 1 00447 /*! 00448 \def _deop 00449 \brief "deop" command 00450 */ 00451 #define _deop 2 00452 /*! 00453 \def _voice 00454 \brief "voice" command 00455 */ 00456 #define _voice 5 00457 /*! 00458 \def _devoice 00459 \brief "devoice" command 00460 */ 00461 #define _devoice 6 00462 /*! 00463 \def _kick 00464 \brief "kick" command 00465 */ 00466 #define _kick 7 00467 /*! 00468 \def _msg 00469 \brief "msg" command 00470 */ 00471 #define _msg 8 00472 /*! 00473 \def _if_match 00474 \brief "if_match" command 00475 */ 00476 #define _if_match 9 00477 /*! 00478 \def _if_group 00479 \brief "if_group" command 00480 */ 00481 #define _if_group 10 00482 /*! 00483 \def _return 00484 \brief "return" command 00485 */ 00486 #define _return 11 00487 /*! 00488 \def _timer_once 00489 \brief "timer_once" command 00490 */ 00491 #define _timer_once 12 00492 /*! 00493 \def _timer_every 00494 \brief "timer_every" command 00495 */ 00496 #define _timer_every 13 00497 /*! 00498 \def _execute 00499 \brief "execute" command 00500 */ 00501 #define _execute 14 00502 /*! 00503 \def _smtp 00504 \brief "SMTP" command 00505 */ 00506 #define _smtp 15 00507 /*! 00508 \def _net_send 00509 \brief "NET_SEND" command 00510 */ 00511 #define _net_send 16 00512 /*! 00513 \def _log 00514 \brief "LOG" command 00515 */ 00516 #define _log 17 00517 /*! 00518 \def _join 00519 \brief "join" command 00520 */ 00521 #define _join 18 00522 /*! 00523 \def _part 00524 \brief "part" command 00525 */ 00526 #define _part 19 00527 /*! 00528 \def _disconnect 00529 \brief "disconnect" command 00530 */ 00531 #define _disconnect 20 00532 /*! 00533 \def _try_connect 00534 \brief "try_connect" command 00535 */ 00536 #define _try_connect 21 00537 /*! 00538 \def _bot_nick 00539 \brief "bot_nick" command 00540 */ 00541 #define _bot_nick 22 00542 /*! 00543 \def _bot_ident 00544 \brief "bot_ident" command 00545 */ 00546 #define _bot_ident 23 00547 /*! 00548 \def _bot_fullname 00549 \brief "bot_fullname" command 00550 */ 00551 #define _bot_fullname 24 00552 /*! 00553 \def _bot_auth 00554 \brief "bot_auth" command 00555 */ 00556 #define _bot_auth 25 00557 /*! 00558 \def _bot_redir 00559 \brief "bot_redir" command 00560 */ 00561 #define _bot_redir 26 00562 /*! 00563 \def _wait 00564 \brief "wait" command 00565 */ 00566 #define _wait 27 00567 /*! 00568 \def _sleep_ 00569 \brief "sleep" command 00570 */ 00571 #define _sleep_ 28 00572 /*! 00573 \def _restart 00574 \brief "restart" command 00575 */ 00576 #define _restart 29 00577 /*! 00578 \def _notice 00579 \brief "notice" command 00580 */ 00581 #define _notice 30 00582 /*! 00583 \def _unban_mask 00584 \brief "unban_mask" command 00585 */ 00586 #define _unban_mask 31 00587 /*! 00588 \def _ban_mask 00589 \brief "ban_mask" command 00590 */ 00591 #define _ban_mask 32 00592 /*! 00593 \def _dcc_server 00594 \brief "dcc_server" command 00595 */ 00596 #define _dcc_server 33 00597 /*! 00598 \def _if_error 00599 \brief "if_error" command 00600 */ 00601 #define _if_error 34 00602 /*! 00603 \def _real_label 00604 \brief Working value (for _goto) 00605 */ 00606 #define _real_label 35 00607 /*! 00608 \def _real_goto 00609 \brief "goto" command 00610 */ 00611 #define _real_goto 36 00612 /*! 00613 \def _end_bracket 00614 \brief Working value (for conversion function back to text) 00615 */ 00616 #define _end_bracket 37 00617 /*! 00618 \def _ident 00619 \brief "ident" command 00620 */ 00621 #define _ident 38 00622 /*! 00623 \def _host 00624 \brief "host" command 00625 */ 00626 #define _host 39 00627 /*! 00628 \def _script 00629 \brief "SCRIPT" command 00630 */ 00631 #define _script 40 00632 /*! 00633 \def _if_match_case_insensitive 00634 \brief "if_match_case_insensitive" command 00635 */ 00636 #define _if_match_case_insensitive 41 00637 /*! 00638 \def _telnet_server 00639 \brief "telnet_server" command 00640 */ 00641 #define _telnet_server 42 00642 /*! 00643 \def _link 00644 \brief "link" command 00645 */ 00646 #define _link 43 00647 /*! 00648 \def _work 00649 \brief "work" command 00650 */ 00651 #define _work 44 00652 /*! 00653 \def _if_in 00654 \brief "if_in" command 00655 */ 00656 #define _if_in 45 00657 /*! 00658 \def _if_n_in 00659 \brief "!if_in" command 00660 */ 00661 #define _if_n_in 46 00662 /*! 00663 \def _if_n_match 00664 \brief "!if_match" command 00665 */ 00666 #define _if_n_match 47 00667 /*! 00668 \def _if_n_group 00669 \brief "!if_group" command 00670 */ 00671 #define _if_n_group 48 00672 /*! 00673 \def _if_n_match_case_insensitive 00674 \brief "!if_match_case_insensitive" command 00675 */ 00676 #define _if_n_match_case_insensitive 49 00677 /*! 00678 \def _chan_mode 00679 \brief "chan_mode" command 00680 */ 00681 #define _chan_mode 50 00682 /*! 00683 \def _msgq 00684 \brief "msgq" command 00685 */ 00686 #define _msgq 51 00687 /*! 00688 \def _change_nick 00689 \brief "change_nick" command 00690 */ 00691 #define _change_nick 52 00692 /*! 00693 \def _noticeq 00694 \brief "noticeq" command 00695 */ 00696 #define _noticeq 53 00697 /*! 00698 \def _irc_server 00699 \brief "irc_server" command 00700 */ 00701 #define _irc_server 54 00702 /*! 00703 \def _kill_timers 00704 \brief "kill_timers" command 00705 */ 00706 #define _kill_timers 55 00707 /*! 00708 \def _get_chan_mode 00709 \brief "get_chan_mode" command 00710 */ 00711 #define _get_chan_mode 56 00712 /*! 00713 \def _get_chan_topic 00714 \brief "get_chan_topic" command 00715 */ 00716 #define _get_chan_topic 57 00717 /*! 00718 \def _topic 00719 \brief "topic" command 00720 */ 00721 #define _topic 58 00722 /*! 00723 \def _dynamic_ban 00724 \brief "dynamic_ban" command 00725 */ 00726 #define _dynamic_ban 59 00727 /*! 00728 \def _check_dynamic_bans 00729 \brief "check_dynamic_bans" command 00730 */ 00731 #define _check_dynamic_bans 60 00732 /*! 00733 \def _process_on_banned 00734 \brief "process_on_banned" command 00735 */ 00736 #define _process_on_banned 61 00737 /*! 00738 \def _telnet_server_ipv6 00739 \brief "telnet_server_ipv6" command 00740 */ 00741 #define _telnet_server_ipv6 62 00742 /*! 00743 \def _dcc_server_ipv6 00744 \brief "dcc_server_ipv6" command 00745 */ 00746 #define _dcc_server_ipv6 63 00747 00748 // BOTNET version 2 00749 /*! 00750 \def _raw 00751 \brief "raw" command 00752 \warning Botnet protocol version 2 required for replication! 00753 */ 00754 #define _raw 64 //!< "raw" command 00755 00756 // BOTNET version 3 00757 /*! 00758 \def _remote_execute 00759 \brief "remote_execute" command 00760 \warning Botnet protocol version 3 required for replication! 00761 */ 00762 #define _remote_execute 65 00763 00764 // BOTNET version 4 00765 /*! 00766 \def _bot_ident_ipv6 00767 \brief "bot_ident_ipv6" command 00768 \warning Botnet protocol version 4 required for replication! 00769 */ 00770 #define _bot_ident_ipv6 66 00771 00772 // BOTNET version 6 00773 /*! 00774 \def _delete_irc_servers 00775 \brief "delete_irc_servers" command 00776 \warning Botnet protocol version 6 required for replication! 00777 */ 00778 #define _delete_irc_servers 67 00779 00780 // BOTNET version 6 00781 /*! 00782 \def _delete_nicks 00783 \brief "delete_nicks" command 00784 \warning Botnet protocol version 6 required for replication! 00785 */ 00786 #define _delete_nicks 68 00787 00788 // BOTNET version 10 00789 /*! 00790 \def _admin_msg 00791 \brief "admin_msg" command 00792 \warning Botnet protocol version 10 required for replication! 00793 */ 00794 #define _admin_msg 69 00795 00796 string admin_msg_type; //!< For command "admin_msg": type of message 00797 string admin_msg_mask; //!< For command "admin_msg": mask of recipients 00798 string admin_msg_message; //!< For command "admin_msg": the whole message 00799 00800 /*! 00801 \def _label 00802 \brief Working value (for _goto) 00803 */ 00804 #define _label 1001 00805 /*! 00806 \def _goto 00807 \brief Working value 00808 */ 00809 #define _goto 1002 00810 int command; //!< Command (\#define _xxx) 00811 00812 int _goto_line; //!< In some cases, this contains line number to jump to 00813 00814 string label; //!< In some cases, this contains text label (for _goto) 00815 00816 string msg_text; //!< In some cases, this contains message to send 00817 string msg_quoted; //!< As second parameter to commands _msgq && _noticeq 00818 00819 int priority; //!< Priority for "op", "voice",... 00820 00821 string left; //!< contains left-hand comparsion value (for _if_match & _if_group & _if_match_case_insensitive & _if_in & if_n_in) 00822 string right; //!< contains right-hand comparsion value (for _if_match & _if_group & _if_match_case_unsensitive & _if_in & if_n_in) 00823 00824 int timer_sec; //!< In some cases, this contains number of seconds (for _timer_once && _timer_every) 00825 string timer_name; //!< In some cases, this contains name of timer (for _timer_once && _timer_every) 00826 string timer_cmd; //!< In some cases, this contains timer command (for _timer_once && _timer_every) 00827 00828 string exec; //!< In some cases, this contains declaration of function to execute (for _execute) 00829 00830 s_smtp smtp; //!< In some cases, this contains SMTP data (for _smtp) 00831 00832 string net_send_host; //!< In some cases, this contains NET SEND host (for _net_send) 00833 string net_send_msg; //!< In some cases, this contains NET SEND message (for _net_send) 00834 00835 string log; //!< In some cases, this contains message to log (for _log) 00836 00837 string channel; //!< In some cases, this contains channel name (for _join && _part && _dynamic_ban && _check_dynamic_bans) 00838 string channel_key; //!< For join command - +k key to channel 00839 00840 // for _irc_server && _dcc_server && _telnet_server 00841 string server; //!< In some cases, this contains server host (for _irc_server && _dcc_server && _telnet_server) 00842 unsigned short port; //!< In some cases, this contains server port (for _irc_server && _dcc_server && _telnet_server) 00843 // for _dcc_server 00844 int group; //!< In some cases, this contains group of DCC host (for _dcc_server) 00845 00846 string server_type; //!< For dcc_server 00847 00848 vector<string> bot_nick; //!< In some cases, this contains list of bot's nicks 00849 string bot_ident; //!< In some cases, this contains bot's ident 00850 string bot_fullname; //!< In some cases, this contains bot's full name 00851 00852 // for _bot_redir 00853 bool bot_redir; //!< parameter of "allow_redirect" command (_bot_redir) 00854 00855 // for _sleep_ 00856 int sleep_secs; //!< parameter of "sleep" command (_sleep_) 00857 00858 // for indent && host && check_dynamic_bans 00859 string nick; //!< parameter of "ident" command (_ident && _host), or for command "change_nick", or "check_dynamic_bans" 00860 string result; //!< parameter of "ident" command, storing result of "ident" command (_ident && _host && _check_dynamic_bans) 00861 00862 // for script 00863 string script_type; //!< Type of script ("php") 00864 int script_num; //!< number of script in conf.txt file (_script) 00865 string script_channel; //!< channel name for script (_script) 00866 string script_params; //!< list of parameters of script (_script) 00867 00868 string botname; //!< Bot name for "link" command 00869 string botlocalip; //!< Local bind IP for "link" command 00870 string botip; //!< Bot's IP address for "link" commnad 00871 unsigned short botport; //!< Bot's port for "link" commnad 00872 //string bot_remote_passwd; //!< Conatins MD5-encoded password of remote host 00873 string botlinktype; //!< Type of link (e.g. telnet) (for command "link") 00874 string botunlinkproc; //!< Procedure to execute when link to bot has been broken (for command "link") 00875 00876 // for _dynamic_ban 00877 // "channel" member for $channel 00878 string ban_prefix; //!< $prefix for "dynamic_ban" command should be "+" or "-" 00879 string ban_mask; //!< mask for "dynamic_ban" command 00880 string ban_reason; //!< reason for "dynamic_ban" command, or name of variable to store reason of "check_dynamic_bans" into 00881 00882 string chan_mode; //!< For "chan_mode" command 00883 00884 s_command() 00885 { 00886 line=0; 00887 whom=""; 00888 command=0; 00889 _goto_line=0; 00890 label=""; 00891 msg_text=""; 00892 msg_quoted=""; 00893 ban_prefix=""; 00894 ban_mask=""; 00895 ban_reason=""; 00896 left=""; 00897 right=""; 00898 timer_sec=0; 00899 timer_name=""; 00900 timer_cmd=""; 00901 exec=""; 00902 net_send_host=""; 00903 net_send_msg=""; 00904 log=""; 00905 channel=""; 00906 channel_key=""; 00907 string server=""; 00908 port=0; 00909 group=0; 00910 bot_nick.clear(); 00911 bot_ident=""; 00912 bot_fullname=""; 00913 bot_redir=false; 00914 sleep_secs=0; 00915 nick=""; 00916 result=""; 00917 script_type=""; 00918 script_num=0; 00919 script_channel=""; 00920 script_params=""; 00921 botname=""; 00922 botlocalip=""; 00923 botip=""; 00924 botport=0; 00925 //bot_remote_passwd=""; 00926 botlinktype=""; 00927 botunlinkproc=""; 00928 chan_mode=""; 00929 00930 admin_msg_mask=admin_msg_message=admin_msg_type=""; 00931 } 00932 }; 00933 00934 /*! 00935 \brief Stores procedure's properties entry describing ability to call remotely (BOTNET) 00936 \author VooDooMan 00937 \version 1 00938 \date 2005 00939 */ 00940 struct s_rproc { 00941 string remote_bot; //!< Name of remote bot which can call this procedure remotely 00942 }; 00943 00944 /*! 00945 \brief Stores procedure implementation and its properties 00946 \author VooDooMan 00947 \version 1 00948 \date 2004 00949 */ 00950 struct s_procedure { 00951 string name; //!< Declaration string of procedure 00952 list<s_command> commands; //!< Commands of procedure 00953 vector<s_group> groups; //!< List of groups that procedure is member of 00954 vector<s_rproc> rproc; //!< List of bot which can call this procedure remotely (BOTNET) 00955 00956 vector<s_replication> replication; //!< Informations of replication 00957 time_t last_changed; //!< Time of last change 00958 00959 int minimal_botnet_version; //!< Number of minimal BOTNET protocol version (for replication) 00960 00961 s_procedure() 00962 { 00963 name=""; 00964 commands.clear(); 00965 groups.clear(); 00966 replication.clear(); 00967 last_changed=0; 00968 minimal_botnet_version=1; 00969 rproc.clear(); 00970 } 00971 }; 00972 00973 /*! 00974 \brief Stores informations about channel definitions 00975 \author VooDooMan 00976 \version 1 00977 \date 2004 00978 */ 00979 struct s_channel_def { 00980 string channel_name; //!< Name of channel 00981 string on_mode; //!< on_mode event 00982 string on_key; //!< on_key event 00983 string on_limit; //!< on_limit event 00984 string on_topic; //!< on_topic event 00985 string on_ircop; //!< on_ircop event: An irc operator on channel event 00986 string on_privmsg; //!< on_privmsg event: Some has written PRIVMSG to channel 00987 string on_notice; //!< on_notice event 00988 string on_part; //!< on_part event: Some on channel has left channel / quit IRC 00989 string on_dynamic_ban; //!< on_dynamic_ban event 00990 string on_ctcp; //!< on_ctcp event 00991 string on_server_msg; //!< on_server_msg event 00992 vector<s_dynamic_rule> allow_dynamic; //!< Dynamic rules 00993 string dynamic_plus_modes; //!< Which modes accepted? ('+' for +v, '@' for +o) 00994 string dynamic_minus_modes; //!< Which modes accepted? ('+' for -v, '@' for -o) 00995 map<string,string> dynamic_bans; //!< List of dynamically banned users 00996 00997 vector<string> keys; //!< History of +k key's 00998 00999 vector<s_group> groups; //!< List of groups which this channel is member of 01000 01001 vector<string> dynbans_editors; //!< List of groups that can use .dynbans command for this channel 01002 01003 vector<s_replication> replication; //!< Informations of replication 01004 01005 time_t last_changed; //!< Timestamp for replication 01006 01007 s_channel_def() 01008 { 01009 channel_name=""; 01010 on_mode=""; 01011 on_key=""; 01012 on_limit=""; 01013 on_topic=""; 01014 on_dynamic_ban=""; 01015 allow_dynamic.clear(); 01016 dynamic_plus_modes=""; 01017 dynamic_minus_modes=""; 01018 on_ircop=""; 01019 on_privmsg=""; 01020 on_notice=""; 01021 on_part=""; 01022 on_dynamic_ban=""; 01023 on_ctcp=""; 01024 on_server_msg=""; 01025 groups.clear(); 01026 replication.clear(); 01027 last_changed=0; 01028 keys.clear(); 01029 dynamic_bans.clear(); 01030 } 01031 }; 01032 01033 /*! 01034 \brief Stores informations about what to do when someone sends query message 01035 \author VooDooMan 01036 \version 1 01037 \date 2004 01038 */ 01039 struct s_private { 01040 vector<s_replication> replication; //!< Informations of replication 01041 time_t last_changed; //!< Time of last change 01042 01043 vector<s_group> groups; 01044 01045 string on_privmsg; //!< Event for private query 01046 string on_notice; //!< Event for private notice 01047 string on_ctcp; //!< Event for private CTCP message 01048 string on_filesys_got_new; //!< Event to trigger when filesystem got new file / message 01049 string on_fnc; //!< Event for Force Nick Change (for IRCnet) 01050 string on_broadcast; //!< Event for broadcast messages from IRC operators 01051 string on_server_msg; //!< Event for server messages 01052 string on_internal_event; //!< Event for server messages 01053 01054 void clear() { 01055 on_privmsg=""; 01056 on_notice=""; 01057 on_ctcp=""; 01058 on_filesys_got_new=""; 01059 on_fnc=""; 01060 on_broadcast=""; 01061 on_server_msg=""; 01062 replication.clear(); 01063 last_changed=0; 01064 groups.clear(); 01065 on_internal_event=""; 01066 } 01067 01068 s_private() { 01069 clear(); 01070 } 01071 }; 01072 01073 /*! 01074 \brief Stores data about connected user of channel 01075 \author VooDooMan 01076 \version 1 01077 \date 2004 01078 */ 01079 struct s_online_user { 01080 string nick; //!< User's nick name 01081 01082 bool got_whois; //!< Have we received WHOIS command reply yet for this user? 01083 bool whois_sent; //!< Have we sent WHOIS command for this user yet? 01084 bool on_join_called; //!< Have we tried to call on_join event yet? If on_join isn't assigned, there can be true. 01085 01086 string ident; //!< If got_whois == true, there is IDENT of user 01087 string host; //!< If got_whois == true, there is host of user 01088 string fullname; //!< If got_whois == true, there is full name of user 01089 01090 bool got_mode; //!< Have we received mode of user? (+v and +o / '+' and '@' prefixes; and '~' on some irc networks) 01091 string mode; //!< If got_mode == true, there is prefix of mode (i.e. "+", "@", "@+") 01092 string old_mode; //!< Mode of previous WHOIS 01093 01094 bool irc_op; //!< If got_whois == true: Is this user an irc operator? 01095 01096 string in_logic_as; //!< Name of user as in logic.h::s_user structure 01097 01098 // only for var tmp_users 01099 time_t last_whois; //!< Used only in tmp_users variable / for irc_access_to_partyline() function 01100 string dcc_msg; //!< Used only in tmp_users variable / for irc_access_to_partyline() function 01101 01102 // for on_join after JOIN and WHOIS 01103 bool just_joined; //!< true if user just joined the channel (for on_join after JOIN and WHOIS) 01104 string just_joined_channel; //!< Name of channel that user just joined (for on_join after JOIN and WHOIS) 01105 01106 vector<s_flood_history> msg_flood_hist; //!< History for msg_flood (PRIVMSG) detection 01107 vector<s_flood_history> repeat_flood_hist; //!< History for repeat_flood detection 01108 vector<s_flood_history> notice_flood_hist; //!< History for notice_flood detection 01109 vector<s_flood_history> nick_flood_hist; //!< History for nick_flood detection 01110 vector<s_flood_history> join_flood_hist; //!< History for join_flood detection 01111 vector<s_flood_history> mode_flood_hist; //!< History for mode_flood detection 01112 vector<s_flood_history> ctcp_flood_hist; //!< History for ctcp_flood detection 01113 time_t quit_time; //!< Time of user's quit/part/kick-ed (for gone_users variable only) 01114 01115 string old_nick; //!< Workaround to multiple call logic_on_nick_validate 01116 01117 s_online_user() 01118 { 01119 nick=""; 01120 old_nick=""; 01121 got_whois=false; 01122 whois_sent=false; 01123 on_join_called=false; 01124 ident=""; 01125 host=""; 01126 fullname=""; 01127 got_mode=false; 01128 mode=""; 01129 irc_op=true; 01130 in_logic_as=""; 01131 last_whois=0; 01132 dcc_msg=""; 01133 just_joined=false; 01134 just_joined_channel=""; 01135 msg_flood_hist.clear(); 01136 repeat_flood_hist.clear(); 01137 notice_flood_hist.clear(); 01138 nick_flood_hist.clear(); 01139 join_flood_hist.clear(); 01140 mode_flood_hist.clear(); 01141 ctcp_flood_hist.clear(); 01142 quit_time=0; 01143 old_mode="INVALID"; 01144 } 01145 }; 01146 01147 /*! 01148 \brief Stores channels information on wich the bot is 01149 \author VooDooMan 01150 \version 1 01151 \date 2004 01152 */ 01153 struct s_online_channel { 01154 string name; //!< Name of channel 01155 01156 string modes; //!< Channel modes 01157 string topic; //!< Channel's topic 01158 string key; //!< Channel's key (or an empty string for none) 01159 string limit; //!< Channel's limit (or an empty string for none) 01160 01161 bool b_excepts_sent; //!< Have we sent "MODE #channel +e" yet? 01162 bool b_invites_sent; //!< Have we sent "MODE #channel +I" yet? 01163 bool b_bans_sent; //!< Have we send "MODE #channel +b" yet? 01164 bool b_reops_sent; //!< Have we sent "MODE #channel +R" yet? 01165 01166 vector<s_online_user> users; //!< List of users on this channel 01167 01168 vector<string> bans; //!< List of ban masks 01169 bool got_excepts; //!< Have we got exceptions (+e) of bans? (MODE \#channel +e) - NOTE: even if irc network doesn't support +e exceptions, this is set to true if error response was sent by server to command MODE \#channel +e 01170 vector<string> excepts; //!< If got_excepts == true: list of +e exceptions - NOTE: clear, if irc network doesn't support +e exceptions to bans 01171 01172 bool got_invites; //!< Have we got invitations (+I)? 01173 vector<string> invites; //!< List of invitations (+I) 01174 01175 bool got_reops; //!< Have we got reop hints (+R)? 01176 vector<string> reops; //!< List of reop hints (+R) 01177 01178 s_online_channel() 01179 { 01180 clear(); 01181 } 01182 01183 void clear() 01184 { 01185 name=""; 01186 modes=""; 01187 topic=""; 01188 key=limit=""; 01189 users.clear(); 01190 bans.clear(); 01191 got_excepts=false; 01192 excepts.clear(); 01193 got_invites=false; 01194 got_reops=false; 01195 reops.clear(); 01196 b_reops_sent=b_excepts_sent=b_invites_sent=b_bans_sent=false; 01197 invites.clear(); 01198 } 01199 }; 01200 01201 /*! 01202 \brief Stores irc server connection info 01203 \author VooDooMan 01204 \version 1 01205 \date 2004 01206 */ 01207 struct s_irc_server { 01208 string host; //!< Host name 01209 unsigned short port; //!< Port 01210 }; 01211 01212 /*! 01213 \brief Stores DCC requests that are pending to establis, and waiting for whois result 01214 \author VooDooMan 01215 \version 1 01216 \date 2004 01217 */ 01218 struct s_dcc_request_whois { 01219 time_t start; 01220 01221 string str; 01222 string nick; 01223 string host_mask; 01224 01225 bool got_whois; 01226 01227 string ident; 01228 string host; 01229 string full_name; 01230 bool irc_op; 01231 01232 void clear() //!< Cleans-up the structure 01233 { 01234 start=0; 01235 01236 str=""; 01237 nick=""; 01238 host_mask=""; 01239 01240 got_whois=false; 01241 01242 ident=""; 01243 host=""; 01244 full_name=""; 01245 irc_op=false; 01246 } 01247 01248 s_dcc_request_whois() 01249 { 01250 clear(); 01251 } 01252 }; 01253 01254 /*! 01255 \brief Stores information about locked out users due to bad logins 01256 \author VooDooMan 01257 \version 1 01258 \date 2005 01259 */ 01260 struct s_user_to_lock_out { 01261 time_t timestamp; //!< Timestamp of bad log in 01262 string remote; //!< Remote host/IP 01263 }; 01264 01265 // --- 01266 01267 /*! 01268 \def PRIVATE_EVENT_SEVERITY_CODE_NA 01269 \brief For event "on_internal_event": Severity code N/A 01270 */ 01271 #define PRIVATE_EVENT_SEVERITY_CODE_NA 0 01272 01273 /*! 01274 \def PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL 01275 \brief For event "on_internal_event": Severity code INFORMATIONAL 01276 */ 01277 #define PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL 1 01278 01279 /*! 01280 \def PRIVATE_EVENT_SEVERITY_CODE_WARNING 01281 \brief For event "on_internal_event": Severity code WARNING 01282 */ 01283 #define PRIVATE_EVENT_SEVERITY_CODE_WARNING 3 01284 01285 /*! 01286 \def PRIVATE_EVENT_SEVERITY_CODE_ERROR 01287 \brief For event "on_internal_event": Severity code ERROR 01288 */ 01289 #define PRIVATE_EVENT_SEVERITY_CODE_ERROR 5 01290 01291 /*! 01292 \def PRIVATE_EVENT_SEVERITY_CODE_CRITICAL_ERROR 01293 \brief For event "on_internal_event": Severity code CRITICAL_ERROR 01294 */ 01295 #define PRIVATE_EVENT_SEVERITY_CODE_CRITICAL_ERROR 7 01296 01297 /*! 01298 \def PRIVATE_EVENT_SEVERITY_CODE_FATAL_ERROR 01299 \brief For event "on_internal_event": Severity code FATAL_ERROR 01300 */ 01301 #define PRIVATE_EVENT_SEVERITY_CODE_FATAL_ERROR 9 01302 01303 // --- 01304 01305 #endif 01306