1
0
Fork 0
mirror of https://github.com/bjc/prosody.git synced 2025-04-06 22:57:38 +03:00
Commit graph

2540 commits

Author SHA1 Message Date
Kim Alvefur
812652818d util.startup: Use prosody. module namespace
Maybe we need some sort of lint for this?
2023-11-24 13:41:21 +01:00
Kim Alvefur
1e6027da6d util.async: Clip long line [luacheck] 2023-11-21 22:18:17 +01:00
Matthew Wild
9f06132513 util.async: Expose default runner function
This is purely for informational purposes, so it's possible to determine
externally whether a runner is using the default runner function (which
executes functions as work items) or a custom runner function.
2023-11-21 18:14:51 +00:00
Matthew Wild
ac680a900e util.async: Record current work item in the runner object
Mostly expected to be useful for debugging purposes.
2023-11-21 18:13:42 +00:00
Matthew Wild
9e43a7742a util.async: Improve debug logging in a few places
Knowing the state of the coroutine as well as the runner state can be helpful.
2023-11-21 18:12:49 +00:00
Matthew Wild
ab26786924 util.async: Export a table of currently-waiting runners
This can be used for debugging and introspection.
2023-11-21 18:11:40 +00:00
Kim Alvefur
e06c97ca52 util.prosodyctl.check: Disable https cert check if http_external_url set
This would indicate that a reverse proxy is used, which gets to be
responsible for that since it probably holds the actual cert.
2023-11-13 09:58:56 +01:00
Kim Alvefur
8dcd20725a util.prosodyctl.check: Check cert for HTTPS if http module enabled 2023-11-13 09:50:06 +01:00
Kim Alvefur
5146db2da0 util.prosodyctl.check: Update conditions for s2s cert checks
The 'anonymous_login' setting is deprecated and prosodyctl check config
will tell you to change it to 'authentication = "internal_hashed"', so
we shouldn't need to care about here anymore.
2023-11-13 09:44:40 +01:00
Kim Alvefur
8d137609a4 util.prosodyctl.check: Simplify conditions for c2s and s2s cert checks
This code is hard to follow and in need of some refactoring.
2023-11-13 09:43:54 +01:00
Kim Alvefur
3619de6000 util.uuid: Add UUIDv7
Allows sorting by id as a substitute for sorting by timestamp since it
has the timestamp in the encoded in the first part, and only things that
happen extremely close together may get out of order by such a sort,
which might not matter.

From draft-ietf-uuidrev-rfc4122bis formerly draft-peabody-dispatch-new-uuid-format
2021-08-15 14:44:21 +02:00
Kim Alvefur
99d2ebb731 util.prosodyctl.check: Try to clarify check for misplaced k=v in modules_enabled (thanks aab and Menel) 2023-11-11 21:33:53 +01:00
Matthew Wild
7dc676faad util.startup: Attempt to bring some order to startup/shutdown with util.fsm 2023-11-07 12:12:18 +00:00
Kim Alvefur
717ea33160 util.prosodyctl.check: Print DANE TLSA records for certificates
Not the prosodyctl check dane I wanted to make but a start.
2023-11-03 23:08:07 +01:00
Kim Alvefur
ab2dcd8007 util.prosodyctl.check: Wrap each check in a function
One small refactor but one huge step in the right direction

Mostly because adding another check would make the line checking for a
valid check exceed the column limit.
2023-11-03 22:16:53 +01:00
Kim Alvefur
94f9295042 util.datamanager: Clean up list index files on purge (i.e. user deletion) 2023-11-02 17:35:10 +01:00
Kim Alvefur
c6b9037235 Merge 0.12->trunk 2023-08-30 11:09:12 +02:00
Kim Alvefur
a1f053229c util.array: Fix new() library function 2023-07-22 16:31:05 +02:00
Kim Alvefur
6aa08d7c58 util.sql: Remove unused String() and Integer() functions
According to MattJ, leftovers from an earlier vision for util.sql
2023-07-22 14:55:27 +02:00
Kim Alvefur
022159d0f0 util.sqlite3: Clean up unused variables
Many leftovers from the earlier version of util.sql this was based on
and cleanup applied there since then.
2023-07-22 14:54:17 +02:00
Kim Alvefur
8cf6d8d959 util.datamanager: Always reset index after list shift
Shifting the index does not work reliably yet, better to rebuild it from
scratch. Since there is minimal parsing involved in that, it should be
more efficient anyway.
2023-07-22 14:02:01 +02:00
Kim Alvefur
e6d0a3e639 util.datamanager: Add way to close indexed list store 2023-07-21 18:30:06 +02:00
Kim Alvefur
cd5b2664be util.datamanager: Close file handle when done using it
It gets closed eventually but at high load they could potentially
lead to reaching FD limits faster.
2023-07-21 18:28:54 +02:00
Kim Alvefur
1312963f73 util.datamanager: Disable blockwise removal
In desperate need of tests
2023-07-21 18:28:16 +02:00
Kim Alvefur
8699c98ad8 util.datamanager: Disable block alignment
Until we have more test coverage. Somehow the index becomes incorrect
after inserting padding, unclear why.
2023-07-21 18:03:22 +02:00
Kim Alvefur
a9eddf59a5 Merge 0.12->trunk 2023-07-17 14:57:27 +02:00
Kim Alvefur
1459e9cae9 Merge 0.12->trunk 2023-07-17 14:47:39 +02:00
Kim Alvefur
c222b08005 util.human.io: Fix stray 'stty' error by only querying width of real ttys
This adds a dependency on a binary and *nix-specific module but then
stty is probably *nix-specific anyway so maybe that's fine.
2023-07-16 21:21:37 +02:00
Kim Alvefur
bb760b1363 util.human.io: Fix pattern in parse_duration() to cover all used letters
Notably 'h' was missing. Awkwardly, 'hour' would result in 'ho' which
was missing from table.
2023-07-16 19:27:18 +02:00
Kim Alvefur
33986e97b7 util.datamanager: Pad list writes to avoid crossing block boundaries
By padding items so that they do not cross block boundaries, it becomes
eaiser to delete whole blocks with fallocate() without cutting items
in half, improving efficiency of such operations.

