mirror of
https://github.com/matrix-construct/construct
synced 2024-09-28 11:48:54 +02:00
modules/net_dns_cache: Fix room creation related; various.
This commit is contained in:
parent
3c556043fd
commit
61d050024f
4 changed files with 33 additions and 30 deletions
|
@ -35,7 +35,7 @@ IRCD_MODULE_EXPORT_DATA
|
||||||
decltype(ircd::m::matrix::module_names)
|
decltype(ircd::m::matrix::module_names)
|
||||||
ircd::m::matrix::module_names
|
ircd::m::matrix::module_names
|
||||||
{
|
{
|
||||||
//"net_dns",
|
"net_dns",
|
||||||
"key_query",
|
"key_query",
|
||||||
"key_server",
|
"key_server",
|
||||||
"identity_pubkey",
|
"identity_pubkey",
|
||||||
|
|
|
@ -40,10 +40,11 @@ AM_LDFLAGS = \
|
||||||
moduledir = @moduledir@
|
moduledir = @moduledir@
|
||||||
|
|
||||||
stats_la_SOURCES = stats.cc
|
stats_la_SOURCES = stats.cc
|
||||||
net_dns_la_SOURCES = net_dns_cache.cc net_dns.cc
|
net_dns_la_SOURCES = net_dns.cc net_dns_cache.cc
|
||||||
net_dns_la_CPPFLAGS = -include $(top_srcdir)/include/ircd/asio.h
|
net_dns_la_CPPFLAGS = -include $(top_srcdir)/include/ircd/asio.h
|
||||||
net_dns_la_CPPFLAGS += $(AM_CPPFLAGS) @BOOST_CPPFLAGS@
|
net_dns_la_CPPFLAGS += $(AM_CPPFLAGS) @BOOST_CPPFLAGS@
|
||||||
net_dns_la_LDFLAGS = $(AM_LDFLAGS) @BOOST_LDFLAGS@
|
net_dns_la_LDFLAGS = $(AM_LDFLAGS) @BOOST_LDFLAGS@
|
||||||
|
net_dns_la_LDFLAGS += -Wl,--no-gnu-unique
|
||||||
console_la_SOURCES = console.cc
|
console_la_SOURCES = console.cc
|
||||||
web_root_la_SOURCES = web_root.cc
|
web_root_la_SOURCES = web_root.cc
|
||||||
web_hook_la_SOURCES = web_hook.cc
|
web_hook_la_SOURCES = web_hook.cc
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
// copyright notice and this permission notice is present in all copies. The
|
// copyright notice and this permission notice is present in all copies. The
|
||||||
// full license for this software is available in the LICENSE file.
|
// full license for this software is available in the LICENSE file.
|
||||||
|
|
||||||
#include <ircd/asio.h>
|
|
||||||
|
|
||||||
namespace ircd::net::dns::cache
|
namespace ircd::net::dns::cache
|
||||||
{
|
{
|
||||||
struct waiter;
|
struct waiter;
|
||||||
|
@ -17,18 +15,9 @@ namespace ircd::net::dns::cache
|
||||||
bool operator==(const waiter &, const waiter &);
|
bool operator==(const waiter &, const waiter &);
|
||||||
bool operator!=(const waiter &, const waiter &);
|
bool operator!=(const waiter &, const waiter &);
|
||||||
|
|
||||||
bool call_waiter(const string_view &, const string_view &, const json::array &, waiter &);
|
|
||||||
size_t call_waiters(const string_view &, const string_view &, const json::array &);
|
|
||||||
void handle(const m::event &, m::vm::eval &);
|
|
||||||
|
|
||||||
bool put(const string_view &type, const string_view &state_key, const records &rrs);
|
|
||||||
bool put(const string_view &type, const string_view &state_key, const uint &code, const string_view &msg);
|
|
||||||
|
|
||||||
void fini();
|
void fini();
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
extern const m::room::id::buf room_id;
|
|
||||||
extern m::hookfn<m::vm::eval &> hook;
|
|
||||||
extern std::list<waiter> waiting;
|
extern std::list<waiter> waiting;
|
||||||
extern ctx::mutex mutex;
|
extern ctx::mutex mutex;
|
||||||
extern ctx::dock dock;
|
extern ctx::dock dock;
|
||||||
|
|
|
@ -10,19 +10,32 @@
|
||||||
|
|
||||||
#include "net_dns.h"
|
#include "net_dns.h"
|
||||||
|
|
||||||
decltype(ircd::net::dns::cache::room_id)
|
namespace ircd::net::dns::cache
|
||||||
ircd::net::dns::cache::room_id
|
|
||||||
{
|
{
|
||||||
"dns", my_host()
|
static bool call_waiter(const string_view &, const string_view &, const json::array &, waiter &);
|
||||||
|
static size_t call_waiters(const string_view &, const string_view &, const json::array &);
|
||||||
|
static void handle(const m::event &, m::vm::eval &);
|
||||||
|
|
||||||
|
static bool put(const string_view &type, const string_view &state_key, const records &rrs);
|
||||||
|
static bool put(const string_view &type, const string_view &state_key, const uint &code, const string_view &msg);
|
||||||
|
|
||||||
|
extern const m::room::id::buf dns_room_id;
|
||||||
|
extern m::hookfn<m::vm::eval &> hook;
|
||||||
|
}
|
||||||
|
|
||||||
|
decltype(ircd::net::dns::cache::dns_room_id)
|
||||||
|
ircd::net::dns::cache::dns_room_id
|
||||||
|
{
|
||||||
|
"dns", m::my_host()
|
||||||
};
|
};
|
||||||
|
|
||||||
decltype(ircd::net::dns::cache::hook)
|
decltype(ircd::net::dns::cache::hook)
|
||||||
ircd::net::dns::cache::hook
|
ircd::net::dns::cache::hook
|
||||||
{
|
{
|
||||||
handle,
|
ircd::net::dns::cache::handle,
|
||||||
{
|
{
|
||||||
{ "_site", "vm.effect" },
|
{ "_site", "vm.effect" },
|
||||||
{ "room_id", string_view{room_id} },
|
{ "room_id", string_view{dns_room_id} },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -153,11 +166,11 @@ try
|
||||||
content.~object();
|
content.~object();
|
||||||
const m::room room
|
const m::room room
|
||||||
{
|
{
|
||||||
room_id
|
dns_room_id
|
||||||
};
|
};
|
||||||
|
|
||||||
if(unlikely(!exists(room)))
|
if(unlikely(!exists(room)))
|
||||||
create(room);
|
create(room, m::me(), "internal");
|
||||||
|
|
||||||
send(room, m::me(), type, state_key, json::object(out.completed()));
|
send(room, m::me(), type, state_key, json::object(out.completed()));
|
||||||
return true;
|
return true;
|
||||||
|
@ -286,13 +299,13 @@ try
|
||||||
content.~object();
|
content.~object();
|
||||||
const m::room room
|
const m::room room
|
||||||
{
|
{
|
||||||
room_id
|
dns_room_id
|
||||||
};
|
};
|
||||||
|
|
||||||
if(unlikely(!exists(room)))
|
if(unlikely(!exists(room)))
|
||||||
create(room);
|
create(room, m::me(), "internal");
|
||||||
|
|
||||||
send(room_id, m::me(), type, state_key, json::object{out.completed()});
|
send(room, m::me(), type, state_key, json::object{out.completed()});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(const http::error &e)
|
catch(const http::error &e)
|
||||||
|
@ -364,7 +377,7 @@ ircd::net::dns::cache::get(const hostport &hp,
|
||||||
|
|
||||||
const m::room::state state
|
const m::room::state state
|
||||||
{
|
{
|
||||||
room_id
|
dns_room_id
|
||||||
};
|
};
|
||||||
|
|
||||||
const m::event::idx &event_idx
|
const m::event::idx &event_idx
|
||||||
|
@ -426,7 +439,7 @@ ircd::net::dns::cache::for_each(const hostport &hp,
|
||||||
|
|
||||||
const m::room::state state
|
const m::room::state state
|
||||||
{
|
{
|
||||||
room_id
|
dns_room_id
|
||||||
};
|
};
|
||||||
|
|
||||||
const m::event::idx &event_idx
|
const m::event::idx &event_idx
|
||||||
|
@ -472,7 +485,7 @@ ircd::net::dns::cache::for_each(const string_view &type,
|
||||||
|
|
||||||
const m::room::state state
|
const m::room::state state
|
||||||
{
|
{
|
||||||
room_id
|
dns_room_id
|
||||||
};
|
};
|
||||||
|
|
||||||
return state.for_each(full_type, [&closure]
|
return state.for_each(full_type, [&closure]
|
||||||
|
@ -690,13 +703,13 @@ try
|
||||||
{
|
{
|
||||||
const m::room room
|
const m::room room
|
||||||
{
|
{
|
||||||
m::create(room_id, m::me(), "internal")
|
m::create(dns_room_id, m::me(), "internal")
|
||||||
};
|
};
|
||||||
|
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
m::log, "Created '%s' for the DNS cache module.",
|
m::log, "Created '%s' for the DNS cache module.",
|
||||||
string_view{room.room_id}
|
string_view{dns_room_id}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch(const std::exception &e)
|
catch(const std::exception &e)
|
||||||
|
@ -704,7 +717,7 @@ catch(const std::exception &e)
|
||||||
log::critical
|
log::critical
|
||||||
{
|
{
|
||||||
m::log, "Creating the '%s' room failed :%s",
|
m::log, "Creating the '%s' room failed :%s",
|
||||||
string_view{room_id},
|
string_view{dns_room_id},
|
||||||
e.what()
|
e.what()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue