0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00
construct/modules
2018-10-24 18:08:46 -07:00
..
client modules/client/publicrooms: Update endpoint for server and pagination keying. 2018-10-24 18:08:46 -07:00
federation modules/federation/query: Fix directory query for room_id. 2018-10-17 10:09:05 -07:00
js ircd::m/modules: Update various client listeners w/ callback. 2018-07-06 18:40:15 -07:00
key ircd::m/modules/key: Various reorg / modularization. 2018-08-17 12:51:49 -07:00
media modules/media/media: Add some bloom on blocks table. 2018-10-16 09:13:53 -07:00
console.cc modules/console: Add console cmd to iterate public rooms via interface. 2018-10-24 17:31:22 -07:00
m_event.cc modules/m_event: Add modules; move pretty() suite out of ircd:Ⓜ️:. 2018-09-04 20:27:30 -07:00
m_noop.cc Update Copyrastafaris. 2018-02-05 21:24:34 -08:00
m_presence.cc modules/vm: Add eval argument to various hooks; tweak eval struct. 2018-09-13 19:49:25 -07:00
m_receipt.cc modules/vm: Add eval argument to various hooks; tweak eval struct. 2018-09-13 19:49:25 -07:00
m_room.cc ircd:Ⓜ️ Add central interface for room state prefetch; add console cmd; apply to client sync. 2018-10-23 10:01:36 -07:00
m_room_aliases.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
m_room_canonical_alias.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
m_room_create.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
m_room_history_visibility.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
m_room_join_rules.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
m_room_member.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
m_room_message.cc modules/m_room_message: Show event_id in infolog string. 2018-10-17 22:00:50 -07:00
m_room_power_levels.cc modules: Start an m.room.power_levels protocol module. 2018-10-24 12:01:56 -07:00
m_rooms.cc ircd:Ⓜ️:rooms: Retype and rekey the state in !public organized by server. 2018-10-24 17:31:22 -07:00
m_typing.cc modules/m_typing: Minor cleanup. 2018-09-17 08:09:15 -07:00
m_user.cc modules/client/user: Move user create to m_user. 2018-10-23 13:22:08 -07:00
Makefile.am modules: Start an m_rooms unit; move publicrooms summary chunk generation. 2018-10-24 17:31:21 -07:00
README.md modules/README: Remove stale information from the modules README. 2018-09-13 23:59:15 -07:00
s_conf.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
s_control.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
s_dns.cc modules/s_dns: Simplify/breakdown callback stack related. 2018-10-03 14:33:53 -07:00
s_dns.h modules/s_dns_cache: Abstract templates for cache related; minor reorg. 2018-10-03 15:55:01 -07:00
s_dns_cache.cc modules/s_dns_cache: Abstract templates for cache related; minor reorg. 2018-10-03 15:55:01 -07:00
s_dns_resolver.cc modules/s_dns_resolver: Improve the worker shutdown process and related. 2018-10-23 12:25:57 -07:00
s_dns_resolver.h modules/s_dns_resolver: Improve the worker shutdown process and related. 2018-10-23 12:25:57 -07:00
s_fetch.cc modules: Rename vm_fetch to s_fetch. 2018-10-23 09:13:48 -07:00
s_fetch.h modules: Rename vm_fetch to s_fetch. 2018-10-23 09:13:48 -07:00
s_keys.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
s_listen.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
s_node.cc ircd:Ⓜ️ Rename most vm.notify hooks to vm.effect; Refactor vm::accept related. 2018-10-09 20:56:12 -07:00
vm.cc ircd:Ⓜ️:vm: Add more options for fine-grained hook call control during eval. 2018-10-11 01:30:31 -07:00
webroot.cc modules/webroot: Make webroot path a conf item. 2018-09-03 04:45:07 -07:00

IRCd Module Tree

This directory contains dynamically loadable functionality to libircd. These modules are not mere extensions -- they provide essential application functionality, but are not required to be directly linked in libircd proper. Most application-specific functionality (i.e "business logic") is contained in modules within this tree. At the time of this writing, a significant amount of matrix functionality is still contained within libircd proper, but it is intended that as many definitions as possible are pushed out into modules.

Layout

The modules/ directory is primarily shaped the same as the HTTP resource tree in which most of its modules register themselves in. This is not automatic and the mere inclusion of files/directories in modules/ does not automatically expose them over HTTP.

Note that the installation layout is not the same as the development source layout (i.e in git). Upon installation, the module tree is collapsed into a single directory and installed into $prefix/lib/modules/construct/$directory_$module.so; this may be subject to improvement.

  • client/ contains resource handlers for the /_matrix/client/ API
  • federation/ contains resource handlers for the /_matrix/federation/ API
  • key/ contains resource handlers for the /_matrix/key/ API
  • media/ contains resource handlers for the /_matrix/media/ API
  • js/ contains modules specific to the unreleased javascript embedding.
  • s_ modules provide utility to the server's operation.
  • m_ modules implement protocol logic for matrix event types.
  • vm_ modules provide the processing logic for matrix events.

Loading

Modules may be automatically loaded based on their prefix. Certain prefixes are sought by libircd for auto-loading, arbitrarily (i.e there is no magic autoloading prefix; see: ircd/m/m.cc for explicit prefixes). A module may also be loaded when an attempt is made to call into it (i.e with m::import or low-level with ircd::mods::*). Furthermore, a module may be loaded by the console mod command suite, specifically mod load. Otherwise the module is not loaded.

Unloading

Unlike previous incarnations of IRCd, every module is "unloadable" and there are no "core" modules. All central linkages within libircd (and direct links made by other modules) tolerate the unavailability of a module by using weak-pointers and throwing exceptions. Unlike the Atheme approach as well, linkage into a module does not prevent unloading due to dependency; the unloading of a module is propagated to linksites through the weak_ptr's dependency graph and exceptions are thrown from the link upon next use.

Furthermore, modules are free to leverage the ircd::ctx system to wait synchronously for events which are essential for a clean load or unload, even during static initialization and destruction. This is a useful feature which allows all modules to be robustly loadable and unloadable at any time and every time in an intuitive manner.

No modules in this system "stick" whether by accident or on purpose upon unload. Though we all know that dlclose() does not guarantee a module is actually unloaded, we expend the extra effort to ensure there is no reason why dlclose() would not unload the module. This static destruction of a module is verified and alarms will go off if it is actually "stuck" and the developer must fix this.

Getting started

The header mods/mapi.h is specific to modules and included for modules in addition to the core ircd.h. Both of these are included automatically via the compiler's command-line and the developer does not have to #include either in the module.

Every loadable module requires a static ircd::mapi::header with the explicit name of IRCD_MODULE. This is an object which will be sought by the module loader in libircd. Nothing else is required.

Approach

The ideal module in this system is one that is self-contained in that its only interface is through "registrations" to various facilities provided by libircd. The module can still freely read and write to state within libircd or other modules.

  • An example of such is an HTTP resource (see: ircd/resource.h) registration of a URL to handle incoming HTTP requests.

  • Another example is a Matrix Event Hook (see: ircd/m/hook.h) to process matrix events.

Next is a module providing definitions and making them available through exposition (i.e extern "C"). In this approach, function definitions are provided in the module but a "central interface" may be provided by libircd. That central interface is tolerant of the function call failing when the module is not available (or automatically tries to load it, see: ircd/m/import.h and ircd/mods/*.h etc).

Note that many modules use any of these approaches at the same time.