Skip to content

Commit

Permalink
Server: fix formatting of IPv6 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakster authored and mscdex committed Jan 9, 2016
1 parent 4577d30 commit 374f705
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/server.parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Parser.prototype._onData = function(chunk) {
for (var b = 0; b < 16; ++b) {
if (b % 2 === 0 && b > 0)
ipv6str += ':';
ipv6str += addr[b].toString(16);
ipv6str += (addr[b] < 16 ? '0' : '') + addr[b].toString(16);
}
this._dstaddr = ipv6str;
} else
Expand Down
9 changes: 5 additions & 4 deletions test/test-server-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,16 @@ var tests = [
0x01,
0x00,
0x04,
0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA,
0xF9, 0xF8, 0xF7, 0xF6, 0xF5, 0xF4,
0xF3, 0xF2, 0xF1, 0xF0,
0xFF, 0xFE, 0xE0, 0xD0,
0x00, 0x0C, 0x00, 0xA0,
0x00, 0x00, 0x03, 0x00,
0x00, 0x02, 0xB0, 0x01,
0x08, 0x40]));
assert.deepEqual(request,
{ cmd: 'connect',
srcAddr: undefined,
srcPort: undefined,
dstAddr: 'fffe:fdfc:fbfa:f9f8:f7f6:f5f4:f3f2:f1f0',
dstAddr: 'fffe:e0d0:000c:00a0:0000:0300:0002:b001',
dstPort: 2112 },
makeMsg(what, 'Request mismatch'));
next();
Expand Down

0 comments on commit 374f705

Please sign in to comment.