aboutsummaryrefslogtreecommitdiffstats
path: root/util
Commit message (Collapse)AuthorAgeFilesLines
* util.prosodyctl.check: Improve error handling of UDP socket setup (for #1803)origin/0.120.12Matthew Wild45 hours1-4/+14
| | | | Not necessarily a fix, but may give us more information about failure cases.
* util.prosodyctl.cert: Ensure old cert is moved out of the wayKim Alvefur2024-08-301-1/+1
| | | | This should make it visible if the move fails
* util.xtemplate: Fix error on applying each() to zero stanzasKim Alvefur2024-07-111-1/+2
| | | | Backport of 1f93e4f78c53
* prosodyctl check: Warn about invalid domain names in the config fileMatthew Wild2024-03-271-0/+51
| | | | | This ensures that domain names of virtual hosts and components are valid in XMPP, and that they are encoded correctly.
* util.prosodyctl.check: Correct modern replacement for 'disallow_s2s'0.12.4Kim Alvefur2023-08-271-1/+1
| | | | | The code would have suggested adding to modules_enabled instead of modules_disabled
* util.array: Fix new() library functionKim Alvefur2023-07-221-1/+3
| | | | Backport of ffe4adbd2af9 since new was added in the 0.12 branch
* util.prosodyctl.check: Hint about the 'external_addresses' config optionKim Alvefur2023-07-171-0/+5
|
* util.prosodyctl.check: Validate format of module list optionsKim Alvefur2023-07-171-0/+28
| | | | Should detect things like misplaced settings inside modules_enabled
* util.prosodyctl.check: Get some config options via minimal moduleapi #896Kim Alvefur2023-07-171-41/+54
| | | | | | The module API has certain coercion features that are useful. Fixes traceback reported in #1812 and other duplicates
* util.array: Expose new() on module tableKim Alvefur2023-06-101-0/+2
| | | | | | For consistency with other utils. Consistency is good.
* util.prosodyctl.check: Fix error where hostname can't be turned into A labelKim Alvefur2023-05-311-4/+5
| | | | | | | | | 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.
* util.error: Fix error on conversion of invalid error stanza, fix #1805Kim Alvefur2023-04-191-1/+1
| | | | | | | | | 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.
* util.prosodyctl.check: Suggest 'http_cors_override' instead of older CORS ↵Kim Alvefur2023-02-221-2/+2
| | | | | | | | 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.
* util.startup: Close state on exit to ensure GC finalizers are calledKim Alvefur2023-01-221-1/+1
| | | | | | | | | | | | | 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.
* util.prosodyctl.shell: Close state on exit to fix saving shell historyKim Alvefur2023-01-221-2/+2
| | | | | | | | | | | | | | | | | | 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.
* prosodyctl check dns: Check for Direct TLS SRV records even if not ↵Kim Alvefur2023-01-141-4/+8
| | | | | | | 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
* Merge 0.11->0.120.12.2Kim Alvefur2022-12-121-1/+5
|\
| * util.stanza: Allow U+7F0.11.14Kim Alvefur2022-11-221-1/+5
| | | | | | | | | | | | | | | | 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().
* | util.json: Accept empty arrays with whitespace (fixes #1782)Matthew Wild2022-11-041-5/+14
| |
* | util.startup: Ensure import() is available in prosodyctl (thanks keyzer)Kim Alvefur2022-10-201-1/+1
| | | | | | | | | | Fixes error in mod_authz_internal due to import() being unavailable as it was only loaded in Prosody proper
* | util.jsonschema: Use same integer/float logic on Lua 5.2 and 5.3Kim Alvefur2022-10-091-2/+2
| | | | | | | | | | Fixes test case type.json:0:1 covering treatment of 1.0 as an integer according to the JSON definition
* | util.jsonschema: Fix Lua 5.2 integer compatKim Alvefur2022-10-091-1/+1
| | | | | | | | | | math.type() is unavailable before Lua 5.3 so this should use the compat function added at the top
* | util.stanza: Return nil instead of nothing (fix test with luassert >=1.9)Kim Alvefur2022-09-151-0/+5
| | | | | | | | | | Due to a change in luassert, a dependency luassert of the Busted test framework, returning nothing is no longer treated as not falsy.
* | luacheck: Shut up (backports 3caff1f93520, ignores module deleted in trunk)Kim Alvefur2022-05-301-2/+2
| |
* | util.datamapper: Improve handling of schemas with non-obvious "type"Kim Alvefur2022-07-081-10/+27
| | | | | | | | | | | | | | | | | | | | | | | | The JSON Schema specification says that schemas are objects or booleans, and that the 'type' property is optional and can be an array. This module previously allowed bare type names as schemas and did not really handle booleans. It now handles missing 'type' properties and boolean 'true' as a schema. Objects and arrays are guessed based on the presence of 'properties' or 'items' field.
* | util.jsonschema: Fix validation to not assume presence of "type" fieldKim Alvefur2022-07-081-135/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MattJ reported a curious issue where validation did not work as expected. Primarily that the "type" field was expected to be mandatory, and thus leaving it out would result in no checks being performed. This was likely caused by misreading during initial development. Spent some time testing against https://github.com/json-schema-org/JSON-Schema-Test-Suite.git and discovered a multitude of issues, far too many to bother splitting into separate commits. More than half of them fail. Many because of features not implemented, which have been marked NYI. For example, some require deep comparisons e.g. when objects or arrays are present in enums fields. Some because of quirks with how Lua differs from JavaScript, e.g. no distinct array or object types. Tests involving fractional floating point numbers. We're definitely not going to follow references to remote resources. Or deal with UTF-16 sillyness. One test asserted that 1.0 is an integer, where Lua 5.3+ will disagree.
* | util.startup: Fix async waiting for last shutdown stepsKim Alvefur2022-06-141-1/+5
| | | | | | | | | | | | | | | | | | | | | | Observed problem: When shutting down prosody would immediately exit after waiting for s2s connections to close, skipping the last cleanup events and reporting the exit reason and code. This happens because prosody.main_thread is in a waiting state and queuing startup.shutdown is dispatched trough the main loop via nexttick, but since the main loop was no longer running at that point it proceeded to the end of the prosody script and exited there.
* | util.prosodyctl.check: Remove now redundant unbound config tweakKim Alvefur2022-05-261-4/+0
| | | | | | | | | | | | | | This is now done in net.unbound itself Turning it back on in the config may still cause the problem of entries there masking the DNS values.
* | util.jsonschema: Lua <5.3 compat here tooKim Alvefur2022-05-091-1/+4
| |
* | util.jsonpointer: Fix Lua <5.3 compatKim Alvefur2022-05-091-1/+5
| |
* | util.jsonpointer: Fix off-by-one in array resolutionKim Alvefur2022-05-081-1/+1
| | | | | | | | | | | | Fixes #1753 Not known to be used anywhere
* | util.prosodyctl.check: turn: Report lack of TURN services as a problem #1749Kim Alvefur2022-05-031-0/+1
| | | | | | | | | | Rationale: It seems unlikely that someone who has not configured any TURN service runs 'prosodyctl check turn' expecting this to be okay.
* | util.argparse: Revise 553c6204fe5b with a different approachMatthew Wild2022-04-251-2/+5
| | | | | | | | | | | | The second return value is (not insensibly) assumed to be an error. Instead of returning a value there in the success case, copy the positional arguments into the existing opts table.
* | util.argparse: Return final 'arg' table with positional arguments for ↵Matthew Wild2022-04-251-2/+2
| | | | | | | | | | | | | | | | convenience This is the same as the input table (which is mutated during processing), but if that table was created on the fly, such as by packing `...` it's convenient if it also gets returned from the parse function.
* | util.prosodyctl: check turn: ensure a result is always returned from a check ↵Matthew Wild2022-04-131-2/+2
| | | | | | | | (thanks eTaurus)
* | util.random: Test whether util.crand works before using it (fix #1734)Kim Alvefur2022-04-021-1/+1
| | | | | | | | | | | | | | | | | | | | util.crand can be configured at compile time to use the Linux getrandom() system call, available from Linux 3.17, but it is still possible to load it with an older kernel lacking that system call, where attempting to use it throws an ENOSYS error. By testing for this on load we can fall back to /dev/urandom in this case.
* | prosodyctl: check config: Report paths of loaded configuration files (fixed ↵Matthew Wild2022-03-281-0/+7
| | | | | | | | #1729)
* | util.startup: Show error for unrecognized arguments passed to 'prosody' ↵Matthew Wild2022-03-211-6/+13
| | | | | | | | (fixes #1722)
* | prosodyctl: check turn: Fail with error if our own address is supplied for ↵Matthew Wild2022-03-191-0/+6
| | | | | | | | the ping test
* | prosodyctl: check config: Skip bare JID components in orphan checkMatthew Wild2022-03-191-1/+1
| |
* | mod_admin_socket: Comment on LuaSocket UNIX compat codeKim Alvefur2022-03-161-0/+6
| | | | | | | | Ref #1717
* | mod_admin_socket: Compat for luasocket prior to unix datagram supportKim Alvefur2022-03-151-0/+3
| | | | | | | | | | | | | | | | | | | | The "socket.unix" module exported only a function before https://github.com/lunarmodules/luasocket/commit/aa1b8cc9bc35e56de15eeb153c899e4c51de82a8 when datagram support was added. Fixes #1717 Thanks rsc and lucas for reporting and testing
* | prosodyctl: check turn: warn about external port mismatches behind NATMatthew Wild2022-03-111-5/+11
| | | | | | | | | | | | | | Some NATs don't preserve port numbers, which can cause the TURN server's reported relay address to be incorrect (the TURN server has no way to predict what the external port is, so it can't be corrected in config like an IP mismatch can).
* | spelling: non-existing mistakes (thanks timeless)0.12.0Kim Alvefur2022-03-071-2/+2
| |
* | Spelling: Fix various spelling mistakes (thanks timeless)Kim Alvefur2022-03-076-8/+8
| | | | | | | | | | | | Words, sometimes I wonder how they even work Maybe I missed something.
* | prosodyctl: check turn: compare correct addresses for relay mismatch ↵Matthew Wild2022-03-051-2/+5
| | | | | | | | detection (thanks Zash)
* | prosodyctl: check turn: Add check for private IP returned from STUN.Matthew Wild2022-03-051-0/+4
| |
* | prosodyctl: check turn: improve warning text to suggest issuesMatthew Wild2022-03-051-1/+5
| |
* | prosodyctl: check turn: fix traceback when server does not provide realm/nonceMatthew Wild2022-03-051-4/+12
| | | | | | | | As coturn when installed out of the box on Debian (because auth isn't enabled?)
* | prosodyctl: check turn: fix formatting of multiple warningsMatthew Wild2022-03-051-2/+3
| |