diff 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
parents ba1143ddae9b
children 3bbb1af92514
line wrap: on
line diff
--- a/plugins/mod_component.lua	Wed Dec 16 10:55:04 2020 +0100
+++ b/plugins/mod_component.lua	Fri Dec 18 22:29:44 2020 +0100
@@ -193,6 +193,10 @@
 end
 
 function stream_callbacks.streamopened(session, attr)
+	if not attr.to then
+		session:close{ condition = "improper-addressing", text = "A 'to' attribute is required on stream headers" };
+		return;
+	end
 	if not hosts[attr.to] or not hosts[attr.to].modules.component then
 		session:close{ condition = "host-unknown", text = tostring(attr.to).." does not match any configured external components" };
 		return;