GH-18: Server not handling unknown message types gracefull

This commit is contained in:
Mark Cavage 2011-09-26 13:47:33 -07:00
parent c57470804c
commit e2cac51a29
3 changed files with 10 additions and 6 deletions

View File

@ -222,7 +222,8 @@ Parser.prototype._newMessage = function(ber) {
default: default:
var e = new Error('protocolOp 0x' + type.toString(16) + ' not supported'); var e = new Error('protocolOp 0x' + type.toString(16) + ' not supported');
this.emit('error', e, new LDAPResult({ this.emit('error', e, new LDAPResult({
messageID: messageID messageID: messageID,
protocolOp: type
})); }));
this._reset(); this._reset();
return false; return false;

View File

@ -378,10 +378,13 @@ function Server(options) {
c.ldap.id, err.stack); c.ldap.id, err.stack);
var res = getResponse(message); var res = getResponse(message);
if (res) {
res.status = 0x02; // protocol error res.status = 0x02; // protocol error
res.errorMessage = err.toString(); res.errorMessage = err.toString();
c.end(res.toBer()); c.end(res.toBer());
} else {
c.destroy();
}
}); });
c.on('data', function(data) { c.on('data', function(data) {

View File

@ -3,7 +3,7 @@
"name": "ldapjs", "name": "ldapjs",
"homepage": "http://ldapjs.org", "homepage": "http://ldapjs.org",
"description": "LDAP client and server APIs", "description": "LDAP client and server APIs",
"version": "0.1.5", "version": "0.1.6",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/mcavage/node-ldapjs.git" "url": "git://github.com/mcavage/node-ldapjs.git"