[xmppd-dev] commit r1563 - in trunk/jabberd14: dialback resolver
mail at jabberd.org
mail at jabberd.org
Sun Nov 1 03:09:09 CET 2009
Author: mawis
Date: Sun Nov 1 03:09:09 2009
New Revision: 1563
Log:
Let the new resolver code handle routed stanzas as well. (also supported by old resolver code)
Modified:
trunk/jabberd14/dialback/dialback_in.cc
trunk/jabberd14/dialback/dialback_out.cc
trunk/jabberd14/resolver/resolver.cc
trunk/jabberd14/resolver/resolver.h
Modified: trunk/jabberd14/dialback/dialback_in.cc
==============================================================================
--- trunk/jabberd14/dialback/dialback_in.cc Thu Oct 22 03:22:12 2009 (r1562)
+++ trunk/jabberd14/dialback/dialback_in.cc Sun Nov 1 03:09:09 2009 (r1563)
@@ -297,6 +297,13 @@
xmlnode_put_attrib_ns(x2, "dnsqueryby", NULL, NULL, c->d->i->id); /* so this instance gets the DNS result back */
xmlnode_put_attrib_ns(x2, "id", NULL, NULL, c->id);
xmlnode_insert_node(x2, xmlnode_get_firstchild(x)); /* copy in any children */
+
+ // wrap by a route packet, so that we can ensure, that it gets routed to the resolver
+ x2 = xmlnode_wrap_ns(x2, "route", NULL, NS_SERVER);
+ xmlnode_put_attrib_ns(x2, "type", NULL, NULL, "resolve");
+ xmlnode_put_attrib_ns(x2, "to", NULL, NULL, "dnsrv.amessage.info");
+ xmlnode_put_attrib_ns(x2, "from", NULL, NULL, c->d->i->id);
+
deliver(dpacket_new(x2), c->d->i);
return;
Modified: trunk/jabberd14/dialback/dialback_out.cc
==============================================================================
--- trunk/jabberd14/dialback/dialback_out.cc Thu Oct 22 03:22:12 2009 (r1562)
+++ trunk/jabberd14/dialback/dialback_out.cc Sun Nov 1 03:09:09 2009 (r1563)
@@ -316,7 +316,7 @@
log_debug2(ZONE, LOGT_IO, "dbout packet[%s]: %s", ip, xmlnode_serialize_string(x, xmppd::ns_decl_list(), 0));
/* db:verify packets come in with us as the sender */
- if (j_strcmp(from->get_domain().c_str(), d->i->id) == 0) {
+ if (j_strcmp(xmlnode_get_localname(x), "verify") == 0 && j_strcmp(xmlnode_get_namespace(x), NS_DIALBACK) == 0 || j_strcmp(from->get_domain().c_str(), d->i->id) == 0) {
verify = 1;
/* fix the headers, restore the real from */
/* (I think we wouldn't need to from/ofrom thing anymore because we have dnsqueryby, that we need for s2s clustering) */
Modified: trunk/jabberd14/resolver/resolver.cc
==============================================================================
--- trunk/jabberd14/resolver/resolver.cc Thu Oct 22 03:22:12 2009 (r1562)
+++ trunk/jabberd14/resolver/resolver.cc Sun Nov 1 03:09:09 2009 (r1563)
@@ -182,6 +182,25 @@
return r_DONE;
}
+ result resolver::on_route_packet(dpacket dp) {
+ // only packets addressed to us directly (no default route) are accepted as routed packets
+ if (!dp->host || get_instance_id() != dp->host) {
+ return instance_base::on_route_packet(dp);
+ }
+
+ // the routed packet has to have a to attribute
+ jid to = jid_new(dp->p, xmlnode_get_attrib_ns(xmlnode_get_firstchild(dp->x), "to", NULL));
+ if (to == NULL) {
+ return r_ERR;
+ }
+
+ // unpack the routed packet and process it
+ dp->x = xmlnode_get_firstchild(dp->x);
+ dp->id = to;
+ dp->host = pstrdup(dp->p, to->get_domain().c_str());
+ return on_stanza_packet(dp);
+ }
+
void resolver::resend_packet(xmlnode pkt, Glib::ustring ips, Glib::ustring to) {
if (ips.empty()) {
jutil_error_xmpp(pkt, (xterror){502, N_("Unable to resolve hostname."), "wait", "service-unavailable"});
@@ -195,6 +214,11 @@
pkt = xmlnode_wrap_ns(pkt, "route", NULL, NS_SERVER);
xmlnode_put_attrib_ns(pkt, "to", NULL, NULL, dnsresultto);
xmlnode_put_attrib_ns(pkt, "ip", NULL, NULL, ips.c_str());
+
+ // XXX
+ if (std::string("verify") == xmlnode_get_localname(pkt) && std::string(NS_DIALBACK) == xmlnode_get_namespace(pkt)) {
+ log(xmppd::notice) << "DB resend: " << xmlnode_serialize_string(pkt, xmppd::ns_decl_list(), 0);
+ }
}
deliver(pkt);
}
Modified: trunk/jabberd14/resolver/resolver.h
==============================================================================
--- trunk/jabberd14/resolver/resolver.h Thu Oct 22 03:22:12 2009 (r1562)
+++ trunk/jabberd14/resolver/resolver.h Sun Nov 1 03:09:09 2009 (r1563)
@@ -325,6 +325,11 @@
result on_stanza_packet(dpacket dp);
/**
+ * handle received routed packets
+ */
+ result on_route_packet(dpacket dp);
+
+ /**
* create socket for lwresd access
*/
void open_lwresd_socket();
More information about the dev
mailing list