Commit graph

13225 commits

Author SHA1 Message Date
Kim Alvefur
88e969dec2 mod_auth_ldap: Use enum option method 2023-07-18 12:31:29 +02:00
Kim Alvefur
5d673d0620 mod_storage_sql: Use integer config option for cache size
Missed this one, was probably only looking for get_option_number
2023-07-18 11:53:31 +02:00
Kim Alvefur
3b448c4479 mod_storage_sql: Use config enum for 'sqlite_tune' 2023-07-18 11:53:12 +02:00
Kim Alvefur
e1b3be0015 mod_storage_sql: Allow higher precision timestamps in SQLite3
Since it doesn't actually do strict typing :)
2023-07-17 04:52:50 +02:00
Kim Alvefur
a9eddf59a5 Merge 0.12->trunk 2023-07-17 14:57:27 +02:00
Kim Alvefur
683b90f871 util.prosodyctl.check: Hint about the 'external_addresses' config option 2023-07-17 14:56:57 +02:00
Kim Alvefur
1459e9cae9 Merge 0.12->trunk 2023-07-17 14:47:39 +02:00
Kim Alvefur
43c39930c3 util.prosodyctl.check: Validate format of module list options
Should detect things like misplaced settings inside modules_enabled
2023-07-17 14:45:15 +02:00
Kim Alvefur
3f81654a66 util.prosodyctl.check: Get some config options via minimal moduleapi #896
The module API has certain coercion features that are useful.

Fixes traceback reported in #1812 and other duplicates
2023-07-17 14:03:13 +02:00
Kim Alvefur
aaa6b2b4d6 core.moduleapi: Fix min/maxinteger fallback for Lua 5.2
Maybe these should live in util.mathcompat?
2023-07-17 02:32:47 +02:00
Kim Alvefur
fd63cc11c1 mod_http: Fix passing minimum limits in wrong argument position 2023-07-17 02:26:16 +02:00
Kim Alvefur
71ad48095d plugins: Use integer config API with interval specification where sensible
Many of these fall into a few categories:
- util.cache size, must be >= 1
- byte or item counts that logically can't be negative
- port numbers that should be in 1..0xffff
2023-07-17 01:38:54 +02:00
Kim Alvefur
55768509a3 core.moduleapi: Add min/max range support to :get_option_period
To match :get_option_number etc, specifying the allowed interval.

Default is essentially (0, inf].
2023-07-17 00:37:44 +02:00
Kim Alvefur
210f608086 moduleapi: Add :get_option_integer()
Many options in Prosody that are treated as numbers don't make sense as
floats, e.g. sizes and limits measured in bytes.

Simplified implementation based on an earlier attempt dating back to 2020
2023-07-17 00:09:41 +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
1987a7411f plugins: Switch to :get_option_period() for time range options
Improves readability ("1 day" vs 86400) and centralizes validation.
2023-07-16 20:49:33 +02:00
Kim Alvefur
903e945d09 core.moduleapi: Accept boolean false to disable period setting 2023-07-16 21:04:42 +02:00
Kim Alvefur
c8ed05967a core.moduleapi: Log error for unexpected types (booleans?) set as periods 2023-07-16 21:02:24 +02:00
Kim Alvefur
f3aac1a4be core.moduleapi: Turn negative periods or "never" into infinity
As a way to signal that the periodic thing should be disabled, matching
existing mod_mam usage
2023-07-16 21:01:31 +02:00
Kim Alvefur
15a2cec870 core.moduleapi: Improve handling of different types in :get_option_period
Pass positive numbers trough unharmed, parse strings as periods, discard
anything else.
2023-07-16 20:59:27 +02:00
Kim Alvefur
3c4dc9a754 core.moduleapi: Add :get_option_period for parsing time intervals
E.g. for use in mod_mam and others that take an amount of time before
some (usually cleanup) action is taken.
2023-07-16 19:49:12 +02:00
Kim Alvefur
59f9a608fd core.certmanager: Update Mozilla TLS config to version 5.7
Ref https://github.com/mozilla/server-side-tls/issues/285
2023-07-09 21:18:47 +02:00
Kim Alvefur
c82f504f6a mod_pubsub: Send correct jid attribute in disco#items
Fixes use in PEP where the JID does not equal the bare domain.
2023-07-08 18:23:40 +02:00
Kim Alvefur
960f406662 mod_http: Fix error if 'access_control_allow_origins' is set
Because it changes the type of the 'opt_origins' variable from util.set
to the internal _items table so next time an http app is added an error
"attempt to call a nil value (method 'empty')" is triggered.  The value
is not used anywhere else.

Noticed when reviewing uses of the '_items' set property.

Not reported by any users, implying this setting is rarely used.
2023-06-10 12:33:58 +02:00
Kim Alvefur
cbed7dfdf5 util.array: Expose new() on module table
For consistency with other utils.

Consistency is good.
2023-06-10 12:14:12 +02:00
Kim Alvefur
e4d5c15396 util.prosodyctl.check: Fix error where hostname can't be turned into A label
Where gethostname or tohostname returns an invalid name, e.g. containing
underscores or something, to_ascii would reject this and return nil,
which triggers an error in the dns lookup.

