Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
Merge pull request #29 from libp2p/feat/refactor
Browse files Browse the repository at this point in the history
refactor transports to be fully featured
  • Loading branch information
Stebalien authored Jun 6, 2018
2 parents 4953346 + 69216c1 commit e4d6a1a
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 264 deletions.
2 changes: 1 addition & 1 deletion .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.14: QmPUHzTLPZFYqv8WqcBTuMFYTgeom4uHHEaxzk7bd5GYZB
3.0.0: QmYnjSGtvn7LhrxCvwrU9uDWxKyg28uBYeXvgzTDDDzVy4
24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ A common interface for network transports.

This is the 'base' layer for any transport that wants to be used by libp2p and ipfs. If you want to make 'ipfs work over X', the first thing you'll want to do is to implement the `Transport` interface for 'X'.

Transports are:

* Encrypted: Connections must be end-to-end encrypted.
* Authenticated: The endpoints, RemotePeer and LocalPeer, must be authenticated.
* Multiplexed: It must be possible to multiplex multiple reliable streams over a single transport connection.

## Install

```sh
Expand All @@ -23,23 +29,9 @@ This is the 'base' layer for any transport that wants to be used by libp2p and i

## Usage

```go
var t Transport

t = NewTCPTransport()
To actually *use* a transport, you'll likely want to register it with a `transport.Network` (e.g., [go-libp2p-swarm](https://github.com/libp2p/go-libp2p-swarm)). However, you're probably more interested in *implementing* transports.

list, err := t.Listen(listener_maddr)
if err != nil {
log.Fatal(err)
}

con, err := list.Accept()
if err != nil {
log.Fatal(err)
}

fmt.Fprintln(con, "Hello World!")
```
Transports construct fully featured, encrypted, multiplexed connections. However, there's a fairly good chance your transport won't meet all of those requirements. To make life easier, we've created a helper library called [go-libp2p-transport-upgrader](https://github.com/libp2p/go-libp2p-transport-upgrader) for upgrading simple stream transports to fully-featured (encrypted, authenticated, multiplexed) transports. Check out that packages [README]([go-libp2p-transport-upgrader](https://github.com/libp2p/go-libp2p-transport-upgrader/blob/master/README.md) for an example.

## Contribute

Expand Down
53 changes: 0 additions & 53 deletions fallback.go

This file was deleted.

96 changes: 0 additions & 96 deletions fallback_test.go

This file was deleted.

32 changes: 19 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@
"dvcsimport": "github.com/libp2p/go-libp2p-transport"
},
"gxDependencies": [
{
"author": "jbenet",
"hash": "QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB",
"name": "go-multiaddr-net",
"version": "1.5.7"
},
{
"author": "whyrusleeping",
"hash": "QmTy17Jm1foTnvUS9JXRhLbRQ3XuC64jPTjUfpB4mHz2QM",
"name": "mafmt",
"version": "1.2.5"
},
{
"hash": "QmTG23dvpBCBjqQwyDxV8CQT6jmS4PSftNr1VqHhE3MLy7",
"name": "go-log",
Expand All @@ -29,13 +17,31 @@
"hash": "QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb",
"name": "go-multiaddr",
"version": "1.2.6"
},
{
"author": "whyrusleeping",
"hash": "QmYj8wdn5sZEHX2XMDWGBvcXJNdzVbaVpHmXvhHBVZepen",
"name": "go-libp2p-net",
"version": "3.0.0"
},
{
"author": "whyrusleeping",
"hash": "QmY9JXR3FupnYAYJWK9aMr9bCpqWKcToQ1tz8DVGTrHpHw",
"name": "go-stream-muxer",
"version": "3.0.0"
},
{
"author": "whyrusleeping",
"hash": "QmcJukH2sAFjY3HdBKq35WDzWoL3UUu2gt9wdfqZTUyM74",
"name": "go-libp2p-peer",
"version": "2.3.2"
}
],
"gxVersion": "0.4.0",
"language": "go",
"license": "MIT",
"name": "go-libp2p-transport",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "2.2.14"
"version": "3.0.0"
}

Loading

0 comments on commit e4d6a1a

Please sign in to comment.