Skip to content

Commit 9e10bb9

Browse files
committed
Circuit hop tests
Signed-off-by: Gustavo Sampaio <[email protected]>
1 parent 3cf4719 commit 9e10bb9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ require (
2020
github.com/libp2p/go-libp2p-kad-dht v0.1.0
2121
github.com/libp2p/go-libp2p-peerstore v0.1.0
2222
github.com/libp2p/go-libp2p-record v0.1.0
23+
github.com/libp2p/go-libp2p-swarm v0.1.0
2324
github.com/multiformats/go-multiaddr v0.0.4
2425
github.com/multiformats/go-multihash v0.0.5
2526
github.com/stretchr/testify v1.3.0

host.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ func HostNew(settings *options.Settings, ds ipfsDatastore.Batching, blockstore b
7070

7171
opts := []libp2p.Option{
7272
libp2p.ListenAddrs(sourceMultiAddrIP4, sourceMultiAddrIP6),
73-
libp2p.EnableRelay(libp2pCircuit.OptDiscovery),
73+
}
74+
75+
if settings.RelayOnly {
76+
opts = append(opts, libp2p.EnableRelay(libp2pCircuit.OptHop))
77+
} else {
78+
opts = append(opts, libp2p.EnableRelay(libp2pCircuit.OptDiscovery))
7479
}
7580

7681
id, ok := settings.Identity.(*identity.Libp2pIdentity)
@@ -147,6 +152,10 @@ func (host *hostImpl) Close() error {
147152
return err
148153
}
149154

155+
if err := host.p2pHost.Network().Close(); err != nil {
156+
return err
157+
}
158+
150159
return host.p2pHost.Close()
151160
}
152161

0 commit comments

Comments
 (0)