InspIRCd
2.0
|
#include <users.h>
Public Member Functions | |
const char * | 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, const std::string &srv, int objtype) | |
bool | CheckLines (bool doZline=false) |
virtual const std::string & | GetFullHost () |
virtual const std::string & | GetFullRealHost () |
void | InvalidateCache () |
const char * | FormatNoticeMasks () |
std::string | ProcessNoticeMasks (const char *sm) |
bool | IsNoticeMaskSet (unsigned char sm) |
void | SetNoticeMask (unsigned char sm, bool value) |
const char * | FormatModes (bool showparameters=false) |
bool | IsModeSet (unsigned char m) |
void | SetMode (unsigned char m, bool value) |
virtual bool | HasPermission (const std::string &command) |
virtual bool | HasPrivPermission (const std::string &privstr, bool noisy=false) |
virtual bool | HasModePermission (unsigned char mode, ModeType type) |
char * | MakeWildHost () |
const std::string & | MakeHost () |
const std::string & | MakeHostIP () |
void | AddToWhoWas () |
void | Oper (OperInfo *info) |
bool | ForceNickChange (const char *newnick) |
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 | WriteNumeric (unsigned int numeric, const char *text,...) CUSTOM_PRINTF(3 |
void void void | WriteNumeric (unsigned int numeric, const std::string &text) |
void | WriteFrom (User *user, const std::string &text) |
void | WriteFrom (User *user, const char *text,...) CUSTOM_PRINTF(3 |
void void | WriteTo (User *dest, const std::string &data) |
void | WriteTo (User *dest, const char *data,...) CUSTOM_PRINTF(3 |
void void | WriteCommonRaw (const std::string &line, bool include_self=true) |
void | WriteCommon (const char *text,...) CUSTOM_PRINTF(2 |
void void | WriteCommonExcept (const char *text,...) CUSTOM_PRINTF(2 |
void void void | WriteCommonQuit (const std::string &normal_text, const std::string &oper_text) |
void | SendText (const std::string &LinePrefix, std::stringstream &TextStream) |
virtual void | SendText (const std::string &line)=0 |
void | SendText (const char *text,...) CUSTOM_PRINTF(2 |
void bool | SharesChannelWith (User *other) |
void | DoHostCycle (const std::string &quitline) |
bool | ChangeDisplayedHost (const char *host) |
bool | ChangeIdent (const char *newident) |
bool | ChangeName (const char *gecos) |
bool | ChangeNick (const std::string &newnick, bool force=false) |
void | SendAll (const char *command, const char *text,...) CUSTOM_PRINTF(3 |
void std::string | ChannelList (User *source, bool spy) |
void | SplitChanList (User *dest, const std::string &cl) |
void | PurgeEmptyChannels () |
virtual ConnectClass * | GetClass () |
virtual | ~User () |
virtual CullResult | cull () |
![]() | |
const ExtensibleStore & | GetExtList () const |
void | doUnhookExtensions (const std::vector< reference< ExtensionItem > > &toRemove) |
Public Attributes | |
std::string | host |
time_t | age |
time_t | signon |
time_t | idle_lastmsg |
irc::sockets::sockaddrs | client_sa |
std::string | nick |
const std::string | uuid |
std::string | ident |
std::string | dhost |
std::string | fullname |
std::bitset< 64 > | modes |
std::bitset< 64 > | snomasks |
UserChanList | chans |
const std::string | server |
std::string | awaymsg |
time_t | awaytime |
reference< OperInfo > | oper |
unsigned int | registered:3 |
unsigned int | dns_done:1 |
unsigned int | quietquit:1 |
unsigned int | quitting:1 |
unsigned int | quitting_sendq:1 |
unsigned int | exempt:1 |
unsigned int | lastping:1 |
const unsigned int | usertype:2 |
Additional Inherited Members | |
![]() | |
typedef std::map< reference< ExtensionItem >, void * > | ExtensibleStore |
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.
User::User | ( | const std::string & | uid, |
const std::string & | srv, | ||
int | objtype | ||
) |
Constructor
CoreException | if the UID allocated to the user already exists |
|
virtual |
Default destructor
void User::AddToWhoWas | ( | ) |
Add the user to WHOWAS system
bool User::ChangeDisplayedHost | ( | const char * | 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. This will also emulate a QUIT and rejoin (where configured) before setting their host field.
host | The new hostname to set |
bool User::ChangeIdent | ( | const char * | newident | ) |
Change the ident (username) of a user. ALWAYS use this function, rather than writing User::ident directly, as this correctly causes the user to seem to quit (where configured) before setting their ident field.
newident | The new ident to set |
bool User::ChangeName | ( | const char * | 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.
gecos | The user's new realname |
bool User::ChangeNick | ( | const std::string & | newnick, |
bool | force = false |
||
) |
Change a user's nick
newnick | The new nick |
force | True if the change is being forced (should not be blocked by modes like +N) |
std::string User::ChannelList | ( | User * | source, |
bool | spy | ||
) |
Compile a channel list for this user. Used internally by WHOIS
source | The user to prepare the channel list for |
spy | Whether to return the spy channel list rather than the normal one |
bool User::CheckLines | ( | bool | doZline = false | ) |
Check if the user matches a G or K line, and disconnect them if they do.
doZline | True if ZLines should be checked (if IP has changed since initial connect) Returns true if the user matched a ban, false else. |
|
virtual |
Called just prior to destruction via cull list.
Reimplemented from Extensible.
void User::DoHostCycle | ( | const std::string & | quitline | ) |
Send fake quit/join messages for host or ident cycle. Run this after the item in question has changed. You should not need to use this function, call ChangeDisplayedHost instead
quitline | The entire QUIT line, including the source using the old value |
|
inline |
Force a nickname change. If the nickname change fails (for example, because the nick in question already exists) this function will return false, and you must then either output an error message, or quit the user for nickname collision.
newnick | The nickname to change to |
const char * User::FormatModes | ( | bool | showparameters = false | ) |
Create a displayable mode string for this users umodes
showparameters | The mode string |
const char * User::FormatNoticeMasks | ( | ) |
Create a displayable mode string for this users snomasks
irc::sockets::cidr_mask User::GetCIDRMask | ( | ) |
Get CIDR mask, using default range, for this user
|
virtual |
Get the connect class which this user belongs to. NULL for remote users.
Reimplemented in LocalUser.
|
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.
Reimplemented in FakeUser.
|
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.
Reimplemented in FakeUser.
const char * User::GetIPString | ( | ) |
Get client IP string from sockaddr, using static internal buffer
|
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.
mode | The mode the check |
type | ModeType (MODETYPE_CHANNEL or MODETYPE_USER). |
Reimplemented in LocalUser.
|
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.
command | A command (should be all CAPS) |
Reimplemented in LocalUser.
|
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.
privstr | The priv to chec, e.g. "users/override/topic". These are loaded free-form from the config file. |
noisy | If set to true, the user is notified that they do not have the specified permission where applicable. If false, no notification is sent. |
Reimplemented in LocalUser.
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.
bool User::IsModeSet | ( | unsigned char | m | ) |
Returns true if a specific mode is set
m | The user mode |
bool User::IsNoticeMaskSet | ( | unsigned char | sm | ) |
Returns true if a notice mask is set
sm | A notice mask character to check |
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]
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]
char * User::MakeWildHost | ( | ) |
Creates a wildcard host. Takes a buffer to use and fills the given buffer with the host in the format !@hostname
void User::Oper | ( | OperInfo * | info | ) |
Oper up the user using the given opertype. This will also give the +o usermode.
std::string User::ProcessNoticeMasks | ( | const char * | sm | ) |
Process a snomask modifier string, e.g. +abc-de
sm | A sequence of notice mask characters |
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!
void User::SendAll | ( | const char * | command, |
const char * | text, | ||
... | |||
) |
Send a command to all local users from this user The command given must be able to send text with the first parameter as a servermask (e.g. $*), so basically you should use PRIVMSG or NOTICE.
command | the command to send |
text | The text format string to send |
... | Format arguments |
void User::SendText | ( | const char * | text, |
... | |||
) |
Write to the user, routing the line if the user is remote.
|
pure virtual |
Write to the user, routing the line if the user is remote.
Implemented in FakeUser, RemoteUser, and LocalUser.
void User::SendText | ( | const std::string & | LinePrefix, |
std::stringstream & | TextStream | ||
) |
Dump text to a user target, splitting it appropriately to fit
LinePrefix | text to prefix each complete line with |
TextStream | the text to send to the user |
|
virtual |
Sets the client IP for this user
Reimplemented in LocalUser.
void User::SetMode | ( | unsigned char | m, |
bool | value | ||
) |
Set a specific usermode to on or off
m | The user mode |
value | On or off setting of the mode |
void User::SetNoticeMask | ( | unsigned char | sm, |
bool | value | ||
) |
Changed a specific notice mask value
sm | The server notice mask to change |
value | An on/off value for this mask |
bool User::SharesChannelWith | ( | User * | other | ) |
Return true if the user shares at least one channel with another user
other | The other user to compare the channel list against |
void User::SplitChanList | ( | User * | dest, |
const std::string & | cl | ||
) |
Split the channel list in cl which came from dest, and spool it to this user Used internally by WHOIS
dest | The user the original channel list came from |
cl | The channel list as a string obtained from User::ChannelList() |
void User::UnOper | ( | ) |
Oper down. This will clear the +o usermode and unset the user's oper type
|
virtual |
Write text to this user, appending CR/LF. Works on local users only.
text | The format string for text to send to the user |
... | POD-type format arguments |
Reimplemented in LocalUser.
|
virtual |
Write text to this user, appending CR/LF. Works on local users only.
text | A std::string to send to the user |
Reimplemented in LocalUser.
void User::WriteCommon | ( | const char * | text, |
... | |||
) |
Write to all users that can see this user (including this user in the list), appending CR/LF
text | The format string for text to send to the users |
... | POD-type format arguments |
void User::WriteCommonExcept | ( | const char * | text, |
... | |||
) |
Write to all users that can see this user (not including this user in the list), appending CR/LF
text | The format string for text to send to the users |
... | POD-type format arguments |
void User::WriteCommonQuit | ( | const std::string & | normal_text, |
const std::string & | oper_text | ||
) |
Write a quit message to all common users, as in User::WriteCommonExcept but with a specific quit message for opers only.
normal_text | Normal user quit message |
oper_text | Oper only quit message |
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
line | A std::string to send to the users |
include_self | Should the message be sent back to the author? |
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.
user | The user to prepend the :[email protected] of |
text | The format string for text to send to the user |
... | POD-type format arguments |
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.
user | The user to prepend the :[email protected] of |
text | A std::string to send to the user |
void User::WriteServ | ( | const char * | text, |
... | |||
) |
Write text to this user, appending CR/LF and prepending :server.name Works on local users only.
text | The format string for text to send to the user |
... | POD-type format arguments |
WriteServ() Same as Write(), except ‘text’ is prefixed with ‘:server.name ’.
void User::WriteServ | ( | const std::string & | text | ) |
Write text to this user, appending CR/LF and prepending :server.name Works on local users only.
text | A std::string to send to the user |
void User::WriteTo | ( | User * | dest, |
const char * | data, | ||
... | |||
) |
Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :[email protected]
dest | The user to route the message to |
data | The format string for text to send to the user |
... | POD-type format arguments |
void User::WriteTo | ( | User * | dest, |
const std::string & | data | ||
) |
Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :[email protected]
dest | The user to route the message to |
data | A std::string to send to the user |
time_t User::age |
Time that the object was instantiated (used for TS calculation etc)
std::string User::awaymsg |
The user's away message. If this string is empty, the user is not marked as away.
time_t User::awaytime |
Time the user last went away. This is ONLY RELIABLE if user IS_AWAY()!
UserChanList User::chans |
Channels this user is on
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.
std::string User::dhost |
The host displayed to non-opers (used for cloaking etc). This usually matches the value of User::host.
unsigned int User::dns_done |
True when DNS lookups are completed. The UserResolver classes res_forward and res_reverse will set this value once they complete.
unsigned int User::exempt |
This is true if the user matched an exception (E:Line). It is used to save time on ban checks.
std::string User::fullname |
The users full name (GECOS).
std::string User::host |
Hostname of connection. This should be valid as per RFC1035.
std::string User::ident |
The users ident reply. Two characters are added to the user-defined limit to compensate for the tilde etc.
time_t User::idle_lastmsg |
Time that the connection last sent a message, used to calculate idle time
unsigned int User::lastping |
has the user responded to their previous ping?
std::bitset<64> User::modes |
The user's mode list. NOT a null terminated string. Also NOT an array. Much love to the STL for giving us an easy to use bitset, saving us RAM. if (modes[modeletter-65]) is set, then the mode is set, for example, to work out if mode +s is set, we check the field User::modes['s'-65] != 0. The following RFC characters o, w, s, i have constants defined via an enum, such as UM_SERVERNOTICE and UM_OPETATOR.
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.
unsigned int User::quietquit |
Whether or not to send an snotice about this user's 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.
unsigned int User::quitting_sendq |
Recursion fix: user is out of SendQ and will be quit as soon as possible. This can't be handled normally because QuitUser itself calls Write on other users, which could trigger their SendQ to overrun.
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.
const std::string User::server |
The server the user is connected to.
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.
std::bitset<64> User::snomasks |
What snomasks are set on this user. This functions the same as the above modes.
const unsigned int User::usertype |
What type of user is this?
const std::string User::uuid |
The user's unique identifier. This is the unique identifier which the user has across the network.