main.lua

changeset 181
3a9b9c98304a
parent 174
662bd8c5ae28
--- a/main.lua	Thu Mar 23 18:27:22 2023 +0000
+++ b/main.lua	Thu Mar 23 18:28:20 2023 +0000
@@ -21,7 +21,10 @@
 local serve_origin = nil;
 local only_tags, skip_tags;
 
-local property_rules = {};
+local property_rules = {
+	-- Components connect to localhost by default, regardless of their hostname
+	{ class = "component", properties = { connect_host = "localhost" } };
+};
 
 local function apply_object_properties(class, name, object)
 	for _, rule in ipairs(property_rules) do
@@ -54,6 +57,12 @@
 		elseif opt == "--host" or opt == "-h" then
 			local host = get_value();
 			table.insert(property_rules, { class = "client", properties = { connect_host = host } });
+		elseif opt == "--component-port" then
+			local port = assert(tonumber(get_value()), "port number must be a number");
+			table.insert(property_rules, { class = "component", properties = { connect_port = port } });
+		elseif opt == "--component-host" then
+			local host = get_value();
+			table.insert(property_rules, { class = "component", properties = { connect_host = host } });
 		elseif opt == "--out" or opt == "-o" then
 			result_log_filename = get_value();
 		elseif opt == "--server-log" or opt == "-s" then
@@ -152,7 +161,7 @@
 		object.handler = o;
 		object.script = script;
 		apply_object_properties(object.type, object.name, object);
-		if object.type == "client" and not object.stanza_timeout then
+		if (object.type == "client" or object.type == "component") and not object.stanza_timeout then
 			object.stanza_timeout = action_timeout - 1;
 		end
 		o._validate(object);

mercurial