void dnsrv_resend(xmlnode pkt, char *ip, char *to) { if(ip != NULL) { pkt = xmlnode_wrap(pkt,"route"); xmlnode_put_attrib(pkt, "to", to); xmlnode_put_attrib(pkt, "ip", ip); }else{ jutil_error(pkt, (terror){502, "Unable to resolve hostname."}); xmlnode_put_attrib(pkt, "iperror", ""); } deliver(dpacket_new(pkt),NULL); }
mreturn mod_log_archiver(mapi m, void *arg) { jid svcs = (jid) arg; xmlnode x; char ts[101]; struct tm now; unsigned long ltime; if (m->packet->type != JPACKET_MESSAGE) return M_IGNORE; log_debug("archiving message"); /* get a copy wrapped w/ a route and stamp it w/ a type='archive' (why not?) */ x = xmlnode_wrap(xmlnode_dup(m->packet->x), "route"); xmlnode_put_attrib(x, "type", "archive"); /* Mark the route with an direction attribute */ switch (m->e) { case es_IN: xmlnode_put_attrib(x, "direction", "in"); break; case es_OUT: xmlnode_put_attrib(x, "direction", "out"); break; } /* Mark the route with a timeStamp attribute */ time(<ime); #ifdef WIN32 now = *localtime(<ime); #else localtime_r(<ime, &now); #endif strftime((char *) ts, 100, "%m/%d/%Y %H:%M:%S", &now); xmlnode_put_attrib(x, "stamp", ts); /* if there's more than one service, copy to the others */ for (; svcs->next != NULL; svcs = svcs->next) { xmlnode_put_attrib(x, "to", jid_full(svcs)); deliver(dpacket_new(xmlnode_dup(x)), NULL); } /* send off to the last (or only) one */ xmlnode_put_attrib(x, "to", jid_full(svcs)); deliver(dpacket_new(x), NULL); return M_PASS; }
/* delivers a route packet to all listeners for this session */ static void js_session_route(session s, xmlnode in) { /* NULL means this is an error from the session ending */ if (in == NULL) { in = xmlnode_new_tag("route"); xmlnode_put_attrib(in, "type", "error"); xmlnode_put_attrib(in, "error", "Disconnected"); } else { in = xmlnode_wrap(in, "route"); } xmlnode_put_attrib(in, "from", jid_full(s->route)); xmlnode_put_attrib(in, "to", jid_full(s->sid)); deliver(dpacket_new(in), s->si->i); }