Comparison

plugins/mod_component.lua @ 11240:0f7ecc9a4560

mod_component: Distinguish missing stream @to from unknown local component (thanks Daniel_W) Spectrum2 did not include a stream @to attribute due to a configuration error. "nil does not match ..." is not very clear in pointing this out and is somewhat confusing, tho it did help pinpoint what went wrong. It's also not great leak to programming language internals like "nil" out into user-facing strings like this.
author Kim Alvefur <zash@zash.se>
date Fri, 18 Dec 2020 22:29:44 +0100
parent 11035:ba1143ddae9b
child 11560:3bbb1af92514
comparison
equal deleted inserted replaced
11239:06a5919e2496 11240:0f7ecc9a4560
191 session:close(nil, text); 191 session:close(nil, text);
192 end 192 end
193 end 193 end
194 194
195 function stream_callbacks.streamopened(session, attr) 195 function stream_callbacks.streamopened(session, attr)
196 if not attr.to then
197 session:close{ condition = "improper-addressing", text = "A 'to' attribute is required on stream headers" };
198 return;
199 end
196 if not hosts[attr.to] or not hosts[attr.to].modules.component then 200 if not hosts[attr.to] or not hosts[attr.to].modules.component then
197 session:close{ condition = "host-unknown", text = tostring(attr.to).." does not match any configured external components" }; 201 session:close{ condition = "host-unknown", text = tostring(attr.to).." does not match any configured external components" };
198 return; 202 return;
199 end 203 end
200 session.host = attr.to; 204 session.host = attr.to;