Commit graph

12980 commits

Author SHA1 Message Date
Matthew Wild
a4556fc67a sessionmanager: Improve logging around session destruction 2023-02-09 15:09:03 +00:00
Kim Alvefur
1ea488deee util.crypto: Preemptively silence 'strict-prototypes' warning
With `gcc-12 -Wstrict-prototypes` the following warning is shown:

crypto.c:43:13: warning: function declaration isn't a prototype [-Wstrict-prototypes]
   43 | static BIO* new_memory_BIO() {
      |             ^~~~~~~~~~~~~~
2023-01-31 16:27:55 +01:00
Kim Alvefur
3605137656 mod_storage_sql: Remove module status on unknown 'debug' level
Expected this to be translated to 'core', but it logs an error instead.
See previous commit.
2023-01-31 07:52:33 +01:00
Kim Alvefur
d90a094949 core.moduleapi: Fix passing variable to logging 2023-01-31 07:48:21 +01:00
Kim Alvefur
89f652ff0b mod_storage_sql: Silence luacheck warning 2023-01-30 00:40:47 +01:00
Kim Alvefur
0147b972e0 mod_storage_sql: Record connection to database as module status
Allows retrieving this in e.g. a health reporting module

Thanks pfak
2023-01-30 00:38:26 +01:00
Kim Alvefur
dc958f1e40 mod_admin_shell: Match substring in muc:affiliations() like muc:occupants()
Maybe one day we'll get consistent filtering semantics everywhere.
2023-01-30 00:14:50 +01:00
Kim Alvefur
1b71a53fb7 mod_admin_shell: Sort MUC users by relation and JID
Suggested by MattJ, our resident UI expert :)
2023-01-29 21:37:13 +01:00
Kim Alvefur
5c676bab58 mod_admin_shell: Make Role and Affiliation columns the same width for aesthetics
The length of the title "Affiliation" made them both close enough that
it looked off.
2023-01-29 18:57:28 +01:00
Kim Alvefur
6e120ad485 mod_admin_shell: Use tables to present MUC users
Tables are awesome!
2023-01-29 18:31:25 +01:00
Kim Alvefur
d5b5b5ba86 mod_admin_shell: Factor out room retrieval into common function
Justification: See diffstat
2023-01-29 17:55:56 +01:00
Kim Alvefur
08a730746c mod_admin_shell: Add muc:affiliations(room) command to list memberships
Easier than going trough muc:room():each_affiliation() since you have to
do fiddly things to reach the print() function.
2023-01-29 17:53:21 +01:00
Kim Alvefur
2b0584d2ee mod_admin_shell: Add muc:occupants(room) command to list occupants
Easier than going trough muc:room():each_occupant() since you have to do
fiddly things to reach the print() function.
2023-01-29 17:41:08 +01:00
Kim Alvefur
9228a851bc Merge 0.12->trunk 2023-01-22 15:43:44 +01:00
Kim Alvefur
435e008568 util.startup: Close state on exit to ensure GC finalizers are called
Ensures a last round of garbage collection and that finalizers are
called. Fixes things like proper closing of SQLite3 state.

There are more calls to os.exit() but most of them exit with an error or
in a case where a final GC sweep might not matter as much.

It would be nice if this was the default.

Calling util.statup.exit() everywhere may be sensible, but would be more
involved, requiring imports everywhere.
2023-01-22 14:45:47 +01:00
Kim Alvefur
7c302e9c4c util.prosodyctl.shell: Close state on exit to fix saving shell history
This ensures a last round of garbage collection and finalizers, which
should include flushing the readline history file.

Test procedure:
```
$ ./prosodyctl shell
prosody> s2s:show() -- any command that is not the last in history
... output
prosody> bye
$ ./prosodyctl shell
prosody> ^P
```