Since list stores are used for message archives, where the most common
deletion operation would be of the oldest entires, at the top of the
file. With this, all blocks that contain items to be removed could be
deleted without needing to read, delete and write out the whole file.
2023-06-07 00:39:30 +02:00
Kim Alvefur
3346561d43 util.datamanager: Efficiently remove whole blocks to shift lists
Using the new pposix.remove_blocks() it should be very performant to
delete whole sections of a file, given a supporting file system.
2023-07-12 11:45:12 +02:00
Kim Alvefur
50ae2083ca util.datamanager: Add way to efficiently remove first items in a list
Copying data without parsing it should be more performant than parsing
it serializing back.
2023-07-12 11:42:41 +02:00
Kim Alvefur
deecaafbfb util.datamanager: Fix indexing first item if not at the very start
If the first item does not start at position 0 then the index function
produces a phantom first entry covering position zero until where the
real first item starts. When using the index, this would make it either
appear as the first item was missing or cause an off-by-one issue with
remaining items.
2023-07-10 17:19:05 +02:00
Kim Alvefur
5ee4b4e8a6 util.datamanager: Reduce log level of left over debug messages to debug (thanks Trung)
These were mostly 'warn' to make them stand out from the debug noise
2023-07-12 10:24:28 +02:00
Kim Alvefur
96bc5fd439 util.datamanager: Fix missing separator in log line 2023-07-10 17:52:52 +02:00
Kim Alvefur
915ef3a222 util.cache: Pass cache itself to eviction callback
Simplifies access to the cache without moving code around a lot given
the currently common pattern of

	local some_cache = cache.new(size, function(k,v) end)
2023-06-30 22:01:55 +02:00
Kim Alvefur
29b6ed4f0a util.cache: Keep eviction candidate if callback resized to make room
Previously either the old or the new values would be rejected, even if
the cache was resized to allow more items.
2023-06-30 22:01:49 +02:00
Kim Alvefur
af2cf5f188 renamening: Fix newly added imports to use the new namespace 2023-06-18 16:48:56 +02:00
Kim Alvefur
597f3c7f0a util.jsonschema: Remove wrapper function
This was to silence some Teal warning that seems to have gone away.
2023-06-17 17:19:40 +02:00
Kim Alvefur
f0242ae57c util.jsonschema: Silence Teal warnings about utf8 library
Teal worries that we redefine the global.

Also that the fallback was missing type information.
2023-06-17 17:17:44 +02:00
Kim Alvefur
c8b5d7e99a util.jsonschema: Silence Teal warnings about counting items in tables
Teal thinks that these are key-value maps which are always of length
zero, but that is not the case.
2023-06-17 17:12:54 +02:00
Kim Alvefur
21740a1382 util.argparse: Add support for repeatable parameters
These are gathered into arrays
2022-01-05 04:46:27 +01:00
Kim Alvefur
dd37d17425 util.sqlite3: Don't cache prepared statements for one-off queries
The :execute method is mainly used for one-off queries such as creating
tables and indices. There is no need to cache this prepared statement,
as those queries are only done on startup.

Further, prepared statements can't be reused without being reset, so
this was likely broken anyway.
2023-06-10 22:20:26 +02:00
Kim Alvefur
95687d9ddd util.sqlite3: Deduplicate query methods
There were 3 very similar methods:
-   :execute()
-   :execute_query()
-   :execute_update()

The first one returns the prepared statement and is mainly used
internally in the library for CREATE statements.

The later two only really differ in how the results are returned.
Those two are one main method and one small one that only picks out the
iterator.
2023-06-10 22:02:15 +02:00
Kim Alvefur
eaf8765ee9 util.sqlite3: Fix indentation 2023-06-10 22:00:43 +02:00
Kim Alvefur
0d6c625f93 Merge 0.12->trunk 2023-06-10 13:06:05 +02:00
Kim Alvefur
2d69c8c4ea util.datamanager: Halve size of list index
Instead of storing (start, length) tuples, store the offset to the end
of items and derive length using the previous entry.
2021-05-14 05:49:35 +02:00
Kim Alvefur
74ea750bc4 util.datamanager: Add O(1) list indexing with on-disk index
Index file contains offsets and lengths of each item() which allows
seeking directly to each item and reading it without parsing the entire
file.

Also allows tricks like binary search, assuming items have some defined
order.

We take advantage of the 1-based indexing in tables to store a magic
header in the 0 position, so that table index 1 ends up at file index 1.
2021-05-11 02:09:56 +02:00
Kim Alvefur
f3414a43d8 util.serialization: Add a "pretty" preset
This is the config I want 90% of the time when just showing data in the
console or so.
2023-06-09 17:26:38 +02:00
Kim Alvefur
99906e5b9c util.http: Implement parser for RFC 7239 Forwarded header
Standardized and structured replacement for the X-Forwarded-For,
X-Forwarded-Proto set of headers.

Notably, this allows per-hop protocol information, unlike
X-Forwarded-Proto which is always a single value for some reason.
2023-06-03 16:15:52 +02:00