Mercurial > prosody-hg
comparison plugins/mod_external_services.lua @ 13911:79ae4821c05e
mod_external_services: Allow custom XML content in service items
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 30 Jun 2025 11:16:52 +0100 |
| parents | 7e6deed12e03 |
| children |
comparison
equal
deleted
inserted
replaced
| 13910:622790951285 | 13911:79ae4821c05e |
|---|---|
| 99 if secret_cb then | 99 if secret_cb then |
| 100 secret_cb(srv, item, secret); | 100 secret_cb(srv, item, secret); |
| 101 srv.restricted = true; | 101 srv.restricted = true; |
| 102 end | 102 end |
| 103 end | 103 end |
| 104 if item.extra and st.is_stanza(item.extra) then | |
| 105 srv.extra = item.extra; | |
| 106 end | |
| 104 return srv; | 107 return srv; |
| 105 end | 108 end |
| 106 | 109 |
| 107 function module.load() | 110 function module.load() |
| 108 -- Trigger errors on startup | 111 -- Trigger errors on startup |
| 147 port = srv.port and string.format("%d", srv.port) or nil; | 150 port = srv.port and string.format("%d", srv.port) or nil; |
| 148 username = srv.username; | 151 username = srv.username; |
| 149 password = srv.password; | 152 password = srv.password; |
| 150 expires = srv.expires and dt.datetime(srv.expires) or nil; | 153 expires = srv.expires and dt.datetime(srv.expires) or nil; |
| 151 restricted = srv.restricted and "1" or nil; | 154 restricted = srv.restricted and "1" or nil; |
| 152 }):up(); | 155 }); |
| 156 if srv.extra then | |
| 157 reply:add_child(srv.extra); | |
| 158 end | |
| 159 reply:up(); | |
| 153 end | 160 end |
| 154 | 161 |
| 155 return reply; | 162 return reply; |
| 156 end | 163 end |
| 157 | 164 |
| 260 local services = get_services(); | 267 local services = get_services(); |
| 261 for _, srv in ipairs(services) do | 268 for _, srv in ipairs(services) do |
| 262 if not service_type or service_type:lower() == srv.type:lower() then | 269 if not service_type or service_type:lower() == srv.type:lower() then |
| 263 c = c + 1; | 270 c = c + 1; |
| 264 print(srv.type.." ("..srv.transport..")", srv.host..(srv.port and (":"..srv.port) or "")); | 271 print(srv.type.." ("..srv.transport..")", srv.host..(srv.port and (":"..srv.port) or "")); |
| 272 print(" auth:", srv.restricted and "required" or "none"); | |
| 265 for _, prop in ipairs({ "username", "password", "expires" }) do | 273 for _, prop in ipairs({ "username", "password", "expires" }) do |
| 266 local val = srv[prop]; | 274 local val = srv[prop]; |
| 267 if val then | 275 if val then |
| 268 if prop == "expires" then | 276 if prop == "expires" then |
| 269 val = dt.datetime(val); | 277 val = dt.datetime(val); |
| 270 end | 278 end |
| 271 print(" "..prop..":", val); | 279 print(" "..prop..":", val); |
| 272 end | 280 end |
| 273 end | 281 end |
| 274 if srv.restricted then | 282 if srv.extra then |
| 275 print(" restricted:", "yes"); | 283 print(" extra:"); |
| 284 print(" "..tostring(srv.extra:indent(3, " "))); | |
| 276 end | 285 end |
| 277 print(""); | 286 print(""); |
| 278 end | 287 end |
| 279 end | 288 end |
| 280 return true, ("%d services"):format(c); | 289 return true, ("%d services"):format(c); |
