InspIRCd  3.0
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
User Class Reference

#include <users.h>

Inheritance diagram for User:
Extensible classbase FakeUser LocalUser RemoteUser

Classes

class  ForEachNeighborHandler
 

Public Types

typedef insp::intrusive_list< MembershipChanList
 
- Public Types inherited from Extensible
typedef insp::flat_map< reference< ExtensionItem >, void * > ExtensibleStore
 

Public Member Functions

const std::string & GetIPString ()
 
irc::sockets::cidr_mask GetCIDRMask ()
 
virtual bool SetClientIP (const char *sip, bool recheck_eline=true)
 
virtual void SetClientIP (const irc::sockets::sockaddrs &sa, bool recheck_eline=true)
 
 User (const std::string &uid, Server *srv, int objtype)
 
virtual const std::string & GetFullHost ()
 
virtual const std::string & GetFullRealHost ()
 
void InvalidateCache ()
 
bool IsAway () const
 
bool IsOper () const
 
bool IsNoticeMaskSet (unsigned char sm)
 
std::string GetModeLetters (bool includeparams=false) const
 
bool IsModeSet (unsigned char m) const
 
bool IsModeSet (const ModeHandler *mh) const
 
bool IsModeSet (const ModeHandler &mh) const
 
bool IsModeSet (UserModeReference &moderef) const
 
void SetMode (ModeHandler *mh, bool value)
 
void SetMode (ModeHandler &mh, bool value)
 
virtual bool HasPermission (const std::string &command)
 
virtual bool HasPrivPermission (const std::string &privstr, bool noisy=false)
 
virtual bool HasModePermission (const ModeHandler *mh) const
 
const std::string & MakeHost ()
 
const std::string & MakeHostIP ()
 
void Oper (OperInfo *info)
 
void UnOper ()
 
virtual void Write (const std::string &text)
 
