mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Allow changing of an oper's host on oper up using <type:class> (give it a connect allow or deny line name) - implements bug #367
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7760 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
9130c31f74
commit
c61fac32bc
@ -845,7 +845,7 @@ class CoreExport userrec : public connection
|
||||
|
||||
/** Call this method to find the matching <connect> for a user, and to check them against it.
|
||||
*/
|
||||
void CheckClass();
|
||||
void CheckClass(const std::string &explicit_class = "");
|
||||
|
||||
/** Use this method to fully connect a user.
|
||||
* This will send the message of the day, check G/K/E lines, etc.
|
||||
@ -1056,9 +1056,10 @@ class CoreExport userrec : public connection
|
||||
void PurgeEmptyChannels();
|
||||
|
||||
/** Get the connect class which matches this user's host or IP address
|
||||
* @param explicit_name Set this string to tie the user to a specific class name
|
||||
* @return A reference to this user's connect class
|
||||
*/
|
||||
ConnectClass* GetClass();
|
||||
ConnectClass* GetClass(const std::string &explicit_name = "");
|
||||
|
||||
/** Show the message of the day to this user
|
||||
*/
|
||||
|
@ -46,6 +46,7 @@ CmdResult cmd_oper::Handle (const char** parameters, int pcnt, userrec *user)
|
||||
char OperType[MAXBUF];
|
||||
char TypeName[MAXBUF];
|
||||
char HostName[MAXBUF];
|
||||
char ClassName[MAXBUF];
|
||||
char TheHost[MAXBUF];
|
||||
char TheIP[MAXBUF];
|
||||
int j;
|
||||
@ -75,7 +76,8 @@ CmdResult cmd_oper::Handle (const char** parameters, int pcnt, userrec *user)
|
||||
type_invalid = true;
|
||||
for (j =0; j < ServerInstance->Config->ConfValueEnum(ServerInstance->Config->config_data, "type"); j++)
|
||||
{
|
||||
ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "type","name", j, TypeName, MAXBUF);
|
||||
ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "type", "name", j, TypeName, MAXBUF);
|
||||
ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "type", "class", j, ClassName, MAXBUF);
|
||||
|
||||
if (!strcmp(TypeName,OperType))
|
||||
{
|
||||
@ -90,6 +92,8 @@ CmdResult cmd_oper::Handle (const char** parameters, int pcnt, userrec *user)
|
||||
ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "type","host", j, HostName, MAXBUF);
|
||||
if (*HostName)
|
||||
user->ChangeDisplayedHost(HostName);
|
||||
if (*ClassName)
|
||||
user->CheckClass(ClassName);
|
||||
found = true;
|
||||
type_invalid = false;
|
||||
break;
|
||||
|
@ -413,7 +413,7 @@ bool DoConnect(ServerConfig* conf, const char* tag, char** entries, ValueList &v
|
||||
/* Find 'parent' and inherit a new class from it,
|
||||
* then overwrite any values that are set here
|
||||
*/
|
||||
for (std::vector<ConnectClass>::iterator item = conf->Classes.begin(); item != conf->Classes.end(); ++item)
|
||||
for (ClassVector::iterator item = conf->Classes.begin(); item != conf->Classes.end(); ++item)
|
||||
{
|
||||
if (item->GetName() == name)
|
||||
{
|
||||
|
@ -1011,9 +1011,9 @@ unsigned long userrec::LocalCloneCount()
|
||||
/*
|
||||
* Check class restrictions
|
||||
*/
|
||||
void userrec::CheckClass()
|
||||
void userrec::CheckClass(const std::string &explicit_class)
|
||||
{
|
||||
ConnectClass* a = this->GetClass();
|
||||
ConnectClass* a = this->GetClass(explicit_class);
|
||||
|
||||
if ((!a) || (a->GetType() == CC_DENY))
|
||||
{
|
||||
@ -1859,23 +1859,34 @@ void userrec::SplitChanList(userrec* dest, const std::string &cl)
|
||||
* then their ip will be taken as 'priority' anyway, so for example,
|
||||
* <connect allow="127.0.0.1"> will match joe!bloggs@localhost
|
||||
*/
|
||||
ConnectClass* userrec::GetClass()
|
||||
ConnectClass* userrec::GetClass(const std::string &explicit_name)
|
||||
{
|
||||
for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
|
||||
if (!explicit_name.empty())
|
||||
{
|
||||
if (((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str()))))
|
||||
for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
|
||||
{
|
||||
if (i->GetPort())
|
||||
{
|
||||
if (this->GetPort() == i->GetPort())
|
||||
return &(*i);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if (explicit_name == i->GetName())
|
||||
return &(*i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
|
||||
{
|
||||
if (((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str()))))
|
||||
{
|
||||
if (i->GetPort())
|
||||
{
|
||||
if (this->GetPort() == i->GetPort())
|
||||
return &(*i);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
return &(*i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user