0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

ircd:Ⓜ️ Add conf init sequence for m::self related.

This commit is contained in:
Jason Volk 2018-04-22 15:17:07 -07:00
parent f866c9a4de
commit 87bd9bc429
3 changed files with 124 additions and 78 deletions

View file

@ -25,6 +25,8 @@ namespace ircd::m
namespace ircd::m::self
{
struct init;
string_view host();
bool host(const string_view &);
}
@ -39,7 +41,6 @@ namespace ircd::m
extern struct user me;
extern struct room my_room;
extern struct node my_node;
extern struct room control;
inline string_view my_host() { return self::host(); }
inline bool my_host(const string_view &h) { return self::host(h); }
@ -78,12 +79,19 @@ namespace ircd
#include "txn.h"
#include "hook.h"
struct ircd::m::self::init
{
init(const json::object &config);
~init() noexcept;
};
struct ircd::m::init
{
struct modules;
struct listeners;
json::object config;
self::init _self;
keys::init _keys;
dbs::init _dbs;
vm::init _vm;

View file

@ -26,70 +26,6 @@ decltype(ircd::m::listeners)
ircd::m::listeners
{};
//
// my user
//
const ircd::m::user::id::buf
ircd_user_id
{
"ircd", ircd::my_host() //TODO: hostname
};
ircd::m::user
ircd::m::me
{
ircd_user_id
};
//
// my room
//
const ircd::m::room::id::buf
ircd_room_id
{
"ircd", ircd::my_host()
};
ircd::m::room
ircd::m::my_room
{
ircd_room_id
};
//
// my node
//
const ircd::m::node::id::buf
ircd_node_id
{
"", ircd::my_host() //TODO: hostname
};
ircd::m::node
ircd::m::my_node
{
ircd_node_id
};
//
// misc
//
const ircd::m::room::id::buf
control_room_id
{
"control", ircd::my_host()
};
ircd::m::room
ircd::m::control
{
control_room_id
};
//
// init
//
@ -116,6 +52,10 @@ try
{
ircd::conf::config
}
,_self
{
this->config
}
,_keys
{
this->config
@ -271,6 +211,14 @@ ircd::m::init::bootstrap()
"database is empty. I will be bootstrapping it with initial events now..."
);
if(me.user_id.hostname() == "localhost")
log::warning
{
"The ircd.origin is configured to localhost. This is probably not"
" what you want. To fix this now, you will have to remove the "
" database and start over."
};
create(user::users, me.user_id);
create(my_room, me.user_id);
create(me.user_id);
@ -298,18 +246,6 @@ ircd::m::init::bootstrap()
});
}
bool
ircd::m::self::host(const string_view &s)
{
return s == host();
}
ircd::string_view
ircd::m::self::host()
{
return "zemos.net"; //me.user_id.host();
}
ircd::conf::item<std::string>
me_online_status_msg
{
@ -343,6 +279,103 @@ ircd::m::leave_ircd_room()
presence::set(me, "offline", me_offline_status_msg);
}
///////////////////////////////////////////////////////////////////////////////
//
// m/self.h
//
//
// my user
//
ircd::m::user::id::buf
ircd_user_id
{
"ircd", "localhost" // gets replaced after conf init
};
ircd::m::user
ircd::m::me
{
ircd_user_id
};
//
// my room
//
ircd::m::room::id::buf
ircd_room_id
{
"ircd", "localhost" // replaced after conf init
};
ircd::m::room
ircd::m::my_room
{
ircd_room_id
};
//
// my node
//
ircd::m::node::id::buf
ircd_node_id
{
"", "localhost" // replaced after conf init
};
ircd::m::node
ircd::m::my_node
{
ircd_node_id
};
bool
ircd::m::self::host(const string_view &s)
{
return s == host();
}
ircd::string_view
ircd::m::self::host()
{
return me.user_id.host();
}
//
// init
//
ircd::m::self::init::init(const json::object &config)
{
const string_view &origin_name
{
unquote(config.get({"ircd", "origin"}, "localhost"))
};
ircd_user_id = {"ircd", origin_name};
m::me = {ircd_user_id};
ircd_room_id = {"ircd", origin_name};
m::my_room = {ircd_room_id};
ircd_node_id = {"ircd", origin_name};
m::my_node = {ircd_node_id};
if(origin_name == "localhost")
log::warning
{
"The ircd.origin is configured or has defaulted to 'localhost'"
};
}
ircd::m::self::init::~init()
noexcept
{
}
///////////////////////////////////////////////////////////////////////////////
//
// m/keys.h

View file

@ -309,6 +309,11 @@ _first_user_registered(const m::event &event)
if(!content.get<bool>("active"))
return;
join(m::control, user);
const m::room::id::buf control_room_id
{
"!control", m::self::host()
};
join(m::room{control_room_id}, user);
already = true;
}