Mercurial > prosody-hg
annotate plugins/mod_http_altconnect.lua @ 14024:f65302ea37b0 13.0 13.0.3
mod_limits: Allow configuration of general 's2s' limit, and have s2sout inherit from s2sin
Most people don't currently have a limit set for s2sout, as usually such
sessions don't have significant incoming traffic. However, having limits in
place is still sensible, especially with the rising use of bidi.
The goal here is to switch people to a general 's2s' limit, which s2sin and
s2sout both inherit from. Due to the widespread existence of 's2sin' in
existing configurations, s2sout will inherit from that unless explicitly set.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 05 Jan 2026 11:35:32 +0000 |
| parents | 569fae28a2f3 |
| children |
| rev | line source |
|---|---|
|
13718
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 -- mod_http_altconnect |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 -- XEP-0156: Discovering Alternative XMPP Connection Methods |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 module:depends"http"; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 local mm = require "prosody.core.modulemanager"; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 local json = require"prosody.util.json"; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 local st = require"prosody.util.stanza"; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 local array = require"prosody.util.array"; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 local advertise_bosh = module:get_option_boolean("advertise_bosh", true); |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 local advertise_websocket = module:get_option_boolean("advertise_websocket", true); |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 local function get_supported() |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 local uris = array(); |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 if advertise_bosh and (mm.is_loaded(module.host, "bosh") or mm.is_loaded("*", "bosh")) then |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 uris:push({ rel = "urn:xmpp:alt-connections:xbosh", href = module:http_url("bosh", "/http-bind") }); |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 end |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 if advertise_websocket and (mm.is_loaded(module.host, "websocket") or mm.is_loaded("*", "websocket")) then |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 uris:push({ rel = "urn:xmpp:alt-connections:websocket", href = module:http_url("websocket", "xmpp-websocket"):gsub("^http", "ws") }); |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 end |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 return uris; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 end |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 local function GET_xml(event) |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 local response = event.response; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 local xrd = st.stanza("XRD", { xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0' }); |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 local uris = get_supported(); |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 for _, method in ipairs(uris) do |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 xrd:tag("Link", method):up(); |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 end |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 response.headers.content_type = "application/xrd+xml" |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 response.headers.access_control_allow_origin = "*"; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 return '<?xml version="1.0" encoding="UTF-8"?>' .. tostring(xrd); |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 end |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 local function GET_json(event) |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 local response = event.response; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 local jrd = { links = get_supported() }; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 response.headers.content_type = "application/json" |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 response.headers.access_control_allow_origin = "*"; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 return json.encode(jrd); |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 end; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 module:provides("http", { |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 default_path = "/.well-known"; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 route = { |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 ["GET /host-meta"] = GET_xml; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 ["GET /host-meta.json"] = GET_json; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 }; |
|
569fae28a2f3
mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 }); |
