Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coap

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coap - npm Package Compare versions

Comparing version 0.10.4 to 0.10.5

lib/polyfill.js

6

lib/agent.js

@@ -27,2 +27,3 @@ /*

, maxMessageId = Math.pow(2, 16)
, pf = require('./polyfill')

@@ -159,2 +160,5 @@ function Agent(opts) {

}
} else if (packet.code != '0.00' && (req._packet.token.length != packet.token.length || pf.compareBuffers(req._packet.token, packet.token) != 0)) {
// The tokens don't match, ignore the message since it is a malformed response
return
}

@@ -222,3 +226,3 @@

}
else if (!req.url.observe)
else if (!req.url.observe && packet.token.length > 0)
// it is not, so delete the token

@@ -225,0 +229,0 @@ delete that._tkToReq[packet.token.readUInt32BE(0)]

@@ -9,2 +9,4 @@ /*

require('./polyfill')
var dgram = require('dgram')

@@ -11,0 +13,0 @@ , net = require('net')

2

package.json
{
"name": "coap",
"version": "0.10.4",
"version": "0.10.5",
"description": "A CoAP library for node modelled after 'http'",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -510,2 +510,3 @@ node-coap

<tr><th align="left">Daniel Moran Jimenez</th><td><a href="https://github.com/dmoranj">GitHub/nqd</a></td><td><a href="https://twitter.com/erzeneca">Twitter/@erzeneca</a></td></tr>
<tr><th align="left">Ignacio Martín</th><td><a href="https://github.com/neich">GitHub/neich</a></td><td><a href="https://twitter.com/natxupitxu">Twitter/@natxupitxu</a></td></tr>
</tbody></table>

@@ -512,0 +513,0 @@

@@ -22,3 +22,3 @@ /*

beforeEach(function(done) {
beforeEach(function (done) {
port = nextPort()

@@ -29,3 +29,3 @@ server = dgram.createSocket('udp4')

afterEach(function() {
afterEach(function () {
server.close()

@@ -42,13 +42,13 @@

, toSend = generate({
messageId: packet.messageId
, ack: true
, code: '0.00'
})
messageId: packet.messageId
, ack: true
, code: '0.00'
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
}
it('should return a pipeable stream', function(done) {
it('should return a pipeable stream', function (done) {
var req = request('coap://localhost:' + port)
, stream = bl()
stream.append('hello world')

@@ -61,7 +61,7 @@

it('should send the data to the server', function(done) {
it('should send the data to the server', function (done) {
var req = request('coap://localhost:' + port)
req.end(new Buffer('hello world'))
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
ackBack(msg, rsinfo)

@@ -73,7 +73,7 @@ expect(parse(msg).payload.toString()).to.eql('hello world')

it('should send a confirmable message by default', function(done) {
it('should send a confirmable message by default', function (done) {
var req = request('coap://localhost:' + port)
req.end(new Buffer('hello world'))
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
ackBack(msg, rsinfo)

@@ -85,7 +85,7 @@ expect(parse(msg).confirmable).to.be.true

it('should emit the errors in the req', function(done) {
it('should emit the errors in the req', function (done) {
var req = request('coap://aaa.eee:' + 1234)
req.end(new Buffer('hello world'))
req.on('error', function() {
req.on('error', function () {
done()

@@ -95,6 +95,6 @@ })

it('should error if the message is too big', function(done) {
it('should error if the message is too big', function (done) {
var req = request('coap://localhost:' + port)
req.on('error', function() {
req.on('error', function () {
done()

@@ -106,10 +106,10 @@ })

it('should imply a default port', function(done) {
it('should imply a default port', function (done) {
server2 = dgram.createSocket('udp4')
server2.bind(5683, function() {
server2.bind(5683, function () {
request('coap://localhost').end()
})
server2.on('message', function(msg, rsinfo) {
server2.on('message', function (msg, rsinfo) {
ackBack(msg, rsinfo)

@@ -120,7 +120,7 @@ done()

it('should send the path to the server', function(done) {
it('should send the path to the server', function (done) {
var req = request('coap://localhost:' + port + '/hello')
req.end(new Buffer('hello world'))
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
ackBack(msg, rsinfo)

@@ -135,8 +135,8 @@

})
it('should send a longer path to the server', function(done) {
it('should send a longer path to the server', function (done) {
var req = request('coap://localhost:' + port + '/hello/world')
req.end(new Buffer('hello world'))
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
ackBack(msg, rsinfo)

@@ -153,5 +153,5 @@

it('should accept an object instead of a string', function(done) {
it('should accept an object instead of a string', function (done) {
var req = request({
hostname: 'localhost'
hostname: 'localhost'
, port: port

@@ -163,3 +163,3 @@ , pathname: '/hello/world'

server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
ackBack(msg, rsinfo)

@@ -176,7 +176,7 @@

it('should send a query string to the server', function(done) {
it('should send a query string to the server', function (done) {
var req = request('coap://localhost:' + port + '?a=b&c=d')
req.end(new Buffer('hello world'))
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
ackBack(msg, rsinfo)

@@ -193,9 +193,9 @@

it('should accept a method parameter', function(done) {
it('should accept a method parameter', function (done) {
request({
port: port
port: port
, method: 'POST'
}).end()
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
ackBack(msg, rsinfo)

@@ -209,22 +209,22 @@

it('should emit a response with a piggyback CON message', function(done) {
it('should emit a response with a piggyback CON message', function (done) {
var req = request({
port: port
port: port
, confirmable: true
})
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, payload: new Buffer('42')
, ack: true
, code: '2.00'
})
messageId: packet.messageId
, token: packet.token
, payload: new Buffer('42')
, ack: true
, code: '2.00'
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
})
req.on('response', function(res) {
res.pipe(bl(function(err, data) {
req.on('response', function (res) {
res.pipe(bl(function (err, data) {
expect(data).to.eql(new Buffer('42'))

@@ -238,21 +238,21 @@ done()

it('should emit a response with a delayed CON message', function(done) {
it('should emit a response with a delayed CON message', function (done) {
var req = request({
port: port
port: port
, confirmable: true
})
server.once('message', function(msg, rsinfo) {
server.once('message', function (msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, payload: new Buffer('')
, ack: true
, code: '0.00'
})
messageId: packet.messageId
, token: packet.token
, payload: new Buffer('')
, ack: true
, code: '0.00'
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
toSend = generate({
token: packet.token
token: packet.token
, payload: new Buffer('42')

@@ -265,4 +265,4 @@ , confirmable: true

req.on('response', function(res) {
res.pipe(bl(function(err, data) {
req.on('response', function (res) {
res.pipe(bl(function (err, data) {
expect(data).to.eql(new Buffer('42'))

@@ -277,19 +277,19 @@ done()

it('should send an ACK back after receiving a CON response', function(done) {
it('should send an ACK back after receiving a CON response', function (done) {
var req = request({
port: port
port: port
, confirmable: true
})
server.once('message', function(msg, rsinfo) {
server.once('message', function (msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, ack: true
, code: '0.00'
})
messageId: packet.messageId
, ack: true
, code: '0.00'
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
toSend = generate({
token: packet.token
token: packet.token
, payload: new Buffer('42')

@@ -302,3 +302,3 @@ , confirmable: true

server.once('message', function(msg, rsinfo) {
server.once('message', function (msg, rsinfo) {
packet = parse(msg)

@@ -315,11 +315,11 @@ expect(packet.code).to.eql('0.00')

it('should not emit a response with an ack', function(done) {
it('should not emit a response with an ack', function (done) {
var req = request({
port: port
port: port
, confirmable: true
})
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
ackBack(msg, rsinfo)
setTimeout(function() {
setTimeout(function () {
done()

@@ -329,3 +329,3 @@ }, 20)

req.on('response', function(res) {
req.on('response', function (res) {
done(new Error('Unexpected response'))

@@ -337,21 +337,21 @@ })

it('should emit a response with a NON message', function(done) {
it('should emit a response with a NON message', function (done) {
var req = request({
port: port
port: port
, confirmable: false
})
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, payload: new Buffer('42')
, code: '2.00'
})
messageId: packet.messageId
, token: packet.token
, payload: new Buffer('42')
, code: '2.00'
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
})
req.on('response', function(res) {
res.pipe(bl(function(err, data) {
req.on('response', function (res) {
res.pipe(bl(function (err, data) {
expect(data).to.eql(new Buffer('42'))

@@ -365,12 +365,12 @@ done()

it('should allow to add an option', function(done) {
it('should allow to add an option', function (done) {
var req = request({
port: port
})
port: port
})
, buf = new Buffer(3)
req.setOption('ETag', buf)
req.end()
server.on('message', function(msg) {
server.on('message', function (msg) {
expect(parse(msg).options[0].name).to.eql('ETag')

@@ -382,8 +382,8 @@ expect(parse(msg).options[0].value).to.eql(buf)

it('should overwrite the option', function(done) {
it('should overwrite the option', function (done) {
var req = request({
port: port
})
port: port
})
, buf = new Buffer(3)
req.setOption('ETag', new Buffer(3))

@@ -393,3 +393,3 @@ req.setOption('ETag', buf)

server.on('message', function(msg) {
server.on('message', function (msg) {
expect(parse(msg).options[0].value).to.eql(buf)

@@ -400,12 +400,12 @@ done()

it('should alias setOption to setHeader', function(done) {
it('should alias setOption to setHeader', function (done) {
var req = request({
port: port
})
port: port
})
, buf = new Buffer(3)
req.setHeader('ETag', buf)
req.end()
server.on('message', function(msg) {
server.on('message', function (msg) {
expect(parse(msg).options[0].value).to.eql(buf)

@@ -416,13 +416,13 @@ done()

it('should set multiple options', function(done) {
it('should set multiple options', function (done) {
var req = request({
port: port
})
port: port
})
, buf1 = new Buffer(3)
, buf2 = new Buffer(3)
req.setOption('433', [buf1, buf2])
req.end()
server.on('message', function(msg) {
server.on('message', function (msg) {
expect(parse(msg).options[0].value).to.eql(buf1)

@@ -434,11 +434,11 @@ expect(parse(msg).options[1].value).to.eql(buf2)

it('should alias the \'Content-Format\' option to \'Content-Type\'', function(done) {
it('should alias the \'Content-Format\' option to \'Content-Type\'', function (done) {
var req = request({
port: port
})
port: port
})
req.setOption('Content-Type', new Buffer([0]))
req.end()
server.on('message', function(msg) {
server.on('message', function (msg) {
expect(parse(msg).options[0].name).to.eql('Content-Format')

@@ -451,3 +451,3 @@ expect(parse(msg).options[0].value).to.eql(new Buffer([0]))

var formatsString = {
'text/plain': new Buffer([0])
'text/plain': new Buffer([0])
, 'application/link-format': new Buffer([40])

@@ -460,13 +460,13 @@ , 'application/xml': new Buffer([41])

describe('with the \'Content-Format\' header in the outgoing message', function() {
describe('with the \'Content-Format\' header in the outgoing message', function () {
function buildTest(format, value) {
it('should parse ' + format, function(done) {
it('should parse ' + format, function (done) {
var req = request({
port: port
})
port: port
})
req.setOption('Content-Format', format)
req.end()
server.on('message', function(msg) {
server.on('message', function (msg) {
expect(parse(msg).options[0].value).to.eql(value)

@@ -483,13 +483,13 @@ done()

describe('with the \'Accept\' header in the outgoing message', function() {
describe('with the \'Accept\' header in the outgoing message', function () {
function buildTest(format, value) {
it('should parse ' + format, function(done) {
it('should parse ' + format, function (done) {
var req = request({
port: port
})
port: port
})
req.setHeader('Accept', format)
req.end()
server.on('message', function(msg) {
server.on('message', function (msg) {
expect(parse(msg).options[0].value).to.eql(value)

@@ -506,14 +506,14 @@ done()

describe('with the \'Content-Format\' in the response', function() {
describe('with the \'Content-Format\' in the response', function () {
function buildResponse(value) {
return function(msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, options: [{
name: 'Content-Format'
, value: value
}]
})
return function (msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, options: [{
name: 'Content-Format'
, value: value
}]
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)

@@ -524,3 +524,3 @@ }

function buildTest(format, value) {
it('should parse ' + format, function(done) {
it('should parse ' + format, function (done) {
var req = request({

@@ -532,3 +532,3 @@ port: port

req.on('response', function(res) {
req.on('response', function (res) {
expect(res.options[0].value).to.eql(format)

@@ -541,3 +541,3 @@ done()

it('should include ' + format + ' in the headers', function(done) {
it('should include ' + format + ' in the headers', function (done) {
var req = request({

@@ -549,3 +549,3 @@ port: port

req.on('response', function(res) {
req.on('response', function (res) {
expect(res.headers['Content-Format']).to.eql(format)

@@ -565,3 +565,3 @@ expect(res.headers['Content-Type']).to.eql(format)

it('should include \'ETag\' in the response headers', function(done) {
it('should include \'ETag\' in the response headers', function (done) {
var req = request({

@@ -571,16 +571,16 @@ port: port

server.on('message', function(msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, options: [{
name: 'ETag'
, value: new Buffer('abcdefgh')
}]
})
server.on('message', function (msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, options: [{
name: 'ETag'
, value: new Buffer('abcdefgh')
}]
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
})
req.on('response', function(res) {
req.on('response', function (res) {
expect(res.headers).to.have.property('ETag', 'abcdefgh')

@@ -593,3 +593,3 @@ done()

it('should include original and destination socket information in the response', function(done) {
it('should include original and destination socket information in the response', function (done) {
var req = request({

@@ -599,13 +599,13 @@ port: port

server.on('message', function(msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, options: []
})
server.on('message', function (msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, options: []
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
})
req.on('response', function(res) {
req.on('response', function (res) {
expect(res).to.have.property('rsinfo')

@@ -621,10 +621,10 @@ expect(res).to.have.property('outSocket')

describe('non-confirmable retries', function() {
describe('non-confirmable retries', function () {
var clock
beforeEach(function() {
beforeEach(function () {
clock = sinon.useFakeTimers()
})
afterEach(function() {
afterEach(function () {
clock.restore()

@@ -635,3 +635,3 @@ })

return request({
port: port
port: port
, confirmable: false

@@ -647,6 +647,6 @@ }).end()

it('should error after ~247 seconds', function(done) {
it('should error after ~247 seconds', function (done) {
var req = doReq()
req.on('error', function(err) {
req.on('error', function (err) {
expect(err).to.have.property('message', 'No reply in 247s')

@@ -660,8 +660,9 @@ expect(err).to.have.property('retransmitTimeout', 247)

it('should timeout after ~247 seconds', function(done) {
it('should timeout after ~247 seconds', function (done) {
var req = doReq()
req.on('error', function() {})
req.on('error', function () {
})
req.on('timeout', function(err) {
req.on('timeout', function (err) {
expect(err).to.have.property('message', 'No reply in 247s')

@@ -675,11 +676,11 @@ expect(err).to.have.property('retransmitTimeout', 247)

it('should retry four times before erroring', function(done) {
it('should retry four times before erroring', function (done) {
var req = doReq()
, messages = 0
server.on('message', function(msg) {
server.on('message', function (msg) {
messages++
})
req.on('error', function(err) {
req.on('error', function (err) {
// original one plus 4 retries

@@ -693,11 +694,11 @@ expect(messages).to.eql(5)

it('should retry four times before 45s', function(done) {
it('should retry four times before 45s', function (done) {
var req = doReq()
, messages = 0
server.on('message', function(msg) {
server.on('message', function (msg) {
messages++
})
setTimeout(function() {
setTimeout(function () {
// original one plus 4 retries

@@ -711,21 +712,21 @@ expect(messages).to.eql(5)

it('should stop retrying if it receives a message', function(done) {
it('should stop retrying if it receives a message', function (done) {
var req = doReq()
, messages = 0
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
messages++
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, code: '2.00'
, ack: true
, payload: new Buffer(5)
})
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: packet.token
, code: '2.00'
, ack: true
, payload: new Buffer(5)
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
})
setTimeout(function() {
setTimeout(function () {
expect(messages).to.eql(1)

@@ -739,10 +740,10 @@ done()

describe('confirmable retries', function() {
describe('confirmable retries', function () {
var clock
beforeEach(function() {
beforeEach(function () {
clock = sinon.useFakeTimers()
})
afterEach(function() {
afterEach(function () {
clock.restore()

@@ -753,3 +754,3 @@ })

return request({
port: port
port: port
, confirmable: true

@@ -765,6 +766,6 @@ }).end()

it('should error after ~247 seconds', function(done) {
it('should error after ~247 seconds', function (done) {
var req = doReq()
req.on('error', function(err) {
req.on('error', function (err) {
expect(err).to.have.property('message', 'No reply in 247s')

@@ -777,11 +778,11 @@ done()

it('should retry four times before erroring', function(done) {
it('should retry four times before erroring', function (done) {
var req = doReq()
, messages = 0
server.on('message', function(msg) {
server.on('message', function (msg) {
messages++
})
req.on('error', function(err) {
req.on('error', function (err) {
// original one plus 4 retries

@@ -795,7 +796,7 @@ expect(messages).to.eql(5)

it('should retry with the same message id', function(done) {
it('should retry with the same message id', function (done) {
var req = doReq()
, messageId
server.on('message', function(msg) {
server.on('message', function (msg) {
var packet = parse(msg)

@@ -809,3 +810,3 @@

req.on('error', function(err) {
req.on('error', function (err) {
done()

@@ -817,11 +818,11 @@ })

it('should retry four times before 45s', function(done) {
it('should retry four times before 45s', function (done) {
var req = doReq()
, messages = 0
server.on('message', function(msg) {
server.on('message', function (msg) {
messages++
})
setTimeout(function() {
setTimeout(function () {
// original one plus 4 retries

@@ -835,19 +836,19 @@ expect(messages).to.eql(5)

it('should stop retrying if it receives an ack', function(done) {
it('should stop retrying if it receives an ack', function (done) {
var req = doReq()
, messages = 0
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
messages++
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, code: '0.00'
, ack: true
})
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, code: '0.00'
, ack: true
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
})
setTimeout(function() {
setTimeout(function () {
expect(messages).to.eql(1)

@@ -861,6 +862,6 @@ done()

describe('observe', function() {
describe('observe', function () {
function doObserve() {
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
var packet = parse(msg)

@@ -870,5 +871,5 @@

return
ssend(rsinfo, {
messageId: packet.messageId
messageId: packet.messageId
, token: packet.token

@@ -878,5 +879,5 @@ , payload: new Buffer('42')

, options: [{
name: 'Observe'
, value: new Buffer([1])
}]
name: 'Observe'
, value: new Buffer([1])
}]
, code: '2.05'

@@ -886,9 +887,9 @@ })

ssend(rsinfo, {
token: packet.token
token: packet.token
, payload: new Buffer('24')
, confirmable: true
, options: [{
name: 'Observe'
, value: new Buffer([2])
}]
name: 'Observe'
, value: new Buffer([2])
}]
, code: '2.05'

@@ -899,3 +900,3 @@ })

return request({
port: port
port: port
, observe: true

@@ -910,7 +911,7 @@ }).end()

it('should ack the update', function(done) {
it('should ack the update', function (done) {
var req = doObserve()
server.on('message', function(msg) {
server.on('message', function (msg) {
if (parse(msg).ack)

@@ -921,8 +922,8 @@ done()

it('should emit any more data after close', function(done) {
it('should emit any more data after close', function (done) {
var req = doObserve()
req.on('response', function(res) {
res.once('data', function(data) {
req.on('response', function (res) {
res.once('data', function (data) {
expect(data.toString()).to.eql('42')

@@ -932,3 +933,3 @@ res.close()

res.on('data', function(data) {
res.on('data', function (data) {
done(new Error('this should never happen'))

@@ -940,8 +941,8 @@ })

it('should send origin and destination socket data along with the response', function(done) {
it('should send origin and destination socket data along with the response', function (done) {
var req = doObserve()
req.on('response', function(res) {
res.once('data', function(data) {
req.on('response', function (res) {
res.once('data', function (data) {
expect(res).to.have.property('rsinfo')

@@ -957,8 +958,8 @@ expect(res).to.have.property('outSocket')

it('should emit any more data after close', function(done) {
it('should emit any more data after close', function (done) {
var req = doObserve()
req.on('response', function(res) {
res.once('data', function(data) {
req.on('response', function (res) {
res.once('data', function (data) {
expect(data.toString()).to.eql('42')

@@ -968,3 +969,3 @@ res.close()

res.on('data', function(data) {
res.on('data', function (data) {
done(new Error('this should never happen'))

@@ -976,9 +977,9 @@ })

it('should send an empty Observe option', function(done) {
it('should send an empty Observe option', function (done) {
var req = request({
port: port
port: port
, observe: true
}).end()
server.on('message', function(msg, rsinfo) {
server.on('message', function (msg, rsinfo) {
var packet = parse(msg)

@@ -991,2 +992,78 @@ expect(packet.options[0].name).to.eql('Observe')

})
})
describe('token', function () {
var clock
beforeEach(function () {
clock = sinon.useFakeTimers()
})
afterEach(function () {
clock.restore()
})
function fastForward(increase, max) {
clock.tick(increase)
if (increase < max)
setImmediate(fastForward.bind(null, increase, max - increase))
}
it('should timeout if the response token size doesn\'t match the request\'s', function (done) {
var req = request({
port: port
})
server.on('message', function (msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: new Buffer(2)
, options: []
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
})
req.on('error', function () {})
req.on('timeout', function () {
done()
})
req.end()
fastForward(1000, 247 * 1000)
})
it('should timeout if the response token content doesn\'t match the request\'s', function (done) {
var req = request({
port: port
})
server.on('message', function (msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
messageId: packet.messageId
, token: new Buffer(4)
, options: []
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
})
req.on('error', function () {})
req.on('timeout', function () {
done()
})
req.end()
fastForward(1000, 247 * 1000)
})
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc