diff --git a/.gitattributes b/.gitattributes index 8d58d9be..09878b46 100644 --- a/.gitattributes +++ b/.gitattributes @@ -437,8 +437,6 @@ src/transfer.c -text src/transfer.h -text src/users.c eol=lf src/users.h eol=lf -src/win32/getopt.c -text -src/win32/getopt.h -text src/win32/neostats.aps -text src/win32/neostats.bmp -text src/win32/neostats.rc -text diff --git a/ChangeLog b/ChangeLog index 53f97f28..2c5262d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,27 @@ Anything we add/remove/fix/change is in here (even our rants) Fish (F), Mark (M) =============================================================================== * NeoStats * Version 3.0.genesis + - makeconf updated to reflect changes and some tidy ups (M) + - Depreciate some useless config items from neostats.cfg: + STATSERV_NETNAME - we do not use this and overwrite it when we get netinfo + NEOSTAT_HOST - Default to servername as host and allow online config + NEOSTAT_USER - Default to Neo and allow online config + This makes configuration easier (M) + - Extend BotInfo structure and simplify init_bot function to use extended + structure. (M) + - Add synched field to Module structure so modules can tell when they are + online without having to maintain local variables and can be taken offline + easily by the core. (M) + - Add automatic bot_info SET options. (M) + - Core command processor now uses a hash for SET options to speed up option + processing. (M) + - Add feature check to load modules so that modules will not load if the + selected protocol does not support a required feature. e.g. HostServ + required SVSHOST support. (M) + - Update auth modules so that they just calculate a level and leave the core + to decide whether it overrides a current level. (M) + - Reg nick support might not use mode +r so calculate the correct char when + loading IRCd and use variable for checking it. (M) - Optimise UserLevel processing so after a user level is calculated it is then a lookup rather than needing to recalculate every time. (M) - Send STATS u request to incoming servers so we can store uptime info for diff --git a/makeconf b/makeconf index c64e190a..7154c439 100755 --- a/makeconf +++ b/makeconf @@ -1,21 +1,17 @@ #!/bin/sh -# makeconf v 1.0 2001/02/11 15:21:32 Shmad +# makeconf $Id TIME=`date +"%H:%M:%S %Z"` DATE=`date +"%a, %b %e %Y"` STATSCONF="neostats.cfg" SERVNAME="stats.somenet.net" SERVNUMERIC="1" -COMMENT="NeoStats 3.0 IRC Statistical and Alternative Services" +COMMENT="NeoStats 3.0 IRC Services" LINKPORT="6667" LINKSERVER="127.0.0.1" LINKPASS="LinkPass" -NETNAME="SomeNet-IRC" -NEOHOST="NeoStats.Net" -NEOUSER="Neo" NEOCHAN="#services" NEOCONN="10" -NEOREC="10" BINDIP="127.0.0.1" LOGFNAMEFORMAT="-%m-%d" SETSERVERTIMES="24" @@ -186,30 +182,6 @@ if [ ! -z "$cc" ]; then COMMENT="$cc" fi -echo " " -echo "Network name? (refer to your networks file. ie: CyberChat-IRC)" -echo $n " [$NETNAME] -> $c" -read cc -if [ ! -z "$cc" ]; then - NETNAME="$cc" -fi - -echo " " -echo "The host NeoStats is connecting from, most people use services.theirnetwork.net" -echo $n " [$NEOHOST] -> $c" -read cc -if [ ! -z "$cc" ]; then - NEOHOST="$cc" -fi - -echo " " -echo "NeoStats User? (This is the part before @yourhost.net)" -echo $n " [$NEOUSER] -> $c" -read cc -if [ ! -z "$cc" ]; then - NEOUSER="$cc" -fi - echo " " echo "What channel should NeoStats join on IRC?" echo $n " [$NEOCHAN] -> $c" @@ -327,41 +299,10 @@ SERVER_INFOLINE "$COMMENT" SERVER_NUMERIC "$SERVNUMERIC" -# STATSERV_NETNAME [REQUIRED] -# Your network name, if unknown refer to your network file. Does not -# apply to all IRCDs e.g. -# -# STATSERV_NETNAME neostats -# -# For irc.neostats.net - -STATSERV_NETNAME $NETNAME - ########################## # NeoStats Configuration # ########################## -# NEOSTAT_HOST [REQUIRED] -# Specifies the Hostname that NeoStats comes from. Some people like to -# make it the same as the Services host (e.g., services.neostats.net) -# or one just for NeoStats (e.g., stats.neostats.net) e.g. -# -# NEOSTATS_HOST stats.neostats.net -# -# The bot will appear as NeoStats!user@stats.neostats.net - -NEOSTAT_HOST $NEOHOST - -# NEOSTAT_USER [REQUIRED] -# Specifies the User/ident of the NeoStats Bot (the part before the -# @host) e.g. -# -# NEOSTATS_USER neo -# -# The bot will apear as NeoStats!neo@Host - -NEOSTAT_USER $NEOUSER - # SERVICES_CHAN # [REQUIRED] # Specify the channel that all bots on NeoStats # will automatically join, and echo out any diff --git a/src/auth.c b/src/auth.c index 2fea1b55..bb813919 100644 --- a/src/auth.c +++ b/src/auth.c @@ -26,58 +26,50 @@ #include "dl.h" #include "services.h" -typedef int (*getauthfunc) (User *, int curlvl); +typedef int (*userauthfunc) (User *u); typedef int (*listauthfunc) (User * u); typedef struct AuthModule { Module* module_ptr; - getauthfunc getauth; + userauthfunc userauth; listauthfunc listauth; }AuthModule; extern void *load_auth_mods[NUM_MODULES]; static AuthModule AuthModList[NUM_MODULES]; - static int AuthModuleCount = 0; -/* Do dl lookups in advance to speed up UserLevel processing - * - */ - int UserAuth(User * u) { - int tmplvl = 0; + int newauthlvl = 0; int authlvl = 0; int i; - if(IsServiceRoot(u)) { - return(NS_ULEVEL_ROOT); - } for(i = 0; i < AuthModuleCount; i ++) { - if (AuthModList[i].getauth) { - authlvl = AuthModList[i].getauth (u, tmplvl); - /* if authlvl is greater than tmplvl, then auth is authoritive */ - if (authlvl > tmplvl) { - tmplvl = authlvl; + if (AuthModList[i].userauth) { + authlvl = AuthModList[i].userauth (u); + /* if authlvl is greater than newauthlvl, then auth is authoritive */ + if (authlvl > newauthlvl) { + newauthlvl = authlvl; } } } - return tmplvl; + return newauthlvl; } static void load_auth_module(const char* name) { - AuthModule* newauth; + AuthModule* auth_module; - newauth = &AuthModList[AuthModuleCount]; - newauth->module_ptr = load_module (name, NULL); - if(newauth->module_ptr) { - newauth->getauth = - ns_dlsym (newauth->module_ptr->dl_handle, "ModAuthUser"); - newauth->listauth = - ns_dlsym (newauth->module_ptr->dl_handle, "ModAuthList"); + auth_module = &AuthModList[AuthModuleCount]; + auth_module->module_ptr = load_module (name, NULL); + if(auth_module->module_ptr) { + auth_module->userauth = + ns_dlsym (auth_module->module_ptr->dl_handle, "ModAuthUser"); + auth_module->listauth = + ns_dlsym (auth_module->module_ptr->dl_handle, "ModAuthList"); AuthModuleCount ++; } } diff --git a/src/bots.c b/src/bots.c index 13d595ea..a58eac8d 100755 --- a/src/bots.c +++ b/src/bots.c @@ -21,6 +21,11 @@ ** $Id$ */ +/* TODO: + * - find free nick for bots if NICK and ALTNICK are in use + * - CTCP handler + */ + #include "neostats.h" #include "modules.h" #include "ircd.h" @@ -345,7 +350,7 @@ new_bot (const char *bot_name) SET_SEGV_LOCATION(); dlog(DEBUG2, "new_bot: %s", bot_name); - botptr = smalloc (sizeof (Bot)); + botptr = scalloc (sizeof (Bot)); strlcpy (botptr->nick, bot_name, MAXNICK); bn = hnode_create (botptr); if (hash_isfull (bothash)) { @@ -372,8 +377,6 @@ add_ns_bot (Module* modptr, const char *nick) botptr = new_bot (nick); if(botptr) { botptr->moduleptr = modptr; - botptr->botcmds = NULL; - botptr->bot_settings = NULL; botptr->set_ulevel = NS_ULEVEL_ROOT; return botptr; } @@ -418,6 +421,8 @@ del_ns_bot (const char *bot_name) hash_delete (bothash, bn); botptr = hnode_get (bn); del_all_bot_cmds(botptr); + del_all_bot_settings(botptr); + del_bot_info_settings(botptr); hnode_destroy (bn); sfree (botptr); return NS_SUCCESS; @@ -482,7 +487,7 @@ list_bots (CmdParams* cmdparams) hash_scan_begin (&bs, bothash); while ((bn = hash_scan_next (&bs)) != NULL) { botptr = hnode_get (bn); - if(botptr->moduleptr == 0) { + if((botptr->flags & 0x80000000)) { prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "NeoStats"); prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "Bots: %s", botptr->nick); } else { @@ -521,13 +526,14 @@ int del_bots (Module *mod_ptr) * * @return NS_SUCCESS if suceeds, NS_FAILURE if not */ -Bot * init_bot (BotInfo* botinfo, const char* modes, unsigned int flags, bot_cmd *bot_cmd_list, bot_setting *bot_setting_list) +Bot *init_bot (BotInfo* botinfo) { Bot * botptr; User *u; long Umode; char* nick; Module* modptr; + char* host; SET_SEGV_LOCATION(); /* When we are using single bot mode, for example in client mode where we @@ -535,8 +541,8 @@ Bot * init_bot (BotInfo* botinfo, const char* modes, unsigned int flags, bot_cmd * commands and settings to it */ if(config.singlebotmode && ns_botptr) { - add_bot_cmd_list (ns_botptr, bot_cmd_list); - add_bot_settings (ns_botptr, bot_setting_list); + add_bot_cmd_list (ns_botptr, botinfo->bot_cmd_list); + add_bot_setting_list (ns_botptr, botinfo->bot_setting_list); return(ns_botptr); } modptr = GET_CUR_MODULE(); @@ -564,27 +570,28 @@ Bot * init_bot (BotInfo* botinfo, const char* modes, unsigned int flags, bot_cmd nlog (LOG_WARNING, "add_ns_bot failed for module %s bot %s", modptr->info->name, nick); return NULL; } - Umode = UmodeStringToMask(modes, 0); - signon_newbot (nick, botinfo->user, ((*botinfo->host)==0?me.name:botinfo->host), - botinfo->realname, modes, Umode); + host = ((*botinfo->host)==0?me.name:botinfo->host); + if(botinfo->flags&BOT_FLAG_SERVICEBOT) { + Umode = UmodeStringToMask(me.servicesumode, 0); + signon_newbot (nick, botinfo->user, host, botinfo->realname, me.servicesumode, Umode); + } else { + signon_newbot (nick, botinfo->user, host, botinfo->realname, "", 0); + } u = finduser (nick); /* set our link back to user struct for bot */ botptr->u = u; - /* Mark bot as services bot if needed */ - if ((Umode & service_umode_mask)) { - flags |= BOT_FLAG_SERVICEBOT; - } - if (HaveUmodeDeaf()&&flags&BOT_FLAG_DEAF) { + if (HaveUmodeDeaf()&&(botinfo->flags&BOT_FLAG_DEAF)) { sumode_cmd (nick, nick, UMODE_DEAF); } - botptr->flags = flags; + botptr->flags = botinfo->flags; SET_RUN_LEVEL(modptr); - if (bot_cmd_list) { - add_bot_cmd_list (botptr, bot_cmd_list); + if (botinfo->bot_cmd_list) { + add_bot_cmd_list (botptr, botinfo->bot_cmd_list); } - if (bot_setting_list) { - add_bot_settings (botptr, bot_setting_list); + if (botinfo->bot_setting_list) { + add_bot_setting_list (botptr, botinfo->bot_setting_list); } + add_bot_info_settings (botptr, botinfo); RESET_RUN_LEVEL(); return botptr; } diff --git a/src/commands.c b/src/commands.c index a9f7f6d9..a5081f49 100755 --- a/src/commands.c +++ b/src/commands.c @@ -21,10 +21,17 @@ ** $Id$ */ +/* TODO: + * - Finish off error processing + * - Make command logging optional + * - Make command alerts optional + */ + #ifndef WIN32 #include #endif #include "neostats.h" +#include "ns_help.h" #include "modules.h" #include "services.h" @@ -48,48 +55,6 @@ char * help_level_title[]= * by the core. A module can override these by defining them * in it's local bot command array. */ -static const char cmd_help_oneline[]="Online help"; -static const char *cmd_help_help[] = { - "Syntax: \2HELP [command]\2", - "", - "Provides help on the bot commands", - NULL -}; - -const char cmd_help_about_oneline[] = "About Module"; -const char *cmd_help_about[] = { - "Syntax: \2ABOUT\2", - "", - "Provides information about the module", - NULL -}; - -const char cmd_help_credits_oneline[] = "Display credits"; -const char *cmd_help_credits[] = { - "Syntax: \2CREDITS\2", - "", - "Show credits", - NULL -}; - -const char cmd_help_version_oneline[] = "Display version"; -const char *cmd_help_version[] = { - "Syntax: \2VERSION\2", - "", - "Show version information", - NULL -}; - -static const char *cmd_help_set[] = { - "Syntax: \2SET LIST\2", - " \2SET