mirror of
https://github.com/anope/anope.git
synced 2026-06-12 19:14:47 +02:00
Added oper:host and oper:vhost
This commit is contained in:
@@ -841,6 +841,14 @@ oper
|
||||
|
||||
/* An optional SSL fingerprint. If defined is required to use this opertype. */
|
||||
#certfp = "ed3383b3f7d74e89433ddaa4a6e5b2d7"
|
||||
|
||||
/* An optional list of user@host masks. If defined the user must be connected from one of them */
|
||||
#host = "*@*.anope.org ident@*"
|
||||
|
||||
/* An optional vhost to set on users who identify for this oper block.
|
||||
* This will override HostServ vhosts, and may not be available on all IRCds
|
||||
*/
|
||||
#vhost = "oper.mynet"
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+5
-3
@@ -15,13 +15,15 @@ class OperType;
|
||||
struct CoreExport Oper
|
||||
{
|
||||
Anope::string name;
|
||||
OperType *ot;
|
||||
Anope::string password;
|
||||
Anope::string certfp;
|
||||
OperType *ot;
|
||||
bool config;
|
||||
|
||||
Oper(const Anope::string &n, const Anope::string &p, const Anope::string &c, OperType *o) :
|
||||
name(n), password(p), certfp(c), ot(o), config(false) { }
|
||||
std::vector<Anope::string> hosts;
|
||||
Anope::string vhost;
|
||||
|
||||
Oper(const Anope::string &n, OperType *o) : name(n), ot(o) { }
|
||||
|
||||
/** Find an oper block by name
|
||||
* @param name The name
|
||||
|
||||
@@ -47,7 +47,7 @@ class CommandOSOper : public Command
|
||||
else
|
||||
{
|
||||
delete na->nc->o;
|
||||
na->nc->o = new Oper(na->nc->display, "", "", ot);
|
||||
na->nc->o = new Oper(na->nc->display, ot);
|
||||
|
||||
Log(LOG_ADMIN, source.u, this) << "ADD " << na->nick << " as type " << ot->GetName();
|
||||
source.Reply("%s (%s) added to the \2%s\2 list.", na->nick.c_str(), na->nc->display.c_str(), ot->GetName().c_str());
|
||||
@@ -209,7 +209,7 @@ class OSOper : public Module
|
||||
OperType *ot = OperType::Find(params[2]);
|
||||
if (ot == NULL)
|
||||
return EVENT_CONTINUE;
|
||||
nc->o = new Oper(nc->display, "", "", ot);
|
||||
nc->o = new Oper(nc->display, ot);
|
||||
Log(LOG_NORMAL, "operserv/oper") << "Tied oper " << nc->display << " to type " << ot->GetName();
|
||||
}
|
||||
return EVENT_CONTINUE;
|
||||
|
||||
@@ -46,7 +46,7 @@ class IdentifyInterface : public LDAPInterface
|
||||
my_opers.erase(o);
|
||||
delete o;
|
||||
}
|
||||
o = new Oper(u->nick, "", "", ot);
|
||||
o = new Oper(u->nick, ot);
|
||||
my_opers.insert(o);
|
||||
u->Account()->o = o;
|
||||
Log() << "m_ldap_oper: Tied " << u->nick << " (" << u->Account()->display << ") to opertype " << ot->GetName();
|
||||
|
||||
+10
-4
@@ -656,6 +656,8 @@ static bool DoOper(ServerConfig *config, const Anope::string &, const Anope::str
|
||||
Anope::string type = values[1].GetValue();
|
||||
Anope::string password = values[2].GetValue();
|
||||
Anope::string certfp = values[3].GetValue();
|
||||
Anope::string host = values[4].GetValue();
|
||||
Anope::string vhost = values[5].GetValue();
|
||||
|
||||
ValueItem vi(name);
|
||||
if (!ValidateNotEmpty(config, "oper", "name", vi))
|
||||
@@ -672,8 +674,12 @@ static bool DoOper(ServerConfig *config, const Anope::string &, const Anope::str
|
||||
if (ot == NULL)
|
||||
throw ConfigException("Oper block for " + name + " has invalid oper type " + type);
|
||||
|
||||
Oper *o = new Oper(name, password, certfp, ot);
|
||||
Oper *o = new Oper(name, ot);
|
||||
o->config = true;
|
||||
o->password = password;
|
||||
o->certfp = certfp;
|
||||
o->hosts = BuildStringVector(host);
|
||||
o->vhost = vhost;
|
||||
config->Opers.push_back(o);
|
||||
|
||||
return true;
|
||||
@@ -1257,9 +1263,9 @@ ConfigItems::ConfigItems(ServerConfig *conf)
|
||||
{DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING},
|
||||
InitOperTypes, DoOperType, DoneOperTypes},
|
||||
{"oper",
|
||||
{"name", "type", "password", "certfp", ""},
|
||||
{"", "", "", "", ""},
|
||||
{DT_STRING, DT_STRING, DT_STRING, DT_STRING},
|
||||
{"name", "type", "password", "certfp", "host", "vhost", ""},
|
||||
{"", "", "", "", "", "", ""},
|
||||
{DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING},
|
||||
InitOpers, DoOper, DoneOpers},
|
||||
{"service",
|
||||
{"nick", "user", "host", "gecos", "modes", "channels", ""},
|
||||
|
||||
+24
-4
@@ -367,12 +367,22 @@ void User::Identify(NickAlias *na)
|
||||
|
||||
FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(this));
|
||||
|
||||
if (na->nc->o != NULL && na->nc->o->ot != NULL && !na->nc->o->ot->modes.empty())
|
||||
if (this->IsServicesOper())
|
||||
{
|
||||
BotInfo *bi = findbot(Config->OperServ);
|
||||
this->SetModes(bi, "%s", na->nc->o->ot->modes.c_str());
|
||||
if (bi != NULL)
|
||||
this->SendMessage(bi, "Changing your usermodes to \002%s\002", na->nc->o->ot->modes.c_str());
|
||||
if (!this->nc->o->ot->modes.empty())
|
||||
{
|
||||
this->SetModes(bi, "%s", this->nc->o->ot->modes.c_str());
|
||||
if (bi != NULL)
|
||||
this->SendMessage(bi, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str());
|
||||
}
|
||||
if (ircd->vhost && !this->nc->o->vhost.empty())
|
||||
{
|
||||
if (bi != NULL)
|
||||
this->SendMessage(bi, "Changing your vhost to \002%s\002", this->nc->o->vhost.c_str());
|
||||
this->SetDisplayedHost(this->nc->o->vhost);
|
||||
ircdproto->SendVhost(this, "", this->nc->o->vhost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,6 +468,16 @@ bool User::IsServicesOper()
|
||||
else if (!this->nc->o->certfp.empty() && this->fingerprint != this->nc->o->certfp)
|
||||
// Certfp mismatch
|
||||
return false;
|
||||
else if (!this->nc->o->hosts.empty())
|
||||
{
|
||||
bool match = false;
|
||||
Anope::string match_host = this->GetIdent() + "@" + this->host;
|
||||
for (unsigned i = 0; i < this->nc->o->hosts.size(); ++i)
|
||||
if (Anope::Match(match_host, this->nc->o->hosts[i]))
|
||||
match = true;
|
||||
if (match == false)
|
||||
return false;
|
||||
}
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(I_IsServicesOper, IsServicesOper(this));
|
||||
|
||||
Reference in New Issue
Block a user