diff options
author | Sadie Powell <sadie@witchery.services> | 2020-04-11 15:09:34 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2020-04-11 15:44:51 +0100 |
commit | 6fcbfc072387752ec345d7589e986b9959f350fc (patch) | |
tree | c62f9074e1d1409ac4379025d6938cbaf8c8e29f /src/users.cpp | |
parent | 41f781a9a6560eab393b18815dbdfa9073c6810b (diff) |
Add support for limiting what opers can subscribe to snomasks.
Diffstat (limited to 'src/users.cpp')
-rw-r--r-- | src/users.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/users.cpp b/src/users.cpp index e8e292615..bd7d046b8 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -229,6 +229,19 @@ bool LocalUser::HasPrivPermission(const std::string& privstr) return oper->AllowedPrivs.Contains(privstr); } +bool User::HasSnomaskPermission(char chr) const +{ + return true; +} + +bool LocalUser::HasSnomaskPermission(char chr) const +{ + if (!this->IsOper() || !ModeParser::IsModeChar(chr)) + return false; + + return this->oper->AllowedSnomasks[chr - 'A']; +} + void UserIOHandler::OnDataReady() { if (user->quitting) @@ -419,6 +432,7 @@ void OperInfo::init() AllowedPrivs.Clear(); AllowedUserModes.reset(); AllowedChanModes.reset(); + AllowedSnomasks.reset(); AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want. for(std::vector<reference<ConfigTag> >::iterator iter = class_blocks.begin(); iter != class_blocks.end(); ++iter) @@ -447,6 +461,16 @@ void OperInfo::init() else if (ModeParser::IsModeChar(chr)) this->AllowedChanModes[chr - 'A'] = true; } + + const std::string snomasks = tag->getString("snomasks", "*"); + for (std::string::const_iterator c = snomasks.begin(); c != snomasks.end(); ++c) + { + const char& chr = *c; + if (chr == '*') + this->AllowedSnomasks.set(); + else if (ModeParser::IsModeChar(chr)) + this->AllowedSnomasks[chr - 'A'] = true; + } } } |