xmppo / node-xmpp-bosh

An XMPP BOSH & WebSocket server (connection manager) written on node.js using Javascript
https://github.com/xmppo/node-xmpp-bosh
263 stars 85 forks source link

always route to localhost #87

Closed rbrcurtis closed 10 years ago

rbrcurtis commented 10 years ago

I'm running a server I wrote using node-xmpp which will server multiple xmpp domains. I'd like to use this project to terminate all bosh since the bosh server in node-xmpp looks buggy. Is there a way to configure node-xmpp-bosh to always route to a specific host, or is that a feature you could add? I can hack the lookup service easily enough, but it looks like passing a config into it would be trickier hence I wanted to submit an issue instead of doing a PR.

dhruvbird commented 10 years ago

@rbrcurtis The idea of having a lookup-service was so that such custom actions can be performed by extending/re-implementing it, so that is the expected way to override the behaviour. Ideally, the bosh server should allow you to override the lookup-service file to load, but it currently doesn't [sorry about that :-( ]. For now, you could maintain a fork where you just change the require() to require your custom lookup service. I don't know the best way to go about performing the DI for such things yet.

dhruvbird commented 10 years ago

Q. What's a PR?

rbrcurtis commented 10 years ago

PR = Pull Request. IE, I didn't know the best way to do the DI either given your code structure. Anyway, no worries, I can fork and modify it easily enough to use a custom lookup service.

dhruvbird commented 10 years ago

@rbrcurtis So, the current easiest way (I think) to do this would be to replace the require call here: https://plus.google.com/photos/107716439220114654738/albums/5910944123711098801 with require('your-custom-lookup-service.js');

Sorry, but DI with the current code base is very broken - and I apologize for that.

If I were you, I wouldn't bother extending the current lookup-service - since it's pretty dedicated to doing what the XEP specifies. What you want is a specific implementation of a lookup service which always connects to a specified host.

Alternatively, you can hack into https://github.com/dhruvbird/node-xmpp-bosh/blob/master/src/session.js#L110 and always set the route attribute - this is admittedly much easier to do, but much more hacky. In fact, a 1 line change here will do what you want it to do.