# HG changeset patch # User Guus der Kinderen # Date 1704366351 -3600 # Node ID 55b99f593c3af92b4841867d53a65795db31ce0b # Parent c3eeeb96840309bc9c8619edd0af5d827cd8214a mod_pubsub_serverinfo: Disco/info cache TTL should be configurable This module caches the disco/info results of remote domains. This commit introduces a new configuration option that allows an admin to configure the cache expiry duration. diff -r c3eeeb968403 -r 55b99f593c3a mod_pubsub_serverinfo/README.markdown --- a/mod_pubsub_serverinfo/README.markdown Thu Jan 04 11:59:35 2024 +0100 +++ b/mod_pubsub_serverinfo/README.markdown Thu Jan 04 12:05:51 2024 +0100 @@ -41,3 +41,9 @@ is 300 seconds (5 minutes). To change this simply put in the config: pubsub_serverinfo_publication_interval = 180 -- or any other number of seconds + +To detect if remote domains allow their domain name to be included in the data that this module publishes, this module will perform a service +discovery request to each remote domain. To prevent a continuous flood of disco/info requests, the response to these requests is cached. By default, +a cached value will remain in cache for one hour. This duration can be modified by adding this configuration option: + + pubsub_serverinfo_cache_ttl = 1800 -- or any other number of seconds diff -r c3eeeb968403 -r 55b99f593c3a mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua --- a/mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua Thu Jan 04 11:59:35 2024 +0100 +++ b/mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua Thu Jan 04 12:05:51 2024 +0100 @@ -7,6 +7,7 @@ local node = module:get_option(module.name .. "_node") or "serverinfo"; local actor = module.host .. "/modules/" .. module.name; local publication_interval = module:get_option(module.name .. "_publication_interval") or 300; +local cache_ttl = module:get_option(module.name .. "_cache_ttl") or 3600; local opt_in_reports @@ -213,7 +214,7 @@ if feature.attr.var == 'urn:xmpp:serverinfo:0' then opt_in_cache[remoteDomain] = { opt_in = true; - expires = os.time() + 3600; + expires = os.time() + cache_ttl; } return; -- prevent 'false' to be cached, down below. end @@ -222,13 +223,13 @@ end opt_in_cache[remoteDomain] = { opt_in = false; - expires = os.time() + 3600; + expires = os.time() + cache_ttl; } end, function(response) opt_in_cache[remoteDomain] = { opt_in = false; - expires = os.time() + 3600; + expires = os.time() + cache_ttl; } end );