source: ralphm-patches/router_unknown.patch @ 57:0d8b6cf41728

Last change on this file since 57:0d8b6cf41728 was 57:0d8b6cf41728, checked in by Ralph Meijer <ralphm@…>, 9 years ago

Wokkel 0.7.0 release, clean up various patches.

File size: 1.5 KB
  • wokkel/component.py

    # HG changeset patch
    # Parent 3d3065a425fa27c45c1f25aae8910f282f3049a4
    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`).
    
    diff -r 3d3065a425fa wokkel/component.py
    a b  
    332332        """
    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
    343355
Note: See TracBrowser for help on using the repository browser.