virtual void Write (const char *text,...) CUSTOM_PRINTF(2
 
virtual void void WriteServ (const std::string &text)
 
void WriteServ (const char *text,...) CUSTOM_PRINTF(2
 
void void WriteCommand (const char *command, const std::string &text)
 
void WriteNotice (const std::string &text)
 
virtual void WriteRemoteNotice (const std::string &text)
 
virtual void WriteRemoteNumeric (const Numeric::Numeric &numeric)
 
template<typename T1 >
void WriteRemoteNumeric (unsigned int numeric, T1 p1)
 
template<typename T1 , typename T2 >
void WriteRemoteNumeric (unsigned int numeric, T1 p1, T2 p2)
 
template<typename T1 , typename T2 , typename T3 >
void WriteRemoteNumeric (unsigned int numeric, T1 p1, T2 p2, T3 p3)
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
void WriteRemoteNumeric (unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
void WriteRemoteNumeric (unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
 
void WriteNumeric (const Numeric::Numeric &numeric)
 
template<typename T1 >
void WriteNumeric (unsigned int numeric, T1 p1)
 
template<typename T1 , typename T2 >
void WriteNumeric (unsigned int numeric, T1 p1, T2 p2)
 
template<typename T1 , typename T2 , typename T3 >
void WriteNumeric (unsigned int numeric, T1 p1, T2 p2, T3 p3)
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
void WriteNumeric (unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
void WriteNumeric (unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
 
void WriteFrom (User *user, const std::string &text)
 
void WriteFrom (User *user, const char *text,...) CUSTOM_PRINTF(3
 
void void WriteCommonRaw (const std::string &line, bool include_self=true)
 
void WriteCommon (const char *text,...) CUSTOM_PRINTF(2
 
void void ForEachNeighbor (ForEachNeighborHandler &handler, bool include_self=true)
 
bool SharesChannelWith (User *other)
 
bool ChangeDisplayedHost (const std::string &host)
 
bool ChangeIdent (const std::string &newident)
 
bool ChangeName (const std::string &gecos)
 
bool ChangeNick (const std::string &newnick, time_t newts=0)
 
void PurgeEmptyChannels ()
 
virtual ~User ()
 
virtual CullResult cull () CXX11_OVERRIDE
 
- Public Member Functions inherited from Extensible
const ExtensibleStoreGetExtList () const
 
void doUnhookExtensions (const std::vector< reference< ExtensionItem > > &toRemove)
 
void FreeAllExtItems ()
 

Public Attributes

std::string host
 
time_t age
 
time_t signon
 
irc::sockets::sockaddrs client_sa
 
std::string nick
 
const std::string uuid
 
std::string ident
 
std::string dhost
 
std::string fullname
 
std::bitset< 64 > snomasks
 
ChanList chans
 
Serverserver
 
std::string awaymsg
 
time_t awaytime
 
reference< OperInfooper
 
unsigned int registered:3
 
unsigned int quitting:1
 
const unsigned int usertype:2
 

Detailed Description

Holds all information about a user This class stores all information about a user connected to the irc server. Everything about a connection is stored here primarily, from the user's socket ID (file descriptor) through to the user's nickname and hostname.

Member Typedef Documentation

◆ ChanList

List of Memberships for this user

Constructor & Destructor Documentation

◆ User()

User::User ( const std::string &  uid,
Server srv,
int  objtype 
)

Constructor

Exceptions
CoreExceptionif the UID allocated to the user already exists

◆ ~User()

User::~User ( )
virtual

Default destructor

Member Function Documentation

◆ ChangeDisplayedHost()

bool User::ChangeDisplayedHost ( const std::string &  host)

Change the displayed host of a user. ALWAYS use this function, rather than writing User::dhost directly, as this triggers module events allowing the change to be syncronized to remote servers.

Parameters
hostThe new hostname to set
Returns
True if the change succeeded, false if it didn't (a module vetoed the change).

◆ ChangeIdent()

bool User::ChangeIdent ( const std::string &  newident)

Change the ident (username) of a user. ALWAYS use this function, rather than writing User::ident directly, as this triggers module events allowing the change to be syncronized to remote servers.

Parameters
newidentThe new ident to set
Returns
True if the change succeeded, false if it didn't

◆ ChangeName()

bool User::ChangeName ( const std::string &  gecos)

Change a users realname field. ALWAYS use this function, rather than writing User::fullname directly, as this triggers module events allowing the change to be syncronized to remote servers.

Parameters
gecosThe user's new realname
Returns
True if the change succeeded, false if otherwise

◆ ChangeNick()

bool User::ChangeNick ( const std::string &  newnick,
time_t  newts = 0 
)

Change a user's nick

Parameters
newnickThe new nick. If equal to the users uuid, the nick change always succeeds.
newtsThe time at which this nick change happened.
Returns
True if the change succeeded

◆ cull()

CullResult User::cull ( )
virtual

Called just prior to destruction via cull list.

Reimplemented from Extensible.

Reimplemented in FakeUser, and LocalUser.

◆ ForEachNeighbor()

void User::ForEachNeighbor ( ForEachNeighborHandler handler,
bool  include_self = true 
)

Execute a function once for each local neighbor of this user. By default, the neighbors of a user are the users who have at least one common channel with the user. Modules are allowed to alter the set of neighbors freely. This function is used for example to send something conditionally to neighbors, or to send different messages to different users depending on their oper status.

Parameters
handlerFunction object to call, inherited from ForEachNeighborHandler.
include_selfTrue to include this user in the set of neighbors, false otherwise. Modules may override this. Has no effect if this user is not local.

◆ GetCIDRMask()

irc::sockets::cidr_mask User::GetCIDRMask ( )

Get CIDR mask, using default range, for this user

◆ GetFullHost()

const std::string & User::GetFullHost ( )
virtual

Returns the full displayed host of the user This member function returns the hostname of the user as seen by other users on the server, in [email protected] form.

Returns
The full masked host of the user

Reimplemented in FakeUser.

◆ GetFullRealHost()

const std::string & User::GetFullRealHost ( )
virtual

Returns the full real host of the user This member function returns the hostname of the user as seen by other users on the server, in [email protected] form. If any form of hostname cloaking is in operation, e.g. through a module, then this method will ignore it and return the true hostname.

Returns
The full real host of the user

Reimplemented in FakeUser.

◆ GetIPString()

const std::string & User::GetIPString ( )

Get client IP string from sockaddr, using static internal buffer

Returns
The IP string

◆ GetModeLetters()

std::string User::GetModeLetters ( bool  includeparams = false) const

Get the mode letters of modes set on the user as a string.

Parameters
includeparamsTrue to get the parameters of the modes as well. Defaults to false.
Returns
Mode letters of modes set on the user and optionally the parameters of those modes, if any. The returned string always begins with a '+' character. If the user has no modes set, "+" is returned.

◆ HasModePermission()

bool User::HasModePermission ( const ModeHandler mh) const
virtual

Returns true or false if a user can set a privileged user or channel mode. This is done by looking up their oper type from User::oper, then referencing this to their oper classes, and checking the modes they can set.

Parameters
mhMode to check
Returns
True if the user can set or unset this mode.

Reimplemented in LocalUser.

◆ HasPermission()

bool User::HasPermission ( const std::string &  command)
virtual

Returns true or false for if a user can execute a privilaged oper command. This is done by looking up their oper type from User::oper, then referencing this to their oper classes and checking the commands they can execute.

Parameters
commandA command (should be all CAPS)
Returns
True if this user can execute the command

Reimplemented in LocalUser.

◆ HasPrivPermission()

bool User::HasPrivPermission ( const std::string &  privstr,
bool  noisy = false 
)
virtual

Returns true if a user has a given permission. This is used to check whether or not users may perform certain actions which admins may not wish to give to all operators, yet are not commands. An example might be oper override, mass messaging (/notice $*), etc.

Parameters
privstrThe priv to chec, e.g. "users/override/topic". These are loaded free-form from the config file.
noisyIf set to true, the user is notified that they do not have the specified permission where applicable. If false, no notification is sent.
Returns
True if this user has the permission in question.

Reimplemented in LocalUser.

◆ InvalidateCache()

void User::InvalidateCache ( )

This clears any cached results that are used for GetFullRealHost() etc. The results of these calls are cached as generating them can be generally expensive.

◆ IsAway()

bool User::IsAway ( ) const
inline

Returns whether this user is currently away or not. If true, further information can be found in User::awaymsg and User::awaytime

Returns
True if the user is away, false otherwise

◆ IsModeSet()

bool User::IsModeSet ( unsigned char  m) const

Returns true if a specific mode is set

Parameters
mThe user mode
Returns
True if the mode is set

◆ IsNoticeMaskSet()

bool User::IsNoticeMaskSet ( unsigned char  sm)

Returns true if a notice mask is set

Parameters
smA notice mask character to check
Returns
True if the notice mask is set

◆ IsOper()

bool User::IsOper ( ) const
inline

Returns whether this user is an oper or not. If true, oper information can be obtained from User::oper

Returns
True if the user is an oper, false otherwise

◆ MakeHost()

const std::string & User::MakeHost ( )

Creates a usermask with real host. Takes a buffer to use and fills the given buffer with the hostmask in the format [email protected]

Returns
the usermask in the format [email protected]

◆ MakeHostIP()

const std::string & User::MakeHostIP ( )

Creates a usermask with real ip. Takes a buffer to use and fills the given buffer with the ipmask in the format [email protected]

Returns
the usermask in the format [email protected]

◆ Oper()

void User::Oper ( OperInfo info)

Oper up the user using the given opertype. This will also give the +o usermode.

◆ PurgeEmptyChannels()

void User::PurgeEmptyChannels ( )

Remove this user from all channels they are on, and delete any that are now empty. This is used by QUIT, and will not send part messages!

◆ SetClientIP()

bool User::SetClientIP ( const char *  sip,
bool  recheck_eline = true 
)
virtual

Sets the client IP for this user

Returns
true if the conversion was successful

Reimplemented in LocalUser.

◆ SetMode()

void User::SetMode ( ModeHandler mh,
bool  value 
)
inline

Set a specific usermode to on or off

Parameters
mhThe user mode
valueOn or off setting of the mode

◆ SharesChannelWith()

bool User::SharesChannelWith ( User other)

Return true if the user shares at least one channel with another user

Parameters
otherThe other user to compare the channel list against
Returns
True if the given user shares at least one channel with this user

◆ UnOper()

void User::UnOper ( )

Oper down. This will clear the +o usermode and unset the user's oper type

◆ Write() [1/2]

void User::Write ( const std::string &  text)
virtual

Write text to this user, appending CR/LF. Works on local users only.

Parameters
textA std::string to send to the user

Reimplemented in LocalUser.

◆ Write() [2/2]

void User::Write ( const char *  text,
  ... 
)
virtual

Write text to this user, appending CR/LF. Works on local users only.

Parameters
textThe format string for text to send to the user
...POD-type format arguments

Reimplemented in LocalUser.

◆ WriteCommand()

void User::WriteCommand ( const char *  command,
const std::string &  text 
)

Sends a command to this user.

Parameters
commandThe command to be sent.
textThe message to send.

◆ WriteCommon()

void User::WriteCommon ( const char *  text,
  ... 
)

Write to all users that can see this user (including this user in the list), appending CR/LF

Parameters
textThe format string for text to send to the users
...POD-type format arguments

◆ WriteCommonRaw()

void User::WriteCommonRaw ( const std::string &  line,
bool  include_self = true 
)

Write to all users that can see this user (including this user in the list if include_self is true), appending CR/LF

Parameters
lineA std::string to send to the users
include_selfShould the message be sent back to the author?

◆ WriteFrom() [1/2]

void User::WriteFrom ( User user,
const std::string &  text 
)

Write text to this user, appending CR/LF and prepending :[email protected] of the user provided in the first parameter.

Parameters
userThe user to prepend the :[email protected] of
textA std::string to send to the user

◆ WriteFrom() [2/2]

void User::WriteFrom ( User user,
const char *  text,
  ... 
)

Write text to this user, appending CR/LF and prepending :[email protected] of the user provided in the first parameter.

Parameters
userThe user to prepend the :[email protected] of
textThe format string for text to send to the user
...POD-type format arguments

◆ WriteNotice()

void User::WriteNotice ( const std::string &  text)
inline

Sends a server notice to this user.

Parameters
textThe contents of the message to send.

◆ WriteRemoteNotice()

void User::WriteRemoteNotice ( const std::string &  text)
virtual

Send a NOTICE message from the local server to the user.

Parameters
textText to send

Reimplemented in LocalUser.

◆ WriteServ() [1/2]

void User::WriteServ ( const std::string &  text)

Write text to this user, appending CR/LF and prepending :server.name Works on local users only.

Parameters
textA std::string to send to the user

◆ WriteServ() [2/2]

void User::WriteServ ( const char *  text,
  ... 
)

Write text to this user, appending CR/LF and prepending :server.name Works on local users only.

Parameters
textThe format string for text to send to the user
...POD-type format arguments

WriteServ() Same as Write(), except `text' is prefixed with `:server.name '.

Member Data Documentation

◆ age

time_t User::age

Time that the object was instantiated (used for TS calculation etc)

◆ awaymsg

std::string User::awaymsg

The user's away message. If this string is empty, the user is not marked as away.

◆ awaytime

time_t User::awaytime

Time the user last went away. This is ONLY RELIABLE if user IsAway()!

◆ chans

ChanList User::chans

Channels this user is on

◆ client_sa

irc::sockets::sockaddrs User::client_sa

Client address that the user is connected from. Do not modify this value directly, use SetClientIP() to change it. Port is not valid for remote users.

◆ dhost

std::string User::dhost

The host displayed to non-opers (used for cloaking etc). This usually matches the value of User::host.

◆ fullname

std::string User::fullname

The users full name (GECOS).

◆ host

std::string User::host

Hostname of connection. This should be valid as per RFC1035.

◆ ident

std::string User::ident

The users ident reply. Two characters are added to the user-defined limit to compensate for the tilde etc.

◆ nick

std::string User::nick

The users nickname. An invalid nickname indicates an unregistered connection prior to the NICK command. Use InspIRCd::IsNick() to validate nicknames.

◆ oper

reference<OperInfo> User::oper

The oper type they logged in as, if they are an oper.

◆ quitting

unsigned int User::quitting

If this is set to true, then all socket operations for the user are dropped into the bit-bucket. This value is set by QuitUser, and is not needed seperately from that call. Please note that setting this value alone will NOT cause the user to quit.

◆ registered

unsigned int User::registered

Used by User to indicate the registration status of the connection It is a bitfield of the REG_NICK, REG_USER and REG_ALL bits to indicate the connection state.

◆ server

Server* User::server

The server the user is connected to.

◆ signon

time_t User::signon

Time the connection was created, set in the constructor. This may be different from the time the user's classbase object was created.

◆ snomasks

std::bitset<64> User::snomasks

What snomasks are set on this user. This functions the same as the above modes.

◆ usertype

const unsigned int User::usertype

What type of user is this?

◆ uuid

const std::string User::uuid

The user's unique identifier. This is the unique identifier which the user has across the network.


The documentation for this class was generated from the following files: