#include "message.h"
#include "mode.h"
#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
#ifdef GCC3
#define nspace __gnu_cxx
using namespace std;
extern int MODCOUNT;
-extern vector<Module*> modules;
-extern vector<ircd_module*> factory;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
extern int LogLevel;
extern char ServerName[MAXBUF];
namespace nspace
{
- template<> struct nspace::hash<in_addr>
- {
- size_t operator()(const struct in_addr &a) const
- {
- size_t q;
- memcpy(&q,&a,sizeof(size_t));
- return q;
- }
- };
-
- template<> struct nspace::hash<string>
- {
- size_t operator()(const string &s) const
- {
- char a[MAXBUF];
- static struct hash<const char *> strhash;
- strlcpy(a,s.c_str(),MAXBUF);
- strlower(a);
- return strhash(a);
- }
- };
-}
+#ifdef GCC34
+ template<> struct hash<in_addr>
+#else
+ template<> struct nspace::hash<in_addr>
+#endif
+ {
+ size_t operator()(const struct in_addr &a) const
+ {
+ size_t q;
+ memcpy(&q,&a,sizeof(size_t));
+ return q;
+ }
+ };
+#ifdef GCC34
+ template<> struct hash<string>
+#else
+ template<> struct nspace::hash<string>
+#endif
+ {
+ size_t operator()(const string &s) const
+ {
+ char a[MAXBUF];
+ static struct hash<const char *> strhash;
+ strlcpy(a,s.c_str(),MAXBUF);
+ strlower(a);
+ return strhash(a);
+ }
+ };
+}
struct StrHashComp
{
WriteServ(user->fd,"301 %s %s :%s",user->nick, dest->nick, dest->awaymsg);
}
- if (strchr(dest->modes,'o'))
+ if ((strchr(dest->modes,'o')) && (strcmp(dest->oper,"")))
{
WriteServ(user->fd,"313 %s %s :is %s %s on %s",user->nick, dest->nick,
(strchr("aeiou",dest->oper[0]) ? "an" : "a"),dest->oper, Network);
}
if (Ptr)
{
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, Ptr->name);
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick , parameters[0]);
}
else
{
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, user->nick);
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
}
return;
}
WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, Ptr->name, i->second->ident, i->second->dhost, i->second->server, i->second->nick, tmp, i->second->fullname);
}
}
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, Ptr->name);
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
}
else
{
}
}
}
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, user->nick);
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
return;
}
}
void handle_rehash(char **parameters, int pcnt, userrec *user)
{
WriteServ(user->fd,"382 %s %s :Rehashing",user->nick,CleanFilename(CONFIG_FILE));
- ReadConfig();
+ ReadConfig(false,user);
FOREACH_MOD OnRehash();
WriteOpers("%s is rehashing config file %s",user->nick,CleanFilename(CONFIG_FILE));
}
char TypeName[MAXBUF];
char Hostname[MAXBUF];
int i,j;
+ bool found = false;
+ bool fail2 = false;
+ char global[MAXBUF];
for (int i = 0; i < ConfValueEnum("oper",&config_f); i++)
{
ConfValue("oper","name",i,LoginName,&config_f);
ConfValue("oper","password",i,Password,&config_f);
+ ConfValue("oper","type",i,OperType,&config_f);
if ((!strcmp(LoginName,parameters[0])) && (!strcmp(Password,parameters[1])))
{
- /* correct oper credentials */
- ConfValue("oper","type",i,OperType,&config_f);
- WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType);
- WriteServ(user->fd,"381 %s :You are now an IRC operator of type %s",user->nick,OperType);
- WriteServ(user->fd,"MODE %s :+o",user->nick);
- char global[MAXBUF];
- snprintf(global,MAXBUF,"M %s +o",user->nick);
- NetSendToAll(global);
+ fail2 = true;
for (j =0; j < ConfValueEnum("type",&config_f); j++)
{
ConfValue("type","name",j,TypeName,&config_f);
+
if (!strcmp(TypeName,OperType))
{
/* found this oper's opertype */
ConfValue("type","host",j,Hostname,&config_f);
ChangeDisplayedHost(user,Hostname);
strlcpy(user->oper,TypeName,NICKMAX);
+ found = true;
+ fail2 = false;
+ break;
}
}
- if (!strchr(user->modes,'o'))
- {
- strcat(user->modes,"o");
- }
+ }
+ if (found)
+ break;
+ }
+ if (found)
+ {
+ /* correct oper credentials */
+ WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType);
+ WriteServ(user->fd,"381 %s :You are now an IRC operator of type %s",user->nick,OperType);
+ if (!strchr(user->modes,'o'))
+ {
+ strcat(user->modes,"o");
+ WriteServ(user->fd,"MODE %s :+o",user->nick);
+ snprintf(global,MAXBUF,"M %s +o",user->nick);
+ NetSendToAll(global);
FOREACH_MOD OnOper(user);
- return;
}
}
- /* no such oper */
- WriteServ(user->fd,"491 %s :Invalid oper credentials",user->nick);
- WriteOpers("*** WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
+ else
+ {
+ if (!fail2)
+ {
+ WriteServ(user->fd,"491 %s :Invalid oper credentials",user->nick);
+ WriteOpers("*** WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
+ }
+ else
+ {
+ WriteServ(user->fd,"491 %s :Your oper block does not have a valid opertype associated with it",user->nick);
+ WriteOpers("*** CONFIGURATION ERROR! Oper block mismatch for OperType %s",OperType);
+ }
+ }
+ return;
}
void handle_nick(char **parameters, int pcnt, userrec *user)
log(DEBUG,"new nick set: %s",user->nick);
if (user->registered < 3)
+ {
user->registered = (user->registered | 2);
+ // dont attempt to look up the dns until they pick a nick... because otherwise their pointer WILL change
+ // and unless we're lucky we'll get a duff one later on.
+ user->dns_done = (!lookup_dns(user->nick));
+ if (user->dns_done)
+ log(DEBUG,"Aborting dns lookup of %s because dns server experienced a failure.",user->nick);
+ }
if (user->registered == 3)
{
/* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
snprintf(buffer,MAXBUF,"+ %s %s %d %d",tcp_host,ipaddr,port,authcookie);
NetSendToAllExcept(tcp_host,buffer);
break;
+ case '/':
+ WriteOpers("Server %s is IRCServices-based server (assumes-SVSMODE) - Nickname Services: %s",tcp_host,params);
+ strlcpy(source->nickserv,params,NICKMAX);
+ break;
// F <TS>
// end netburst with no mesh creation
case 'f':
}
if (!strcmp(command,"SVSMODE"))
{
- snprintf(udp_msg,MAXBUF,"M %s",data);
+ snprintf(udp_msg,MAXBUF,"m %s %s",source,data);
log(DEBUG,"Rewrote SVSMODE from services to: '%s'",udp_msg);
token = udp_msg[0];
}
if (!strcmp(command,"SVS2MODE"))
{
- snprintf(udp_msg,MAXBUF,"M %s",data);
- log(DEBUG,"Rewrote SVSMODE from services to: '%s'",udp_msg);
+ snprintf(udp_msg,MAXBUF,"m %s %s",source,data);
+ log(DEBUG,"Rewrote SVS2MODE from services to: '%s'",udp_msg);
token = udp_msg[0];
}
// todo: this wont work without u:lines
ConfValue("link","sendpass",i,Link_SendPass,&config_f);
log(DEBUG,"(%d) Comparing against name='%s', ipaddr='%s', port='%s', recvpass='%s'",i,Link_ServerName,Link_IPAddr,Link_Port,Link_Pass);
LinkPort = atoi(Link_Port);
- if (!strcasecmp(Link_ServerName,servername))
+ if ((!strcasecmp(Link_ServerName,servername)) && (!strcmp(Link_Pass,password)))
{
// we have a matching link line -
// send a 'diminutive' server message back...
ConfValue("link","sendpass",i,Link_SendPass,&config_f);
log(DEBUG,"(%d) Comparing against name='%s', ipaddr='%s', port='%s', recvpass='%s'",i,Link_ServerName,Link_IPAddr,Link_Port,Link_Pass);
LinkPort = atoi(Link_Port);
- if (!strcasecmp(Link_ServerName,servername))
+ if ((!strcasecmp(Link_ServerName,servername)) && (!strcmp(Link_Pass,password)))
{
// matching link at this end too, we're all done!
// at this point we must begin key exchange and insert this