main.lua

changeset 181
3a9b9c98304a
parent 174
662bd8c5ae28
equal deleted inserted replaced
180:249197af6c01 181:3a9b9c98304a
19 local force_summary = false; 19 local force_summary = false;
20 local serve_mode = false; 20 local serve_mode = false;
21 local serve_origin = nil; 21 local serve_origin = nil;
22 local only_tags, skip_tags; 22 local only_tags, skip_tags;
23 23
24 local property_rules = {}; 24 local property_rules = {
25 -- Components connect to localhost by default, regardless of their hostname
26 { class = "component", properties = { connect_host = "localhost" } };
27 };
25 28
26 local function apply_object_properties(class, name, object) 29 local function apply_object_properties(class, name, object)
27 for _, rule in ipairs(property_rules) do 30 for _, rule in ipairs(property_rules) do
28 if (not(rule.class) or tostring(rule.class):lower() == tostring(class):lower()) 31 if (not(rule.class) or tostring(rule.class):lower() == tostring(class):lower())
29 and (not(rule.name) or tostring(rule.name):lower() == tostring(name):lower()) then 32 and (not(rule.name) or tostring(rule.name):lower() == tostring(name):lower()) then
52 local port = assert(tonumber(get_value()), "port number must be a number"); 55 local port = assert(tonumber(get_value()), "port number must be a number");
53 table.insert(property_rules, { class = "client", properties = { connect_port = port } }); 56 table.insert(property_rules, { class = "client", properties = { connect_port = port } });
54 elseif opt == "--host" or opt == "-h" then 57 elseif opt == "--host" or opt == "-h" then
55 local host = get_value(); 58 local host = get_value();
56 table.insert(property_rules, { class = "client", properties = { connect_host = host } }); 59 table.insert(property_rules, { class = "client", properties = { connect_host = host } });
60 elseif opt == "--component-port" then
61 local port = assert(tonumber(get_value()), "port number must be a number");
62 table.insert(property_rules, { class = "component", properties = { connect_port = port } });
63 elseif opt == "--component-host" then
64 local host = get_value();
65 table.insert(property_rules, { class = "component", properties = { connect_host = host } });
57 elseif opt == "--out" or opt == "-o" then 66 elseif opt == "--out" or opt == "-o" then
58 result_log_filename = get_value(); 67 result_log_filename = get_value();
59 elseif opt == "--server-log" or opt == "-s" then 68 elseif opt == "--server-log" or opt == "-s" then
60 local server_log = assert(io.open(get_value(), "r")); 69 local server_log = assert(io.open(get_value(), "r"));
61 function server_log_reader() 70 function server_log_reader()
150 context.line = object.defined_line 159 context.line = object.defined_line
151 local o = require("scansion.objects."..object.type); 160 local o = require("scansion.objects."..object.type);
152 object.handler = o; 161 object.handler = o;
153 object.script = script; 162 object.script = script;
154 apply_object_properties(object.type, object.name, object); 163 apply_object_properties(object.type, object.name, object);
155 if object.type == "client" and not object.stanza_timeout then 164 if (object.type == "client" or object.type == "component") and not object.stanza_timeout then
156 object.stanza_timeout = action_timeout - 1; 165 object.stanza_timeout = action_timeout - 1;
157 end 166 end
158 o._validate(object); 167 o._validate(object);
159 c = c + 1; 168 c = c + 1;
160 end 169 end

mercurial