Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
include:
- stage: check
script:
- npx aegir commitlint --travis
- npx aegir dep-check
- npm run lint

Expand Down
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,95 @@ js-libp2p-utp

[Vasco Santos](https://github.com/vasco-santos).

## Table of Contents

- [Install](#install)
- [npm](#npm)
- [Usage](#usage)
- [API](#api)
- [Contribute](#contribute)
- [License](#license)
- [Acknowledgements](#acknowledgements)

## Install

### npm

```sh
> npm install libp2p-utp
```

```js
const UTP = require('libp2p-utp')
const multiaddr = require('multiaddr')
const pipe = require('it-pipe')
const { collect } = require('streaming-iterables')

// A simple upgrader that just returns the MultiaddrConnection
const upgrader = {
upgradeInbound: maConn => maConn,
upgradeOutbound: maConn => maConn
}

const utp = new UTP({ upgrader })

const listener = utp.createListener((socket) => {
console.log('new connection opened')
pipe(
['hello'],
socket
)
})

const addr = multiaddr('/ip4/127.0.0.1/udp/6000/utp')
await listener.listen(addr)
console.log('listening')

const socket = await utp.dial(addr)
const values = await pipe(
socket,
collect
)
console.log(`Value: ${values.toString()}`)

// Close connection after reading
await listener.close()
```

Outputs:

```sh
listening
new connection opened
Value: hello
```

## API

### Transport

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

### Connection

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

## Contribute

Contributions are welcome! The libp2p implementation in JavaScript is a work in progress. As such, there's a few things you can do right now to help out:

- [Check out the existing issues](//github.com/libp2p/js-libp2p-utp/issues).
- **Perform code reviews**.
- **Add tests**. There can never be enough tests.

Please be aware that all interactions related to libp2p are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).

Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.

# Acknowledgements

`js-libp2p-utp` is a wrapper on top on [utp](https://github.com/mafintosh/utp) originally developed by [Mathias Buus](https://github.com/mafintosh)

## License

[MIT](LICENSE) © Protocol Labs Inc.
31 changes: 20 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
"coverage": "aegir coverage",
"coverage-publish": "aegir coverage publish --providers coveralls"
},
"pre-push": [
"lint"
],
"repository": {
"type": "git",
"url": "https://github.com/libp2p/js-libp2p-utp.git"
},
"keywords": [
"libp2p",
"transport",
"websocket",
"IPFS"
],
"license": "MIT",
Expand All @@ -27,23 +33,26 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-utp",
"devDependencies": {
"aegir": "^18.2.2",
"aegir": "^20.3.1",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1"
"dirty-chai": "^2.0.1",
"interface-transport": "^0.7.0",
"sinon": "^7.5.0"
},
"dependencies": {
"abortable-iterator": "^2.1.0",
"class-is": "^1.1.0",
"debug": "^4.1.1",
"interface-connection": "~0.3.3",
"ip-address": "^5.9.0",
"lodash.includes": "^4.3.0",
"lodash.isfunction": "^3.0.9",
"mafmt": "^6.0.7",
"multiaddr": "^6.0.6",
"err-code": "^2.0.0",
"ip-address": "^6.1.0",
"it-pipe": "^1.0.1",
"libp2p-utils": "^0.1.0",
"mafmt": "^7.0.0",
"multiaddr": "^7.1.0",
"once": "^1.4.0",
"pull-stream": "^3.6.11",
"stream-to-pull-stream": "^1.7.3",
"utp-native": "^2.1.3"
"stream-to-it": "^0.1.1",
"streaming-iterables": "^4.1.0",
"utp-native": "^2.1.4"
},
"contributors": [
"David Dias <[email protected]>",
Expand Down
8 changes: 8 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'

// p2p multi-address code
exports.CODE_P2P = 421
exports.CODE_CIRCUIT = 290

// Time to wait for a connection to close gracefully before destroying it manually
exports.CLOSE_TIMEOUT = 2000
126 changes: 0 additions & 126 deletions src/create-listener.js

This file was deleted.

33 changes: 0 additions & 33 deletions src/get-multiaddr.js

This file was deleted.

Loading