anope

- supernets anope source code & configuration
git clone git://git.acid.vegas/anope.git
Log | Files | Refs | Archive | README

opertype.h (3565B)

      1 /*
      2  *
      3  * (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
      4  * (C) 2008-2022 Anope Team <team@anope.org>
      5  *
      6  * Please read COPYING and README for further details.
      7  */
      8 
      9 #ifndef OPERTYPE_H
     10 #define OPERTYPE_H
     11 
     12 #include "services.h"
     13 #include "account.h"
     14 
     15 /* A services operator. Usually made by the configuration file, but not always.
     16  * NickAlias::Find(name)->nc->o == this
     17  */
     18 struct CoreExport Oper
     19 {
     20 	/* The oper's nick */
     21 	Anope::string name;
     22 	/* The type of operator this operator is */
     23 	OperType *ot;
     24 	/* Whether the user must be an IRC operator (umode +o) to be considered a services operator */
     25 	bool require_oper;
     26 	Anope::string password;
     27 	Anope::string certfp;
     28 	/* Hosts allowed to use this operator block */
     29 	std::vector<Anope::string> hosts;
     30 	Anope::string vhost;
     31 
     32 	Oper(const Anope::string &n, OperType *o);
     33 	virtual ~Oper();
     34 
     35 	static std::vector<Oper *> opers;
     36 
     37 	/** Find an oper block by name
     38 	 * @param name The name
     39 	 * @return the oper block
     40 	 */
     41 	static Oper *Find(const Anope::string &name);
     42 };
     43 
     44 class CoreExport OperType
     45 {
     46  private:
     47 	/** The name of this opertype, e.g. "sra".
     48 	 */
     49 	Anope::string name;
     50 
     51 	/** Privs that this opertype may use, e.g. 'users/auspex'.
     52 	 * This *must* be std::list, see commands comment for details.
     53 	 */
     54 	std::list<Anope::string> privs;
     55 
     56 	/** Commands this user may execute, e.g:
     57 	 * botserv/set/ *, botserv/set/private, botserv/ *
     58 	 * et cetera.
     59 	 *
     60 	 * This *must* be std::list, not std::map, because
     61 	 * we support full globbing here. This shouldn't be a problem
     62 	 * as we don't invoke it often.
     63 	 */
     64 	std::list<Anope::string> commands;
     65 
     66 	/** Set of opertypes we inherit from
     67 	 */
     68 	std::set<OperType *> inheritances;
     69  public:
     70 	/** Modes to set when someone identifies using this opertype
     71 	 */
     72 	Anope::string modes;
     73 
     74 	/** Find an oper type by name
     75 	 * @param name The name
     76 	 * @return The oper type
     77 	 */
     78 	static OperType *Find(const Anope::string &name);
     79 
     80 	/** Create a new opertype of the given name.
     81 	 * @param nname The opertype name, e.g. "sra".
     82 	 */
     83 	OperType(const Anope::string &nname);
     84 
     85 	/** Check whether this opertype has access to run the given command string.
     86 	 * @param cmdstr The string to check, e.g. botserv/set/private.
     87 	 * @return True if this opertype may run the specified command, false otherwise.
     88 	 */
     89 	bool HasCommand(const Anope::string &cmdstr) const;
     90 
     91 	/** Check whether this opertype has access to the given special permission.
     92 	 * @param privstr The priv to check for, e.g. users/auspex.
     93 	 * @return True if this opertype has the specified priv, false otherwise.
     94 	 */
     95 	bool HasPriv(const Anope::string &privstr) const;
     96 
     97 	/** Add the specified command to this opertype.
     98 	 * @param cmdstr The command mask to grant this opertype access to, e.g: nickserv/ *, chanserv/set/ *, botserv/set/private.
     99 	 */
    100 	void AddCommand(const Anope::string &cmdstr);
    101 
    102 	/** Add the specified priv mask to this opertype.
    103 	 * @param privstr The specified mask of privs to grant this opertype access to,  e.g. users/auspex, users/ *, etc.
    104 	 */
    105 	void AddPriv(const Anope::string &privstr);
    106 
    107 	/** Returns the name of this opertype.
    108 	 */
    109 	const Anope::string &GetName() const;
    110 
    111 	/** Make this opertype inherit commands and privs from another opertype
    112 	 * @param ot The opertype to inherit from
    113 	 */
    114 	void Inherits(OperType *ot);
    115 
    116 	/** Gets the icommands for this opertype
    117 	 * @return A list of commands
    118 	 */
    119 	const std::list<Anope::string> GetCommands() const;
    120 
    121 	/** Gets the privileges for this opertype
    122 	 * @return A list of privileges
    123 	 */
    124 	const std::list<Anope::string> GetPrivs() const;
    125 };
    126 
    127 #endif // OPERTYPE_H