After this, the shell prompt should contain the last command from before
the "bye". Before this patch, recent history is gone most of the time.
2023-01-22 14:42:07 +01:00
Kim Alvefur
27d63ff731 mod_muc_mam: Use higher precision timestamps
See also 781772c8b6d9
2023-01-21 17:24:45 +01:00
Kim Alvefur
dbbde4a0f0 Merge 0.12->trunk 2023-01-21 17:18:16 +01:00
Kim Alvefur
81fd03356f mod_muc_mam: Copy "include total" behavior from mod_mam
Not sure why this was missing from MUC MAM, it already had some of the
code for dealing with it.
2023-01-21 17:14:55 +01:00
Kim Alvefur
d0321442c9 mod_muc_mam: Add mam#extended form fields #1796 (Thanks Rain)
Oversight in cabb022f31c0
2023-01-21 17:09:22 +01:00
Kim Alvefur
4830568435 mod_mam,mod_muc_mam: Minimize differences (reorder, copy some comments)
Should have no functional difference, but makes it easier keeping
mod_mam and mod_muc_mam in sync.
2023-01-21 16:54:43 +01:00
Kim Alvefur
2a5953f569 util.dnsregistry: Remove unintentional 'Unassigned' record 2023-01-20 23:40:54 +01:00
Kim Alvefur
45579e5609 tools/dnsregistry: Fix to ignore unassigned entries 2023-01-20 23:39:39 +01:00
Kim Alvefur
0aae39f660 MUC: Add note about non-existant room method 2023-01-20 19:47:00 +01:00
Kim Alvefur
2e44f8260b util.struct: Fix typo in comment 2023-01-20 18:19:34 +01:00
Kim Alvefur
b15a8e1360 mod_admin_socket: Fix typo in comments
Introduced in 6966026262f4
2023-01-20 18:16:10 +01:00
Kim Alvefur
d616d70f3c core.sessionmanager: Mark session as destroyed to prevent reentry
If it reaches this point, then the session will be most definitely be
destroyed, so try to prevent destroy_session() from being called again.
2023-01-19 21:40:09 +01:00
Kim Alvefur
b89b219406 core.sessionmanager: Skip log when (not) destroying destroyed sessions
On regular disconnects, </stream> is sent, then
sessionmanager.destroy_session() is called, then
sessionmanager.destroy_session() is called again when the TCP connection
is closed, from ondisconnect in mod_c2s.

