From c8c23158a4ff74822d6c7d201dc53d879e3d91e8 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 22 Apr 2011 03:16:11 -0400 Subject: Moved the core pseudo clients out into their own modules --- CMakeLists.txt | 4 +- data/example.conf | 273 ++++++++++--- docs/Changes.conf | 17 + docs/README | 31 -- include/anope.h | 26 +- include/bots.h | 6 + include/channels.h | 33 +- include/config.h | 56 +-- include/extern.h | 89 +--- include/logger.h | 2 +- include/modules.h | 75 ++-- include/oper.h | 231 +++++++++++ include/operserv.h | 250 ------------ include/regchannel.h | 5 + include/services.h | 70 +--- include/sysconf.h.cmake | 2 - modules/core/botserv.h | 65 +++ modules/core/bs_act.cpp | 8 +- modules/core/bs_assign.cpp | 6 +- modules/core/bs_badwords.cpp | 8 +- modules/core/bs_bot.cpp | 6 +- modules/core/bs_botlist.cpp | 6 +- modules/core/bs_help.cpp | 14 +- modules/core/bs_info.cpp | 8 +- modules/core/bs_kick.cpp | 301 ++++++++++++-- modules/core/bs_main.cpp | 265 ++++++++++++ modules/core/bs_say.cpp | 8 +- modules/core/bs_set.cpp | 8 +- modules/core/bs_unassign.cpp | 8 +- modules/core/chanserv.h | 15 + modules/core/cs_access.cpp | 14 +- modules/core/cs_akick.cpp | 10 +- modules/core/cs_ban.cpp | 10 +- modules/core/cs_clearusers.cpp | 10 +- modules/core/cs_clone.cpp | 6 +- modules/core/cs_drop.cpp | 8 +- modules/core/cs_forbid.cpp | 8 +- modules/core/cs_getkey.cpp | 6 +- modules/core/cs_help.cpp | 13 +- modules/core/cs_info.cpp | 6 +- modules/core/cs_invite.cpp | 14 +- modules/core/cs_kick.cpp | 10 +- modules/core/cs_list.cpp | 7 +- modules/core/cs_main.cpp | 256 ++++++++++++ modules/core/cs_mode.cpp | 6 +- modules/core/cs_modes.cpp | 39 +- modules/core/cs_register.cpp | 8 +- modules/core/cs_saset.cpp | 10 +- modules/core/cs_saset_noexpire.cpp | 8 +- modules/core/cs_set.cpp | 10 +- modules/core/cs_set_bantype.cpp | 12 +- modules/core/cs_set_description.cpp | 12 +- modules/core/cs_set_founder.cpp | 12 +- modules/core/cs_set_keeptopic.cpp | 14 +- modules/core/cs_set_opnotice.cpp | 14 +- modules/core/cs_set_peace.cpp | 14 +- modules/core/cs_set_persist.cpp | 20 +- modules/core/cs_set_private.cpp | 14 +- modules/core/cs_set_restricted.cpp | 12 +- modules/core/cs_set_secure.cpp | 16 +- modules/core/cs_set_securefounder.cpp | 12 +- modules/core/cs_set_secureops.cpp | 12 +- modules/core/cs_set_signkick.cpp | 14 +- modules/core/cs_set_successor.cpp | 12 +- modules/core/cs_set_topiclock.cpp | 14 +- modules/core/cs_set_xop.cpp | 12 +- modules/core/cs_status.cpp | 3 +- modules/core/cs_suspend.cpp | 5 +- modules/core/cs_topic.cpp | 5 +- modules/core/cs_unban.cpp | 5 +- modules/core/cs_xop.cpp | 35 +- modules/core/db_plain.cpp | 40 +- modules/core/gl_global.cpp | 67 +++ modules/core/gl_help.cpp | 58 +++ modules/core/gl_main.cpp | 111 +++++ modules/core/global.h | 22 + modules/core/hostserv.h | 17 + modules/core/hs_del.cpp | 6 +- modules/core/hs_delall.cpp | 6 +- modules/core/hs_group.cpp | 8 +- modules/core/hs_help.cpp | 10 +- modules/core/hs_list.cpp | 6 +- modules/core/hs_main.cpp | 123 ++++++ modules/core/hs_off.cpp | 6 +- modules/core/hs_on.cpp | 6 +- modules/core/hs_set.cpp | 6 +- modules/core/hs_setall.cpp | 8 +- modules/core/memoserv.h | 44 ++ modules/core/ms_cancel.cpp | 14 +- modules/core/ms_check.cpp | 6 +- modules/core/ms_del.cpp | 6 +- modules/core/ms_help.cpp | 14 +- modules/core/ms_ignore.cpp | 8 +- modules/core/ms_info.cpp | 6 +- modules/core/ms_list.cpp | 6 +- modules/core/ms_main.cpp | 250 ++++++++++++ modules/core/ms_read.cpp | 42 +- modules/core/ms_rsend.cpp | 44 +- modules/core/ms_send.cpp | 18 +- modules/core/ms_sendall.cpp | 8 +- modules/core/ms_set.cpp | 8 +- modules/core/ms_staff.cpp | 8 +- modules/core/nickserv.h | 17 + modules/core/ns_access.cpp | 8 +- modules/core/ns_ajoin.cpp | 10 +- modules/core/ns_alist.cpp | 3 +- modules/core/ns_cert.cpp | 12 +- modules/core/ns_drop.cpp | 10 +- modules/core/ns_forbid.cpp | 8 +- modules/core/ns_getemail.cpp | 6 +- modules/core/ns_getpass.cpp | 12 +- modules/core/ns_ghost.cpp | 8 +- modules/core/ns_group.cpp | 18 +- modules/core/ns_help.cpp | 17 +- modules/core/ns_identify.cpp | 8 +- modules/core/ns_info.cpp | 6 +- modules/core/ns_list.cpp | 7 +- modules/core/ns_logout.cpp | 10 +- modules/core/ns_main.cpp | 282 +++++++++++++ modules/core/ns_recover.cpp | 12 +- modules/core/ns_register.cpp | 23 +- modules/core/ns_release.cpp | 8 +- modules/core/ns_resetpass.cpp | 16 +- modules/core/ns_saset.cpp | 12 +- modules/core/ns_saset_noexpire.cpp | 8 +- modules/core/ns_sendpass.cpp | 14 +- modules/core/ns_set.cpp | 12 +- modules/core/ns_set_autoop.cpp | 12 +- modules/core/ns_set_email.cpp | 16 +- modules/core/ns_set_greet.cpp | 12 +- modules/core/ns_set_hide.cpp | 16 +- modules/core/ns_set_kill.cpp | 16 +- modules/core/ns_set_language.cpp | 12 +- modules/core/ns_set_message.cpp | 12 +- modules/core/ns_set_private.cpp | 18 +- modules/core/ns_set_secure.cpp | 16 +- modules/core/ns_status.cpp | 6 +- modules/core/ns_suspend.cpp | 8 +- modules/core/ns_update.cpp | 17 +- modules/core/operserv.h | 15 + modules/core/os_akill.cpp | 64 ++- modules/core/os_chankill.cpp | 8 +- modules/core/os_chanlist.cpp | 8 +- modules/core/os_config.cpp | 6 +- modules/core/os_defcon.cpp | 496 ----------------------- modules/core/os_global.cpp | 67 --- modules/core/os_help.cpp | 14 +- modules/core/os_ignore.cpp | 6 +- modules/core/os_jupe.cpp | 6 +- modules/core/os_kick.cpp | 10 +- modules/core/os_login.cpp | 12 +- modules/core/os_main.cpp | 137 +++++++ modules/core/os_mode.cpp | 12 +- modules/core/os_modinfo.cpp | 24 +- modules/core/os_modlist.cpp | 6 +- modules/core/os_modload.cpp | 8 +- modules/core/os_modreload.cpp | 8 +- modules/core/os_modunload.cpp | 8 +- modules/core/os_news.cpp | 22 +- modules/core/os_noop.cpp | 6 +- modules/core/os_oline.cpp | 14 +- modules/core/os_quit.cpp | 9 +- modules/core/os_reload.cpp | 16 +- modules/core/os_restart.cpp | 9 +- modules/core/os_session.cpp | 234 +++++++++-- modules/core/os_session.h | 80 ++++ modules/core/os_set.cpp | 12 +- modules/core/os_shutdown.cpp | 9 +- modules/core/os_snline.cpp | 67 +-- modules/core/os_sqline.cpp | 54 ++- modules/core/os_staff.cpp | 6 +- modules/core/os_stats.cpp | 160 +------- modules/core/os_svsnick.cpp | 10 +- modules/core/os_szline.cpp | 62 ++- modules/core/os_update.cpp | 6 +- modules/core/os_userlist.cpp | 6 +- modules/core/ss_main.cpp | 65 --- modules/extra/cs_appendtopic.cpp | 14 +- modules/extra/cs_enforce.cpp | 10 +- modules/extra/cs_entrymsg.cpp | 12 +- modules/extra/cs_set_misc.cpp | 16 +- modules/extra/cs_tban.cpp | 12 +- modules/extra/db_mysql.cpp | 87 ++-- modules/extra/hs_request.cpp | 47 ++- modules/extra/m_alias.cpp | 9 +- modules/extra/m_dnsbl.cpp | 44 +- modules/extra/m_helpchan.cpp | 9 +- modules/extra/m_ldap.cpp | 4 +- modules/extra/m_ldap_authentication.cpp | 19 +- modules/extra/m_ldap_oper.cpp | 4 +- modules/extra/m_mysql.cpp | 4 +- modules/extra/m_xmlrpc.cpp | 6 +- modules/extra/m_xmlrpc_main.cpp | 7 +- modules/extra/ns_maxemail.cpp | 10 +- modules/extra/ns_set_misc.cpp | 13 +- modules/extra/os_defcon.cpp | 693 ++++++++++++++++++++++++++++++++ modules/protocol/bahamut.cpp | 27 +- modules/protocol/inspircd-ts6.h | 20 +- modules/protocol/inspircd11.cpp | 21 +- modules/protocol/inspircd12.cpp | 38 +- modules/protocol/inspircd20.cpp | 36 +- modules/protocol/plexus.cpp | 15 +- modules/protocol/ratbox.cpp | 26 +- modules/protocol/unreal32.cpp | 31 +- src/bots.cpp | 75 ++-- src/botserv.cpp | 554 ------------------------- src/channels.cpp | 52 +-- src/chanserv.cpp | 274 +------------ src/commands.cpp | 8 +- src/config.cpp | 207 ++-------- src/hostserv.cpp | 97 ----- src/init.cpp | 47 +-- src/logger.cpp | 65 +-- src/main.cpp | 57 +-- src/memoserv.cpp | 334 --------------- src/misc.cpp | 310 ++++---------- src/modes.cpp | 2 +- src/nickalias.cpp | 11 - src/nickcore.cpp | 20 - src/nickserv.cpp | 242 ----------- src/operserv.cpp | 294 ++------------ src/protocol.cpp | 64 +-- src/regchannel.cpp | 16 +- src/servers.cpp | 4 - src/sessions.cpp | 292 -------------- src/users.cpp | 109 +---- src/win32/anope_windows.h | 6 +- src/win32/windows.cpp | 152 ++++++- 228 files changed, 5449 insertions(+), 5153 deletions(-) create mode 100644 include/oper.h delete mode 100644 include/operserv.h create mode 100644 modules/core/botserv.h create mode 100644 modules/core/bs_main.cpp create mode 100644 modules/core/chanserv.h create mode 100644 modules/core/cs_main.cpp create mode 100644 modules/core/gl_global.cpp create mode 100644 modules/core/gl_help.cpp create mode 100644 modules/core/gl_main.cpp create mode 100644 modules/core/global.h create mode 100644 modules/core/hostserv.h create mode 100644 modules/core/hs_main.cpp create mode 100644 modules/core/memoserv.h create mode 100644 modules/core/ms_main.cpp create mode 100644 modules/core/nickserv.h create mode 100644 modules/core/ns_main.cpp create mode 100644 modules/core/operserv.h delete mode 100644 modules/core/os_defcon.cpp delete mode 100644 modules/core/os_global.cpp create mode 100644 modules/core/os_main.cpp create mode 100644 modules/core/os_session.h delete mode 100644 modules/core/ss_main.cpp create mode 100644 modules/extra/os_defcon.cpp delete mode 100644 src/sessions.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f76306ab..db6bbf837 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,7 +222,7 @@ option(USE_RUN_CC_PL "Use run-cc.pl for building" OFF) # Use the following directories as includes # Note that it is important the binary include directory comes before the # source include directory so the precompiled headers work correctly. -include_directories(${Anope_BINARY_DIR}/include ${Anope_SOURCE_DIR}/include ${Anope_BINARY_DIR}/language) +include_directories(${Anope_BINARY_DIR}/include ${Anope_SOURCE_DIR}/include ${Anope_BINARY_DIR}/language ${Anope_SOURCE_DIR}/modules/core) # If using Windows, always add the _WIN32 define if(WIN32) @@ -337,8 +337,6 @@ check_include_file(sys/eventfd.h HAVE_SYS_EVENTFD_H) check_function_exists(setgrent HAVE_SETGRENT) check_function_exists(strcasecmp HAVE_STRCASECMP) check_function_exists(stricmp HAVE_STRICMP) -check_function_exists(strlcat HAVE_STRLCAT) -check_function_exists(strlcpy HAVE_STRLCPY) check_function_exists(umask HAVE_UMASK) check_function_exists(backtrace HAVE_BACKTRACE) check_function_exists(eventfd HAVE_EVENTFD) diff --git a/data/example.conf b/data/example.conf index 5ad787180..66588cdee 100644 --- a/data/example.conf +++ b/data/example.conf @@ -470,35 +470,6 @@ options */ #hidestatso = yes - /* - * If set, Services will send global messages on starting up and shutting - * down/restarting. - * - * This directive is optional. - */ - #globaloncycle = yes - - /* - * This is the global message that will be sent when Services are being - * shutdown/restarted. This directive is only required if you enable - * globaloncycle above. - */ - globaloncycledown = "Services are restarting, they will be back shortly - please be good while we're gone" - - /* - * This is the global message that will be sent when Services (re)join the - * network. This directive is only required if you enable globaloncycle above. - */ - globaloncycleup = "Services are now back online - have a nice day" - - /* - * If set, Services will hide the IRC operator's nick in a global - * message/notice. - * - * This directive is optional. - */ - #anonymousglobal = yes - /* * Prevents users from registering their nick if they are not connected * for at least the given number of seconds. @@ -590,8 +561,8 @@ log /* * Target(s) to log to, which may be one of the following: * - a channel name + * - a filename * - globops - * - filename */ target = "services.log" /* Log to both services.log and the channel #services */ @@ -668,7 +639,7 @@ log log { target = "globops" - admin = "operserv/global operserv/mode operserv/kick opeserv/akill operserv/s*line operserv/noop operserv/jupe */forbid nickserv/getpass */drop" + admin = "global/* operserv/mode operserv/kick opeserv/akill operserv/s*line operserv/noop operserv/jupe */forbid nickserv/getpass */drop" } /* @@ -690,6 +661,7 @@ log * chanserv/set - Can modify the settings of any channel (incl. changing of the owner and password!) * memoserv/info - Can see any information with /memoserv info * memoserv/set-limit - Can set the limit of max stored memos on any user and channel + * memoserv/no-limit - Can send memos through limits and throttles * nickserv/auspex - Can see any information with /nickserv info * nickserv/confirm - Can confirm other users nicknames * nickserv/drop - Can drop other users nicks @@ -703,8 +675,8 @@ log * chanserv/mode * * chanserv/saset/bantype chanserv/saset/description chanserv/saset/email chanserv/saset/entrymsg - * chanserv/saset/founder chanserv/saset/keeptopic chanserv/saset/opnotice - * chanserv/saset/peace chanserv/saset/persist chanserv/saset/private chanserv/saset/restricted + * chanserv/saset/founder chanserv/saset/keeptopic chanserv/saset/opnotice chanserv/saset/restricted + * chanserv/saset/peace chanserv/saset/persist chanserv/saset/private * chanserv/saset/secure chanserv/saset/securefounder chanserv/saset/secureops * chanserv/saset/signkick chanserv/saset/successor chanserv/saset/topiclock * chanserv/saset/url chanserv/saset/xop @@ -720,10 +692,12 @@ log * * hostserv/set hostserv/del * - * operserv/global operserv/news operserv/stats operserv/kick + * global/global + * + * operserv/news operserv/stats operserv/kick * operserv/mode operserv/session operserv/modlist operserv/ignore * operserv/chankill operserv/akill operserv/sqline operserv/snline - * operserv/szline operserv/staff operserv/defcon operserv/config + * operserv/szline operserv/staff operserv/config * operserv/modload operserv/jupe operserv/set operserv/noop * operserv/quit operserv/update operserv/reload operserv/restart * operserv/shutdown operserv/svsnick operserv/oline @@ -767,7 +741,7 @@ opertype inherits = "Services Operator" - commands = "chanserv/access/list chanserv/drop chanserv/forbid chanserv/getkey chanserv/set/noexpire memoserv/sendall nickserv/saset/* nickserv/getemail operserv/global operserv/news operserv/jupe operserv/svsnick operserv/stats operserv/oline operserv/defcon operserv/noop" + commands = "chanserv/access/list chanserv/drop chanserv/forbid chanserv/getkey chanserv/set/noexpire memoserv/sendall nickserv/saset/* nickserv/getemail operserv/news operserv/jupe operserv/svsnick operserv/stats operserv/oline operserv/noop global/*" privs = "*" } @@ -910,6 +884,13 @@ dns timeout = 5 } +/* + * [RECOMMENDED] NickServ + * + * Comment the following line to disable NickServ. + */ +module { name = "ns_main" } + /* * [REQUIRED] NickServ Config * @@ -1133,6 +1114,13 @@ nickserv ajoinmax = 10 } +/* + * [RECOMMENDED] ChanServ + * + * Comment the following line to disable ChanServ. + */ +module { name = "cs_main" } + /* * [RECOMMENDED] ChanServ Config * @@ -1158,7 +1146,7 @@ chanserv * * This directive is optional, but highly recommended. */ - modules = "cs_help cs_register cs_set cs_saset cs_saset_noexpire cs_set_bantype cs_set_description cs_set_entrymsg cs_set_founder cs_set_keeptopic cs_set_opnotice cs_set_peace cs_set_persist cs_set_private cs_set_restricted cs_set_secure cs_set_securefounder cs_set_secureops cs_set_signkick cs_set_successor cs_set_topiclock cs_set_xop cs_xop cs_access cs_akick cs_drop cs_ban cs_clearusers cs_modes cs_getkey cs_invite cs_kick cs_list cs_topic cs_info cs_forbid cs_suspend cs_status cs_unban cs_clone cs_mode" + modules = "cs_help cs_register cs_set cs_saset cs_saset_noexpire cs_set_bantype cs_set_description cs_set_founder cs_set_keeptopic cs_set_opnotice cs_set_peace cs_set_persist cs_set_private cs_set_restricted cs_set_secure cs_set_securefounder cs_set_secureops cs_set_signkick cs_set_successor cs_set_topiclock cs_set_xop cs_xop cs_access cs_akick cs_drop cs_ban cs_clearusers cs_modes cs_getkey cs_invite cs_kick cs_list cs_topic cs_info cs_forbid cs_suspend cs_status cs_unban cs_clone cs_mode" /* * The default options for newly registered channels. Note that changing these options @@ -1276,10 +1264,16 @@ chanserv } /* - * [OPTIONAL] MemoServ Config + * [OPTIONAL] MemoServ * - * This section is used to set up the Memo Service pseudo-client. Unless specified otherwise, - * all directives are required if you wish to use MemoServ. + * Comment the following line to disable MemoServ. + */ +module { name = "ms_main" } + +/* [OPTIONAL] MemoServ configuration + * + * This section is used to set up the Memo Service pseudo-client. This is only required if ms_main + * is being loaded. */ memoserv { @@ -1322,15 +1316,6 @@ memoserv */ senddelay = 3s - /* - * Should we notify all appropriate users of a new memo? This applies in cases where a memo is - * sent to a nick which is in the group of another nick. Note that, unlike before, it is currently - * more efficient to enable this. - * - * This directive is optional. - */ - notifyall = yes - /* * Allow the use of memo receipts for the following groups: * @@ -1343,11 +1328,16 @@ memoserv } /* - * [OPTIONAL] BotServ Config + * [OPTIONAL] BotServ * - * This section is used to set up the Bot Service pseudo-client. The block is optional and can be - * removed if you do not wish to have BotServ on your network. Unless specified otherwise, - * all directives are required if you do wish to use BotServ. + * Comment the following line to disable BotServ. + */ +module { name = "bs_main" } + +/* [OPTIONAL] BotServ configuration + * + * This section is used to set up the Bot Service pseudo-client. This is only required if ms_main + * is being loaded. */ botserv { @@ -1442,13 +1432,18 @@ botserv #fantasycharacter = "!" } +/* + * [OPTIONAL] HostServ + * + * Comment the following line to disable HostServ. + */ +module { name = "hs_main" } + /* * [OPTIONAL] HostServ Config * * This section is used to set up the vHost Service pseudo-client. * - * The block is optional and can be removed if you do not wish to have HostServ on your network. - * * Unless specified otherwise, all directives are required if you do wish to use HostServ. */ hostserv @@ -1473,6 +1468,13 @@ hostserv modules = "hs_help hs_on hs_off hs_group hs_list hs_set hs_setall hs_del hs_delall" } +/* + * [RECOMMENDED] OperServ + * + * Comment the following line to disable OperServ. + */ +module { name = "os_main" } + /* * [RECOMMENDED] OperServ Config * @@ -1498,7 +1500,7 @@ operserv * * This directive is optional, but highly recommended. */ - modules = "os_help os_global os_stats os_staff os_mode os_kick os_akill os_snline os_sqline os_szline os_chanlist os_userlist os_news os_session os_noop os_jupe os_ignore os_set os_reload os_update os_restart os_quit os_shutdown os_defcon os_chankill os_svsnick os_oline os_modload os_modunload os_modreload os_modlist os_modinfo os_config os_login" + modules = "os_help os_stats os_staff os_mode os_kick os_akill os_snline os_sqline os_szline os_chanlist os_userlist os_news os_session os_noop os_jupe os_ignore os_set os_reload os_update os_restart os_quit os_shutdown os_chankill os_svsnick os_oline os_modload os_modunload os_modreload os_modlist os_modinfo os_config os_login" /* * If set, Services Admins will be able to use SUPERADMIN [ON|OFF] which will temporarily grant @@ -1650,6 +1652,13 @@ operserv opersonly = yes } +/* + * [RECOMMENDED] Global + * + * Comment the following line to disable Global. + */ +module { name = "gl_main" } + /* * [RECOMMENDED] Global Config * @@ -1671,6 +1680,43 @@ global * (real name) of the client. */ description = "Global Noticer" + + /* + * The core modules to load for OperServ. This is a space separated list that corresponds + * to the base names of the modules for OperServ. + * + * This directive is optional, but highly recommended. + */ + modules = "gl_help gl_global" + + /* + * If set, Services will send global messages on starting up and shutting + * down/restarting. + * + * This directive is optional. + */ + #globaloncycle = yes + + /* + * This is the global message that will be sent when Services are being + * shutdown/restarted. This directive is only required if you enable + * globaloncycle above. + */ + globaloncycledown = "Services are restarting, they will be back shortly - please be good while we're gone" + + /* + * This is the global message that will be sent when Services (re)join the + * network. This directive is only required if you enable globaloncycle above. + */ + globaloncycleup = "Services are now back online - have a nice day" + + /* + * If set, Services will hide the IRC operator's nick in a global + * message/notice. + * + * This directive is optional. + */ + #anonymousglobal = yes } /* @@ -1750,18 +1796,10 @@ defcon #globalondefcon = yes /* - * If set, Services will send the global message defined in the message directive on DefCon level - * changes. + * Defines a message that will be sent on DefCon level changes. * * This directive is optional. */ - #globalondefconmore = yes - - /* - * Defines the message that will be sent on DefCon level changes when globalondefconmore is set. - * - * This directive is required only when globalondefconmore is set. - */ #message = "Put your message to send your users here. Dont forget to uncomment globalondefconmore" /* @@ -2208,3 +2246,108 @@ ns_set_misc desc = "Associate an ICQ number with the nick" } + +/* + * os_defcon + * + * Allows you to set services in defcon mode, which can be used to restrict services access + * during bot attacks. + */ +#module { "os_defcon" } +os_defcon +{ + /* + * Default DefCon level (1-5) to use when starting Services up. Level 5 constitutes normal operation + * while level 1 constitutes the most restrictive operation. If this setting is left out or set to + * 0, DefCon will be disabled and the rest of this block will be ignored. + */ + #defaultlevel = 5 + + /* + * The following 4 directives define what operations will take place when DefCon is set to levels + * 1 through 4. Each level is a list that must be separated by spaces. + * + * The following operations can be defined at each level: + * - nonewchannels: Disables registering new channels + * - nonewnicks: Disables registering new nicks + * - nomlockchanges: Disables changing MLOCK on registered channels + * - forcechanmodes: Forces all channels to have the modes given in the later chanmodes directive + * - reducedsessions: Reduces the session limit to the value given in the later sessionlimit directive + * - nonewclients: KILL any new clients trying to connect + * - operonly: Services will ignore all non-IRCops + * - silentoperonly: Services will silently ignore all non-IRCops + * - akillnewclients: AKILL any new clients trying to connect + * - nonewmemos: No new memos will be sent to block MemoServ attacks + */ + level4 = "nonewchannels nonewnicks nomlockchanges reducedsessions" + level3 = "nonewchannels nonewnicks nomlockchanges forcechanmodes reducedsessions" + level2 = "nonewchannels nonewnicks nomlockchanges forcechanmodes reducedsessions silentoperonly" + level1 = "nonewchannels nonewnicks nomlockchanges forcechanmodes reducedsessions silentoperonly akillnewclients" + + /* + * New session limit to use when a DefCon level is using "reduced" session limiting. + */ + #sessionlimit = 2 + + /* + * Length of time to add an AKILL for when DefCon is preventing new clients from connecting to the + * network. + */ + #akillexpire = 5m + + /* + * The channel modes to set on all channels when the DefCon channel mode system is in use. + * + * Note 1: Choose these modes carefully, because when DefCon switches to a level which does NOT have + * the mode setting selected, Services will set the reverse on all channels, e.g. if this setting + * is +RN when DefCon is used, all channels will be set to +RN, when DefCon is removed, all + * channels will be set to -RN. You don't want to set this to +k for example, because when DefCon + * is removed all channels with -k. + * + * Note 2: MLOCKed modes will not be lost. + */ + #chanmodes = "+R" + + /* + * This value can be used to automatically return the network to DefCon level 5 after the specified + * time period, just in case any IRC Operator forgets to remove a DefCon setting. + * + * This directive is optional. + */ + #timeout = 15m + + /* + * If set, Services will send a global message on DefCon level changes. + * + * This directive is optional. + */ + #globalondefcon = yes + + /* + * If set, Services will send the global message defined in the message directive on DefCon level + * changes. + * + * This directive is optional. + */ + #globalondefconmore = yes + + /* + * Defines the message that will be sent on DefCon level changes when globalondefconmore is set. + * + * This directive is required only when globalondefconmore is set. + */ + #message = "Put your message to send your users here. Dont forget to uncomment globalondefconmore" + + /* + * Defines the message that will be sent when DefCon is returned to level 5. This directive is optional, + * and will also override globalondefcon and globalondefconmore when set. + */ + #offmessage = "Services are now back to normal, sorry for any inconvenience" + + /* + * Defines the reason to use when clients are KILLed or AKILLed from the network while the proper + * DefCon operation is in effect. + */ + #akillreason = "This network is currently not accepting connections, please try again later" +} + diff --git a/docs/Changes.conf b/docs/Changes.conf index 3690de84a..aae4b6658 100644 --- a/docs/Changes.conf +++ b/docs/Changes.conf @@ -1,5 +1,22 @@ Anope Version 1.9.5 ------------------- +** ADDED CONFIGURATION DIRECTIVES ** +global:modules +global:globaloncycle +global:globaloncycledown +global:globaloncycleup +global:anonymousglobal + +** MODIFIED CONFIGURATION DIRECTIVES ** +opertype:permissions added memoserv/no-limit +operserv:modules removed os_global + +** DELETED CONFIGURATION DIRECTIVES ** +memoserv:notifyall +options:globaloncycle +options:globaloncycledown +options:globaloncycleup +options:anonymousglobal Anope Version 1.9.4 ------------------- diff --git a/docs/README b/docs/README index 34bdaa0be..79a6619c7 100644 --- a/docs/README +++ b/docs/README @@ -116,37 +116,6 @@ Table of Contents * Christopher N. (fr.l) * Yusuf Kurekci (tr.l) - Anope uses the strlcat() and strlcpy() functions from OpenSSH 2.5.1p2. - These functions are copyrighted by Todd C. Miller: - - Copyright (c) 1998 Todd C. Miller - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED `AS IS'' AND ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - - 2) Presentation Anope is a set of Services for IRC networks that allows users to manage diff --git a/include/anope.h b/include/anope.h index 4f116c37e..7aa505661 100644 --- a/include/anope.h +++ b/include/anope.h @@ -468,7 +468,21 @@ class dynamic_reference : public dynamic_reference_base this->invalid = false; this->ref = NULL; } - return this->ref; + return this->ref != NULL; + } + + virtual inline operator T*() + { + if (this->operator bool()) + return this->ref; + return NULL; + } + + virtual inline T *operator->() + { + if (this->operator bool()) + return this->ref; + return NULL; } virtual inline void operator=(T *newref) @@ -484,16 +498,6 @@ class dynamic_reference : public dynamic_reference_base if (this->ref) this->ref->AddReference(this); } - - virtual inline T *operator->() - { - return this->ref; - } - - virtual inline T *operator*() - { - return this->ref; - } }; #endif // ANOPE_H diff --git a/include/bots.h b/include/bots.h index bcbbc83d7..7316f074e 100644 --- a/include/bots.h +++ b/include/bots.h @@ -90,6 +90,12 @@ class CoreExport BotInfo : public User, public Flags * @param reason The reason we're parting */ void Part(Channel *c, const Anope::string &reason = ""); + + /** Called when a user messages this bot + * @param u The user + * @param message The users' message + */ + virtual void OnMessage(User *u, const Anope::string &message); }; #endif // BOTS_H diff --git a/include/channels.h b/include/channels.h index d0f899794..5d18a381f 100644 --- a/include/channels.h +++ b/include/channels.h @@ -12,38 +12,9 @@ typedef Anope::insensitive_map channel_map; extern CoreExport channel_map ChannelList; -struct UserData -{ - UserData() - { - Clear(); - } - - virtual ~UserData() { } - - void Clear() - { - last_use = last_start = Anope::CurTime; - lines = times = 0; - lastline.clear(); - } - - /* Data validity */ - time_t last_use; - - /* for flood kicker */ - int16 lines; - time_t last_start; - - /* for repeat kicker */ - Anope::string lastline; - int16 times; -}; - -struct UserContainer +struct UserContainer : public Extensible { User *user; - UserData ud; ChannelStatus *Status; UserContainer(User *u) : user(u) { } @@ -93,8 +64,6 @@ class CoreExport Channel : public Extensible, public Flags Anope::string topic_setter; /* Who set the topic */ time_t topic_time; /* When the topic was set*/ - std::list bd; - time_t server_modetime; /* Time of last server MODE */ time_t chanserv_modetime; /* Time of last check_modes() */ int16 server_modecount; /* Number of server MODEs this second */ diff --git a/include/config.h b/include/config.h index 5cba79587..666649253 100644 --- a/include/config.h +++ b/include/config.h @@ -167,7 +167,7 @@ template<> class ValueContainer : public ValueContainerBase return; } *val = new char[s]; - strlcpy(*val, newval, s); + memcpy(*val, newval, s); } }; @@ -264,7 +264,6 @@ bool ValidateHostServ(ServerConfig *config, const Anope::string &tag, const Anop bool ValidateLimitSessions(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); bool ValidateOperServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); bool ValidateGlobal(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); -bool ValidateDefCon(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); bool ValidateNickLen(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &data); bool ValidateMail(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); bool ValidateGlobalOnCycle(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); @@ -435,7 +434,7 @@ class CoreExport ServerConfig /* OperServ name */ Anope::string s_OperServ; /* Global name */ - Anope::string s_GlobalNoticer; + Anope::string s_Global; /* NickServs realname */ Anope::string desc_NickServ; /* ChanServ realname */ @@ -447,18 +446,26 @@ class CoreExport ServerConfig /* OperServ realname */ Anope::string desc_OperServ; /* Global realname */ - Anope::string desc_GlobalNoticer; + Anope::string desc_Global; /* HostServ Name */ Anope::string s_HostServ; /* HostServ realname */ Anope::string desc_HostServ; + /* Core HostServ modules */ + Anope::string HostCoreModules; /* Filename for the PID file */ Anope::string PIDFilename; /* MOTD filename */ Anope::string MOTDFilename; + /* Core MemoServ Modules */ + Anope::string MemoCoreModules; + /* Core OperServ Modules */ + Anope::string OperCoreModules; + /* Core Global Modules */ + Anope::string GlobalCoreModules; /* True if its ok to not be able to save backs */ bool NoBackupOkay; /* Do password checking when new people register */ @@ -578,6 +585,8 @@ class CoreExport ServerConfig bool NSStrictPrivileges; /* Use email to verify new users registering */ bool NSEmailReg; + /* Core NickServ modules */ + Anope::string NickCoreModules; /* Set the proper channel modes on users when they identify */ bool NSModeOnID; /* Add the users hostnask their access list when they register */ @@ -585,6 +594,8 @@ class CoreExport ServerConfig /* Maximum number of channels on AJoin */ unsigned AJoinMax; + /* Core ChanServ modules */ + Anope::string ChanCoreModules; /* Default flags for newly registered channels */ Flags CSDefFlags; /* Max number of channels a user can own */ @@ -621,7 +632,9 @@ class CoreExport ServerConfig /* Who can use memos reciepts */ unsigned MSMemoReceipt; - /* Defai;t BotServ flags */ + /* Core BotServ modules */ + Anope::string BotCoreModules; + /* Default BotServ flags */ Flags BSDefFlags; /* How long before botserv forgets a user. This is used for flood kickers etc */ time_t BSKeepData; @@ -710,39 +723,6 @@ class CoreExport ServerConfig std::list EncModuleList; /* Database modules */ std::list DBModuleList; - /* HostServ Core Modules */ - std::list HostServCoreModules; - /* MemoServ Core Modules */ - std::list MemoServCoreModules; - /* BotServ Core Modules */ - std::list BotServCoreModules; - /* OperServ Core Modules */ - std::list OperServCoreModules; - /* NickServ Core Modules */ - std::list NickServCoreModules; - /* ChanServ Core Modules */ - std::list ChanServCoreModules; - - /* Default defcon level */ - int DefConLevel; - /* Timeout before defcon is reset */ - time_t DefConTimeOut; - /* Session limiit to use when using defcon */ - unsigned DefConSessionLimit; - /* How long to add akills for defcon */ - time_t DefConAKILL; - /* Chan modes for defcon */ - Anope::string DefConChanModes; - /* Should we global on defcon */ - bool GlobalOnDefcon; - /* Should we send DefconMessage aswell? */ - bool GlobalOnDefconMore; - /* Message to send when defcon is off */ - Anope::string DefConOffMessage; - /* Message to send when defcon is on*/ - Anope::string DefconMessage; - /* Reason to akill clients for defcon */ - Anope::string DefConAkillReason; /* The socket engine in use */ Anope::string SocketEngine; diff --git a/include/extern.h b/include/extern.h index 0b29c0d03..6ec3310e9 100644 --- a/include/extern.h +++ b/include/extern.h @@ -31,35 +31,15 @@ E void kill_user(const Anope::string &source, User *user, const Anope::string &r E bool bad_password(User *u); E void common_unban(ChannelInfo *ci, User *u, bool full = false); -E BotInfo *BotServ; -E BotInfo *ChanServ; -E BotInfo *Global; -E BotInfo *HostServ; -E BotInfo *MemoServ; -E BotInfo *NickServ; -E BotInfo *OperServ; - /**** botserv.c ****/ -E void get_botserv_stats(long *nrec, long *memuse); -E void bs_init(); -E void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf); E BotInfo *findbot(const Anope::string &nick); -/** Finds a pseudoclient, given a UID. Useful for TS6 protocol modules. - * @param uid The UID to search for - * @return The pseudoclient structure, or NULL if one could not be found - */ -E Anope::string normalizeBuffer(const Anope::string &); - -E void check_ban(ChannelInfo *ci, User *u, int ttbtype); -E void bot_kick(ChannelInfo *ci, User *u, const char *message, ...); E void bot_raw_ban(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason); E void bot_raw_kick(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason); /**** channels.c ****/ -E void get_channel_stats(long *nrec, long *memuse); E Channel *findchan(const Anope::string &chan); @@ -75,27 +55,14 @@ E void MassChannelModes(BotInfo *bi, const Anope::string &modes); E void chan_set_correct_modes(User *user, Channel *c, int give_modes); -inline BotInfo *whosends(ChannelInfo *ci) -{ - if (!ci || !ci->bi || !ci->c || !ci->botflags.HasFlag(BS_SYMBIOSIS) || !ci->c->FindUser(ci->bi)) - return ChanServ ? ChanServ : NickServ; - return ci->bi; -} - /**** chanserv.c ****/ E LevelInfo levelinfo[]; -E void get_chanserv_stats(long *nrec, long *memuse); E void reset_levels(ChannelInfo *ci); -E void cs_init(); -E void expire_chans(); -E void cs_remove_nick(NickCore *nc); E void check_modes(Channel *c); -E int check_valid_admin(User *user, Channel *chan, int servermode); -E int check_valid_op(User *user, Channel *chan, int servermode); E ChannelInfo *cs_findchan(const Anope::string &chan); E int check_access(User *user, ChannelInfo *ci, int what); @@ -111,17 +78,11 @@ E Anope::string get_mlock_modes(ChannelInfo *ci, int complete); E ConfigurationFile services_conf; E ServerConfig *Config; -/* hostserv.c */ -E void do_on_id(User *u); -E void HostServSyncVhosts(NickAlias *na); - /**** encrypt.c ****/ E int enc_encrypt(const Anope::string &src, Anope::string &dest); E int enc_decrypt(const Anope::string &src, Anope::string &dest); /**** hostserv.c ****/ -E void get_hostserv_stats(long *nrec, long *memuse); -E void hostserv_init(); /**** init.c ****/ @@ -146,9 +107,6 @@ E void PopLanguage(); E const char *anope_gettext(const char *string); E void SyntaxError(CommandSource &source, const Anope::string &command, const Anope::string &message); -/*** logger.cpp ***/ -E void InitLogChannels(ServerConfig *); - /**** main.c ****/ E Anope::string services_dir; @@ -169,7 +127,6 @@ E time_t start_time; E ConnectionSocket *UplinkSock; E void save_databases(); -E void expire_all(); E void sighandler(int signum); E void do_restart_services(); @@ -184,14 +141,6 @@ class CoreExport UplinkSocket : public ConnectionSocket bool Read(const Anope::string &buf); }; -/**** memoserv.c ****/ - -E void ms_init(); -E void rsend_notify(CommandSource &source, Memo *m, const Anope::string &chan); -E void check_memos(User *u); -E MemoInfo *getmemoinfo(const Anope::string &name, bool &ischan, bool &isforbid); -E void memo_send(CommandSource &source, const Anope::string &name, const Anope::string &text, int z); - /**** messages.cpp ****/ E void init_core_messages(); @@ -225,12 +174,6 @@ E bool OnError(const Anope::string &, const std::vector &); E bool IsFile(const Anope::string &filename); E int toupper(char); E int tolower(char); -#ifndef HAVE_STRLCPY -E size_t strlcpy(char *, const char *, size_t); -#endif -#ifndef HAVE_STRLCAT -E size_t strlcat(char *, const char *, size_t); -#endif E time_t dotime(const Anope::string &s); E Anope::string duration(time_t seconds); @@ -260,6 +203,7 @@ E std::vector BuildStringVector(const Anope::string &, char = ' ' E bool str_is_wildcard(const Anope::string &str); E bool str_is_pure_wildcard(const Anope::string &str); +E Anope::string normalizeBuffer(const Anope::string &); /**** modes.cpp ****/ /* Number of generic modes we support */ @@ -269,15 +213,9 @@ E void SetDefaultMLock(ServerConfig *config); /**** nickserv.c ****/ -E void get_aliases_stats(long &count, long &mem); -E void get_core_stats(long &count, long &mem); E void change_core_display(NickCore *nc); E void change_core_display(NickCore *nc, const Anope::string &newdisplay); -E int do_setmodes(User *u); -E void ns_init(); -E int validate_user(User *u); -E void expire_nicks(); E NickAlias *findnick(const Anope::string &nick); E NickCore *findcore(const Anope::string &nick); E bool is_on_access(const User *u, const NickCore *nc); @@ -292,24 +230,6 @@ E void send_cmd(const Anope::string &source, const char *fmt, ...) FORMAT(printf E void notice_server(const Anope::string &source, const Server *s, const char *fmt, ...) FORMAT(printf, 3, 4); -/**** sessions.c ****/ - -E std::vector exceptions; - -E void get_session_stats(long &count, long &mem); -E void get_exception_stats(long &count, long &mem); - -E void add_session(User *u); -E void del_session(User *u); - -E void expire_exceptions(); - -E Session *findsession(const Anope::string &host); - -E Exception *find_host_exception(const Anope::string &host); -E Exception *find_hostip_exception(const Anope::string &host, const Anope::string &hostip); -E int exception_add(User *u, const Anope::string &mask, unsigned limit, const Anope::string &reason, const Anope::string &who, time_t expires); - /**** sockets.cpp ****/ E SocketEngineBase *SocketEngine; @@ -323,8 +243,6 @@ E int32 opcnt; E uint32 maxusercnt, usercnt; E time_t maxusertime; -E void get_user_stats(long &count, long &mem); - E User *finduser(const Anope::string &nick); E User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid, const Anope::string &modes); @@ -342,9 +260,4 @@ E Anope::string create_mask(User *u); E void b64_encode(const Anope::string &src, Anope::string &target); E void b64_decode(const Anope::string &src, Anope::string &target); -#ifdef _WIN32 -E Anope::string GetWindowsVersion(); -E bool SupportedWindowsVersion(); -#endif - #endif /* EXTERN_H */ diff --git a/include/logger.h b/include/logger.h index 6d134c227..cb3d00d6a 100644 --- a/include/logger.h +++ b/include/logger.h @@ -39,7 +39,7 @@ class CoreExport Log std::stringstream buf; - Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = Global); + Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = NULL); /* LOG_COMMAND/OVERRIDE/ADMIN */ Log(LogType type, User *u, Command *c, ChannelInfo *ci = NULL); diff --git a/include/modules.h b/include/modules.h index 51a550316..badb59616 100644 --- a/include/modules.h +++ b/include/modules.h @@ -314,9 +314,8 @@ class CoreExport Module : public Extensible virtual void OnUserKicked(Channel *c, User *target, const Anope::string &source, const Anope::string &kickmsg) { } /** Called when Services' configuration has been loaded. - * @param startup True if Services is starting for the first time, false otherwise. */ - virtual void OnReload(bool startup) {} + virtual void OnReload() { } /** Called before a bot is assigned to a channel. * @param sender The user assigning the bot @@ -333,20 +332,11 @@ class CoreExport Module : public Extensible */ virtual EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) { return EVENT_CONTINUE; } - /** Called after a user has been introduced, but before any type - * of checking has been done (akills, defcon, s*lines, etc) - * return EVENT_STOP here to allow the user to get by untouched, - * or kill them then return EVENT_STOP to tell Anope the user no - * longer exists - * @param u The user - * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to stop processing - */ - virtual EventReturn OnPreUserConnect(User *u) { return EVENT_CONTINUE; } - /** Called when a new user connects to the network. * @param u The connecting user. + * @param exempt set to true/is true if the user should be excepted from bans etc */ - virtual void OnUserConnect(User *u) { } + virtual void OnUserConnect(dynamic_reference &u, bool &exempt) { } /** Called when a new server connects to the network. * @param s The server that has connected to the network @@ -523,16 +513,6 @@ class CoreExport Module : public Extensible */ virtual void OnServerDisconnect() { } - /** Called before the database expire routines are called - * Note: Code that is in seperate expiry routines should just be done - * when we save the DB, theres no need to have both - */ - virtual void OnPreDatabaseExpire() { } - - /** Called when the database expire routines are called - */ - virtual void OnDatabaseExpire() { } - /** Called when the flatfile dbs are being written * @param Write A callback to the function used to insert a line into the database */ @@ -639,11 +619,10 @@ class CoreExport Module : public Extensible virtual void OnDefconLevel(int level) { } /** Called before an akill is added - * @param u The user adding the akill * @param ak The akill * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnAddAkill(User *u, XLine *ak) { return EVENT_CONTINUE; } + virtual EventReturn OnAddAkill(XLine *ak) { return EVENT_CONTINUE; } /** Called before an akill is deleted * @param u The user removing the akill @@ -652,11 +631,10 @@ class CoreExport Module : public Extensible virtual void OnDelAkill(User *u, XLine *ak) { } /** Called after an exception has been added - * @param u The user who added it * @param ex The exception * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnExceptionAdd(User *u, Exception *ex) { return EVENT_CONTINUE; } + virtual EventReturn OnExceptionAdd(Exception *ex) { return EVENT_CONTINUE; } /** Called before an exception is deleted * @param u The user who is deleting it @@ -665,12 +643,11 @@ class CoreExport Module : public Extensible virtual void OnExceptionDel(User *u, Exception *ex) { } /** Called before a XLine is added - * @param u The user adding the XLine * @param sx The XLine * @param Type The type of XLine this is * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnAddXLine(User *u, XLine *x, XLineType Type) { return EVENT_CONTINUE; } + virtual EventReturn OnAddXLine(XLine *x, XLineType Type) { return EVENT_CONTINUE; } /** Called before a XLine is deleted * @param u The user deleting the XLine @@ -932,12 +909,22 @@ class CoreExport Module : public Extensible */ virtual EventReturn OnCheckAuthentication(User *u, Command *c, const std::vector ¶ms, const Anope::string &account, const Anope::string &password) { return EVENT_CONTINUE; } + /** Called when a user does /ns update + * @param u The user + */ + virtual void OnNickUpdate(User *u) { } + /** Called when we get informed about a users SSL fingerprint * when we call this, the fingerprint should already be stored in the user struct * @param u pointer to the user */ virtual void OnFingerprint(User *u) { } + /** Called when a user becomes (un)away + * @param message The message, is .empty() if unaway + */ + virtual void OnUserAway(User *u, const Anope::string &message) { } + /** Called when a vhost is deleted * @param na The nickalias of the vhost */ @@ -949,18 +936,12 @@ class CoreExport Module : public Extensible virtual void OnSetVhost(NickAlias *na) { } /** Called when a memo is sent - * @param u The user sending the memo - * @param nc The nickcore of who the memo was sent to - * @param m The memo - */ - virtual void OnMemoSend(User *u, NickCore *nc, Memo *m) { } - - /** Called when a memo is sent - * @param u The user sending the memo - * @param ci The channel the memo was sent to + * @param source The source of the memo + * @param target The target of the memo + * @param mi Memo info for target * @param m The memo */ - virtual void OnMemoSend(User *u, ChannelInfo *ci, Memo *m) { } + virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) { } /** Called when a memo is deleted * @param nc The nickcore of the memo being deleted @@ -1064,10 +1045,8 @@ class CoreExport Module : public Extensible * @param u The source of the message * @param ci The channel * @param msg The message - * @param Allow set to false to make the flood kickers halt - * @return MOD_STOP to stop processing completely */ - virtual EventReturn OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg, bool &Allow) { return EVENT_CONTINUE; } + virtual void OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg) { } /** Called when any object is destroyed * @param b The object @@ -1087,6 +1066,7 @@ enum Implementation I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess, I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert, I_OnNickInfo, I_OnFindNick, I_OnFindCore, I_OnCheckAuthentication, + I_OnNickUpdate, /* ChanServ */ I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd, I_OnAccessChange, @@ -1105,8 +1085,8 @@ enum Implementation I_OnMemoSend, I_OnMemoDel, /* Users */ - I_OnPreUserConnect, I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnUserLogoff, I_OnPreJoinChannel, - I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel, I_OnFingerprint, + I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnUserLogoff, I_OnPreJoinChannel, + I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel, I_OnFingerprint, I_OnUserAway, /* OperServ */ I_OnDefconLevel, I_OnAddAkill, I_OnDelAkill, I_OnExceptionAdd, I_OnExceptionDel, @@ -1114,7 +1094,6 @@ enum Implementation /* Database */ I_OnPostLoadDatabases, I_OnSaveDatabase, I_OnLoadDatabase, - I_OnDatabaseExpire, I_OnDatabaseWrite, I_OnDatabaseRead, I_OnDatabaseReadMetadata, I_OnDatabaseWriteMetadata, /* Modules */ @@ -1122,7 +1101,7 @@ enum Implementation /* Other */ I_OnReload, I_OnPreServerConnect, I_OnNewServer, I_OnServerConnect, I_OnPreUplinkSync, I_OnServerDisconnect, I_OnPreCommandRun, - I_OnPreCommand, I_OnPostCommand, I_OnPreDatabaseExpire, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal, + I_OnPreCommand, I_OnPostCommand, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal, I_OnServerQuit, I_OnTopicUpdated, I_OnEncrypt, I_OnDecrypt, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, @@ -1293,10 +1272,6 @@ class service_reference : public dynamic_reference { } - virtual ~service_reference() - { - } - operator bool() { if (this->invalid) diff --git a/include/oper.h b/include/oper.h new file mode 100644 index 000000000..cebd079ca --- /dev/null +++ b/include/oper.h @@ -0,0 +1,231 @@ +/* OperServ support + * + * (C) 2008-2011 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#ifndef OPER_H +#define OPER_H + +extern CoreExport std::vector News; + +class XLineManager; +extern CoreExport XLineManager *SGLine; +extern CoreExport XLineManager *SZLine; +extern CoreExport XLineManager *SQLine; +extern CoreExport XLineManager *SNLine; + +enum XLineType +{ + X_SNLINE, + X_SQLINE, + X_SZLINE +}; + +class CoreExport XLine +{ + public: + Anope::string Mask; + Anope::string By; + time_t Created; + time_t Expires; + Anope::string Reason; + + XLine(const Anope::string &mask, const Anope::string &reason = ""); + + XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason); + + Anope::string GetNick() const; + Anope::string GetUser() const; + Anope::string GetHost() const; +}; + +class CoreExport XLineManager +{ + private: + /* List of XLine managers we check users against in XLineManager::CheckAll */ + static std::list XLineManagers; + + protected: + /* List of XLines in this XLineManager */ + std::vector XLines; + public: + /** Constructor + */ + XLineManager(); + + /** Destructor + */ + virtual ~XLineManager(); + + /** Register a XLineManager, places it in XLineManagers for use in XLineManager::CheckAll + * It is important XLineManagers are registered in the proper order. Eg, if you had one akilling + * clients and one handing them free olines, you would want the akilling one first. This way if a client + * matches an entry on both of the XLineManagers, they would be akilled. + * @param xlm THe XLineManager + */ + static void RegisterXLineManager(XLineManager *xlm); + + /** Unregister a XLineManager + * @param xlm The XLineManager + */ + static void UnregisterXLineManager(XLineManager *xlm); + + /** Check a user against all known XLineManagers + * Wparam u The user + * @return A pair of the XLineManager the user was found in and the XLine they matched, both may be NULL for no match + */ + static std::pair CheckAll(User *u); + + /** Get the number of XLines in this XLineManager + * @return The number of XLines + */ + size_t GetCount() const; + + /** Get the XLine vector + * @return The vector + */ + const std::vector &GetList() const; + + /** Add an entry to this XLineManager + * @param x The entry + */ + void AddXLine(XLine *x); + + /** Delete an entry from this XLineManager + * @param x The entry + * @return true if the entry was found and deleted, else false + */ + bool DelXLine(XLine *x); + + /** Gets an entry by index + * @param index The index + * @return The XLine, or NULL if the index is out of bounds + */ + XLine *GetEntry(unsigned index); + + /** Clear the XLine vector + */ + void Clear(); + + /** Add an entry to this XLine Manager + * @param mask The mask of the XLine + * @param creator The creator of the XLine + * @param expires When this should expire + * @param reaosn The reason + * @return A pointer to the XLine + */ + virtual XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason); + + private: + /** Delete an XLine, eg, remove it from the IRCd. + * @param x The xline + */ + virtual void Del(XLine *x); + + public: + /** Checks if a mask can/should be added to the XLineManager + * @param mask The mask + * @param expires When the mask would expire + * @return A pair of int and XLine*. + * 1 - Mask already exists + * 2 - Mask already exists, but the expiry time was changed + * 3 - Mask is already covered by another mask + * In each case the XLine it matches/is covered by is returned in XLine* + */ + std::pair CanAdd(const Anope::string &mask, time_t expires); + + /** Checks if this list has an entry + * @param mask The mask + * @return The XLine the user matches, or NULL + */ + XLine *HasEntry(const Anope::string &mask); + + /** Check a user against all of the xlines in this XLineManager + * @param u The user + * @return The xline the user marches, if any. Also calls OnMatch() + */ + virtual XLine *Check(User *u); + + /** Called when a user matches a xline in this XLineManager + * @param u The user + * @param x The XLine they match + */ + virtual void OnMatch(User *u, XLine *x); + + /** Called when an XLine expires + * @param x The xline + */ + virtual void OnExpire(XLine *x); + + /** Called to send an XLine to the IRCd + * @param u The user, if we know it + * @param x The xline + */ + virtual void Send(User *u, XLine *x) = 0; +}; + +/* This is for AKILLS */ +class SGLineManager : public XLineManager +{ + public: + XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason); + + void Del(XLine *x); + + void OnMatch(User *u, XLine *x); + + void OnExpire(XLine *x); + + void Send(User *u, XLine *x); +}; + +class SNLineManager : public XLineManager +{ + public: + XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason); + + void Del(XLine *x); + + void OnMatch(User *u, XLine *x); + + void OnExpire(XLine *x); + + void Send(User *u, XLine *x); + + XLine *Check(User *u); +}; + +class SQLineManager : public XLineManager +{ + public: + XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason); + + void Del(XLine *x); + + void OnMatch(User *u, XLine *x); + + void OnExpire(XLine *x); + + void Send(User *u, XLine *x); + + static bool Check(Channel *c); +}; + +class SZLineManager : public XLineManager +{ + public: + XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason); + + void Del(XLine *x); + + void OnMatch(User *u, XLine *x); + + void OnExpire(XLine *x); + + void Send(User *u, XLine *x); +}; + +#endif // OPER_H diff --git a/include/operserv.h b/include/operserv.h deleted file mode 100644 index f039b6107..000000000 --- a/include/operserv.h +++ /dev/null @@ -1,250 +0,0 @@ -/* OperServ support - * - * (C) 2008-2011 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#ifndef OPERSERV_H -#define OPERSERV_H - -extern CoreExport std::vector News; -extern CoreExport std::vector > DefCon; -extern CoreExport bool DefConModesSet; -extern CoreExport Flags DefConModesOn; -extern CoreExport Flags DefConModesOff; -extern CoreExport std::map DefConModesOnParams; - -class XLineManager; -extern CoreExport XLineManager *SGLine; -extern CoreExport XLineManager *SZLine; -extern CoreExport XLineManager *SQLine; -extern CoreExport XLineManager *SNLine; - -extern CoreExport bool SetDefConParam(ChannelModeName, const Anope::string &); -extern CoreExport bool GetDefConParam(ChannelModeName, Anope::string &); -extern CoreExport void UnsetDefConParam(ChannelModeName); -extern CoreExport bool CheckDefCon(DefconLevel Level); -extern CoreExport bool CheckDefCon(int level, DefconLevel Level); -extern CoreExport void AddDefCon(int level, DefconLevel Level); -extern CoreExport void DelDefCon(int level, DefconLevel Level); - -extern CoreExport void os_init(); - -extern CoreExport void oper_global(const Anope::string &nick, const char *fmt, ...); -extern CoreExport void server_global(const Server *s, const Anope::string &message); - -enum XLineType -{ - X_SNLINE, - X_SQLINE, - X_SZLINE -}; - -class CoreExport XLine -{ - public: - Anope::string Mask; - Anope::string By; - time_t Created; - time_t Expires; - Anope::string Reason; - - XLine(const Anope::string &mask, const Anope::string &reason = ""); - - XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason); - - Anope::string GetNick() const; - Anope::string GetUser() const; - Anope::string GetHost() const; -}; - -class CoreExport XLineManager -{ - private: - /* List of XLine managers we check users against in XLineManager::CheckAll */ - static std::list XLineManagers; - - protected: - /* List of XLines in this XLineManager */ - std::vector XLines; - public: - /** Constructor - */ - XLineManager(); - - /** Destructor - */ - virtual ~XLineManager(); - - /** Register a XLineManager, places it in XLineManagers for use in XLineManager::CheckAll - * It is important XLineManagers are registered in the proper order. Eg, if you had one akilling - * clients and one handing them free olines, you would want the akilling one first. This way if a client - * matches an entry on both of the XLineManagers, they would be akilled. - * @param xlm THe XLineManager - */ - static void RegisterXLineManager(XLineManager *xlm); - - /** Unregister a XLineManager - * @param xlm The XLineManager - */ - static void UnregisterXLineManager(XLineManager *xlm); - - /** Check a user against all known XLineManagers - * Wparam u The user - * @return A pair of the XLineManager the user was found in and the XLine they matched, both may be NULL for no match - */ - static std::pair CheckAll