powered by Jive Software

Multiple level subdomains do not work as component names (with patch)

When I try to register a component with relative domain name “rsearch.realms”, the component gets the disco#info message and sends a reply advertising its functionality, still that reply gets discarded because the ComponentManager cannot map the fully qualified domain name to the relative domain name used in InternalComponentManager.

A possible fix for this problem would be to store the components keyed by fully qualified domain name. This would require changes in addComponent() and removeComponent() to append the XMPP base domain name. And getComponent() would be simplified to this:

public Component getComponent(JID componentJID) {

Component c = components.get(jid.toString());

if (c==null) return components.get(jid.toString() + “.” + serverDomain);

}

/code

If we want to keep the mapping keys as relative domain names, I suggest we change the getComponent() to:

public Component getComponent(JID componentJID) {

String jid = componentJID.toBareJID();

if (components.containsKey(jid)) {

return components.get(jid);

}

else {

if (!jid.contains(serverDomain)) {

// Ignore JIDs that doesn’'t belong to this server

return null;

}

String serverName = new JID(jid).getDomain();

int index = serverName.indexOf("." + serverDomain); // MODIFIED: added serverDomain

if (index != -1) {

jid = serverName.substring(0, index);

}

}

return components.get(jid);

}

/code

(org.jivesoftware.wildfire.component.InternalComponentManager, line 226, version #3229)

Hey Dimitar,

Thanks for the bug report. By coincidence this problem was in the same area of an optimization we were thinking of doing. JM-555 and JM-556 are now fixed.

Thanks,

– Gato

Erm… I have an issue with this fix…

This is the code that got checked in in version #3388 linked to Jira ticket JM-555

org.jivesoftware.wildfire.component.InternalComponentManager

public Component getComponent(JID componentJID) {

Component component = components.get(componentJID.getDomain());

if (component != null) {

return component;

}

else {

// Search again for those JIDs whose domain include the server name but this

// time remove the server name from the JID’'s domain

String serverName = componentJID.getDomain();

int index = serverName.lastIndexOf(serverDomain);

if (index > 0) {

return components.get(serverName.substring(0, --index));

}

}

return null;

}

/code

Imagine that you have a component with relative domain name ‘‘gorgo’’ and your server domain is ‘‘zola.com’’.

Then when you receive packet with toJID foo@gorgonzola.com -> the getComponent will dispatch the packet to gorgo.

We really need that dot in the search condition:

int index = serverName.indexOf("." + serverDomain);

/code

Or at least you have to make sure that the serverName.charAt(index-1)==’’.’’

In my opinion, if we are after efficiency, the best thing is to register the components internally by full domain name. This way we can use the simple implementation shown in my first post which is as fast as it can get. Since the components map is well encapsulated (no references escape this class), there should be no impact to the client classes.

If you want I can send you a patch? (just let me know what format do you prefer)

cheers,

Dimitar

Hey Dimitar,

Bug fix will be available in the next nightly build. Thanks again for catching this up.

Regards,

– Gato