It is a bit annoying and doesn't really tell you much.
2023-01-19 21:38:14 +01:00
Kim Alvefur
762e56920b Merge 0.12->trunk 2023-01-19 21:14:31 +01:00
Kim Alvefur
67b6440d9b mod_smacks: Log something when hibernation starts
Will hopefully save future confusion about sessions being destroyed when
they are in fact not.
2023-01-19 20:59:28 +01:00
Kim Alvefur
66d38cb199 luacheck: Remove long gone mod_storage_sql1 from excludes
No point not checking a file that doesn't exist
2023-01-19 17:29:40 +01:00
Kim Alvefur
c9fb0c2cab prosodyctl check dns: Check for Direct TLS SRV records even if not configured (fix #1793)
Existing such records may cause timeouts or errors in clients and
servers trying to connect, despite prosodyctl check saying all is well
2023-01-14 05:47:47 +01:00
Kim Alvefur
b18280d35f mod_invites: Prefer landing page over xmpp URI in shell command
To mirror behavior of prosodyctl invocation
2023-01-10 21:10:58 +01:00
Kim Alvefur
fe97c773a6 net.http.server: Fix #1789
Unregistering the response before sending the trailer of the chunked
transfer encoding prevents opportunistic writes from being invoked and
running this code again when, which may cause an error when closing the
file handle a second time.

Normally the file size is known, so no chuck headers are sent.
2023-01-08 13:35:04 +01:00
Kim Alvefur
91a064bd49 mod_storage_sql: Fix #1639
Patch by Peter Kieser
2023-01-01 16:20:58 +01:00
Matthew Wild
e853a1652b configure: Fix quoting of $LUA_SUFFIX (thanks shellcheck/Zash)
Transplanted 6b43bf85032b from trunk
2022-12-29 16:29:03 +00:00
Kim Alvefur
2317f6a09f mod_storage_sql: Don't avoid initialization under prosodyctl (fix #1787)
Fixes `prosodyctl adduser` etc.

Prior to d580e6a57cbb the line did nothing.

Sometimes storage in the prosodyctl context does cause weirdness, as it
is not in a host context, but rather a variant of global.
2022-12-29 18:06:35 +01:00
Kim Alvefur
baff85a52c Tag 0.12.2 2022-12-12 20:40:23 +01:00
Kim Alvefur
63fde85044 Merge 0.11->0.12 2022-12-12 07:07:13 +01:00
Kim Alvefur
caf2e27362 Tag 0.11.14 2022-12-12 07:03:31 +01:00
Kim Alvefur
4fa3808e8d util.stanza: Allow U+7F
Allowed by XML despite arguably being a control character.

Drops the part of the range meant to rule out octets invalid in UTF-8
(\247 starts a 4-byte sequence), since UTF-8 correctness is validated by
util.encodings.utf8.valid().
2022-11-22 23:56:01 +01:00
Kim Alvefur
d158455de6 mod_smacks: Disable resumption behavior on s2s
Since resumption is not supported on s2s currently, there is no point in
allocating resumption tokens.  The code that removes entries from
session_registry is only invoked for c2s sessions, thus enabling
resumable smacks on s2s adds an entry that never goes away.
2022-11-13 18:16:59 +01:00
Matthew Wild
d4daf40caa util.json: Accept empty arrays with whitespace (fixes #1782) 2022-11-04 12:26:10 +00:00
Matthew Wild
246d797f81 mod_http: Allow disabling CORS in the http_cors_override option and by default
Fixes #1779.

Due to an oversight in the logic, if the user set 'enabled' to false in an
override, it would disable the item's requested CORS settings, but still apply
Prosody's default CORS policy.

This change ensures that 'enabled = false' will now disable CORS entirely for
the requested item.

Due to the new structure of the code, it was necessary to have a flag to say
whether CORS is to be applied at all. Rather than hard-coding 'true' here, I
chose to add a new option: 'http_default_cors_enabled'. This is a boolean that
allows the operator to disable Prosody's default CORS policy entirely (the one
that is used when a module or config does not override it). This makes it
easier to disable CORS and then selectively enable it only on services you
want it on.
2022-10-31 14:32:02 +00:00
Kim Alvefur
20532df525 mod_admin_shell: Ensure available connection for column 'secure'
Similar to #1777
2022-10-23 16:22:12 +02:00
Kim Alvefur
c51152432a mod_admin_shell: Ensure connection exists to get port from (fixes #1777) 2022-10-23 16:19:39 +02:00
Kim Alvefur
bab0635179 util.startup: Ensure import() is available in prosodyctl (thanks keyzer)
Fixes error in mod_authz_internal due to import() being unavailable as
it was only loaded in Prosody proper
2022-10-20 16:31:18 +02:00
Kim Alvefur
bca11bfc73 util.jsonschema: Use same integer/float logic on Lua 5.2 and 5.3
Fixes test case type.json:0:1 covering treatment of 1.0 as an integer
according to the JSON definition
2022-10-09 15:42:25 +02:00
Kim Alvefur
060dc12013 util.jsonschema: Fix Lua 5.2 integer compat
math.type() is unavailable before Lua 5.3 so this should use the compat
function added at the top
2022-10-09 15:38:36 +02:00
Kim Alvefur
c617f27a54 util.jsonschema: Ignore test case for JavaScript specific detail
Also touching on how arrays are indistinguishable from tables in Lua
2022-10-09 15:24:30 +02:00