Skip to content

Commit

Permalink
Send back an error if there is no known route to the stanza's destina…
Browse files Browse the repository at this point in the history
…tion.

This is most useful in situations where there is no server-to-server
component that acts as the default route (indexed by `None`).
  • Loading branch information
ralphm committed Sep 1, 2012
1 parent bb83eb6 commit 3b46f34
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions wokkel/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,24 @@ def route(self, stanza):
"""
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)
else:
elif None in self.routes:
log.msg("Routing to %s (default route): %r" % (destination.full(),
stanza.toXml()))
self.routes[None].send(stanza)
else:
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)



Expand Down

0 comments on commit 3b46f34

Please sign in to comment.