Software /
code /
prosody
Diff
core/hostmanager.lua @ 6706:60c692828cf6
hostmanager: Metatable with __tostring on hosts
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 18 May 2015 20:50:50 +0200 |
parent | 6618:469151b08065 |
child | 6721:3807af36d773 |
child | 6779:6236668da30a |
line wrap: on
line diff
--- a/core/hostmanager.lua Fri May 15 15:32:39 2015 +0200 +++ b/core/hostmanager.lua Mon May 18 20:50:50 2015 +0200 @@ -26,9 +26,23 @@ local pairs, select, rawget = pairs, select, rawget; local tostring, type = tostring, type; +local setmetatable = setmetatable; module "hostmanager" +local host_mt = { } +function host_mt:__tostring() + if self.type == "component" then + local typ = configmanager.get(self.host, "component_module"); + if typ == "component" then + return ("Component %q"):format(self.host); + end + return ("Component %q %q"):format(self.host, typ); + elseif self.type == "local" then + return ("VirtualHost %q"):format(self.host); + end +end + local hosts_loaded_once; local function load_enabled_hosts(config) @@ -76,6 +90,7 @@ send = host_send; modules = {}; }; + setmetatable(host_session, host_mt); if not host_config.component_module then -- host host_session.type = "local"; host_session.sessions = {};