Mercurial > prosody-hg
comparison plugins/mod_c2s.lua @ 13504:2159a206684e
mod_c2s,mod_s2s: Advertise idle-seconds per XEP-0478
This is the time after liveness checks are performed via the respective
read-timeout event, which by default involves sending a space character
but could be overridden e.g. as is done by mod_smacks.
Only advertised, unsure what we would do with it.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 03 Aug 2024 16:28:59 +0200 |
| parents | 7dc7e2e15b2a |
| children | 750ff9f579e2 |
comparison
equal
deleted
inserted
replaced
| 13503:8b68e8faab52 | 13504:2159a206684e |
|---|---|
| 28 local c2s_timeout = module:get_option_period("c2s_timeout", "5 minutes"); | 28 local c2s_timeout = module:get_option_period("c2s_timeout", "5 minutes"); |
| 29 local stream_close_timeout = module:get_option_period("c2s_close_timeout", 5); | 29 local stream_close_timeout = module:get_option_period("c2s_close_timeout", 5); |
| 30 local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true)); | 30 local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true)); |
| 31 local stanza_size_limit = module:get_option_integer("c2s_stanza_size_limit", 1024*256,10000); | 31 local stanza_size_limit = module:get_option_integer("c2s_stanza_size_limit", 1024*256,10000); |
| 32 | 32 |
| 33 local advertised_idle_timeout = 14*60; -- default in all net.server implementations | |
| 34 local network_settings = module:get_option("network_settings"); | |
| 35 if type(network_settings) == "table" and type(network_settings.read_timeout) == "number" then | |
| 36 advertised_idle_timeout = network_settings.read_timeout; | |
| 37 end | |
| 38 | |
| 33 local measure_connections = module:metric("gauge", "connections", "", "Established c2s connections", {"host", "type", "ip_family"}); | 39 local measure_connections = module:metric("gauge", "connections", "", "Established c2s connections", {"host", "type", "ip_family"}); |
| 34 | 40 |
| 35 local sessions = module:shared("sessions"); | 41 local sessions = module:shared("sessions"); |
| 36 local core_process_stanza = prosody.core_process_stanza; | 42 local core_process_stanza = prosody.core_process_stanza; |
| 37 local hosts = prosody.hosts; | 43 local hosts = prosody.hosts; |
| 128 end | 134 end |
| 129 | 135 |
| 130 local features = st.stanza("stream:features"); | 136 local features = st.stanza("stream:features"); |
| 131 hosts[session.host].events.fire_event("stream-features", { origin = session, features = features, stream = attr }); | 137 hosts[session.host].events.fire_event("stream-features", { origin = session, features = features, stream = attr }); |
| 132 if features.tags[1] or session.full_jid then | 138 if features.tags[1] or session.full_jid then |
| 133 if stanza_size_limit then | 139 if stanza_size_limit or advertised_idle_timeout then |
| 134 features:reset(); | 140 features:reset(); |
| 135 features:tag("limits", { xmlns = "urn:xmpp:stream-limits:0" }) | 141 local limits = features:tag("limits", { xmlns = "urn:xmpp:stream-limits:0" }); |
| 136 :text_tag("max-bytes", string.format("%d", stanza_size_limit)):up(); | 142 if stanza_size_limit then |
| 143 limits:text_tag("max-bytes", string.format("%d", stanza_size_limit)); | |
| 144 end | |
| 145 if advertised_idle_timeout then | |
| 146 limits:text_tag("idle-seconds", string.format("%d", advertised_idle_timeout)); | |
| 147 end | |
| 148 limits:reset(); | |
| 137 end | 149 end |
| 138 send(features); | 150 send(features); |
| 139 else | 151 else |
| 140 if session.secure then | 152 if session.secure then |
| 141 -- Here SASL should be offered | 153 -- Here SASL should be offered |
