From a1740642f2a9af6bf42747fe0b4bf2148fc38449 Mon Sep 17 00:00:00 2001
From: Waqas Hussain <waqas20@gmail.com>
Date: Thu, 13 Nov 2008 19:14:31 +0500
Subject: Added error replies for unhandled stanzas

---
 core/stanza_router.lua | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'core')

diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index 5d6358ec..1793f547 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -173,11 +173,16 @@ function core_handle_stanza(origin, stanza)
 				end
 				stanza.attr.to = nil; -- reset it
 			else
-				-- TODO error, bad type
+				log("warn", "Unhandled c2s presence: %s", tostring(stanza));
+				origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
 			end
+		else
+			log("warn", "Unhandled c2s stanza: %s", tostring(stanza));
+			origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
 		end -- TODO handle other stanzas
 	else
-		log("warn", "Unhandled origin: %s", origin.type); -- FIXME reply with error
+		log("warn", "Unhandled origin: %s", origin.type);
+		origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
 	end
 end
 
-- 
cgit v1.2.3