2007-01-25 07:40:21 +01:00
|
|
|
/*
|
2007-12-03 17:59:25 +01:00
|
|
|
* charybdis: an advanced ircd.
|
2007-01-25 07:40:21 +01:00
|
|
|
* client.c: Controls clients.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
2007-12-03 17:59:25 +01:00
|
|
|
* Copyright (C) 2007 William Pitcock
|
2016-09-10 21:57:33 +02:00
|
|
|
* Copyright (C) 2016 Charybdis Development Team
|
|
|
|
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
|
2007-01-25 07:40:21 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
2016-09-10 21:57:33 +02:00
|
|
|
#include <boost/asio.hpp>
|
2016-09-11 08:05:38 +02:00
|
|
|
#include <ircd/sock.h>
|
2016-09-13 08:31:05 +02:00
|
|
|
#include "rbuf.h"
|
2016-09-12 23:07:46 +02:00
|
|
|
|
2016-09-23 08:59:24 +02:00
|
|
|
namespace ircd {
|
|
|
|
|
|
|
|
struct client
|
|
|
|
:std::enable_shared_from_this<client>
|
2016-09-11 08:05:38 +02:00
|
|
|
{
|
2016-09-23 08:59:24 +02:00
|
|
|
struct rbuf rbuf;
|
|
|
|
clist::const_iterator clit;
|
|
|
|
std::shared_ptr<struct sock> sock;
|
2016-09-11 08:05:38 +02:00
|
|
|
|
2016-09-23 08:59:24 +02:00
|
|
|
client();
|
|
|
|
client(const client &) = delete;
|
|
|
|
client &operator=(const client &) = delete;
|
|
|
|
~client() noexcept;
|
|
|
|
};
|
2016-09-11 08:05:38 +02:00
|
|
|
|
2016-10-26 11:39:28 +02:00
|
|
|
client *me;
|
2016-09-23 08:59:24 +02:00
|
|
|
std::unique_ptr<db::handle> client_db;
|
|
|
|
clist client_list;
|
2016-09-11 08:05:38 +02:00
|
|
|
|
2016-09-23 08:59:24 +02:00
|
|
|
hook::sequence<client &> h_client_added;
|
|
|
|
|
|
|
|
bool handle_ec_eof(client &);
|
|
|
|
bool handle_ec_cancel(client &);
|
|
|
|
bool handle_ec_success(client &);
|
|
|
|
bool handle_ec(client &, const error_code &);
|
|
|
|
void handle_recv(client &, const error_code &, const size_t);
|
|
|
|
|
|
|
|
} // namespace ircd
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-24 01:08:40 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-09-23 08:59:24 +02:00
|
|
|
client_init::client_init()
|
|
|
|
{
|
|
|
|
client_db.reset(new db::handle("clients"));
|
|
|
|
}
|
|
|
|
|
|
|
|
client_init::~client_init()
|
|
|
|
noexcept
|
|
|
|
{
|
|
|
|
disconnect_all();
|
|
|
|
client_db.reset(nullptr);
|
|
|
|
}
|
|
|
|
|
2016-09-11 08:05:38 +02:00
|
|
|
client::client()
|
|
|
|
{
|
|
|
|
}
|
2016-08-22 03:57:43 +02:00
|
|
|
|
2016-09-11 08:05:38 +02:00
|
|
|
client::~client()
|
|
|
|
noexcept
|
|
|
|
{
|
|
|
|
}
|
2016-08-22 03:57:43 +02:00
|
|
|
|
2016-09-11 08:05:38 +02:00
|
|
|
const clist &
|
|
|
|
ircd::clients()
|
|
|
|
{
|
2016-09-23 08:59:24 +02:00
|
|
|
return client_list;
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
2016-08-22 03:57:43 +02:00
|
|
|
|
2016-09-11 08:05:38 +02:00
|
|
|
std::shared_ptr<client>
|
2016-09-13 02:10:04 +02:00
|
|
|
ircd::add_client(std::shared_ptr<struct sock> sock)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-09-11 08:05:38 +02:00
|
|
|
auto client(add_client());
|
|
|
|
client->sock = std::move(sock);
|
|
|
|
log::info("New client[%s] on local[%s]",
|
|
|
|
string(remote_address(*client)).c_str(),
|
|
|
|
string(local_address(*client)).c_str());
|
|
|
|
|
2016-09-23 08:59:24 +02:00
|
|
|
h_client_added(*client);
|
|
|
|
async_recv_next(*client);
|
2016-09-11 08:05:38 +02:00
|
|
|
return client;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2016-09-11 08:05:38 +02:00
|
|
|
|
|
|
|
std::shared_ptr<client>
|
|
|
|
ircd::add_client()
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-09-11 08:05:38 +02:00
|
|
|
auto client(std::make_shared<client>());
|
2016-09-23 08:59:24 +02:00
|
|
|
client->clit = client_list.emplace(end(client_list), client);
|
2016-09-11 08:05:38 +02:00
|
|
|
return client;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-09-19 01:25:58 +02:00
|
|
|
void
|
2016-09-23 08:59:24 +02:00
|
|
|
ircd::finished(client &client)
|
|
|
|
{
|
|
|
|
const auto p(shared_from(client));
|
|
|
|
client_list.erase(client.clit);
|
|
|
|
log::debug("client[%p] finished. (refs: %zu)", (const void *)p.get(), p.use_count());
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ircd::recv(client &client,
|
|
|
|
char *const &buf,
|
|
|
|
const size_t &max,
|
|
|
|
milliseconds &timeout)
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using std::chrono::duration_cast;
|
|
|
|
|
|
|
|
auto &sock(socket(client));
|
|
|
|
sock.set_timeout(timeout);
|
|
|
|
const auto ret(sock.recv_some(mutable_buffers_1(buf, max)));
|
|
|
|
if(timeout < milliseconds(0))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
sock.timer.cancel();
|
|
|
|
timeout = duration_cast<milliseconds>(sock.timer.expires_from_now());
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
catch(const boost::system::system_error &e)
|
2016-09-19 01:25:58 +02:00
|
|
|
{
|
2016-09-23 08:59:24 +02:00
|
|
|
using namespace boost::system::errc;
|
|
|
|
using boost::asio::error::eof;
|
|
|
|
|
|
|
|
switch(e.code().value())
|
2016-09-19 01:25:58 +02:00
|
|
|
{
|
2016-09-23 08:59:24 +02:00
|
|
|
case success:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case eof:
|
|
|
|
throw disconnected();
|
|
|
|
|
|
|
|
case operation_canceled:
|
|
|
|
if(socket(client).timedout)
|
|
|
|
throw ctx::timeout();
|
|
|
|
else
|
|
|
|
throw ctx::interrupted();
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw error("%s", e.what());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::send(client &client,
|
|
|
|
text_terminate_t,
|
|
|
|
const std::string &text)
|
|
|
|
{
|
|
|
|
send(client, text_terminate, text.c_str(), text.size());
|
|
|
|
}
|
2016-09-19 01:25:58 +02:00
|
|
|
|
2016-09-23 08:59:24 +02:00
|
|
|
void
|
|
|
|
ircd::send(client &client,
|
|
|
|
text_terminate_t,
|
|
|
|
const char *const &text)
|
|
|
|
{
|
|
|
|
send(client, text_terminate, text, strlen(text));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::send(client &client,
|
|
|
|
text_terminate_t,
|
|
|
|
const char *const &text,
|
|
|
|
const size_t &len)
|
|
|
|
{
|
|
|
|
assert(len <= 510);
|
2016-09-19 01:25:58 +02:00
|
|
|
const std::array<const_buffer, 2> buffers
|
|
|
|
{{
|
2016-09-23 08:59:24 +02:00
|
|
|
{ text, len },
|
|
|
|
{ "\r\n", 2 }
|
2016-09-19 01:25:58 +02:00
|
|
|
}};
|
|
|
|
|
|
|
|
auto &sock(socket(client));
|
|
|
|
sock.send(buffers);
|
|
|
|
}
|
|
|
|
|
2016-09-23 08:59:24 +02:00
|
|
|
void
|
|
|
|
ircd::send(client &client,
|
|
|
|
text_raw_t,
|
|
|
|
const std::string &text)
|
|
|
|
{
|
|
|
|
send(client, text_raw, text.c_str(), text.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::send(client &client,
|
|
|
|
text_raw_t,
|
|
|
|
const char *const &text)
|
|
|
|
{
|
|
|
|
send(client, text_raw, text, strlen(text));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::send(client &client,
|
|
|
|
text_raw_t,
|
|
|
|
const char *const &text,
|
|
|
|
const size_t &len)
|
|
|
|
{
|
|
|
|
assert(len <= 512);
|
|
|
|
auto &sock(socket(client));
|
|
|
|
sock.send(const_buffers_1(text, len));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::disconnect_all()
|
|
|
|
{
|
|
|
|
for(auto &client : client_list)
|
|
|
|
disconnect(std::nothrow, *client, dc::RST);
|
|
|
|
}
|
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
bool
|
|
|
|
ircd::disconnect(std::nothrow_t,
|
|
|
|
client &client,
|
|
|
|
const dc &type)
|
|
|
|
noexcept try
|
2016-09-11 08:05:38 +02:00
|
|
|
{
|
2016-09-23 08:59:24 +02:00
|
|
|
if(!client.sock)
|
|
|
|
return true;
|
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
disconnect(client, type);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
return false;
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
void
|
|
|
|
ircd::disconnect(client &client,
|
|
|
|
const dc &type)
|
2016-09-11 08:05:38 +02:00
|
|
|
{
|
2016-09-23 08:59:24 +02:00
|
|
|
auto &sock(socket(client));
|
|
|
|
sock.disconnect(type);
|
2016-09-12 23:07:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ircd::connected(const client &client)
|
|
|
|
noexcept
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return socket(client).sd.is_open();
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
return false;
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-09-23 08:59:24 +02:00
|
|
|
ircd::async_recv_next(client &client)
|
2016-09-13 02:10:04 +02:00
|
|
|
{
|
2016-09-23 08:59:24 +02:00
|
|
|
async_recv_next(client, std::chrono::milliseconds(-1));
|
2016-09-13 02:10:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-09-23 08:59:24 +02:00
|
|
|
ircd::async_recv_next(client &client,
|
|
|
|
const std::chrono::milliseconds &timeout)
|
2015-12-13 00:22:21 +01:00
|
|
|
{
|
2016-09-11 08:05:38 +02:00
|
|
|
using boost::asio::async_read;
|
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
auto &rbuf(client.rbuf);
|
|
|
|
rbuf.reset();
|
2016-09-11 08:05:38 +02:00
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
auto &sock(*client.sock);
|
2016-09-13 02:10:04 +02:00
|
|
|
sock.set_timeout(timeout);
|
2016-09-28 23:17:04 +02:00
|
|
|
async_read(sock.sd, mutable_buffers_1(data(rbuf.buf), size(rbuf.buf)),
|
2016-09-12 23:07:46 +02:00
|
|
|
std::bind(&rbuf::handle_pck, &rbuf, ph::_1, ph::_2),
|
2016-09-11 08:05:38 +02:00
|
|
|
std::bind(&ircd::handle_recv, std::ref(client), ph::_1, ph::_2));
|
2015-12-13 00:22:21 +01:00
|
|
|
}
|
|
|
|
|
2016-09-13 02:10:04 +02:00
|
|
|
void
|
2016-09-23 08:59:24 +02:00
|
|
|
ircd::async_recv_cancel(client &client)
|
2016-09-13 02:10:04 +02:00
|
|
|
{
|
|
|
|
auto &sock(socket(client));
|
|
|
|
sock.sd.cancel();
|
|
|
|
}
|
|
|
|
|
2016-09-11 08:05:38 +02:00
|
|
|
void
|
|
|
|
ircd::handle_recv(client &client,
|
|
|
|
const error_code &ec,
|
|
|
|
const size_t bytes)
|
|
|
|
try
|
|
|
|
{
|
2016-09-13 02:10:04 +02:00
|
|
|
if(!handle_ec(client, ec))
|
2016-09-11 08:05:38 +02:00
|
|
|
return;
|
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
auto &rbuf(client.rbuf);
|
2016-09-13 03:21:24 +02:00
|
|
|
execute(client, rbuf.reel);
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
|
|
|
catch(const std::exception &e)
|
|
|
|
{
|
2016-09-13 02:10:04 +02:00
|
|
|
log::error("client[%s]: error: %s",
|
|
|
|
string(remote_address(client)).c_str(),
|
|
|
|
e.what());
|
|
|
|
|
|
|
|
finished(client);
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-09-13 02:10:04 +02:00
|
|
|
ircd::handle_ec(client &client,
|
|
|
|
const error_code &ec)
|
2016-09-11 08:05:38 +02:00
|
|
|
{
|
|
|
|
using namespace boost::system::errc;
|
|
|
|
using boost::asio::error::eof;
|
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
if(client.rbuf.eptr)
|
|
|
|
std::rethrow_exception(client.rbuf.eptr);
|
2016-09-11 08:05:38 +02:00
|
|
|
|
|
|
|
switch(ec.value())
|
|
|
|
{
|
2016-09-13 02:10:04 +02:00
|
|
|
case success: return handle_ec_success(client);
|
|
|
|
case operation_canceled: return handle_ec_cancel(client);
|
|
|
|
case eof: return handle_ec_eof(client);
|
|
|
|
default: throw boost::system::system_error(ec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ircd::handle_ec_success(client &client)
|
|
|
|
{
|
|
|
|
auto &sock(*client.sock);
|
|
|
|
{
|
|
|
|
error_code ec;
|
|
|
|
sock.timer.cancel(ec);
|
|
|
|
assert(ec == boost::system::errc::success);
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
2016-09-13 00:10:56 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ircd::handle_ec_cancel(client &client)
|
|
|
|
{
|
|
|
|
auto &sock(*client.sock);
|
|
|
|
|
|
|
|
// The cancel can come from a timeout or directly.
|
|
|
|
// If directly, the timer may still needs to be canceled
|
|
|
|
if(!sock.timedout)
|
|
|
|
{
|
|
|
|
error_code ec;
|
|
|
|
sock.timer.cancel(ec);
|
|
|
|
assert(ec == boost::system::errc::success);
|
|
|
|
log::debug("client[%s]: recv canceled", string(remote_address(client)).c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
log::debug("client[%s]: recv timeout", string(remote_address(client)).c_str());
|
|
|
|
finished(client);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ircd::handle_ec_eof(client &client)
|
|
|
|
{
|
|
|
|
log::debug("client[%s]: eof", string(remote_address(client)).c_str());
|
|
|
|
finished(client);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-09-23 08:59:24 +02:00
|
|
|
ircd::execute(client &client,
|
|
|
|
const uint8_t *const &ptr,
|
|
|
|
const size_t &len)
|
2016-09-13 00:10:56 +02:00
|
|
|
{
|
2016-09-23 08:59:24 +02:00
|
|
|
execute(client, line(ptr, len));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::execute(client &client,
|
|
|
|
const std::string &l)
|
|
|
|
{
|
|
|
|
execute(client, line(l));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::execute(client &client,
|
|
|
|
tape &reel)
|
|
|
|
{
|
|
|
|
context([wp(weak_from(client)), &client, &reel]
|
|
|
|
{
|
|
|
|
// Hold the client for the lifetime of this context
|
|
|
|
const life_guard<struct client> lg(wp);
|
|
|
|
|
|
|
|
while(!reel.empty()) try
|
|
|
|
{
|
|
|
|
auto &line(reel.front());
|
|
|
|
const scope pop([&reel]
|
|
|
|
{
|
|
|
|
reel.pop_front();
|
|
|
|
});
|
|
|
|
|
|
|
|
if(line.empty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
auto &handle(cmds::find(command(line)));
|
|
|
|
handle(client, std::move(line));
|
|
|
|
}
|
|
|
|
catch(const std::exception &e)
|
|
|
|
{
|
|
|
|
log::error("vm: %s", e.what());
|
|
|
|
disconnect(client);
|
|
|
|
finished(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
async_recv_next(client);
|
|
|
|
},
|
|
|
|
ctx::DEFER_POST | ctx::SELF_DESTRUCT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::execute(client &c,
|
|
|
|
line line)
|
|
|
|
{
|
|
|
|
if(line.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto &handle(cmds::find(command(line)));
|
|
|
|
handle(c, std::move(line));
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
ircd::string(const ip_port &pair)
|
|
|
|
{
|
|
|
|
std::string ret(64, '\0');
|
|
|
|
ret.resize(snprintf(&ret.front(), ret.size(), "%s:%u",
|
|
|
|
pair.first.c_str(),
|
|
|
|
pair.second));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ircd::ip_port
|
|
|
|
ircd::local_address(const client &client)
|
2016-09-12 23:07:46 +02:00
|
|
|
try
|
2016-09-11 08:05:38 +02:00
|
|
|
{
|
2016-09-12 23:07:46 +02:00
|
|
|
const auto &sock(socket(client));
|
|
|
|
return { local_ip(sock), local_port(sock) };
|
|
|
|
}
|
|
|
|
catch(const std::bad_weak_ptr &)
|
|
|
|
{
|
|
|
|
return { "0.0.0.0"s, 0 };
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ircd::ip_port
|
|
|
|
ircd::remote_address(const client &client)
|
2016-09-12 23:07:46 +02:00
|
|
|
try
|
2016-09-11 08:05:38 +02:00
|
|
|
{
|
2016-09-12 23:07:46 +02:00
|
|
|
const auto &sock(socket(client));
|
|
|
|
return { remote_ip(sock), remote_port(sock) };
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
2016-09-12 23:07:46 +02:00
|
|
|
catch(const std::bad_weak_ptr &)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-09-12 23:07:46 +02:00
|
|
|
return { "0.0.0.0"s, 0 };
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2016-09-11 08:05:38 +02:00
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
sock &
|
|
|
|
ircd::socket(client &client)
|
2016-08-22 03:57:43 +02:00
|
|
|
{
|
2016-09-12 23:07:46 +02:00
|
|
|
if(unlikely(!has_socket(client)))
|
|
|
|
throw std::bad_weak_ptr();
|
2016-09-11 08:05:38 +02:00
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
return *client.sock;
|
|
|
|
}
|
2016-09-11 08:05:38 +02:00
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
const sock &
|
|
|
|
ircd::socket(const client &client)
|
|
|
|
{
|
|
|
|
if(unlikely(!has_socket(client)))
|
|
|
|
throw std::bad_weak_ptr();
|
2016-09-11 08:05:38 +02:00
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
return *client.sock;
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
2016-09-12 23:07:46 +02:00
|
|
|
|
|
|
|
bool
|
|
|
|
ircd::has_socket(const client &client)
|
2016-09-11 08:05:38 +02:00
|
|
|
{
|
2016-09-12 23:07:46 +02:00
|
|
|
return bool(client.sock);
|
2016-08-22 03:57:43 +02:00
|
|
|
}
|
2016-09-11 08:05:38 +02:00
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
std::weak_ptr<client>
|
|
|
|
ircd::weak_from(client &client)
|
2016-09-11 08:05:38 +02:00
|
|
|
{
|
2016-09-12 23:07:46 +02:00
|
|
|
return shared_from(client);
|
2016-09-11 08:05:38 +02:00
|
|
|
}
|
|
|
|
|
2016-09-13 21:39:13 +02:00
|
|
|
std::weak_ptr<const client>
|
|
|
|
ircd::weak_from(const client &client)
|
|
|
|
{
|
|
|
|
return shared_from(client);
|
|
|
|
}
|
|
|
|
|
2016-09-12 23:07:46 +02:00
|
|
|
std::shared_ptr<client>
|
|
|
|
ircd::shared_from(client &client)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-09-12 23:07:46 +02:00
|
|
|
return client.shared_from_this();
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2016-09-13 21:39:13 +02:00
|
|
|
|
|
|
|
std::shared_ptr<const client>
|
|
|
|
ircd::shared_from(const client &client)
|
|
|
|
{
|
|
|
|
return client.shared_from_this();
|
|
|
|
}
|