annotate mod_log_http/mod_log_http.lua @ 6224:86989059de5b

:multibe Readme.md: correct prosody 0.13 to 13 diff --git a/mod_muc_anonymize_moderation_actions/README.md b/mod_muc_anonymize_moderation_actions/README.md --- a/mod_muc_anonymize_moderation_actions/README.md +++ b/mod_muc_anonymize_moderation_actions/README.md @@ -34,7 +34,7 @@ Component "muc.example.com" "muc" ------ ---------------------- trunk Works as of 25-05-12 - 0.13 Works + 13 Works 0.12 Works ------ ---------------------- diff --git a/mod_sasl2/README.md b/mod_sasl2/README.md --- a/mod_sasl2/README.md +++ b/mod_sasl2/README.md @@ -32,6 +32,6 @@ This module requires Prosody **trunk** a Prosody Version Status ----------------------- ---------------- trunk as of 2025-05-25 Works - 0.13 Works + 13 Works 0.12 Does not work ----------------------- ---------------- diff --git a/mod_sasl2_bind2/README.md b/mod_sasl2_bind2/README.md --- a/mod_sasl2_bind2/README.md +++ b/mod_sasl2_bind2/README.md @@ -17,5 +17,5 @@ This module depends on [mod_sasl2]. It e Prosody-Version Status --------------- ---------------------- trunk Works as of 2025-05-25 - 0.13 Works + 13 Works 0.12 Does not work diff --git a/mod_sasl2_fast/README.md b/mod_sasl2_fast/README.md --- a/mod_sasl2_fast/README.md +++ b/mod_sasl2_fast/README.md @@ -34,5 +34,5 @@ clients being logged out unexpectedly. Prosody-Version Status --------------- ---------------------- trunk Works as of 2025-05-25 - 0.13 Work + 13 Work 0.12 Does not work diff --git a/mod_sasl2_sm/README.md b/mod_sasl2_sm/README.md --- a/mod_sasl2_sm/README.md +++ b/mod_sasl2_sm/README.md @@ -18,5 +18,5 @@ configuration options. Prosody-Version Status --------------- ---------------------- trunk Works as of 2025-05-25 - 0.13 Work + 13 Work 0.12 Does not work diff --git a/mod_sasl_ssdp/README.md b/mod_sasl_ssdp/README.md --- a/mod_sasl_ssdp/README.md +++ b/mod_sasl_ssdp/README.md @@ -21,5 +21,5 @@ There are no configuration options for t Prosody-Version Status --------------- ---------------------- trunk Works as of 2025-05-25 - 0.13 Works + 13 Works 0.12 Does not work diff --git a/mod_vcard_muc/README.md b/mod_vcard_muc/README.md --- a/mod_vcard_muc/README.md +++ b/mod_vcard_muc/README.md @@ -23,7 +23,7 @@ modules_enabled = { # Compatibility ------------------------- ---------------------------------------- - 0.13 Room avatar feature included in Prosody + 13 Room avatar feature included in Prosody 0.12 Works ------------------------- ---------------------------------------- diff --git a/mod_warn_legacy_tls/README.md b/mod_warn_legacy_tls/README.md --- a/mod_warn_legacy_tls/README.md +++ b/mod_warn_legacy_tls/README.md @@ -44,5 +44,5 @@ legacy_tls_versions = { "TLSv1", "TLSv1. Prosody-Version Status --------------- --------------------- trunk Works as of 25-05-25 -0.13 Works +13 Works 0.12 Works
author Menel <menel@snikket.de>
date Wed, 14 May 2025 23:32:04 +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