tedious 2.2.0 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/bulk-load.js +1 -1
- package/lib/connection.js +148 -131
- package/lib/data-type.js +79 -1669
- package/lib/data-types/bigint.js +46 -0
- package/lib/data-types/binary.js +57 -0
- package/lib/data-types/bit.js +38 -0
- package/lib/data-types/bitn.js +8 -0
- package/lib/data-types/char.js +72 -0
- package/lib/data-types/daten.js +48 -0
- package/lib/data-types/datetime.js +68 -0
- package/lib/data-types/datetime2n.js +105 -0
- package/lib/data-types/datetimen.js +8 -0
- package/lib/data-types/datetimeoffsetn.js +91 -0
- package/lib/data-types/decimal.js +88 -0
- package/lib/data-types/decimaln.js +10 -0
- package/lib/data-types/float.js +38 -0
- package/lib/data-types/floatn.js +8 -0
- package/lib/data-types/image.js +46 -0
- package/lib/data-types/int.js +41 -0
- package/lib/data-types/intn.js +8 -0
- package/lib/data-types/money.js +38 -0
- package/lib/data-types/moneyn.js +8 -0
- package/lib/data-types/nchar.js +72 -0
- package/lib/data-types/ntext.js +11 -0
- package/lib/data-types/null.js +7 -0
- package/lib/data-types/numeric.js +88 -0
- package/lib/data-types/numericn.js +10 -0
- package/lib/data-types/nvarchar.js +86 -0
- package/lib/data-types/real.js +38 -0
- package/lib/data-types/smalldatetime.js +60 -0
- package/lib/data-types/smallint.js +41 -0
- package/lib/data-types/smallmoney.js +41 -0
- package/lib/data-types/sql-variant.js +12 -0
- package/lib/data-types/text.js +51 -0
- package/lib/data-types/timen.js +95 -0
- package/lib/data-types/tinyint.js +41 -0
- package/lib/data-types/tvp.js +83 -0
- package/lib/data-types/udt.js +8 -0
- package/lib/data-types/uniqueidentifiern.js +46 -0
- package/lib/data-types/varbinary.js +77 -0
- package/lib/data-types/varchar.js +86 -0
- package/lib/data-types/xml.js +8 -0
- package/lib/instance-lookup.js +8 -7
- package/lib/message-io.js +1 -1
- package/lib/ntlm-payload.js +5 -5
- package/lib/packet.js +3 -3
- package/lib/prelogin-payload.js +7 -7
- package/lib/request.js +37 -16
- package/lib/tracking-buffer/bigint.js +1 -1
- package/lib/tracking-buffer/writable-tracking-buffer.js +52 -48
- package/lib/value-parser.js +13 -13
- package/package.json +1 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
id: 0x29,
|
|
5
|
+
type: 'TIMEN',
|
|
6
|
+
name: 'TimeN',
|
|
7
|
+
aliases: ['Time'],
|
|
8
|
+
hasScale: true,
|
|
9
|
+
dataLengthLength: 1,
|
|
10
|
+
|
|
11
|
+
dataLengthFromScale: function dataLengthFromScale(scale) {
|
|
12
|
+
switch (scale) {
|
|
13
|
+
case 0:
|
|
14
|
+
case 1:
|
|
15
|
+
case 2:
|
|
16
|
+
return 3;
|
|
17
|
+
case 3:
|
|
18
|
+
case 4:
|
|
19
|
+
return 4;
|
|
20
|
+
case 5:
|
|
21
|
+
case 6:
|
|
22
|
+
case 7:
|
|
23
|
+
return 5;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
declaration: function declaration(parameter) {
|
|
28
|
+
return 'time(' + this.resolveScale(parameter) + ')';
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
resolveScale: function resolveScale(parameter) {
|
|
32
|
+
if (parameter.scale != null) {
|
|
33
|
+
return parameter.scale;
|
|
34
|
+
} else if (parameter.value === null) {
|
|
35
|
+
return 0;
|
|
36
|
+
} else {
|
|
37
|
+
return 7;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
writeTypeInfo: function writeTypeInfo(buffer, parameter) {
|
|
42
|
+
buffer.writeUInt8(this.id);
|
|
43
|
+
buffer.writeUInt8(parameter.scale);
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
writeParameterData: function writeParameterData(buffer, parameter, options) {
|
|
47
|
+
if (parameter.value != null) {
|
|
48
|
+
var time = new Date(+parameter.value);
|
|
49
|
+
|
|
50
|
+
var timestamp = void 0;
|
|
51
|
+
if (options.useUTC) {
|
|
52
|
+
timestamp = ((time.getUTCHours() * 60 + time.getUTCMinutes()) * 60 + time.getUTCSeconds()) * 1000 + time.getUTCMilliseconds();
|
|
53
|
+
} else {
|
|
54
|
+
timestamp = ((time.getHours() * 60 + time.getMinutes()) * 60 + time.getSeconds()) * 1000 + time.getMilliseconds();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
timestamp = timestamp * Math.pow(10, parameter.scale - 3);
|
|
58
|
+
timestamp += (parameter.value.nanosecondDelta != null ? parameter.value.nanosecondDelta : 0) * Math.pow(10, parameter.scale);
|
|
59
|
+
timestamp = Math.round(timestamp);
|
|
60
|
+
|
|
61
|
+
switch (parameter.scale) {
|
|
62
|
+
case 0:
|
|
63
|
+
case 1:
|
|
64
|
+
case 2:
|
|
65
|
+
buffer.writeUInt8(3);
|
|
66
|
+
buffer.writeUInt24LE(timestamp);
|
|
67
|
+
case 3:
|
|
68
|
+
case 4:
|
|
69
|
+
buffer.writeUInt8(4);
|
|
70
|
+
buffer.writeUInt32LE(timestamp);
|
|
71
|
+
case 5:
|
|
72
|
+
case 6:
|
|
73
|
+
case 7:
|
|
74
|
+
buffer.writeUInt8(5);
|
|
75
|
+
buffer.writeUInt40LE(timestamp);
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
buffer.writeUInt8(0);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
validate: function validate(value) {
|
|
83
|
+
if (value == null) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
if (value instanceof Date) {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
value = Date.parse(value);
|
|
90
|
+
if (isNaN(value)) {
|
|
91
|
+
return new TypeError('Invalid time.');
|
|
92
|
+
}
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var IntN = require('./intn');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
id: 0x30,
|
|
7
|
+
type: 'INT1',
|
|
8
|
+
name: 'TinyInt',
|
|
9
|
+
|
|
10
|
+
declaration: function declaration() {
|
|
11
|
+
return 'tinyint';
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
writeTypeInfo: function writeTypeInfo(buffer) {
|
|
15
|
+
buffer.writeUInt8(IntN.id);
|
|
16
|
+
buffer.writeUInt8(1);
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
writeParameterData: function writeParameterData(buffer, parameter) {
|
|
20
|
+
if (parameter.value != null) {
|
|
21
|
+
buffer.writeUInt8(1);
|
|
22
|
+
buffer.writeUInt8(parseInt(parameter.value));
|
|
23
|
+
} else {
|
|
24
|
+
buffer.writeUInt8(0);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
validate: function validate(value) {
|
|
29
|
+
if (value == null) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
value = parseInt(value);
|
|
33
|
+
if (isNaN(value)) {
|
|
34
|
+
return new TypeError('Invalid number.');
|
|
35
|
+
}
|
|
36
|
+
if (value < 0 || value > 255) {
|
|
37
|
+
return new TypeError('Value must be between 0 and 255.');
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
id: 0xF3,
|
|
5
|
+
type: 'TVPTYPE',
|
|
6
|
+
name: 'TVP',
|
|
7
|
+
|
|
8
|
+
declaration: function declaration(parameter) {
|
|
9
|
+
return parameter.value.name + ' readonly';
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
writeTypeInfo: function writeTypeInfo(buffer, parameter) {
|
|
13
|
+
var ref = void 0,
|
|
14
|
+
ref1 = void 0,
|
|
15
|
+
ref2 = void 0,
|
|
16
|
+
ref3 = void 0;
|
|
17
|
+
buffer.writeUInt8(this.id);
|
|
18
|
+
buffer.writeBVarchar('');
|
|
19
|
+
buffer.writeBVarchar((ref = (ref1 = parameter.value) != null ? ref1.schema : undefined) != null ? ref : '');
|
|
20
|
+
buffer.writeBVarchar((ref2 = (ref3 = parameter.value) != null ? ref3.name : undefined) != null ? ref2 : '');
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
writeParameterData: function writeParameterData(buffer, parameter, options) {
|
|
24
|
+
if (parameter.value == null) {
|
|
25
|
+
buffer.writeUInt16LE(0xFFFF);
|
|
26
|
+
buffer.writeUInt8(0x00);
|
|
27
|
+
buffer.writeUInt8(0x00);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
buffer.writeUInt16LE(parameter.value.columns.length);
|
|
32
|
+
|
|
33
|
+
var ref = parameter.value.columns;
|
|
34
|
+
for (var i = 0, len = ref.length; i < len; i++) {
|
|
35
|
+
var column = ref[i];
|
|
36
|
+
buffer.writeUInt32LE(0x00000000);
|
|
37
|
+
buffer.writeUInt16LE(0x0000);
|
|
38
|
+
column.type.writeTypeInfo(buffer, column);
|
|
39
|
+
buffer.writeBVarchar('');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
buffer.writeUInt8(0x00);
|
|
43
|
+
|
|
44
|
+
var ref1 = parameter.value.rows;
|
|
45
|
+
for (var j = 0, len1 = ref1.length; j < len1; j++) {
|
|
46
|
+
var row = ref1[j];
|
|
47
|
+
|
|
48
|
+
buffer.writeUInt8(0x01);
|
|
49
|
+
|
|
50
|
+
for (var k = 0, len2 = row.length; k < len2; k++) {
|
|
51
|
+
var value = row[k];
|
|
52
|
+
var param = {
|
|
53
|
+
value: value,
|
|
54
|
+
length: parameter.value.columns[k].length,
|
|
55
|
+
scale: parameter.value.columns[k].scale,
|
|
56
|
+
precision: parameter.value.columns[k].precision
|
|
57
|
+
};
|
|
58
|
+
parameter.value.columns[k].type.writeParameterData(buffer, param, options);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
buffer.writeUInt8(0x00);
|
|
63
|
+
},
|
|
64
|
+
validate: function validate(value) {
|
|
65
|
+
if (value == null) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof value !== 'object') {
|
|
70
|
+
return new TypeError('Invalid table.');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!Array.isArray(value.columns)) {
|
|
74
|
+
return new TypeError('Invalid table.');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!Array.isArray(value.rows)) {
|
|
78
|
+
return new TypeError('Invalid table.');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var guidParser = require('../guid-parser');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
id: 0x24,
|
|
7
|
+
type: 'GUIDN',
|
|
8
|
+
name: 'UniqueIdentifierN',
|
|
9
|
+
aliases: ['UniqueIdentifier'],
|
|
10
|
+
dataLengthLength: 1,
|
|
11
|
+
|
|
12
|
+
declaration: function declaration() {
|
|
13
|
+
return 'uniqueidentifier';
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
resolveLength: function resolveLength() {
|
|
17
|
+
return 16;
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
writeTypeInfo: function writeTypeInfo(buffer) {
|
|
21
|
+
buffer.writeUInt8(this.id);
|
|
22
|
+
buffer.writeUInt8(0x10);
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
writeParameterData: function writeParameterData(buffer, parameter) {
|
|
26
|
+
if (parameter.value != null) {
|
|
27
|
+
buffer.writeUInt8(0x10);
|
|
28
|
+
buffer.writeBuffer(new Buffer(guidParser.guidToArray(parameter.value)));
|
|
29
|
+
} else {
|
|
30
|
+
buffer.writeUInt8(0);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
validate: function validate(value) {
|
|
35
|
+
if (value == null) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (typeof value !== 'string') {
|
|
39
|
+
if (typeof value.toString !== 'function') {
|
|
40
|
+
return TypeError('Invalid string.');
|
|
41
|
+
}
|
|
42
|
+
value = value.toString();
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var NULL = (1 << 16) - 1;
|
|
4
|
+
var MAX = (1 << 16) - 1;
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
id: 0xA5,
|
|
8
|
+
type: 'BIGVARBIN',
|
|
9
|
+
name: 'VarBinary',
|
|
10
|
+
dataLengthLength: 2,
|
|
11
|
+
maximumLength: 8000,
|
|
12
|
+
|
|
13
|
+
declaration: function declaration(parameter) {
|
|
14
|
+
var length = void 0;
|
|
15
|
+
if (parameter.length) {
|
|
16
|
+
length = parameter.length;
|
|
17
|
+
} else if (parameter.value != null) {
|
|
18
|
+
length = parameter.value.length || 1;
|
|
19
|
+
} else if (parameter.value === null && !parameter.output) {
|
|
20
|
+
length = 1;
|
|
21
|
+
} else {
|
|
22
|
+
length = this.maximumLength;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (length <= this.maximumLength) {
|
|
26
|
+
return 'varbinary(' + length + ')';
|
|
27
|
+
} else {
|
|
28
|
+
return 'varbinary(max)';
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
resolveLength: function resolveLength(parameter) {
|
|
33
|
+
if (parameter.length != null) {
|
|
34
|
+
return parameter.length;
|
|
35
|
+
} else if (parameter.value != null) {
|
|
36
|
+
return parameter.value.length;
|
|
37
|
+
} else {
|
|
38
|
+
return this.maximumLength;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
writeTypeInfo: function writeTypeInfo(buffer, parameter) {
|
|
43
|
+
buffer.writeUInt8(this.id);
|
|
44
|
+
if (parameter.length <= this.maximumLength) {
|
|
45
|
+
buffer.writeUInt16LE(this.maximumLength);
|
|
46
|
+
} else {
|
|
47
|
+
buffer.writeUInt16LE(MAX);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
writeParameterData: function writeParameterData(buffer, parameter) {
|
|
52
|
+
if (parameter.value != null) {
|
|
53
|
+
if (parameter.length <= this.maximumLength) {
|
|
54
|
+
buffer.writeUsVarbyte(parameter.value);
|
|
55
|
+
} else {
|
|
56
|
+
buffer.writePLPBody(parameter.value);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
if (parameter.length <= this.maximumLength) {
|
|
60
|
+
buffer.writeUInt16LE(NULL);
|
|
61
|
+
} else {
|
|
62
|
+
buffer.writeUInt32LE(0xFFFFFFFF);
|
|
63
|
+
buffer.writeUInt32LE(0xFFFFFFFF);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
validate: function validate(value) {
|
|
69
|
+
if (value == null) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
if (!Buffer.isBuffer(value)) {
|
|
73
|
+
return new TypeError('Invalid buffer.');
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var NULL = (1 << 16) - 1;
|
|
4
|
+
var MAX = (1 << 16) - 1;
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
id: 0xA7,
|
|
8
|
+
type: 'BIGVARCHR',
|
|
9
|
+
name: 'VarChar',
|
|
10
|
+
hasCollation: true,
|
|
11
|
+
dataLengthLength: 2,
|
|
12
|
+
maximumLength: 8000,
|
|
13
|
+
|
|
14
|
+
declaration: function declaration(parameter) {
|
|
15
|
+
var length = void 0;
|
|
16
|
+
if (parameter.length) {
|
|
17
|
+
length = parameter.length;
|
|
18
|
+
} else if (parameter.value != null) {
|
|
19
|
+
length = parameter.value.toString().length || 1;
|
|
20
|
+
} else if (parameter.value === null && !parameter.output) {
|
|
21
|
+
length = 1;
|
|
22
|
+
} else {
|
|
23
|
+
length = this.maximumLength;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (length <= this.maximumLength) {
|
|
27
|
+
return 'varchar(' + length + ')';
|
|
28
|
+
} else {
|
|
29
|
+
return 'varchar(max)';
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
resolveLength: function resolveLength(parameter) {
|
|
34
|
+
if (parameter.length != null) {
|
|
35
|
+
return parameter.length;
|
|
36
|
+
} else if (parameter.value != null) {
|
|
37
|
+
if (Buffer.isBuffer(parameter.value)) {
|
|
38
|
+
return parameter.value.length || 1;
|
|
39
|
+
} else {
|
|
40
|
+
return parameter.value.toString().length || 1;
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
return this.maximumLength;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
writeTypeInfo: function writeTypeInfo(buffer, parameter) {
|
|
48
|
+
buffer.writeUInt8(this.id);
|
|
49
|
+
if (parameter.length <= this.maximumLength) {
|
|
50
|
+
buffer.writeUInt16LE(this.maximumLength);
|
|
51
|
+
} else {
|
|
52
|
+
buffer.writeUInt16LE(MAX);
|
|
53
|
+
}
|
|
54
|
+
buffer.writeBuffer(new Buffer([0x00, 0x00, 0x00, 0x00, 0x00]));
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
writeParameterData: function writeParameterData(buffer, parameter) {
|
|
58
|
+
if (parameter.value != null) {
|
|
59
|
+
if (parameter.length <= this.maximumLength) {
|
|
60
|
+
buffer.writeUsVarbyte(parameter.value, 'ascii');
|
|
61
|
+
} else {
|
|
62
|
+
buffer.writePLPBody(parameter.value, 'ascii');
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
if (parameter.length <= this.maximumLength) {
|
|
66
|
+
buffer.writeUInt16LE(NULL);
|
|
67
|
+
} else {
|
|
68
|
+
buffer.writeUInt32LE(0xFFFFFFFF);
|
|
69
|
+
buffer.writeUInt32LE(0xFFFFFFFF);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
validate: function validate(value) {
|
|
75
|
+
if (value == null) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
if (typeof value !== 'string') {
|
|
79
|
+
if (typeof value.toString !== 'function') {
|
|
80
|
+
return TypeError('Invalid string.');
|
|
81
|
+
}
|
|
82
|
+
value = value.toString();
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
};
|
package/lib/instance-lookup.js
CHANGED
|
@@ -68,7 +68,7 @@ var InstanceLookup = function () {
|
|
|
68
68
|
|
|
69
69
|
var onTimeout = function onTimeout() {
|
|
70
70
|
sender.cancel();
|
|
71
|
-
|
|
71
|
+
makeAttempt();
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
var makeAttempt = function makeAttempt() {
|
|
@@ -80,26 +80,27 @@ var InstanceLookup = function () {
|
|
|
80
80
|
sender.execute(function (err, message) {
|
|
81
81
|
clearTimeout(timer);
|
|
82
82
|
if (err) {
|
|
83
|
-
|
|
83
|
+
callback('Failed to lookup instance on ' + server + ' - ' + err.message);
|
|
84
|
+
return;
|
|
84
85
|
} else {
|
|
85
86
|
message = message.toString('ascii', MYSTERY_HEADER_LENGTH);
|
|
86
87
|
var port = _this.parseBrowserResponse(message, instanceName);
|
|
87
88
|
|
|
88
89
|
if (port) {
|
|
89
|
-
|
|
90
|
+
callback(undefined, port);
|
|
90
91
|
} else {
|
|
91
|
-
|
|
92
|
+
callback('Port for ' + instanceName + ' not found in ' + message);
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
});
|
|
95
96
|
|
|
96
|
-
|
|
97
|
+
timer = setTimeout(onTimeout, timeout);
|
|
97
98
|
} else {
|
|
98
|
-
|
|
99
|
+
callback('Failed to get response from SQL Server Browser on ' + server);
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
102
|
|
|
102
|
-
|
|
103
|
+
makeAttempt();
|
|
103
104
|
}
|
|
104
105
|
}, {
|
|
105
106
|
key: 'parseBrowserResponse',
|
package/lib/message-io.js
CHANGED
|
@@ -225,7 +225,7 @@ module.exports = function (_EventEmitter) {
|
|
|
225
225
|
key: 'logPacket',
|
|
226
226
|
value: function logPacket(direction, packet) {
|
|
227
227
|
this.debug.packet(direction, packet);
|
|
228
|
-
|
|
228
|
+
this.debug.data(packet);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
// Temporarily suspends the flow of incoming packets.
|
package/lib/ntlm-payload.js
CHANGED
|
@@ -91,7 +91,7 @@ module.exports = function () {
|
|
|
91
91
|
}, {
|
|
92
92
|
key: 'createClientNonce',
|
|
93
93
|
value: function createClientNonce() {
|
|
94
|
-
var client_nonce = new Buffer(8);
|
|
94
|
+
var client_nonce = new Buffer(8).fill(0);
|
|
95
95
|
var nidx = 0;
|
|
96
96
|
while (nidx < 8) {
|
|
97
97
|
client_nonce.writeUInt8(Math.ceil(Math.random() * 255), nidx);
|
|
@@ -105,7 +105,7 @@ module.exports = function () {
|
|
|
105
105
|
var timestamp = this.createTimestamp(mytime);
|
|
106
106
|
var hash = this.ntv2Hash(domain, user, password);
|
|
107
107
|
var dataLength = 40 + targetInfo.length;
|
|
108
|
-
var data = new Buffer(dataLength);
|
|
108
|
+
var data = new Buffer(dataLength).fill(0);
|
|
109
109
|
serverNonce.copy(data, 0, 0, 8);
|
|
110
110
|
data.writeUInt32LE(0x101, 8);
|
|
111
111
|
data.writeUInt32LE(0x0, 12);
|
|
@@ -142,13 +142,13 @@ module.exports = function () {
|
|
|
142
142
|
key: 'lmv2Response',
|
|
143
143
|
value: function lmv2Response(domain, user, password, serverNonce, clientNonce) {
|
|
144
144
|
var hash = this.ntv2Hash(domain, user, password);
|
|
145
|
-
var data = new Buffer(serverNonce.length + clientNonce.length);
|
|
145
|
+
var data = new Buffer(serverNonce.length + clientNonce.length).fill(0);
|
|
146
146
|
|
|
147
147
|
serverNonce.copy(data);
|
|
148
148
|
clientNonce.copy(data, serverNonce.length, 0, clientNonce.length);
|
|
149
149
|
|
|
150
150
|
var newhash = this.hmacMD5(data, hash);
|
|
151
|
-
var response = new Buffer(newhash.length + clientNonce.length);
|
|
151
|
+
var response = new Buffer(newhash.length + clientNonce.length).fill(0);
|
|
152
152
|
|
|
153
153
|
newhash.copy(response);
|
|
154
154
|
clientNonce.copy(response, newhash.length, 0, clientNonce.length);
|
|
@@ -165,7 +165,7 @@ module.exports = function () {
|
|
|
165
165
|
}, {
|
|
166
166
|
key: 'ntHash',
|
|
167
167
|
value: function ntHash(text) {
|
|
168
|
-
var hash = new Buffer(21);
|
|
168
|
+
var hash = new Buffer(21).fill(0);
|
|
169
169
|
hash.fill(0);
|
|
170
170
|
|
|
171
171
|
var unicodeString = new Buffer(text, 'ucs2');
|
package/lib/packet.js
CHANGED
|
@@ -65,7 +65,7 @@ var Packet = function () {
|
|
|
65
65
|
this.buffer = typeOrBuffer;
|
|
66
66
|
} else {
|
|
67
67
|
var type = typeOrBuffer;
|
|
68
|
-
this.buffer = new Buffer(HEADER_LENGTH);
|
|
68
|
+
this.buffer = new Buffer(HEADER_LENGTH).fill(0);
|
|
69
69
|
this.buffer.writeUInt8(type, OFFSET.Type);
|
|
70
70
|
this.buffer.writeUInt8(STATUS.NORMAL, OFFSET.Status);
|
|
71
71
|
this.buffer.writeUInt16BE(DEFAULT_SPID, OFFSET.SPID);
|
|
@@ -78,7 +78,7 @@ var Packet = function () {
|
|
|
78
78
|
(0, _createClass3.default)(Packet, [{
|
|
79
79
|
key: 'setLength',
|
|
80
80
|
value: function setLength() {
|
|
81
|
-
|
|
81
|
+
this.buffer.writeUInt16BE(this.buffer.length, OFFSET.Length);
|
|
82
82
|
}
|
|
83
83
|
}, {
|
|
84
84
|
key: 'length',
|
|
@@ -94,7 +94,7 @@ var Packet = function () {
|
|
|
94
94
|
} else {
|
|
95
95
|
status &= 0xFF - STATUS.RESETCONNECTION;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
this.buffer.writeUInt8(status, OFFSET.Status);
|
|
98
98
|
}
|
|
99
99
|
}, {
|
|
100
100
|
key: 'last',
|
package/lib/prelogin-payload.js
CHANGED
|
@@ -81,7 +81,7 @@ module.exports = function () {
|
|
|
81
81
|
length += 5 + option.data.length;
|
|
82
82
|
}
|
|
83
83
|
length++; // terminator
|
|
84
|
-
this.data = new Buffer(length);
|
|
84
|
+
this.data = new Buffer(length).fill(0);
|
|
85
85
|
var optionOffset = 0;
|
|
86
86
|
var optionDataOffset = 5 * options.length + 1;
|
|
87
87
|
|
|
@@ -95,7 +95,7 @@ module.exports = function () {
|
|
|
95
95
|
optionDataOffset += _option.data.length;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
this.data.writeUInt8(TOKEN.TERMINATOR, optionOffset);
|
|
99
99
|
}
|
|
100
100
|
}, {
|
|
101
101
|
key: 'createVersionOption',
|
|
@@ -184,7 +184,7 @@ module.exports = function () {
|
|
|
184
184
|
}, {
|
|
185
185
|
key: 'extractVersion',
|
|
186
186
|
value: function extractVersion(offset) {
|
|
187
|
-
|
|
187
|
+
this.version = {
|
|
188
188
|
major: this.data.readUInt8(offset + 0),
|
|
189
189
|
minor: this.data.readUInt8(offset + 1),
|
|
190
190
|
patch: this.data.readUInt8(offset + 2),
|
|
@@ -196,23 +196,23 @@ module.exports = function () {
|
|
|
196
196
|
key: 'extractEncryption',
|
|
197
197
|
value: function extractEncryption(offset) {
|
|
198
198
|
this.encryption = this.data.readUInt8(offset);
|
|
199
|
-
|
|
199
|
+
this.encryptionString = encryptByValue[this.encryption];
|
|
200
200
|
}
|
|
201
201
|
}, {
|
|
202
202
|
key: 'extractInstance',
|
|
203
203
|
value: function extractInstance(offset) {
|
|
204
|
-
|
|
204
|
+
this.instance = this.data.readUInt8(offset);
|
|
205
205
|
}
|
|
206
206
|
}, {
|
|
207
207
|
key: 'extractThreadId',
|
|
208
208
|
value: function extractThreadId(offset) {
|
|
209
|
-
|
|
209
|
+
this.threadId = this.data.readUInt32BE(offset);
|
|
210
210
|
}
|
|
211
211
|
}, {
|
|
212
212
|
key: 'extractMars',
|
|
213
213
|
value: function extractMars(offset) {
|
|
214
214
|
this.mars = this.data.readUInt8(offset);
|
|
215
|
-
|
|
215
|
+
this.marsString = marsByValue[this.mars];
|
|
216
216
|
}
|
|
217
217
|
}, {
|
|
218
218
|
key: 'toString',
|