New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

coap

Package Overview
Dependencies
Maintainers
1
Versions
69
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.11.0 to 0.12.0

1

index.js

@@ -48,3 +48,4 @@ /*

module.exports.registerFormat = optionsConv.registerFormat
module.exports.ignoreOption = optionsConv.ignoreOption
module.exports.parameters = parameters

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

, capitalize = require('capitalize')
, isIgnored = require('./option_converter').isIgnored

@@ -42,2 +43,6 @@ module.exports.genAck = function(request) {

if (isIgnored(name)) {
return this
}
this._packet.options = this._packet.options.filter(function(option) {

@@ -44,0 +49,0 @@ return option.name !== name

@@ -13,2 +13,5 @@ /*

// list of options silently ignored
var ignoredOptions = {};
module.exports.toBinary = function(name, value) {

@@ -40,2 +43,16 @@ if (Buffer.isBuffer(value))

var ignoreOption = function(name) {
ignoredOptions[name] = true;
}
module.exports.ignoreOption = ignoreOption
ignoreOption('Cache-Control')
ignoreOption('Content-Length')
ignoreOption('Accept-Ranges')
module.exports.isIgnored = function(name) {
return !!ignoredOptions[name]
}
// ETag option registration

@@ -42,0 +59,0 @@ var fromString = function(result) {

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

, EventEmitter = require('events').EventEmitter
, parse = require('coap-packet').parse

@@ -27,2 +28,3 @@ function RetrySend(sock, port, host) {

this._sendAttemp = 0
this._lastMessageId = -1
this._currentTime = parameters.ackTimeout * (1 + (parameters.ackRandomFactor - 1) * Math.random()) * 1000

@@ -49,2 +51,8 @@

var messageId = parse(this._message).messageId
if (messageId != this._lastMessageId) {
this._lastMessageId = messageId
this._sendAttemp = 0
}
if (!avoidBackoff && ++this._sendAttemp <= parameters.maxRetransmit)

@@ -51,0 +59,0 @@ this._bOffTimer = setTimeout(this._bOff, this._currentTime)

23

lib/server.js

@@ -164,7 +164,11 @@ /*

if (this._sock && done)
done(new Error('Already listening'))
else if (this._sock)
throw new Error('Already listening')
if (this._sock) {
if (done)
done(new Error('Already listening'))
else
throw new Error('Already listening')
return this
}
if (address && net.isIPv6(address))

@@ -177,3 +181,2 @@ this._options.type = 'udp6'

this._sock = dgram.createSocket(this._options.type, handleRequest(this))
this._sock.on('error', function(error) {

@@ -191,6 +194,2 @@ that.emit('error', error)

CoAPServer.prototype.close = function(done) {
this._sock.close()
this._lru.reset()
if (done) {

@@ -200,3 +199,7 @@ setImmediate(done)

this._sock = null
if (this._sock) {
this._sock.close()
this._lru.reset()
this._sock = null
}

@@ -203,0 +206,0 @@ return this

{
"name": "coap",
"version": "0.11.0",
"version": "0.12.0",
"description": "A CoAP library for node modelled after 'http'",

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

@@ -45,4 +45,2 @@ node-coap

This has been tested only on node v0.10.
<a name="install"></a>

@@ -136,2 +134,3 @@ ## Installation

* <a href="#registerOption"><code>coap.<b>registerOption()</b></code></a>
* <a href="#ignoreOption"><code>coap.<b>ignoreOption()</b></code></a>
* <a href="#registerFormat"><code>coap.<b>registerFormat()</b></code></a>

@@ -314,3 +313,4 @@ * <a href="#agent"><code>coap.<b>Agent</b></code></a>

#### message.writeHead(code, headers)
Functions somewhat like `http`'s `writeHead()` function. If `code` is does not match the CoAP code mask of `#.##`, it is coerced into this mask. `headers` is an object with keys being the header names, and values being the header values.
Functions somewhat like `http`'s `writeHead()` function. If `code` is does not match the CoAP code mask of `#.##`, it is coerced into this mask. `headers` is an object with keys being the header names, and values being the header values.
-------------------------------------------------------

@@ -447,2 +447,9 @@ <a name="incoming"></a>

-------------------------------------------------------
<a name="ignoreOption"></a>
### coap.ignoreOption(name)
Explicitly ignore an option; useful for compatibility with `http`-based
modules.
-------------------------------------------------------
<a name="registerFormat"></a>

@@ -516,4 +523,5 @@ ### coap.registerFormat(name, value)

<tr><th align="left">Nguyen Quoc Dinh</th><td><a href="https://github.com/nqd">GitHub/nqd</a></td><td><a href="https://twitter.com/nqdinh">Twitter/@nqdinh</a></td></tr>
<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">Daniel Moran Jimenez</th><td><a href="https://github.com/dmoranj">GitHub/dmoranj</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>
<tr><th align="left">Christopher Hiller</th><td><a href="https://github.com/boneskull">GitHub/boneskull</a></td><td><a href="https://twitter.com/b0neskull">Twitter/@b0neskull</a></td></tr>
</tbody></table>

@@ -520,0 +528,0 @@

@@ -367,17 +367,28 @@ /*

it("should use the port binded in the agent", function(done){
var agent = new coap.Agent({port: 3636})
, req = coap.request({
port:port
, method:'GET'
, pathname :'a'
, agent:agent
}).end()
it("should use the port binded in the agent", function(done) {
var agent = new coap.Agent({ port: 3636 })
, req = coap.request({port: port
, method: 'GET'
, pathname: 'a'
, agent: agent
}).end()
server.on('request', function(req, res){
res.end('hello');
expect(req.rsinfo.port).eql(3636);
done();
server.on('request', function(req, res) {
res.end('hello');
expect(req.rsinfo.port).eql(3636);
done();
});
});
})
it('should ignore ignored options', function() {
var req = coap.request('coap://localhost:' + port)
req.setOption('Cache-Control', 'private')
req.end()
server.on('request', function(req) {
expect(req.headers).not.to.have.property('Cache-Control')
done()
})
})
})

@@ -48,5 +48,17 @@ /*

clock.restore()
client.close()
server.close()
target.close()
try {
client.close()
} catch (ignored) {
// ignored
}
try {
server.close()
} catch (ignored) {
// ignored
}
try {
target.close()
} catch (ignored) {
// ignored
}
tk.reset()

@@ -53,0 +65,0 @@ })

@@ -244,2 +244,17 @@ /*

it('should only close once', function(done){
server.close(function(){
server.close(done)
})
})
it('should not overwrite existing socket', function(done){
var initial_sock = server._sock
server.listen(server._port+1, function(err){
expect(err.message).to.eql('Already listening')
expect(server._sock).to.eql(initial_sock)
done()
})
})
var formatsString = {

@@ -246,0 +261,0 @@ 'text/plain': new Buffer([0])

Sorry, the diff of this file is not supported yet

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