mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::client: Split client.
This commit is contained in:
parent
f33b369609
commit
9eaf1c80d1
8 changed files with 442 additions and 221 deletions
|
@ -6,6 +6,7 @@
|
||||||
* Copyright (C) 1996-2002 Hybrid Development Team
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
||||||
* Copyright (C) 2002-2004 ircd-ratbox development team
|
* Copyright (C) 2002-2004 ircd-ratbox development team
|
||||||
* Copyright (C) 2005 William Pitcock and Jilles Tjoelker
|
* Copyright (C) 2005 William Pitcock and Jilles Tjoelker
|
||||||
|
* Copyright (C) 2005-2016 Charybdis Development Team
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -25,107 +26,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#define HAVE_IRCD_CLIENT_H
|
#define HAVE_IRCD_CLIENT_H
|
||||||
|
|
||||||
|
#include "client_user.h"
|
||||||
|
#include "client_serv.h"
|
||||||
|
#include "client_mode.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
namespace ircd {
|
|
||||||
namespace client {
|
|
||||||
namespace user
|
|
||||||
{
|
|
||||||
using invites_t = std::set<chan::chan *>;
|
|
||||||
using chans_t = std::map<chan::chan *, chan::membership *>;
|
|
||||||
|
|
||||||
struct user;
|
|
||||||
|
|
||||||
std::string &away(user &);
|
|
||||||
std::string &suser(user &);
|
|
||||||
invites_t &invites(user &);
|
|
||||||
chans_t &chans(user &);
|
|
||||||
}
|
|
||||||
} // namespace client
|
|
||||||
} // namespace ircd
|
|
||||||
|
|
||||||
|
|
||||||
namespace ircd {
|
|
||||||
namespace client {
|
|
||||||
namespace serv
|
|
||||||
{
|
|
||||||
using list = std::list<struct client *>;
|
|
||||||
using user::user;
|
|
||||||
|
|
||||||
struct serv;
|
|
||||||
|
|
||||||
list &users(serv &);
|
|
||||||
list &servers(serv &);
|
|
||||||
|
|
||||||
// who activated this connection
|
|
||||||
std::shared_ptr<struct user> &user(serv &);
|
|
||||||
std::string &by(serv &);
|
|
||||||
|
|
||||||
// capabilities bit-field
|
|
||||||
int &caps(serv &);
|
|
||||||
std::string &fullcaps(serv &);
|
|
||||||
|
|
||||||
struct scache_entry *&nameinfo(serv &);
|
|
||||||
}
|
|
||||||
} // namespace client
|
|
||||||
} // namespace ircd
|
|
||||||
|
|
||||||
|
|
||||||
namespace ircd {
|
|
||||||
namespace client {
|
|
||||||
namespace mode {
|
|
||||||
|
|
||||||
enum mode : uint
|
|
||||||
{
|
|
||||||
SERVNOTICE = 0x0001, // server notices
|
|
||||||
WALLOP = 0x0002, // send wallops to them
|
|
||||||
OPERWALL = 0x0004, // operwalls
|
|
||||||
INVISIBLE = 0x0008, // makes user invisible
|
|
||||||
CALLERID = 0x0010, // block unless caller id's
|
|
||||||
LOCOPS = 0x0020, // show locops
|
|
||||||
SERVICE = 0x0040,
|
|
||||||
DEAF = 0x0080,
|
|
||||||
NOFORWARD = 0x0100, // don't forward
|
|
||||||
REGONLYMSG = 0x0200, // only allow logged in users to msg
|
|
||||||
OPER = 0x1000, // operator
|
|
||||||
ADMIN = 0x2000, // admin on server
|
|
||||||
SSLCLIENT = 0x4000, // using SSL
|
|
||||||
};
|
|
||||||
|
|
||||||
const mode DEFAULT_OPER_UMODES
|
|
||||||
{
|
|
||||||
SERVNOTICE |
|
|
||||||
OPERWALL |
|
|
||||||
WALLOP |
|
|
||||||
LOCOPS
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool
|
|
||||||
is(const mode &mask, const mode &bits)
|
|
||||||
{
|
|
||||||
return (mask & bits) == bits;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
|
||||||
set(mode &mask, const mode &bits)
|
|
||||||
{
|
|
||||||
mask |= bits;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
|
||||||
clear(mode &mask, const mode &bits)
|
|
||||||
{
|
|
||||||
mask &= ~bits;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace mode
|
|
||||||
} // namespace client
|
|
||||||
|
|
||||||
using umode = client::mode::mode;
|
|
||||||
|
|
||||||
} // namespace ircd
|
|
||||||
|
|
||||||
|
|
||||||
namespace ircd {
|
namespace ircd {
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
|
@ -186,16 +93,6 @@ constexpr auto CIPHERKEYLEN = 64; // 512bit
|
||||||
constexpr auto CLIENT_BUFSIZE = 512; // must be at least 512 bytes
|
constexpr auto CLIENT_BUFSIZE = 512; // must be at least 512 bytes
|
||||||
constexpr auto IDLEN = 10;
|
constexpr auto IDLEN = 10;
|
||||||
|
|
||||||
struct ZipStats
|
|
||||||
{
|
|
||||||
unsigned long long in;
|
|
||||||
unsigned long long in_wire;
|
|
||||||
unsigned long long out;
|
|
||||||
unsigned long long out_wire;
|
|
||||||
double in_ratio;
|
|
||||||
double out_ratio;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct client
|
struct client
|
||||||
{
|
{
|
||||||
rb_dlink_node node;
|
rb_dlink_node node;
|
||||||
|
@ -262,6 +159,16 @@ struct client
|
||||||
~client() noexcept;
|
~client() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ZipStats
|
||||||
|
{
|
||||||
|
unsigned long long in;
|
||||||
|
unsigned long long in_wire;
|
||||||
|
unsigned long long out;
|
||||||
|
unsigned long long out_wire;
|
||||||
|
double in_ratio;
|
||||||
|
double out_ratio;
|
||||||
|
};
|
||||||
|
|
||||||
typedef int SSL_OPEN_CB(client *, int status);
|
typedef int SSL_OPEN_CB(client *, int status);
|
||||||
|
|
||||||
struct LocalUser
|
struct LocalUser
|
||||||
|
@ -695,8 +602,30 @@ parse_as_server(const client &client)
|
||||||
|
|
||||||
/* if target is TS6, use id if it has one, else name */
|
/* if target is TS6, use id if it has one, else name */
|
||||||
|
|
||||||
#define has_id(source) ((source)->id[0] != '\0')
|
inline bool
|
||||||
#define use_id(source) ((source)->id[0] != '\0' ? (source)->id : (source)->name)
|
has_id(const client &client)
|
||||||
|
{
|
||||||
|
return client.id[0] != '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
has_id(const client *const &client)
|
||||||
|
{
|
||||||
|
return has_id(*client);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char *
|
||||||
|
use_id(const client &client)
|
||||||
|
{
|
||||||
|
return has_id(client)? client.id : client.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char *
|
||||||
|
use_id(const client *const &client)
|
||||||
|
{
|
||||||
|
return use_id(*client);
|
||||||
|
}
|
||||||
|
|
||||||
bool is_server(const client &client);
|
bool is_server(const client &client);
|
||||||
inline char *get_id(const client *const &source, const client *const &target)
|
inline char *get_id(const client *const &source, const client *const &target)
|
||||||
{
|
{
|
||||||
|
@ -936,6 +865,12 @@ is_flood_done(const client &client)
|
||||||
return client.flags & flags::FLOODDONE;
|
return client.flags & flags::FLOODDONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator==(const client &a, const client &b)
|
||||||
|
{
|
||||||
|
return &a == &b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* local flags */
|
/* local flags */
|
||||||
|
|
||||||
|
@ -1011,7 +946,10 @@ using client::ZipStats;
|
||||||
using client::LocalUser;
|
using client::LocalUser;
|
||||||
using client::ListClient;
|
using client::ListClient;
|
||||||
|
|
||||||
|
const client::user::user &user(const client::client &client);
|
||||||
client::user::user &user(client::client &client);
|
client::user::user &user(client::client &client);
|
||||||
|
|
||||||
|
const client::serv::serv &serv(const client::client &client);
|
||||||
client::serv::serv &serv(client::client &client);
|
client::serv::serv &serv(client::client &client);
|
||||||
|
|
||||||
} // namespace ircd
|
} // namespace ircd
|
||||||
|
|
89
include/ircd/client_mode.h
Normal file
89
include/ircd/client_mode.h
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Charybdis Development Team
|
||||||
|
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice is present in all copies.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#define HAVE_IRCD_CLIENT_MODE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace ircd {
|
||||||
|
namespace client {
|
||||||
|
namespace mode {
|
||||||
|
|
||||||
|
enum mode : uint
|
||||||
|
{
|
||||||
|
SERVNOTICE = 0x0001, // server notices
|
||||||
|
WALLOP = 0x0002, // send wallops to them
|
||||||
|
OPERWALL = 0x0004, // operwalls
|
||||||
|
INVISIBLE = 0x0008, // makes user invisible
|
||||||
|
CALLERID = 0x0010, // block unless caller id's
|
||||||
|
LOCOPS = 0x0020, // show locops
|
||||||
|
SERVICE = 0x0040,
|
||||||
|
DEAF = 0x0080,
|
||||||
|
NOFORWARD = 0x0100, // don't forward
|
||||||
|
REGONLYMSG = 0x0200, // only allow logged in users to msg
|
||||||
|
OPER = 0x1000, // operator
|
||||||
|
ADMIN = 0x2000, // admin on server
|
||||||
|
SSLCLIENT = 0x4000, // using SSL
|
||||||
|
};
|
||||||
|
|
||||||
|
const mode DEFAULT_OPER_UMODES
|
||||||
|
{
|
||||||
|
SERVNOTICE |
|
||||||
|
OPERWALL |
|
||||||
|
WALLOP |
|
||||||
|
LOCOPS
|
||||||
|
};
|
||||||
|
|
||||||
|
bool is(const mode &mask, const mode &bits);
|
||||||
|
void clear(mode &mask, const mode &bits);
|
||||||
|
void set(mode &mask, const mode &bits);
|
||||||
|
|
||||||
|
} // namespace mode
|
||||||
|
} // namespace client
|
||||||
|
|
||||||
|
// Import `umode` type into ircd:: namespace
|
||||||
|
using umode = client::mode::mode;
|
||||||
|
|
||||||
|
} // namespace ircd
|
||||||
|
|
||||||
|
|
||||||
|
inline void
|
||||||
|
ircd::client::mode::set(mode &mask,
|
||||||
|
const mode &bits)
|
||||||
|
{
|
||||||
|
mask |= bits;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
ircd::client::mode::clear(mode &mask,
|
||||||
|
const mode &bits)
|
||||||
|
{
|
||||||
|
mask &= ~bits;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
ircd::client::mode::is(const mode &mask,
|
||||||
|
const mode &bits)
|
||||||
|
{
|
||||||
|
return (mask & bits) == bits;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
50
include/ircd/client_serv.h
Normal file
50
include/ircd/client_serv.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Charybdis Development Team
|
||||||
|
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice is present in all copies.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#define HAVE_IRCD_CLIENT_SERV_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace ircd {
|
||||||
|
namespace client {
|
||||||
|
namespace serv
|
||||||
|
{
|
||||||
|
using list = std::list<client *>;
|
||||||
|
using user::user;
|
||||||
|
|
||||||
|
struct serv;
|
||||||
|
|
||||||
|
list &users(serv &);
|
||||||
|
list &servers(serv &);
|
||||||
|
|
||||||
|
// who activated this connection
|
||||||
|
std::shared_ptr<struct user> &user(serv &);
|
||||||
|
std::string &by(serv &);
|
||||||
|
|
||||||
|
// capabilities bit-field
|
||||||
|
int &caps(serv &);
|
||||||
|
std::string &fullcaps(serv &);
|
||||||
|
|
||||||
|
struct scache_entry *&nameinfo(serv &);
|
||||||
|
}
|
||||||
|
} // namespace client
|
||||||
|
} // namespace ircd
|
||||||
|
#endif // __cplusplus
|
49
include/ircd/client_user.h
Normal file
49
include/ircd/client_user.h
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Charybdis Development Team
|
||||||
|
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice is present in all copies.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#define HAVE_IRCD_CLIENT_USER_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace ircd {
|
||||||
|
namespace client {
|
||||||
|
namespace user
|
||||||
|
{
|
||||||
|
using invites_t = std::set<chan::chan *>;
|
||||||
|
using chans_t = std::map<chan::chan *, chan::membership *>;
|
||||||
|
|
||||||
|
struct user;
|
||||||
|
|
||||||
|
const std::string &away(const user &);
|
||||||
|
std::string &away(user &);
|
||||||
|
|
||||||
|
const std::string &suser(const user &);
|
||||||
|
std::string &suser(user &);
|
||||||
|
|
||||||
|
const invites_t &invites(const user &);
|
||||||
|
invites_t &invites(user &);
|
||||||
|
|
||||||
|
const chans_t &chans(const user &);
|
||||||
|
chans_t &chans(user &);
|
||||||
|
}
|
||||||
|
} // namespace client
|
||||||
|
} // namespace ircd
|
||||||
|
#endif // __cplusplus
|
126
ircd/client.cc
126
ircd/client.cc
|
@ -25,6 +25,11 @@
|
||||||
|
|
||||||
#define DEBUG_EXITED_CLIENTS
|
#define DEBUG_EXITED_CLIENTS
|
||||||
|
|
||||||
|
using namespace ircd;
|
||||||
|
|
||||||
|
#include "client_user.h"
|
||||||
|
#include "client_serv.h"
|
||||||
|
|
||||||
namespace ircd {
|
namespace ircd {
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
|
@ -84,115 +89,6 @@ static rb_dlink_list abort_list;
|
||||||
using namespace ircd;
|
using namespace ircd;
|
||||||
|
|
||||||
|
|
||||||
struct client::user::user
|
|
||||||
{
|
|
||||||
chans_t chans;
|
|
||||||
invites_t invites;
|
|
||||||
std::string suser;
|
|
||||||
std::string away;
|
|
||||||
|
|
||||||
user(const std::string &suser = {});
|
|
||||||
};
|
|
||||||
|
|
||||||
client::user::user::user(const std::string &suser)
|
|
||||||
:suser(suser)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
client::user::invites_t &
|
|
||||||
client::user::invites(user &user)
|
|
||||||
{
|
|
||||||
return user.invites;
|
|
||||||
}
|
|
||||||
|
|
||||||
client::user::chans_t &
|
|
||||||
client::user::chans(user &user)
|
|
||||||
{
|
|
||||||
return user.chans;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string &
|
|
||||||
client::user::away(user &user)
|
|
||||||
{
|
|
||||||
return user.away;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string &
|
|
||||||
client::user::suser(user &user)
|
|
||||||
{
|
|
||||||
return user.suser;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct client::serv::serv
|
|
||||||
{
|
|
||||||
list users;
|
|
||||||
list servers;
|
|
||||||
|
|
||||||
std::shared_ptr<struct user> user; // who activated this connection
|
|
||||||
std::string by;
|
|
||||||
|
|
||||||
int caps; /* capabilities bit-field */
|
|
||||||
std::string fullcaps;
|
|
||||||
|
|
||||||
struct scache_entry *nameinfo;
|
|
||||||
|
|
||||||
serv();
|
|
||||||
~serv() noexcept;
|
|
||||||
};
|
|
||||||
|
|
||||||
client::serv::serv::serv()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
client::serv::serv::~serv()
|
|
||||||
noexcept
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<struct client::serv::user> &
|
|
||||||
client::serv::user(serv &serv)
|
|
||||||
{
|
|
||||||
return serv.user;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string &
|
|
||||||
client::serv::by(serv &serv)
|
|
||||||
{
|
|
||||||
return serv.by;
|
|
||||||
}
|
|
||||||
|
|
||||||
int &
|
|
||||||
client::serv::caps(serv &serv)
|
|
||||||
{
|
|
||||||
return serv.caps;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string &
|
|
||||||
client::serv::fullcaps(serv &serv)
|
|
||||||
{
|
|
||||||
return serv.fullcaps;
|
|
||||||
}
|
|
||||||
|
|
||||||
client::serv::list &
|
|
||||||
client::serv::users(serv &serv)
|
|
||||||
{
|
|
||||||
return serv.users;
|
|
||||||
}
|
|
||||||
|
|
||||||
client::serv::list &
|
|
||||||
client::serv::servers(serv &serv)
|
|
||||||
{
|
|
||||||
return serv.servers;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct scache_entry *&
|
|
||||||
client::serv::nameinfo(serv &serv)
|
|
||||||
{
|
|
||||||
return serv.nameinfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
client::client::client()
|
client::client::client()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -229,12 +125,24 @@ ircd::user(client::client &client)
|
||||||
return *client.user;
|
return *client.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const client::user::user &
|
||||||
|
ircd::user(const client::client &client)
|
||||||
|
{
|
||||||
|
return *client.user;
|
||||||
|
}
|
||||||
|
|
||||||
client::serv::serv &
|
client::serv::serv &
|
||||||
ircd::serv(client::client &client)
|
ircd::serv(client::client &client)
|
||||||
{
|
{
|
||||||
return *client.serv;
|
return *client.serv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const client::serv::serv &
|
||||||
|
ircd::serv(const client::client &client)
|
||||||
|
{
|
||||||
|
return *client.serv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* init_client
|
* init_client
|
||||||
|
|
96
ircd/client_serv.h
Normal file
96
ircd/client_serv.h
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Charybdis Development Team
|
||||||
|
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice is present in all copies.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace ircd {
|
||||||
|
namespace client {
|
||||||
|
namespace serv {
|
||||||
|
|
||||||
|
struct serv
|
||||||
|
{
|
||||||
|
list users;
|
||||||
|
list servers;
|
||||||
|
|
||||||
|
std::shared_ptr<struct user> user; // who activated this connection
|
||||||
|
std::string by;
|
||||||
|
|
||||||
|
int caps; /* capabilities bit-field */
|
||||||
|
std::string fullcaps;
|
||||||
|
|
||||||
|
struct scache_entry *nameinfo;
|
||||||
|
|
||||||
|
serv();
|
||||||
|
~serv() noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
serv::serv()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
serv::~serv()
|
||||||
|
noexcept
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<struct user> &
|
||||||
|
user(serv &serv)
|
||||||
|
{
|
||||||
|
return serv.user;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string &
|
||||||
|
by(serv &serv)
|
||||||
|
{
|
||||||
|
return serv.by;
|
||||||
|
}
|
||||||
|
|
||||||
|
int &
|
||||||
|
caps(serv &serv)
|
||||||
|
{
|
||||||
|
return serv.caps;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string &
|
||||||
|
fullcaps(serv &serv)
|
||||||
|
{
|
||||||
|
return serv.fullcaps;
|
||||||
|
}
|
||||||
|
|
||||||
|
list &
|
||||||
|
users(serv &serv)
|
||||||
|
{
|
||||||
|
return serv.users;
|
||||||
|
}
|
||||||
|
|
||||||
|
list &
|
||||||
|
servers(serv &serv)
|
||||||
|
{
|
||||||
|
return serv.servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct scache_entry *&
|
||||||
|
nameinfo(serv &serv)
|
||||||
|
{
|
||||||
|
return serv.nameinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace serv
|
||||||
|
} // namespace client
|
||||||
|
} // namespace ircd
|
91
ircd/client_user.h
Normal file
91
ircd/client_user.h
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Charybdis Development Team
|
||||||
|
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice is present in all copies.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace ircd {
|
||||||
|
namespace client {
|
||||||
|
namespace user {
|
||||||
|
|
||||||
|
struct user
|
||||||
|
{
|
||||||
|
chans_t chans;
|
||||||
|
invites_t invites;
|
||||||
|
std::string suser;
|
||||||
|
std::string away;
|
||||||
|
|
||||||
|
user(const std::string &suser = {});
|
||||||
|
};
|
||||||
|
|
||||||
|
user::user(const std::string &suser)
|
||||||
|
:suser(suser)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
invites_t &
|
||||||
|
invites(user &user)
|
||||||
|
{
|
||||||
|
return user.invites;
|
||||||
|
}
|
||||||
|
|
||||||
|
const invites_t &
|
||||||
|
invites(const user &user)
|
||||||
|
{
|
||||||
|
return user.invites;
|
||||||
|
}
|
||||||
|
|
||||||
|
chans_t &
|
||||||
|
chans(user &user)
|
||||||
|
{
|
||||||
|
return user.chans;
|
||||||
|
}
|
||||||
|
|
||||||
|
const chans_t &
|
||||||
|
chans(const user &user)
|
||||||
|
{
|
||||||
|
return user.chans;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string &
|
||||||
|
away(user &user)
|
||||||
|
{
|
||||||
|
return user.away;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &
|
||||||
|
away(const user &user)
|
||||||
|
{
|
||||||
|
return user.away;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string &
|
||||||
|
suser(user &user)
|
||||||
|
{
|
||||||
|
return user.suser;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &
|
||||||
|
suser(const user &user)
|
||||||
|
{
|
||||||
|
return user.suser;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace user
|
||||||
|
} // namespace client
|
||||||
|
} // namespace ircd
|
|
@ -608,7 +608,7 @@ register_local_user(client::client *client_p, client::client *source_p)
|
||||||
set_client(*source_p);
|
set_client(*source_p);
|
||||||
|
|
||||||
source_p->servptr = &me;
|
source_p->servptr = &me;
|
||||||
source_p->lnode = users(serv(*source_p)).emplace(end(users(serv(*source_p))), source_p);
|
source_p->lnode = users(serv(*source_p->servptr)).emplace(end(users(serv(*source_p->servptr))), source_p);
|
||||||
|
|
||||||
/* Increment our total user count here */
|
/* Increment our total user count here */
|
||||||
if(++Count.total > Count.max_tot)
|
if(++Count.total > Count.max_tot)
|
||||||
|
|
Loading…
Reference in a new issue