Skip to content

Commit

Permalink
feat(vhosts): add vhosts specified in address to sasl init frame
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Oct 11, 2015
1 parent 14c3913 commit c95b741
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/amqp_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ AMQPClient.prototype.connect = function(url) {
self._defaultQueue = address.path.substr(1);
self.policy.connect.options.hostname = address.host;
var sasl = address.user ? new Sasl() : null;
if (!!sasl && !!address.vhost) sasl._remoteHostname = address.vhost;

self._connection = self._newConnection();
self._connection.on(Connection.Connected, function(c) {
debug('connected');
Expand Down
4 changes: 3 additions & 1 deletion lib/sasl.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Sasl.prototype.headerReceived = function(header) {
debug('Server SASL Version: ' + header.toString('hex') + ' vs ' + constants.saslVersion.toString('hex'));
if (u.bufferEquals(header, constants.saslVersion)) {
this.receivedHeader = true;
// Wait for mechanisms
// Wait for mechanisms
} else {
this.callback(new errors.MalformedHeaderError('Invalid SASL Header ' + header.toString('hex')));
}
Expand All @@ -59,6 +59,8 @@ Sasl.prototype._processFrame = function(frame) {
mechanism: new AMQPSymbol('PLAIN'),
initialResponse: buf.get()
});

if (!!this._remoteHostname) initFrame.hostname = this._remoteHostname;
this.connection.sendFrame(initFrame);
} else {
throw new errors.NotImplementedError('Only supports SASL-PLAIN at the moment.');
Expand Down

0 comments on commit c95b741

Please sign in to comment.