Software /
code /
prosody
Comparison
plugins/mod_admin_shell.lua @ 13108:6cd768e6ac7c
mod_admin_shell: Show internal URL in addition to external in http:list
To help with configuring reverse proxies.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 24 May 2023 14:49:29 +0200 |
parent | 13105:7d9e26003b05 |
child | 13117:7eb6244b4984 |
comparison
equal
deleted
inserted
replaced
13107:9c4dc1e6d2c9 | 13108:6cd768e6ac7c |
---|---|
1835 | 1835 |
1836 function def_env.http:list(hosts) | 1836 function def_env.http:list(hosts) |
1837 local print = self.session.print; | 1837 local print = self.session.print; |
1838 hosts = array.collect(set.new({ not hosts and "*" or nil }) + get_hosts_set(hosts)):sort(_sort_hosts); | 1838 hosts = array.collect(set.new({ not hosts and "*" or nil }) + get_hosts_set(hosts)):sort(_sort_hosts); |
1839 local output = format_table({ | 1839 local output = format_table({ |
1840 { title = "Module", width = "20%" }, | 1840 { title = "Module"; width = "1p" }; |
1841 { title = "URL", width = "80%" }, | 1841 { title = "URL"; width = "3p" }; |
1842 }, self.session.width); | 1842 { title = "Internal URL"; width = "3p" }; |
1843 }, self.session.width); | |
1843 | 1844 |
1844 for _, host in ipairs(hosts) do | 1845 for _, host in ipairs(hosts) do |
1845 local http_apps = modulemanager.get_items("http-provider", host); | 1846 local http_apps = modulemanager.get_items("http-provider", host); |
1846 if #http_apps > 0 then | 1847 if #http_apps > 0 then |
1847 local http_host = module:context(host):get_option_string("http_host"); | 1848 local http_host = module:context(host):get_option_string("http_host"); |
1851 print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":")); | 1852 print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":")); |
1852 end | 1853 end |
1853 print(output()); | 1854 print(output()); |
1854 for _, provider in ipairs(http_apps) do | 1855 for _, provider in ipairs(http_apps) do |
1855 local mod = provider._provided_by; | 1856 local mod = provider._provided_by; |
1856 local url = module:context(host):http_url(provider.name, provider.default_path); | 1857 local external = module:context(host):http_url(provider.name, provider.default_path); |
1858 local internal = module:context(host):http_url(provider.name, provider.default_path, "internal"); | |
1859 if external==internal then internal="" end | |
1857 mod = mod and "mod_"..mod or "" | 1860 mod = mod and "mod_"..mod or "" |
1858 print(output{mod, url}); | 1861 print(output{mod, external, internal}); |
1859 end | 1862 end |
1860 print(""); | 1863 print(""); |
1861 end | 1864 end |
1862 end | 1865 end |
1863 | 1866 |