source: ralphm-patches/router_unknown.patch @ 54:03ec57713c90

Last change on this file since 54:03ec57713c90 was 54:03ec57713c90, checked in by Ralph Meijer <ralphm@…>, 9 years ago

Upstreamed Request patches, split out c2s patches in managable chunks, prepare for release of Wokkel 0.7.0.

File size: 1.6 KB
  • wokkel/component.py

    # HG changeset patch
    # Parent 28a032eab8a5ffbc145aaec1f0044a2a9cad7058
    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 28a032eab8a5 wokkel/component.py
    a b  
    313313        """
    314314        destination = JID(stanza['to'])
    315315
    316         log.msg("Routing to %s: %r" % (destination.full(), stanza.toXml()))
    317316
    318317        if destination.host in self.routes:
     318            msg = "Routing to %s (default route): %r"
     319            log.msg("Routing to %s: %r" % (destination.full(),
     320                                           stanza.toXml()))
    319321            self.routes[destination.host].send(stanza)
     322        elif None in self.routes:
     323            log.msg("Routing to %s (default route): %r" % (destination.full(),
     324                                                           stanza.toXml()))
     325            self.routes[None].send(stanza)
    320326        else:
    321             self.routes[None].send(stanza)
     327            log.msg("No route to %s: %r" % (destination.full(),
     328                                            stanza.toXml()))
     329            if stanza.getAttribute('type') not in ('result', 'error'):
     330                # No route, send back error
     331                exc = error.StanzaError('remote-server-timeout', type='wait')
     332                exc.code = '504'
     333                response = exc.toResponse(stanza)
     334                self.route(response)
    322335
    323336
    324337
Note: See TracBrowser for help on using the repository browser.