Reported by prova2 in the chat, for whom tohostname returned a long name
containing underscores.
2023-05-31 14:08:19 +02:00
Kim Alvefur
20afe7d20d mod_s2s: Add event where resolver for s2sout can be tweaked
Could be used to implement custom connection methods (c.f. mod_onions)
without needing to duplicate the rest of route_to_new_session().

Adds a feature to enable detection since it can be difficult to detect
support for an event otherwise.
2022-08-18 03:26:32 +02:00
Kim Alvefur
8ef7bc2cf4 mod_csi_simple: Disable revert-to-inactive timer when going to active mode
This timer shouldn't kick in in the middle of active mode.
2023-05-01 15:10:32 +02:00
Kim Alvefur
9aecb5cd19 mod_csi_simple: Clear delayed active mode timer on disable
It should not be there afterwards. Noticed that it seems to fire some
time after resumption claiming that the queue size is nil, implying
that it may hold a reference to an expired session somehow.
2023-05-01 14:52:38 +02:00
Kim Alvefur
57c3771614 util.error: Fix error on conversion of invalid error stanza, fix #1805
Error stanzas should have an <error> element, but if you pass a
stanza without one to util.error.from_stanza() it triggers an attempt to
index a nil value, which this patch avoids.

In the conditional, it should be safe to assume error_tag is non-nil
since condition can't have those values then.
2023-04-19 11:32:53 +02:00
Kim Alvefur
506ee45da2 mod_admin_shell: Fix display of remote cert status when expired etc
Looks like autocomplete unhelpfully capitalized this word, but it's
lowercase where it is set in mod_s2s_auth_certs
2023-04-06 17:09:03 +02:00
Matthew Wild
6d8647b333 prosodyctl: Fix using variable content in a format string
This broke if the error message contained a format specified such as '%s'.
2023-04-07 15:54:59 +01:00
Kim Alvefur
d840f27320 mod_smacks: Replace existing watchdog when starting hibernation
There shouldn't be one here but if there is, for some reason, it's
better to close it than have it around to wake up and possibly try to
destroy the session.
2023-04-02 10:40:48 +02:00
Kim Alvefur
3a3d9c6c2c mod_smacks: Fix stray watchdog closing sessions
Unsure exactly how this happens, but sometimes a watchdog appears to
close a session that isn't hibernating, or hasn't hibernating long
enough.
2023-04-02 10:37:44 +02:00
Kim Alvefur
0890b20fbf mod_http: Unhook CORS handlers only if active (fixes #1801) 2023-03-05 15:45:01 +01:00
Kim Alvefur
9c49ca70fd util.prosodyctl.check: Suggest 'http_cors_override' instead of older CORS settings
The cross_domain_* settings were added here prior to http_cors_override
being added back in 17d87fb2312a, so for a time there was no
replacement, but now there is.
2023-02-22 22:27:42 +01:00
Matthew Wild
631a4a3034 Added tag 0.12.3 for changeset 0598d822614f 2023-02-21 10:06:54 +00:00
Matthew Wild
4dcabd36ce mod_websocket: Fire pre-session-close event (fixes #1800)
This event was added in a7c183bb4e64 and is required to make mod_smacks know
that a session was intentionally closed and shouldn't be hibernated (see
fcea4d9e7502).

Because this was missing from mod_websocket's session.close(), mod_smacks
would always attempt to hibernate websocket sessions even if they closed
cleanly.

That mod_websocket has its own copy of session.close() is something to fix
another day (probably not in the stable branch). So for now this commit makes
the minimal change to get things working again.

Thanks to Damian and the Jitsi team for reporting.
2023-02-20 18:10:15 +00:00
Matthew Wild
87ee5a2300 net.http.parser: Fix off-by-one error in chunk parser 2023-02-17 17:01:19 +00:00
Kim Alvefur
67ea0ee50e mod_admin_socket: Return error on unhandled input to prevent apparent freeze
When mod_admin_socket is loaded without mod_admin_shell, attempt to use
`prosodyctl shell` will appear to freeze after any input, since no
response is returned.
2023-02-16 17:20:09 +01:00
Matthew Wild
bc1e51eb83 net.http.server: Add new API to get HTTP request from a connection
This information is sometimes necessary in the context where we have a
connection that we know (or believe to be) associated with an incoming HTTP
request.

For example, it can be used to retrieve the IP address of a request (which may
differ from the IP address of the connection, due to X-Forwarded-For and co).

Thanks to the Jitsi team for highlighting this gap in the API.
2023-02-16 15:59:26 +00:00
Matthew Wild
0fd88a07a4 net.http.parser: Improve handling of responses without content-length
This ensures that we support responses without a content-length header, and
allow streaming them through the streaming handler interface. An example of
such a response would be Server-Sent Events streams.
2023-02-09 22:57:32 +00:00
Matthew Wild
28e3b19ca1 net.http: Add missing log parameter 2023-02-09 22:37:54 +00:00
Matthew Wild
a4556fc67a sessionmanager: Improve logging around session destruction 2023-02-09 15:09:03 +00: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
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
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