Changeset 176:f98da30301ea for wokkel


Ignore:
Timestamp:
Sep 1, 2012, 2:36:39 PM (8 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

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).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/component.py

    r169 r176  
    333333        destination = JID(stanza['to'])
    334334
    335         log.msg("Routing to %s: %r" % (destination.full(), stanza.toXml()))
    336335
    337336        if destination.host in self.routes:
     337            log.msg("Routing to %s: %r" % (destination.full(),
     338                                           stanza.toXml()))
    338339            self.routes[destination.host].send(stanza)
     340        elif None in self.routes:
     341            log.msg("Routing to %s (default route): %r" % (destination.full(),
     342                                                           stanza.toXml()))
     343            self.routes[None].send(stanza)
    339344        else:
    340             self.routes[None].send(stanza)
     345            log.msg("No route to %s: %r" % (destination.full(),
     346                                            stanza.toXml()))
     347            if stanza.getAttribute('type') not in ('result', 'error'):
     348                # No route, send back error
     349                exc = error.StanzaError('remote-server-timeout', type='wait')
     350                exc.code = '504'
     351                response = exc.toResponse(stanza)
     352                self.route(response)
    341353
    342354
Note: See TracChangeset for help on using the changeset viewer.