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

libp2p-tcp

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libp2p-tcp - npm Package Compare versions

Comparing version 0.11.5 to 0.11.6

5

CHANGELOG.md

@@ -0,1 +1,6 @@

<a name="0.11.6"></a>
## [0.11.6](https://github.com/libp2p/js-libp2p-tcp/compare/v0.11.5...v0.11.6) (2018-02-20)
<a name="0.11.5"></a>

@@ -2,0 +7,0 @@ ## [0.11.5](https://github.com/libp2p/js-libp2p-tcp/compare/v0.11.4...v0.11.5) (2018-02-07)

8

package.json
{
"name": "libp2p-tcp",
"version": "0.11.5",
"version": "0.11.6",
"description": "Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces",

@@ -37,3 +37,3 @@ "main": "src/index.js",

"devDependencies": {
"aegir": "^12.4.0",
"aegir": "^13.0.5",
"chai": "^4.1.2",

@@ -44,3 +44,3 @@ "dirty-chai": "^2.0.1",

"pre-commit": "^1.2.2",
"pull-stream": "^3.6.1"
"pull-stream": "^3.6.2"
},

@@ -53,3 +53,3 @@ "dependencies": {

"lodash.isfunction": "^3.0.9",
"mafmt": "^3.0.2",
"mafmt": "^4.0.0",
"multiaddr": "^3.0.2",

@@ -56,0 +56,0 @@ "once": "^1.4.0",

@@ -12,11 +12,8 @@ # js-libp2p-tcp

![](https://raw.githubusercontent.com/libp2p/interface-connection/master/img/badge.png)
![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png)
[![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png)](https://github.com/libp2p/interface-transport)
[![](https://raw.githubusercontent.com/libp2p/interface-connection/master/img/badge.png)](https://github.com/libp2p/interface-connection)
> Node.js implementation of the TCP module that libp2p uses, which implements the [interface-connection](https://github.com/libp2p/interface-connection) interface for dial/listen.
`libp2p-tcp` in Node.js is a very thin shim that adds support for dialing to a `multiaddr`. This small shim will enable libp2p to use other different transports.
> JavaScript implementation of the TCP module for libp2p. It exposes the [interface-transport](https://github.com/libp2p/interface-connection) for dial/listen. `libp2p-tcp` is a very thin shim that adds support for dialing to a `multiaddr`. This small shim will enable libp2p to use other different transports.
**Note:** This module uses [pull-streams](https://pull-stream.github.io) for all stream based interfaces.
## Table of Contents

@@ -27,5 +24,2 @@

- [Usage](#usage)
- [Example](#example)
- [This module uses `pull-streams`](#this-module-uses-pull-streams)
- [Converting `pull-streams` to Node.js Streams](#converting-pull-streams-to-nodejs-streams)
- [API](#api)

@@ -40,3 +34,3 @@ - [Contribute](#contribute)

```sh
> npm i libp2p-tcp
> npm install libp2p-tcp
```

@@ -46,4 +40,2 @@

### Example
```js

@@ -88,28 +80,6 @@ const TCP = require('libp2p-tcp')

### This module uses `pull-streams`
## API
We expose a streaming interface based on `pull-streams`, rather then on the Node.js core streams implementation (aka Node.js streams). `pull-streams` offers us a better mechanism for error handling and flow control guarantees. If you would like to know more about why we did this, see the discussion at this [issue](https://github.com/ipfs/js-ipfs/issues/362).
### Transport
You can learn more about pull-streams at:
- [The history of Node.js streams, nodebp April 2014](https://www.youtube.com/watch?v=g5ewQEuXjsQ)
- [The history of streams, 2016](http://dominictarr.com/post/145135293917/history-of-streams)
- [pull-streams, the simple streaming primitive](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple)
- [pull-streams documentation](https://pull-stream.github.io/)
#### Converting `pull-streams` to Node.js Streams
If you are a Node.js streams user, you can convert a pull-stream to a Node.js stream using the module [`pull-stream-to-stream`](https://github.com/dominictarr/pull-stream-to-stream), giving you an instance of a Node.js stream that is linked to the pull-stream. For example:
```js
const pullToStream = require('pull-stream-to-stream')
const nodeStreamInstance = pullToStream(pullStreamInstance)
// nodeStreamInstance is an instance of a Node.js Stream
```
To learn more about this utility, visit https://pull-stream.github.io/#pull-stream-to-stream.
## API
[![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png)](https://github.com/libp2p/interface-transport)

@@ -124,2 +94,6 @@

### Connection
[![](https://raw.githubusercontent.com/libp2p/interface-connection/master/img/badge.png)](https://github.com/libp2p/interface-connection)
## Contribute

@@ -126,0 +100,0 @@

@@ -7,17 +7,23 @@ 'use strict'

module.exports = (socket) => {
let mh
let ma
if (socket.remoteFamily === 'IPv6') {
var addr = new Address6(socket.remoteAddress)
const addr = new Address6(socket.remoteAddress)
if (addr.v4) {
var ip4 = addr.to4().correctForm()
mh = multiaddr('/ip4/' + ip4 + '/tcp/' + socket.remotePort)
const ip4 = addr.to4().correctForm()
ma = multiaddr('/ip4/' + ip4 +
'/tcp/' + socket.remotePort
)
} else {
mh = multiaddr('/ip6/' + socket.remoteAddress + '/tcp/' + socket.remotePort)
ma = multiaddr('/ip6/' + socket.remoteAddress +
'/tcp/' + socket.remotePort
)
}
} else {
mh = multiaddr('/ip4/' + socket.remoteAddress + '/tcp/' + socket.remotePort)
ma = multiaddr('/ip4/' + socket.remoteAddress +
'/tcp/' + socket.remotePort)
}
return mh
return ma
}

@@ -24,5 +24,4 @@ 'use strict'

callback = callback || noop
callback = once(callback || noop)
callback = once(callback)
const cOpts = ma.toOptions()

@@ -62,3 +61,3 @@ log('Connecting to %s %s', cOpts.port, cOpts.host)

handler = handler || (() => {})
handler = handler || noop

@@ -65,0 +64,0 @@ return createListener(handler)

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