InspIRCd  4.0
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
UserManager Class Reference


struct  CloneCounts

Public Types

typedef std::map< irc::sockets::cidr_mask, CloneCountsCloneMap
typedef std::vector< User * > OperList
typedef std::vector< User * > ServiceList
typedef insp::intrusive_list< LocalUserLocalList

Public Member Functions

 UserManager ()
 ~UserManager ()
void DoBackgroundUserStuff ()
void AddUser (int socket, ListenSocket *via, irc::sockets::sockaddrs *client, irc::sockets::sockaddrs *server)
void QuitUser (User *user, const std::string &quitreason, const std::string *operreason=NULL)
void AddClone (User *user)
void RemoveCloneCounts (User *user)
void RehashCloneCounts ()
const CloneCountsGetCloneCounts (User *user) const
const CloneMapGetCloneMap () const
size_t RegisteredUserCount ()
size_t UnregisteredUserCount () const
size_t ServiceCount () const
size_t LocalUserCount () const
user_hash & GetUsers ()
const LocalListGetLocalUsers () const
void ServerNoticeAll (const char *text,...) CUSTOM_PRINTF(2
void uint64_t NextAlreadySentId ()
UserFind (const std::string &nickuuid)
UserFindNick (const std::string &nick)
UserFindUUID (const std::string &uuid)

Public Attributes

user_hash clientlist
user_hash uuidlist
OperList all_opers
ServiceList all_services
size_t unregistered_count

Member Typedef Documentation

◆ CloneMap

Container that maps IP addresses to clone counts

◆ LocalList

A list holding local users

◆ OperList

typedef std::vector<User*> UserManager::OperList

Sequence container in which each element is a User*

◆ ServiceList

typedef std::vector<User*> UserManager::ServiceList

A list containing users who are on a U-lined servers.

Constructor & Destructor Documentation

◆ UserManager()

UserManager::UserManager ( )

Constructor, initializes variables

◆ ~UserManager()

UserManager::~UserManager ( )

Destructor, destroys all users in clientlist

Member Function Documentation

◆ AddClone()

void UserManager::AddClone ( User user)

Add a user to the clone map

userThe user to add

◆ AddUser()

void UserManager::AddUser ( int  socket,
ListenSocket via,
irc::sockets::sockaddrs client,
irc::sockets::sockaddrs server 

Handle a client connection. Creates a new LocalUser object, inserts it into the appropriate containers, initializes it as not yet registered, and adds it to the socket engine.

The new user may immediately be quit after being created, for example if the user limit is reached or if the user is banned.

socketFile descriptor of the connection
viaListener socket that this user connected to
clientThe IP address and client port of the user
serverThe server IP address and port used by the user

◆ DoBackgroundUserStuff()

void UserManager::DoBackgroundUserStuff ( )

Perform background user events for all local users such as PING checks, registration timeouts, penalty management and recvq processing for users who have data in their recvq due to throttling.

This function is called once a second from the mainloop. It is intended to do background checking on all the users, e.g. do ping checks, registration timeouts, etc.

◆ Find()

User * UserManager::Find ( const std::string &  nickuuid)

Find a user by their nickname or UUID. IMPORTANT: You probably want to use FindNick or FindUUID instead of this.

nickuuidThe nickname or UUID of the user to find.
If the user was found then a pointer to a User object; otherwise, nullptr.

◆ FindNick()

User * UserManager::FindNick ( const std::string &  nick)

Find a user by their nickname.

nickThe nickname of the user to find.
If the user was found then a pointer to a User object; otherwise, nullptr.

◆ FindUUID()

User * UserManager::FindUUID ( const std::string &  uuid)

Find a user by their UUID.

uuidThe UUID of the user to find.
If the user was found then a pointer to a User object; otherwise, nullptr.

◆ GetCloneCounts()

const UserManager::CloneCounts & UserManager::GetCloneCounts ( User user) const

Return the number of local and global clones of this user

userThe user to get the clone counts for
The clone counts of this user. The returned reference is volatile - you must assume that it becomes invalid as soon as you call any function other than your own.

◆ GetCloneMap()

const CloneMap& UserManager::GetCloneMap ( ) const

Return a map containing IP addresses and their clone counts

The clone count map

◆ GetLocalUsers()

const LocalList& UserManager::GetLocalUsers ( ) const

Get a list containing all local users

A const list of local users

◆ GetUsers()

user_hash& UserManager::GetUsers ( )

Get a hash map containing all users, keyed by their nickname

A hash map mapping nicknames to User pointers

◆ LocalUserCount()

size_t UserManager::LocalUserCount ( ) const

Return a count of local registered users

The number of registered local users

◆ NextAlreadySentId()

uint64_t UserManager::NextAlreadySentId ( )

Retrieves the next already sent id, guaranteed to be not equal to any user's already_sent field

Next already_sent id

◆ QuitUser()

void UserManager::QuitUser ( User user,
const std::string &  quitreason,
const std::string *  operreason = NULL 

Disconnect a user gracefully. When this method returns the user provided will be quit, but the User object will continue to be valid and will be deleted at the end of the current main loop iteration.

userThe user to remove
quitreasonThe quit reason to show to normal users
operreasonThe quit reason to show to opers, can be NULL if same as quitreason

◆ RegisteredUserCount()

size_t UserManager::RegisteredUserCount ( )

Return a count of fully registered connections on the network

The number of registered users on the network

◆ RehashCloneCounts()

void UserManager::RehashCloneCounts ( )

Rebuild clone counts. Required when <cidr> settings change.

◆ RemoveCloneCounts()

void UserManager::RemoveCloneCounts ( User user)

Remove all clone counts from the user, you should use this if you change the user's IP address after they have registered.

userThe user to remove

◆ ServerNoticeAll()

void UserManager::ServerNoticeAll ( const char *  text,

Send a server notice to all local users

textThe text format string to send
...The format arguments

◆ ServiceCount()

size_t UserManager::ServiceCount ( ) const

Return a count of users on a services servers.

The number of users on services servers.

◆ UnregisteredUserCount()

size_t UserManager::UnregisteredUserCount ( ) const

Return a count of local unregistered (before NICK/USER) users

The number of local unregistered (unknown) connections

Member Data Documentation

◆ all_opers

OperList UserManager::all_opers

Oper list, a vector containing all local and remote opered users

◆ all_services

ServiceList UserManager::all_services

A list of users on services servers.

◆ clientlist

user_hash UserManager::clientlist

Nickname string -> User* map. Contains all users, including unregistered ones.

◆ unregistered_count

size_t UserManager::unregistered_count

Number of unregistered users online right now. (Unregistered means before USER/NICK/dns)

◆ uuidlist

user_hash UserManager::uuidlist

UUID -> User* map. Contains all users, including unregistered ones.

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