annotate mod_log_http/mod_log_http.lua @ 6252:1661f6a74141

Multible community modules: Update Readme diff --git a/mod_admin_blocklist/README.md b/mod_admin_blocklist/README.md --- a/mod_admin_blocklist/README.md +++ b/mod_admin_blocklist/README.md @@ -24,8 +24,9 @@ admin_blocklist_roles = { "prosody:opera # Compatibility Prosody-Version Status - --------------- ------ - trunk* Works - 0.12 Works + -------------- ------ + trunk* Works + 13 Works + 0.12 Works -*as of 2024-12-21 + *as of 2025-06-13 diff --git a/mod_audit/README.md b/mod_audit/README.md --- a/mod_audit/README.md +++ b/mod_audit/README.md @@ -52,6 +52,7 @@ prosodyctl mod_audit user@example.com # Compatibilty -Requires Prosody **trunk** as of 2025-02-11. - -Does not work with Prosody 0.12 or earlier. + Prosody-Version Status + ----- ------ + 13 Works + 0.12 Does not work diff --git a/mod_csi_grace_period/README.md b/mod_csi_grace_period/README.md --- a/mod_csi_grace_period/README.md +++ b/mod_csi_grace_period/README.md @@ -16,9 +16,9 @@ pocket is not the best use of radio time Works with [mod_csi_simple][doc:modules:mod_csi_simple] which is included with Prosody. - ------- -------------- - trunk* Works - 0.12 Works - ------- -------------- + ------- ------- + trunk* Works + 13 Works + 0.12 Works -*as of 2024-10-22 + *as of 2025-06-13 diff --git a/mod_http_upload_external/README.md b/mod_http_upload_external/README.md --- a/mod_http_upload_external/README.md +++ b/mod_http_upload_external/README.md @@ -19,7 +19,6 @@ Implementations * [PHP implementation](https://hg.prosody.im/prosody-modules/raw-file/tip/mod_http_upload_external/share.php) * [Python3+Flask implementation](https://github.com/horazont/xmpp-http-upload) * [Go implementation, Prosody Filer](https://github.com/ThomasLeister/prosody-filer) -* [Go implementation, HMAC File Server](https://github.com/PlusOne/hmac-file-server) * [Perl implementation for nginx](https://github.com/weiss/ngx_http_upload) * [Rust implementation](https://gitlab.com/nyovaya/xmpp-http-upload) @@ -88,9 +87,10 @@ Compatibility ============= Prosody-Version Status - ---------------- -------------------- - trunk Works as of 24-12-12 - 0.12 Works + ---------------- -------------------- + trunk Works as of 25-06-13 + 13 Works + 0.12 Works Implementation ============== diff --git a/mod_muc_moderation/README.md b/mod_muc_moderation/README.md --- a/mod_muc_moderation/README.md +++ b/mod_muc_moderation/README.md @@ -27,10 +27,11 @@ modules_enabled = { # Compatibility - ------- --------------- - trunk Works^[as of 2024-10-22] - 0.12 Works - ------- --------------- + ------- --------------- + trunk Works^[as of 2025-06-13] + 13 Works + 0.12 Works + ------- --------------- ## XEP version diff --git a/mod_s2s_idle_timeout/README.md b/mod_s2s_idle_timeout/README.md --- a/mod_s2s_idle_timeout/README.md +++ b/mod_s2s_idle_timeout/README.md @@ -25,9 +25,10 @@ Compatibility ============= Prosody Version Status - ----------------- ----------- - trunk[^1] Works - 0.12 Works - ----------------- ----------- + ----------------- ----------- + trunk[^1] Works + 13 Works + 0.12 Works + ----------------- ----------- -[^1]: as of 2024-10-22 +[^1]: as of 2025-06-13 diff --git a/mod_s2s_keepalive/README.md b/mod_s2s_keepalive/README.md --- a/mod_s2s_keepalive/README.md +++ b/mod_s2s_keepalive/README.md @@ -34,9 +34,10 @@ Compatibility ============= Prosody Version Status - ----------------- ----------- - trunk[^1] Works - 0.12 Works - ----------------- ----------- + ----------------- ----------- + trunk[^1] Works + 13 Works + 0.12 Works + ----------------- ----------- -[^1]: as of 2024-11-11 +[^1]: as of 2025-06-13
author Menel <menel@snikket.de>
date Fri, 13 Jun 2025 09:53:41 +0200
parents 3bd725430f40
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4977
3bd725430f40 mod_log_http: Undo mistake in 456b9f608fcf
Kim Alvefur <zash@zash.se>
parents: 4317
diff changeset
1 module:set_global();
2700
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local http = require "net.http";
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local codes = require "net.http.codes";
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 local json = require "util.json";
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 local log = assert(io.open(assert(module:get_option_string("log_http_file"), "Please supply log_http_file in the config"), "a+"));
4317
456b9f608fcf mod_log_http: Switch to line buffering (thanks Zash+Ge0rG)
Matthew Wild <mwild1@gmail.com>
parents: 2705
diff changeset
8 log:setvbuf("line");
2700
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 local function append_request(id, req)
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 local headers = {};
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 for k, v in pairs(req.headers) do
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 table.insert(headers, { name = k, value = v });
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 end
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 local queryString = {};
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 if req.query then
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 for _, pair in ipairs(http.formdecode(req.query)) do
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 table.insert(queryString, pair);
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 end
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 end
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 log:write("<<<", json.encode({
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 id = id;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 type = "request";
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 method = req.method;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 url = req.url;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 httpVersion = "HTTP/1.1";
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 cookies = {};
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 headers = headers;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 queryString = queryString;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 postData = req.body and {
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 mimeType = req.headers["Content-Type"];
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 text = req.body;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 } or nil;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 headersSize = -1;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 bodySize = -1;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 }), "\n");
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 end
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 local function append_response(id, resp)
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 local headers = {};
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 for k, v in pairs(resp.headers) do
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 table.insert(headers, { name = k, value = v });
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 end
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 log:write(">>>", json.encode({
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 id = id;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 type = "response";
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 status = resp.code;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 statusText = codes[resp.code];
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 httpVersion = resp.httpversion;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 cookies = {};
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 headers = headers;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 content = resp.body and {
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 size = #resp.body;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 mimeType = resp.headers.content_type;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 text = resp.body;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 } or nil;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 headersSize = -1;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58 bodySize = -1;
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 }), "\n");
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 end
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 module:hook_object_event(http.events, "request", function (event)
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 module:log("warn", "Request to %s!", event.url);
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 append_request(event.request.id, event.request);
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 end);
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 module:hook_object_event(http.events, "request-connection-error", function (event)
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 module:log("warn", "Failed to make request to %s!", event.url);
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 end);
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 module:hook_object_event(http.events, "response", function (event)
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 module:log("warn", "Received response %d from %s!", event.code, event.url);
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73 append_response(event.request.id, event.response);
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 end);
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 function module.unload()
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 log:close();
7a5dae85f26f mod_log_http: Add new module for logging outgoing HTTP request
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 end