diff --git a/README.md b/README.md index 7320fde6..a10c459a 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ $ node > addr.protos() [ {code: 4, name: 'ip4', size: 32}, - {code: 17, name: 'udp', size: 16} + {code: 273, name: 'udp', size: 16} ] // gives you an object that is friendly with what Node.js core modules expect for addresses diff --git a/src/convert.js b/src/convert.js index 0ade5b98..7d40f418 100644 --- a/src/convert.js +++ b/src/convert.js @@ -25,7 +25,7 @@ Convert.toString = function convertToString (proto, buf) { return ip.toString(buf) case 6: // tcp - case 17: // udp + case 273: // udp case 33: // dccp case 132: // sctp return buf2port(buf) @@ -51,7 +51,7 @@ Convert.toBuffer = function convertToBuffer (proto, str) { return ip2buf(new ipAddress.Address6(str)) case 6: // tcp - case 17: // udp + case 273: // udp case 33: // dccp case 132: // sctp return port2buf(parseInt(str, 10)) diff --git a/src/index.js b/src/index.js index 95ee29e8..3fe1520b 100644 --- a/src/index.js +++ b/src/index.js @@ -372,7 +372,7 @@ Multiaddr.prototype.isThinWaistAddress = function isThinWaistAddress (addr) { if (protos[0].code !== 4 && protos[0].code !== 41) { return false } - if (protos[1].code !== 6 && protos[1].code !== 17) { + if (protos[1].code !== 6 && protos[1].code !== 273) { return false } return true diff --git a/src/protocols-table.js b/src/protocols-table.js index 08e1ccff..6eb4a146 100644 --- a/src/protocols-table.js +++ b/src/protocols-table.js @@ -27,7 +27,7 @@ Protocols.V = V Protocols.table = [ [4, 32, 'ip4'], [6, 16, 'tcp'], - [17, 16, 'udp'], + [273, 16, 'udp'], [33, 16, 'dccp'], [41, 128, 'ip6'], [54, V, 'dns4', 'resolvable'], diff --git a/test/index.spec.js b/test/index.spec.js index a9b46d93..451bad5a 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -98,15 +98,15 @@ describe('requiring varint', () => { describe('manipulation', () => { it('basic', () => { const udpAddrStr = '/ip4/127.0.0.1/udp/1234' - const udpAddrBuf = Buffer.from('047f0000011104d2', 'hex') + const udpAddrBuf = Buffer.from('047f000001910204d2', 'hex') const udpAddr = multiaddr(udpAddrStr) expect(udpAddr.toString()).to.equal(udpAddrStr) expect(udpAddr.buffer).to.deep.equal(udpAddrBuf) - expect(udpAddr.protoCodes()).to.deep.equal([4, 17]) + expect(udpAddr.protoCodes()).to.deep.equal([4, 273]) expect(udpAddr.protoNames()).to.deep.equal(['ip4', 'udp']) - expect(udpAddr.protos()).to.deep.equal([multiaddr.protocols.codes[4], multiaddr.protocols.codes[17]]) + expect(udpAddr.protos()).to.deep.equal([multiaddr.protocols.codes[4], multiaddr.protocols.codes[273]]) expect(udpAddr.protos()[0] === multiaddr.protocols.codes[4]).to.equal(false) const udpAddrBuf2 = udpAddr.encapsulate('/udp/5678') @@ -514,7 +514,7 @@ describe('helpers', () => { it('throws on missing transport', () => { expect( - () => multiaddr.fromNodeAddress({address: '0.0.0.0'}) + () => multiaddr.fromNodeAddress({ address: '0.0.0.0' }) ).to.throw( /requires transport protocol/ ) diff --git a/test/protocols.spec.js b/test/protocols.spec.js index 44c762f8..586190b8 100644 --- a/test/protocols.spec.js +++ b/test/protocols.spec.js @@ -27,7 +27,7 @@ describe('protocols', () => { it('else', () => { expect( - () => protocols({hi: 34}) + () => protocols({ hi: 34 }) ).to.throw( /invalid protocol id type/ )