Ejemplo n.º 1
0
def remotecb(bot, event):
    """ dispatch an event. """
    try:
        container = Container().load(event.txt)
    except TypeError:
        handle_exception()
        logging.warn("remotecallbacks - not a remote event - %s " % event.userhost)
        return
    logging.debug("doing REMOTE callback")
    try:
        digest = hmac.new(str(container.hashkey), xmlstream.XMLunescape(container.payload), hashlib.sha512).hexdigest()
        logging.debug("remotecallbacks - digest is %s" % digest)
    except TypeError:
        handle_exception()
        logging.error("remotecallbacks - can't load payload - %s" % container.payload)
        return
    if container.digest == digest:
        e = EventBase().load(xmlstream.XMLunescape(container.payload))
    else:
        raise NoProperDigest()
    e.txt = xmlstream.XMLunescape(e.txt)
    e.nodispatch = True
    e.forwarded = True
    e.dontbind = True
    bot.doevent(e)
    event.status = "done"
    return
Ejemplo n.º 2
0
def remotecb(bot, event):
    """ dispatch an event. """
    try:
        container = Container().load(event.txt)
    except TypeError:
        handle_exception()
        logging.warn("remotecallbacks - not a remote event - %s " %
                     event.userhost)
        return
    logging.debug('doing REMOTE callback')
    try:
        digest = hmac.new(str(container.hashkey),
                          XMLunescape(container.payload),
                          hashlib.sha512).hexdigest()
        logging.debug("remotecallbacks - digest is %s" % digest)
    except TypeError:
        handle_exception()
        logging.error("remotecallbacks - can't load payload - %s" %
                      container.payload)
        return
    if container.digest == digest:
        e = EventBase().load(XMLunescape(container.payload))
    else:
        raise NoProperDigest()
    e.txt = XMLunescape(e.txt)
    e.nodispatch = True
    e.forwarded = True
    bot.doevent(e)
    event.status = "done"
    return