Commits

Ralph Meijer  committed f98da30

Send back an error if there is no known route to the stanza's destination.

This is most useful in situations where there is no server-to-server
component that acts as the default route (indexed by `None`).

  • Participants
  • Parent commits 28e7ea5

Comments (0)

Files changed (1)

File wokkel/component.py

         """
         destination = JID(stanza['to'])
 
-        log.msg("Routing to %s: %r" % (destination.full(), stanza.toXml()))
 
         if destination.host in self.routes:
+            log.msg("Routing to %s: %r" % (destination.full(),
+                                           stanza.toXml()))
             self.routes[destination.host].send(stanza)
+        elif None in self.routes:
+            log.msg("Routing to %s (default route): %r" % (destination.full(),
+                                                           stanza.toXml()))
+            self.routes[None].send(stanza)
         else:
-            self.routes[None].send(stanza)
+            log.msg("No route to %s: %r" % (destination.full(),
+                                            stanza.toXml()))
+            if stanza.getAttribute('type') not in ('result', 'error'):
+                # No route, send back error
+                exc = error.StanzaError('remote-server-timeout', type='wait')
+                exc.code = '504'
+                response = exc.toResponse(stanza)
+                self.route(response)