Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
14aac9bb
Commit
14aac9bb
authored
Aug 10, 2016
by
Jeromy Johnson
Committed by
GitHub
Aug 10, 2016
Browse files
Merge pull request #84 from libp2p/feat/update-multistream
update multistream deps and fix code to work with new changes
parents
5b9cd671
dd707e22
Changes
56
Hide whitespace changes
Inline
Side-by-side
examples/hosts/main.go
View file @
14aac9bb
...
@@ -5,16 +5,15 @@ import (
...
@@ -5,16 +5,15 @@ import (
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"log"
"log"
"time"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pstore
"github.com/ipfs/go-libp2p-peerstore"
host
"github.com/
ipfs
/go-libp2p/p2p/host"
host
"github.com/
libp2p
/go-libp2p/p2p/host"
bhost
"github.com/
ipfs
/go-libp2p/p2p/host/basic"
bhost
"github.com/
libp2p
/go-libp2p/p2p/host/basic"
metrics
"github.com/
ipfs
/go-libp2p/p2p/metrics"
metrics
"github.com/
libp2p
/go-libp2p/p2p/metrics"
net
"github.com/
ipfs
/go-libp2p/p2p/net"
net
"github.com/
libp2p
/go-libp2p/p2p/net"
conn
"github.com/
ipfs
/go-libp2p/p2p/net/conn"
conn
"github.com/
libp2p
/go-libp2p/p2p/net/conn"
swarm
"github.com/
ipfs
/go-libp2p/p2p/net/swarm"
swarm
"github.com/
libp2p
/go-libp2p/p2p/net/swarm"
testutil
"github.com/
ipfs
/go-libp2p/testutil"
testutil
"github.com/
libp2p
/go-libp2p/testutil"
ipfsaddr
"github.com/ipfs/go-ipfs/thirdparty/ipfsaddr"
ipfsaddr
"github.com/ipfs/go-ipfs/thirdparty/ipfsaddr"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
...
...
p2p/discovery/mdns.go
View file @
14aac9bb
...
@@ -12,10 +12,10 @@ import (
...
@@ -12,10 +12,10 @@ import (
"github.com/cryptix/mdns"
"github.com/cryptix/mdns"
"github.com/ipfs/go-libp2p-peer"
"github.com/ipfs/go-libp2p-peer"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pstore
"github.com/ipfs/go-libp2p-peerstore"
"github.com/ipfs/go-libp2p/p2p/host"
logging
"github.com/ipfs/go-log"
logging
"github.com/ipfs/go-log"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
manet
"github.com/jbenet/go-multiaddr-net"
manet
"github.com/jbenet/go-multiaddr-net"
"github.com/libp2p/go-libp2p/p2p/host"
)
)
var
log
=
logging
.
Logger
(
"mdns"
)
var
log
=
logging
.
Logger
(
"mdns"
)
...
...
p2p/host/basic/basic_host.go
View file @
14aac9bb
...
@@ -5,21 +5,21 @@ import (
...
@@ -5,21 +5,21 @@ import (
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pstore
"github.com/ipfs/go-libp2p-peerstore"
metrics
"github.com/ipfs/go-libp2p/p2p/metrics"
mstream
"github.com/ipfs/go-libp2p/p2p/metrics/stream"
inet
"github.com/ipfs/go-libp2p/p2p/net"
protocol
"github.com/ipfs/go-libp2p/p2p/protocol"
identify
"github.com/ipfs/go-libp2p/p2p/protocol/identify"
relay
"github.com/ipfs/go-libp2p/p2p/protocol/relay"
logging
"github.com/ipfs/go-log"
logging
"github.com/ipfs/go-log"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
goprocess
"github.com/jbenet/goprocess"
goprocess
"github.com/jbenet/goprocess"
metrics
"github.com/libp2p/go-libp2p/p2p/metrics"
mstream
"github.com/libp2p/go-libp2p/p2p/metrics/stream"
inet
"github.com/libp2p/go-libp2p/p2p/net"
protocol
"github.com/libp2p/go-libp2p/p2p/protocol"
identify
"github.com/libp2p/go-libp2p/p2p/protocol/identify"
relay
"github.com/libp2p/go-libp2p/p2p/protocol/relay"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
msmux
"github.com/whyrusleeping/go-multistream"
msmux
"github.com/whyrusleeping/go-multistream"
)
)
var
log
=
logging
.
Logger
(
"github.com/
ipfs
/go-libp2p/p2p/host/basic"
)
var
log
=
logging
.
Logger
(
"github.com/
libp2p
/go-libp2p/p2p/host/basic"
)
// Option is a type used to pass in options to the host.
// Option is a type used to pass in options to the host.
type
Option
int
type
Option
int
...
@@ -114,7 +114,8 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) {
...
@@ -114,7 +114,8 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) {
logStream
:=
mstream
.
WrapStream
(
s
,
protocol
.
ID
(
protoID
),
h
.
bwc
)
logStream
:=
mstream
.
WrapStream
(
s
,
protocol
.
ID
(
protoID
),
h
.
bwc
)
go
handle
(
logStream
)
s
.
SetProtocol
(
protoID
)
go
handle
(
protoID
,
logStream
)
}
}
// ID returns the (local) peer.ID associated with this Host
// ID returns the (local) peer.ID associated with this Host
...
@@ -147,8 +148,10 @@ func (h *BasicHost) IDService() *identify.IDService {
...
@@ -147,8 +148,10 @@ func (h *BasicHost) IDService() *identify.IDService {
// host.Mux().SetHandler(proto, handler)
// host.Mux().SetHandler(proto, handler)
// (Threadsafe)
// (Threadsafe)
func
(
h
*
BasicHost
)
SetStreamHandler
(
pid
protocol
.
ID
,
handler
inet
.
StreamHandler
)
{
func
(
h
*
BasicHost
)
SetStreamHandler
(
pid
protocol
.
ID
,
handler
inet
.
StreamHandler
)
{
h
.
Mux
()
.
AddHandler
(
string
(
pid
),
func
(
rwc
io
.
ReadWriteCloser
)
error
{
h
.
Mux
()
.
AddHandler
(
string
(
pid
),
func
(
p
string
,
rwc
io
.
ReadWriteCloser
)
error
{
handler
(
rwc
.
(
inet
.
Stream
))
is
:=
rwc
.
(
inet
.
Stream
)
is
.
SetProtocol
(
p
)
handler
(
is
)
return
nil
return
nil
})
})
}
}
...
...
p2p/host/basic/basic_host_test.go
View file @
14aac9bb
...
@@ -5,9 +5,9 @@ import (
...
@@ -5,9 +5,9 @@ import (
"io"
"io"
"testing"
"testing"
inet
"github.com/
ipfs
/go-libp2p/p2p/net"
inet
"github.com/
libp2p
/go-libp2p/p2p/net"
protocol
"github.com/
ipfs
/go-libp2p/p2p/protocol"
protocol
"github.com/
libp2p
/go-libp2p/p2p/protocol"
testutil
"github.com/
ipfs
/go-libp2p/p2p/test/util"
testutil
"github.com/
libp2p
/go-libp2p/p2p/test/util"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
)
)
...
...
p2p/host/basic/natmgr.go
View file @
14aac9bb
...
@@ -4,10 +4,10 @@ import (
...
@@ -4,10 +4,10 @@ import (
"sync"
"sync"
lgbl
"github.com/ipfs/go-libp2p-loggables"
lgbl
"github.com/ipfs/go-libp2p-loggables"
inat
"github.com/ipfs/go-libp2p/p2p/nat"
inet
"github.com/ipfs/go-libp2p/p2p/net"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
goprocess
"github.com/jbenet/goprocess"
goprocess
"github.com/jbenet/goprocess"
inat
"github.com/libp2p/go-libp2p/p2p/nat"
inet
"github.com/libp2p/go-libp2p/p2p/net"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
)
)
...
...
p2p/host/host.go
View file @
14aac9bb
...
@@ -3,16 +3,16 @@ package host
...
@@ -3,16 +3,16 @@ package host
import
(
import
(
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pstore
"github.com/ipfs/go-libp2p-peerstore"
metrics
"github.com/ipfs/go-libp2p/p2p/metrics"
inet
"github.com/ipfs/go-libp2p/p2p/net"
protocol
"github.com/ipfs/go-libp2p/p2p/protocol"
logging
"github.com/ipfs/go-log"
logging
"github.com/ipfs/go-log"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
metrics
"github.com/libp2p/go-libp2p/p2p/metrics"
inet
"github.com/libp2p/go-libp2p/p2p/net"
protocol
"github.com/libp2p/go-libp2p/p2p/protocol"
msmux
"github.com/whyrusleeping/go-multistream"
msmux
"github.com/whyrusleeping/go-multistream"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
)
)
var
log
=
logging
.
Logger
(
"github.com/
ipfs
/go-libp2p/p2p/host"
)
var
log
=
logging
.
Logger
(
"github.com/
libp2p
/go-libp2p/p2p/host"
)
// Host is an object participating in a p2p network, which
// Host is an object participating in a p2p network, which
// implements protocols or provides services. It handles
// implements protocols or provides services. It handles
...
...
p2p/host/routed/routed.go
View file @
14aac9bb
...
@@ -7,18 +7,18 @@ import (
...
@@ -7,18 +7,18 @@ import (
lgbl
"github.com/ipfs/go-libp2p-loggables"
lgbl
"github.com/ipfs/go-libp2p-loggables"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pstore
"github.com/ipfs/go-libp2p-peerstore"
host
"github.com/ipfs/go-libp2p/p2p/host"
metrics
"github.com/ipfs/go-libp2p/p2p/metrics"
inet
"github.com/ipfs/go-libp2p/p2p/net"
protocol
"github.com/ipfs/go-libp2p/p2p/protocol"
logging
"github.com/ipfs/go-log"
logging
"github.com/ipfs/go-log"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
host
"github.com/libp2p/go-libp2p/p2p/host"
metrics
"github.com/libp2p/go-libp2p/p2p/metrics"
inet
"github.com/libp2p/go-libp2p/p2p/net"
protocol
"github.com/libp2p/go-libp2p/p2p/protocol"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
msmux
"github.com/whyrusleeping/go-multistream"
msmux
"github.com/whyrusleeping/go-multistream"
)
)
var
log
=
logging
.
Logger
(
"github.com/
ipfs
/go-libp2p/p2p/host/routed"
)
var
log
=
logging
.
Logger
(
"github.com/
libp2p
/go-libp2p/p2p/host/routed"
)
// AddressTTL is the expiry time for our addresses.
// AddressTTL is the expiry time for our addresses.
// We expire them quickly.
// We expire them quickly.
...
...
p2p/metrics/bw_stats.go
View file @
14aac9bb
...
@@ -5,7 +5,7 @@ import (
...
@@ -5,7 +5,7 @@ import (
"sync"
"sync"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
protocol
"github.com/
ipfs
/go-libp2p/p2p/protocol"
protocol
"github.com/
libp2p
/go-libp2p/p2p/protocol"
)
)
type
Stats
struct
{
type
Stats
struct
{
...
...
p2p/metrics/conn/conn.go
View file @
14aac9bb
...
@@ -2,7 +2,7 @@ package meterconn
...
@@ -2,7 +2,7 @@ package meterconn
import
(
import
(
transport
"github.com/ipfs/go-libp2p-transport"
transport
"github.com/ipfs/go-libp2p-transport"
metrics
"github.com/
ipfs
/go-libp2p/p2p/metrics"
metrics
"github.com/
libp2p
/go-libp2p/p2p/metrics"
)
)
type
MeteredConn
struct
{
type
MeteredConn
struct
{
...
...
p2p/metrics/interface.go
View file @
14aac9bb
...
@@ -2,7 +2,7 @@ package metrics
...
@@ -2,7 +2,7 @@ package metrics
import
(
import
(
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
protocol
"github.com/
ipfs
/go-libp2p/p2p/protocol"
protocol
"github.com/
libp2p
/go-libp2p/p2p/protocol"
)
)
type
StreamMeterCallback
func
(
int64
,
protocol
.
ID
,
peer
.
ID
)
type
StreamMeterCallback
func
(
int64
,
protocol
.
ID
,
peer
.
ID
)
...
...
p2p/metrics/stream/metered.go
View file @
14aac9bb
...
@@ -2,9 +2,9 @@ package meterstream
...
@@ -2,9 +2,9 @@ package meterstream
import
(
import
(
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
metrics
"github.com/
ipfs
/go-libp2p/p2p/metrics"
metrics
"github.com/
libp2p
/go-libp2p/p2p/metrics"
inet
"github.com/
ipfs
/go-libp2p/p2p/net"
inet
"github.com/
libp2p
/go-libp2p/p2p/net"
protocol
"github.com/
ipfs
/go-libp2p/p2p/protocol"
protocol
"github.com/
libp2p
/go-libp2p/p2p/protocol"
)
)
type
meteredStream
struct
{
type
meteredStream
struct
{
...
...
p2p/metrics/stream/metered_test.go
View file @
14aac9bb
...
@@ -7,8 +7,8 @@ import (
...
@@ -7,8 +7,8 @@ import (
randbo
"github.com/dustin/randbo"
randbo
"github.com/dustin/randbo"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
inet
"github.com/
ipfs
/go-libp2p/p2p/net"
inet
"github.com/
libp2p
/go-libp2p/p2p/net"
protocol
"github.com/
ipfs
/go-libp2p/p2p/protocol"
protocol
"github.com/
libp2p
/go-libp2p/p2p/protocol"
)
)
type
FakeStream
struct
{
type
FakeStream
struct
{
...
...
p2p/net/conn/conn_test.go
View file @
14aac9bb
...
@@ -8,8 +8,8 @@ import (
...
@@ -8,8 +8,8 @@ import (
"testing"
"testing"
"time"
"time"
travis
"github.com/ipfs/go-libp2p/testutil/ci/travis"
msgio
"github.com/jbenet/go-msgio"
msgio
"github.com/jbenet/go-msgio"
travis
"github.com/libp2p/go-libp2p/testutil/ci/travis"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
)
)
...
...
p2p/net/conn/dial.go
View file @
14aac9bb
...
@@ -10,9 +10,9 @@ import (
...
@@ -10,9 +10,9 @@ import (
lgbl
"github.com/ipfs/go-libp2p-loggables"
lgbl
"github.com/ipfs/go-libp2p-loggables"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
transport
"github.com/ipfs/go-libp2p-transport"
transport
"github.com/ipfs/go-libp2p-transport"
addrutil
"github.com/ipfs/go-libp2p/p2p/net/swarm/addr"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
manet
"github.com/jbenet/go-multiaddr-net"
manet
"github.com/jbenet/go-multiaddr-net"
addrutil
"github.com/libp2p/go-libp2p/p2p/net/swarm/addr"
msmux
"github.com/whyrusleeping/go-multistream"
msmux
"github.com/whyrusleeping/go-multistream"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
)
)
...
...
p2p/net/conn/dial_test.go
View file @
14aac9bb
...
@@ -14,7 +14,7 @@ import (
...
@@ -14,7 +14,7 @@ import (
ic
"github.com/ipfs/go-libp2p-crypto"
ic
"github.com/ipfs/go-libp2p-crypto"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
transport
"github.com/ipfs/go-libp2p-transport"
transport
"github.com/ipfs/go-libp2p-transport"
tu
"github.com/
ipfs
/go-libp2p/testutil"
tu
"github.com/
libp2p
/go-libp2p/testutil"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
msmux
"github.com/whyrusleeping/go-multistream"
msmux
"github.com/whyrusleeping/go-multistream"
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
)
)
func
goroFilter
(
r
*
grc
.
Goroutine
)
bool
{
func
goroFilter
(
r
*
grc
.
Goroutine
)
bool
{
return
strings
.
Contains
(
r
.
Function
,
"go-log."
)
return
strings
.
Contains
(
r
.
Function
,
"go-log."
)
||
strings
.
Contains
(
r
.
Stack
[
0
],
"testing.(*T).Run"
)
}
}
func
echoListen
(
ctx
context
.
Context
,
listener
Listener
)
{
func
echoListen
(
ctx
context
.
Context
,
listener
Listener
)
{
...
...
p2p/net/conn/interface.go
View file @
14aac9bb
...
@@ -8,8 +8,8 @@ import (
...
@@ -8,8 +8,8 @@ import (
ic
"github.com/ipfs/go-libp2p-crypto"
ic
"github.com/ipfs/go-libp2p-crypto"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
transport
"github.com/ipfs/go-libp2p-transport"
transport
"github.com/ipfs/go-libp2p-transport"
filter
"github.com/ipfs/go-libp2p/p2p/net/filter"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
filter
"github.com/libp2p/go-libp2p/p2p/net/filter"
)
)
type
PeerConn
interface
{
type
PeerConn
interface
{
...
...
p2p/net/conn/listen.go
View file @
14aac9bb
...
@@ -10,11 +10,11 @@ import (
...
@@ -10,11 +10,11 @@ import (
ic
"github.com/ipfs/go-libp2p-crypto"
ic
"github.com/ipfs/go-libp2p-crypto"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
transport
"github.com/ipfs/go-libp2p-transport"
transport
"github.com/ipfs/go-libp2p-transport"
filter
"github.com/ipfs/go-libp2p/p2p/net/filter"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
tec
"github.com/jbenet/go-temp-err-catcher"
tec
"github.com/jbenet/go-temp-err-catcher"
"github.com/jbenet/goprocess"
"github.com/jbenet/goprocess"
goprocessctx
"github.com/jbenet/goprocess/context"
goprocessctx
"github.com/jbenet/goprocess/context"
filter
"github.com/libp2p/go-libp2p/p2p/net/filter"
msmux
"github.com/whyrusleeping/go-multistream"
msmux
"github.com/whyrusleeping/go-multistream"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
)
)
...
...
p2p/net/conn/secure_conn_test.go
View file @
14aac9bb
...
@@ -8,7 +8,7 @@ import (
...
@@ -8,7 +8,7 @@ import (
"time"
"time"
ic
"github.com/ipfs/go-libp2p-crypto"
ic
"github.com/ipfs/go-libp2p-crypto"
travis
"github.com/
ipfs
/go-libp2p/testutil/ci/travis"
travis
"github.com/
libp2p
/go-libp2p/testutil/ci/travis"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
)
)
...
...
p2p/net/interface.go
View file @
14aac9bb
...
@@ -5,9 +5,9 @@ import (
...
@@ -5,9 +5,9 @@ import (
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pstore
"github.com/ipfs/go-libp2p-peerstore"
conn
"github.com/ipfs/go-libp2p/p2p/net/conn"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
"github.com/jbenet/goprocess"
"github.com/jbenet/goprocess"
conn
"github.com/libp2p/go-libp2p/p2p/net/conn"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
)
)
...
@@ -26,6 +26,9 @@ type Stream interface {
...
@@ -26,6 +26,9 @@ type Stream interface {
io
.
Writer
io
.
Writer
io
.
Closer
io
.
Closer
Protocol
()
string
SetProtocol
(
string
)
// Conn returns the connection this stream is part of.
// Conn returns the connection this stream is part of.
Conn
()
Conn
Conn
()
Conn
}
}
...
...
p2p/net/mock/interface.go
View file @
14aac9bb
...
@@ -10,8 +10,8 @@ import (
...
@@ -10,8 +10,8 @@ import (
"io"
"io"
"time"
"time"
host
"github.com/
ipfs
/go-libp2p/p2p/host"
host
"github.com/
libp2p
/go-libp2p/p2p/host"
inet
"github.com/
ipfs
/go-libp2p/p2p/net"
inet
"github.com/
libp2p
/go-libp2p/p2p/net"
ic
"github.com/ipfs/go-libp2p-crypto"
ic
"github.com/ipfs/go-libp2p-crypto"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment