Browse Source
Fix nickname error responses to match RFC
fix/wrongParams
Sheogorath
5 years ago
No known key found for this signature in database
GPG Key ID: 1F05CC3635CDDFFD
2 changed files with
4 additions and
4 deletions
-
src/server.js
-
test/command_nick.js
|
@ -57,12 +57,12 @@ server.create = function create(config = {}) { |
|
|
user.setNickname(nickname) |
|
|
user.setNickname(nickname) |
|
|
userlist[user.nickname] = user |
|
|
userlist[user.nickname] = user |
|
|
} else { |
|
|
} else { |
|
|
socket.write(ERR_NICKNAMEINUSE, " nickname in use") |
|
|
|
|
|
|
|
|
socket.write(`:irc.example.com ${ERR_NICKNAMEINUSE} ${nickname} :Nickname is already in use`, 'ascii') |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
socket.write(ERR_NONICKNAMEGIVEN, "ERROR: NO NICKNAME PROVIDED") |
|
|
|
|
|
|
|
|
socket.write(`:irc.example.com ${ERR_NONICKNAMEGIVEN} :No nickname given`, 'ascii') |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
|
@ -31,7 +31,7 @@ describe("NICK already registered", function () { |
|
|
} |
|
|
} |
|
|
let mockedSock2 = new EventEmitter() |
|
|
let mockedSock2 = new EventEmitter() |
|
|
mockedSock2.write = function (data) { |
|
|
mockedSock2.write = function (data) { |
|
|
assert.equal(data.toString("ascii"), "433") |
|
|
|
|
|
|
|
|
assert.equal(data.toString("ascii"), ":irc.example.com 433 some_nick :Nickname is already in use") |
|
|
done() |
|
|
done() |
|
|
} |
|
|
} |
|
|
mockedSock2.destroy = function () { |
|
|
mockedSock2.destroy = function () { |
|
@ -49,7 +49,7 @@ describe("NICK no NICK given", function () { |
|
|
const server = IRCServer.create() |
|
|
const server = IRCServer.create() |
|
|
let mockedSock = new EventEmitter() |
|
|
let mockedSock = new EventEmitter() |
|
|
mockedSock.write = function (data) { |
|
|
mockedSock.write = function (data) { |
|
|
assert.equal(data.toString("ascii"), "431") |
|
|
|
|
|
|
|
|
assert.equal(data.toString("ascii"), ":irc.example.com 431 :No nickname given") |
|
|
done() |
|
|
done() |
|
|
} |
|
|
} |
|
|
mockedSock.destroy = function () { |
|
|
mockedSock.destroy = function () { |
|
|