Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move the go-libp2p-swarm here #1414

Merged
merged 361 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
361 commits
Select commit Hold shift + click to select a range
0ee04d7
Merge pull request #36 from libp2p/feat/better-conn-check
Stebalien Sep 21, 2017
43f3370
don't backoff dialing when the context is canceled
Stebalien Oct 18, 2017
6b32365
Merge pull request #38 from libp2p/fix/libp2p/go-libp2p-kad-dht/96
Stebalien Oct 18, 2017
4381ea2
don't pass the dial timeout option
Stebalien Nov 10, 2017
cae7710
Merge pull request #40 from libp2p/fix/dial-timeout
Stebalien Nov 14, 2017
140bad3
nil out references to finished dials
Stebalien Nov 21, 2017
69bbe79
Merge pull request #45 from libp2p/fix/save-memory
Stebalien Nov 21, 2017
00ded68
preallocate duplicate checking map in Peers
Stebalien Dec 6, 2017
6138f69
clear out extra dial jobs after dial finishes
whyrusleeping Jan 3, 2018
65266bf
Merge pull request #51 from libp2p/fix/clear-cancelled-dials
whyrusleeping Jan 4, 2018
22b7801
cleanup connection setup
Stebalien Jan 9, 2018
7d45aa8
don't leak connections when canceling dials
Stebalien Mar 9, 2018
0f7ab34
Merge pull request #62 from libp2p/fix/close-canceled-dial
Stebalien Mar 9, 2018
4e39954
refactor for new transports
Stebalien Jan 20, 2018
1c4ee32
Merge pull request #63 from libp2p/feat/refactor
Stebalien Jun 6, 2018
f70bce2
feat: lower timeout for local address dials
magik6k Jun 7, 2018
af53412
limiter: cleanup the code
magik6k Jun 11, 2018
8d05824
Merge pull request #72 from libp2p/misc/cleanup-limiter
Stebalien Jun 11, 2018
8beb060
Merge pull request #70 from libp2p/feat/local-timeout
whyrusleeping Jun 17, 2018
ebc7440
add a per-dial transport-level dial timeout
Stebalien Jun 8, 2018
d2b407f
don't hang tests on dial failure
Stebalien Jun 11, 2018
cbd2028
remove unused success boolean
Stebalien Jun 14, 2018
c30ac0e
switch to a per DialPeer/NewStream timeout defined in go-libp2p-net
Stebalien Jun 14, 2018
5c1c3e7
Merge pull request #77 from libp2p/feat/better-timeouts
Stebalien Jun 26, 2018
eb986b0
remove redundant dial timeout
Stebalien Jun 26, 2018
c471b21
Merge pull request #80 from libp2p/fix/dial-additional-dial-timeout
Stebalien Jun 26, 2018
5a9655c
Issue #370 Check if empty peer ID
kishansagathiya Aug 16, 2018
6d836d5
Add support for Stat() to Swarm Stream and Conn
bigs Jun 15, 2018
3f9733a
Update addStream/Conn to accept a Direction
bigs Jun 25, 2018
dae9dd1
Merge branch 'feat/stat'
Stebalien Aug 28, 2018
0bc531b
log an error when we have no transports configured
Stebalien Jun 13, 2018
484fba6
Merge pull request #74 from libp2p/feat/log-no-transports
bigs Sep 4, 2018
602f9d4
gx: update go-libp2p-peerstore
Stebalien Sep 8, 2018
c809618
Refactor and relax filtering of known undialable addresses
Oct 2, 2018
df89bf4
Merge pull request #87 from libp2p/fix/known-undialables
Oct 3, 2018
374d8d9
warn when we encounter a useless transport
Stebalien Nov 16, 2018
c94e1b9
Merge pull request #90 from libp2p/fix/warn-on-useless-transport
Stebalien Nov 16, 2018
7061100
avoid spawning goroutines for canceled dials
Stebalien Jan 23, 2019
8d093f2
dialer: handle dial cancel and/or completion before trying new addresses
Stebalien Jan 23, 2019
10ab830
Merge pull request #95 from libp2p/fix/avoid-useless-goroutines
Stebalien Jan 23, 2019
7168ce8
Merge pull request #96 from libp2p/fix/finish-dial-fast
Stebalien Jan 23, 2019
addf6f1
enhance debug logging in limiter.
raulk Jan 29, 2019
c268db2
Merge pull request #98 from raulk/master
raulk Jan 29, 2019
1c5f240
Add CircleCI config
anacrolix Feb 4, 2019
27f0805
Fix logging race
anacrolix Feb 4, 2019
9d153e8
remove superfluous log statement.
raulk Feb 4, 2019
a04dcb5
Merge pull request #99 from libp2p/add-circleci-config
raulk Feb 4, 2019
b601f9a
Merge pull request #100 from libp2p/fix-logging-race
Kubuxu Feb 4, 2019
96a640d
make FD limits configurable by env prop.
raulk Jan 31, 2019
730e177
Merge pull request #102 from raulk/env-var-fd-limit
raulk Feb 5, 2019
b3789be
Improve context use
anacrolix Feb 15, 2019
a65b8ab
Reflow comments
anacrolix Feb 15, 2019
6ee2ac3
Do notifications synchronously
anacrolix Feb 15, 2019
76866ef
Fix code format
anacrolix Feb 15, 2019
c8c717c
Revert "Do notifications synchronously"
anacrolix Feb 19, 2019
e7afaa3
Fix failing tests?
anacrolix Feb 19, 2019
2b3c820
Merge pull request #105 from libp2p/fix-circleci
Stebalien Feb 19, 2019
0cca6c8
Merge pull request #104 from libp2p/misc
vyzo Feb 19, 2019
f22b6c7
Improve dial error messages
anacrolix Feb 28, 2019
3899936
Add an error for no addresses
anacrolix Mar 8, 2019
31088db
Check for context failure, rather than a specific downstream error
anacrolix Mar 8, 2019
86b63ef
Don't modify the error handling
anacrolix Mar 13, 2019
2df36e5
return all dial errors if dial has failed
reinerRubin Mar 26, 2019
93ac5fe
Merge pull request #115 from reinerRubin/bug/4355-dial-errors
Stebalien Apr 5, 2019
02d01da
context option to disable dialing when opening a new stream
vyzo Apr 10, 2019
b355bce
update to use NoDial option from go-libp2p-net
vyzo Apr 10, 2019
fb0dd0e
kill stray line
vyzo Apr 10, 2019
8de8253
Merge pull request #116 from libp2p/feat/no-dial-option
vyzo Apr 10, 2019
3d252fa
dial: return a nice custom dial error
Stebalien Apr 24, 2019
8192e64
Merge pull request #121 from libp2p/feat/improve-errors
Stebalien Apr 25, 2019
cf873f5
dep: import go-smux-* into the libp2p org
Stebalien May 22, 2019
6991703
Merge pull request #126 from libp2p/dep/import-smux
Stebalien May 22, 2019
e132f6a
migrate to consolidated types; remove CircleCI config (#127)
raulk May 26, 2019
10d45bd
feat: cache interface addresses for 1 minute
Kubuxu Jun 3, 2019
c7245b7
feat: cache full InterfaceListenAddresses
Kubuxu Jun 4, 2019
b80c689
invalidate cache for InterfaceListenAddresses on Listen
Kubuxu Jun 4, 2019
a9e7717
Merge pull request #129 from libp2p/feat/cache-interface-addrs
Stebalien Jun 4, 2019
c12ef6a
logging: make the swarm less noisy
Stebalien Jun 6, 2019
42ff51f
Merge pull request #131 from libp2p/fix/noisy
Stebalien Jun 6, 2019
c0a856c
fix: don't assume that transports implement stringer (#134)
Stebalien Jul 10, 2019
85cc7d8
fix listen addrs race
Stebalien Aug 21, 2019
5d2acb0
Merge pull request #136 from libp2p/fix/listen-addrs-race
Stebalien Aug 21, 2019
11ed2c3
test: close peerstore when closing the test swarm
Stebalien Sep 13, 2019
f47ca44
Merge pull request #139 from libp2p/fix/close-peerstore-testing
Stebalien Sep 19, 2019
b8ac632
dep: update multiaddr for protocol migration
Stebalien Sep 19, 2019
da613ba
Merge pull request #142 from libp2p/fix/global-multiaddr-registry
Stebalien Sep 19, 2019
c96acd8
Minor Docstring correction
AliabbasMerchant Oct 27, 2019
7599d7e
Merge pull request #143 from AliabbasMerchant/patch-1
vyzo Oct 27, 2019
ad8e595
feat(dial): implement the Timeout interface on dial errors
Stebalien Nov 4, 2019
dbf68e0
feat(swarm): return unwrapped context deadline errors
Stebalien Nov 4, 2019
1263fb7
feat(swarm): improve dial context
Stebalien Nov 4, 2019
9fafd77
Merge pull request #145 from libp2p/feat/improve-dial-error
Stebalien Nov 5, 2019
9d0e548
only cancel dials when an outbound connection succeeds. this may resu…
aschmahmann Feb 10, 2020
a731919
fix: fire a listen close event when closing the listener
Stebalien Feb 26, 2020
607c6ba
Merge pull request #174 from libp2p/fix/simul-dial
Stebalien Mar 10, 2020
791cb9d
fix: make sure to include peer in dial error
Stebalien Mar 18, 2020
862c32c
Merge pull request #180 from libp2p/fix/swarm-dial-err
aarshkshah1992 Mar 18, 2020
3639cf8
feat: handle no addresses
Stebalien Mar 30, 2020
ae777a5
Merge pull request #185 from libp2p/fix/listenaddr-err
Stebalien Mar 30, 2020
904165f
fix: set teardown after storing the context.
Stebalien Mar 31, 2020
2e7aed4
Merge pull request #190 from libp2p/fix/189
Stebalien Mar 31, 2020
193a319
change backoffs to per-address
willscott Apr 1, 2020
ac37d0d
add background cleanup task
willscott Apr 1, 2020
390b8ca
simplify data structure
willscott Apr 2, 2020
6811c9c
Merge pull request #191 from libp2p/feat/addrbackoff
Stebalien Apr 2, 2020
035e5dc
chore: slightly simplify backoff logic
Stebalien Apr 2, 2020
f2a473b
Merge pull request #192 from libp2p/fix/simplify-backoff
willscott Apr 2, 2020
240d2fe
don't expire backoffs until 2x backoff period
willscott Apr 2, 2020
5811140
Merge pull request #193 from libp2p/feat/backoff-cleanup
Stebalien Apr 2, 2020
9b8dbb7
fix: avoid calling AddChild after the process may shutdown.
Stebalien Apr 23, 2020
47faf65
Merge pull request #207 from libp2p/fix/pstore-close-race
Stebalien Apr 23, 2020
dc499b7
implement connection gating support: intercept peer, address dials, u…
aarshkshah1992 May 15, 2020
499b4d8
Rank Dial addresses (#212)
aarshkshah1992 May 20, 2020
fba7255
configure private key for test swarm
aarshkshah1992 Jun 2, 2020
adb4842
Merge pull request #223 from libp2p/feat/config-test-keys
Stebalien Jun 2, 2020
ac5726b
`ID()` method on connections and streams + record opening time (#224)
raulk Jun 5, 2020
4bd3294
slim down dependencies
Stebalien Jun 24, 2020
5c3c3a1
Merge pull request #225 from libp2p/fix/slim-dependencies
Stebalien Jun 24, 2020
720a4d3
feat: update to latest go-libp2p-core interfaces
Stebalien Sep 2, 2020
208c17e
Merge pull request #228 from libp2p/feat/rw-close
Stebalien Sep 2, 2020
0526dce
fix: handle case where swarm closes before stream
Stebalien Sep 2, 2020
115dee3
Merge pull request #229 from libp2p/fix/close-lock
Stebalien Sep 2, 2020
1b9128f
use a context for OpenStream and NewStream
marten-seemann Dec 17, 2020
4958803
Merge pull request #232 from libp2p/open-stream-context
marten-seemann Dec 19, 2020
0432da3
Enable QUIC in Test Swarm (#235)
aarshkshah1992 Jan 28, 2021
96218e2
prevent dialing addresses that we're listening on
marten-seemann Feb 8, 2021
6e0d187
only listen on localhost in tests
marten-seemann Feb 9, 2021
80963f8
Merge pull request #237 from libp2p/prevent-self-dial
Stebalien Feb 9, 2021
412d8c3
Merge pull request #238 from libp2p/fix-global-listen-in-tests
Stebalien Feb 9, 2021
8e9ae25
avoid assigning a function to a variable
marten-seemann Feb 12, 2021
6482743
Merge pull request #239 from libp2p/avoid-func-in-variable
Stebalien Feb 12, 2021
0528e44
treat transient conns as opt-in for opening new streams
vyzo Feb 3, 2021
9d3ae86
initialize conn stat with underlying conn stat if available
vyzo Feb 4, 2021
8fa595c
more idiomatic code
vyzo Feb 4, 2021
6b0e958
fix GetTransient usage for interface change
vyzo Feb 17, 2021
443650e
Merge pull request #236 from libp2p/feat/transient-conns
vyzo Feb 17, 2021
d97c24c
Support for Hole punching (#233)
aarshkshah1992 Feb 18, 2021
953af40
fix swarm transient conn (#241)
aarshkshah1992 Feb 19, 2021
757fb56
fix: prefer non-transient connections
Stebalien Mar 19, 2021
1e011b1
fix: DRY direct connect logic
Stebalien Mar 19, 2021
1b4be47
fix: do not use the request context when dialing
Stebalien Mar 19, 2021
4ace085
feat: close transports that implement io.Closer
Stebalien Aug 28, 2020
3263543
fix: use 64bit stream/conn IDs
Stebalien Mar 29, 2021
58ccadf
Merge pull request #227 from libp2p/feat/closer
Stebalien Mar 29, 2021
70b63da
Merge pull request #247 from libp2p/fix/64bit-ids
Stebalien Mar 29, 2021
28671c3
implement dial worker for synchronizing simultaneous dials
vyzo Mar 30, 2021
30d5137
adjust next dial delays
vyzo Mar 30, 2021
1efe95a
fix dial_sync tests
vyzo Mar 30, 2021
b69afe8
clear address dial when they fail because of backoff
vyzo Mar 30, 2021
790edda
nuke incref, it's useless
vyzo Mar 31, 2021
df78bf8
make dialWorker return an error for self dials and responsible for sp…
vyzo Mar 31, 2021
88df309
don't use a goroutine for the actual dial
vyzo Mar 31, 2021
0cf03ba
batch dials together, rework address ranking
vyzo Mar 31, 2021
3707a55
tune down batch dial delays
vyzo Mar 31, 2021
0bd0fcd
use a timer instead of time.After
vyzo Mar 31, 2021
5539ac0
kill dial jump delays
vyzo Mar 31, 2021
91c3668
add TestDialExistingConnection
vyzo Mar 31, 2021
ad3f676
do a last ditch check for acceptable connections before dispatching a…
vyzo Mar 31, 2021
c20de20
merge dial contexts where possible
vyzo Mar 31, 2021
d2bc4f4
add TestDialSimultaneousJoin test
vyzo Mar 31, 2021
167d645
don't add backoff if we have successfully connected
vyzo Mar 31, 2021
80b33ec
fix TestConnectednessCorrect
vyzo Mar 31, 2021
0af34e7
don't store the active dial if it errors while starting the worker
vyzo Mar 31, 2021
3027434
add TestSelfDial
vyzo Mar 31, 2021
7db6ec9
make DialRequest and DialResponse private
vyzo Apr 1, 2021
c55e86c
add comment about the necessity of removing the address tracking when…
vyzo Apr 1, 2021
ace5e25
remove dial batching
vyzo Apr 1, 2021
c2e44d4
add new TestDialSelf
vyzo Apr 1, 2021
c7e4304
make DialWorkerFunc, NewDialSync private
vyzo Apr 1, 2021
bc47c2f
rename dialWorker to startDialWorker
vyzo Apr 1, 2021
4f223e9
make addr utility funcs standalone and not exported
vyzo Apr 1, 2021
78037d7
make IsFdConsumingAddr a standalone utility func
vyzo Apr 1, 2021
ad620bf
Merge pull request #250 from libp2p/fix/simultaneous-dial
vyzo Apr 1, 2021
ce7c0bc
Merge pull request #243 from libp2p/fix/direct-connect
vyzo Apr 1, 2021
fbba082
fix go vet
Apr 15, 2021
8dc70f2
more tests after merge
Apr 15, 2021
b00734a
typeo
Apr 15, 2021
b556f82
Merge pull request #253 from coryschwartz/feat/fix-go-vet
Stebalien Apr 19, 2021
6cc76d5
fix staticcheck
Apr 15, 2021
19c7253
Merge pull request #255 from libp2p/feat/fix-staticcheck
marten-seemann Apr 20, 2021
98d7eef
fix: avoid returning typed nils
Stebalien Apr 20, 2021
4e6eff8
Merge pull request #257 from libp2p/fix/typed-nil
Stebalien Apr 22, 2021
67f91a0
run connection gating tests on both TCP and QUIC
marten-seemann Apr 23, 2021
b6f8348
Merge pull request #258 from libp2p/fix-connection-gating-tests
Stebalien Apr 23, 2021
168f8ab
sync: update CI config files (#248)
web3-bot Apr 30, 2021
048c5dd
remove incorrect call to InterceptAddrDial
marten-seemann May 18, 2021
d965b92
speed up the TestFDLimitUnderflow test
marten-seemann May 19, 2021
1f20d59
Merge pull request #262 from libp2p/speed-up-fd-limit-underflow-test
marten-seemann May 19, 2021
e2285eb
Merge pull request #260 from libp2p/remove-incorrect-gating
marten-seemann May 30, 2021
b6f93bd
wait longer for connection establishment in TestNotifications
marten-seemann Jul 27, 2021
7cf5da4
Merge pull request #263 from libp2p/web3-bot/sync
marten-seemann Jul 27, 2021
258e1e6
fix race condition in TestFailFirst
marten-seemann Aug 22, 2021
0f3ec18
Merge pull request #269 from libp2p/fix-race-in-tests
Stebalien Aug 22, 2021
8252673
remove unused context in Swarm.dialWorkerLoop
marten-seemann Aug 22, 2021
89af06a
simplify limiter by removing the injected isFdConsumingFnc
marten-seemann Aug 25, 2021
31e80d6
Merge pull request #274 from libp2p/remove-limiter-dependency-injection
Stebalien Aug 25, 2021
fc08179
add a test case for the testing package
marten-seemann Aug 27, 2021
e5b2a35
rename DialSync.DialLock to Dial
marten-seemann Aug 23, 2021
9adcf8f
only check for self dials once
marten-seemann Aug 23, 2021
2f389ce
simplify starting of the dialWorkerLoop
marten-seemann Aug 24, 2021
b8426e7
Merge pull request #276 from libp2p/test-testing
Stebalien Aug 27, 2021
76a1e92
read and use the direction from the simultaneous connect context
marten-seemann Sep 5, 2021
bf044ff
Merge pull request #273 from libp2p/clean-up-self-dial
marten-seemann Sep 7, 2021
0e0111c
simplify the DialSync code
marten-seemann Aug 23, 2021
d45e481
Merge pull request #272 from libp2p/clean-up-dial-sync
marten-seemann Sep 7, 2021
014b22f
Merge pull request #277 from libp2p/sim-connect-context-direction
marten-seemann Sep 8, 2021
782897e
stop using goprocess to control teardown
marten-seemann Sep 5, 2021
a872d26
use testing.Cleanup to shut down peerstore and revert most test changes
marten-seemann Sep 7, 2021
0537306
cancel the ctx when closing, use a sync.Once to only close once
marten-seemann Sep 7, 2021
a93170b
Merge pull request #278 from libp2p/remove-goprocess
marten-seemann Sep 8, 2021
21c4486
use functional options to configure the swarm
marten-seemann Sep 7, 2021
c2439b0
convert the metrics reporter to an option
marten-seemann Sep 7, 2021
6343fe4
Merge pull request #279 from libp2p/option
marten-seemann Sep 8, 2021
96eb4c7
add an error return value to the constructor
marten-seemann Sep 8, 2021
0af4415
unexport the DialSync
marten-seemann Sep 8, 2021
83bd75b
Merge pull request #280 from libp2p/constructor-error-return
marten-seemann Sep 8, 2021
fd83499
Merge pull request #281 from libp2p/unexport-dial-sync
marten-seemann Sep 8, 2021
6d9ce0e
remove the ConnHandler
marten-seemann Sep 21, 2021
c3cd06d
update go-tcp-transport to v0.4.0
marten-seemann Sep 29, 2021
e18a6bf
Merge pull request #287 from libp2p/update-tcp
marten-seemann Oct 18, 2021
8707662
feat: plumb contexts through from peerstore (#290)
guseggert Nov 9, 2021
212b671
chore: update go-log to v2 (#294)
marten-seemann Dec 7, 2021
f417a8d
count the number of streams on a connection for the stats
marten-seemann Dec 10, 2021
a32993f
remove addrutil.SubtractFilter
marten-seemann Dec 14, 2021
f545ea3
add constructor options for timeout, stop using transport.DialTimeout
marten-seemann Dec 19, 2021
f3a1f6b
Merge pull request #302 from libp2p/timeout-options
marten-seemann Dec 20, 2021
d12b385
speed up the dial tests
marten-seemann Dec 19, 2021
15bb902
stop using the deprecated libp2p/go-maddr-filter
marten-seemann Dec 20, 2021
cd56cd5
Merge pull request #303 from libp2p/stop-using-libp2p-multiaddr-filter
marten-seemann Dec 20, 2021
67538c8
Merge pull request #301 from libp2p/speedup-dial-tests
marten-seemann Dec 20, 2021
6299c02
increment active dial counter
vyzo Dec 21, 2021
5674317
Merge pull request #305 from libp2p/fix/issue-291
vyzo Dec 21, 2021
c35965b
stop using transport.DialTimeout in tests (#307)
marten-seemann Dec 30, 2021
a2a7e6b
remove dependency on go-addr-util
marten-seemann Dec 14, 2021
27f2a2b
Merge pull request #300 from libp2p/remove-addrutil
marten-seemann Jan 3, 2022
74f9203
use the transport.Upgrader interface
marten-seemann Jan 2, 2022
08a1ca5
Merge pull request #309 from libp2p/upgrader-interface
marten-seemann Jan 4, 2022
9df9700
add support for the resource manager
marten-seemann Dec 30, 2021
c321bbb
Merge pull request #308 from libp2p/rcmgr
marten-seemann Jan 18, 2022
e1de183
release the stream scope if the conn fails to open a new stream
vyzo Jan 20, 2022
a39d1d8
Merge pull request #312 from libp2p/fix/scope-leak
vyzo Jan 21, 2022
53881b2
refactor dialWorkerLoop into an object
vyzo Feb 21, 2022
f50fa57
remove stale comment
vyzo Feb 21, 2022
ebb9e45
RIP active dial tracking
vyzo Feb 21, 2022
3828fa3
dial worker tests
vyzo Feb 21, 2022
0487a88
Merge pull request #315 from libp2p/fix/dial-worker
vyzo Feb 22, 2022
b53bbc5
fix: call to (*T).Fatal from a non-test goroutine
galargh Apr 6, 2022
7ff8ea9
Merge pull request #317 from libp2p/web3-bot/sync
galargh Apr 6, 2022
32027b4
move go-lipbp2-swarm here
marten-seemann Apr 21, 2022
3effab1
switch from github.com/libp2p/go-libp2p-swarm to p2p/net/swarm
marten-seemann Apr 21, 2022
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
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
blankhost "github.com/libp2p/go-libp2p/p2p/host/blank"
routed "github.com/libp2p/go-libp2p/p2p/host/routed"
"github.com/libp2p/go-libp2p/p2p/net/swarm"
circuitv2 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client"
relayv2 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay"
"github.com/libp2p/go-libp2p/p2p/protocol/holepunch"

swarm "github.com/libp2p/go-libp2p-swarm"
tptu "github.com/libp2p/go-libp2p-transport-upgrader"

logging "github.com/ipfs/go-log/v2"
Expand Down
6 changes: 3 additions & 3 deletions config/muxer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package config
import (
"testing"

"github.com/libp2p/go-libp2p-core/network"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"

yamux "github.com/libp2p/go-libp2p-yamux"
)
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ require (
github.com/libp2p/go-libp2p-peerstore v0.6.0
github.com/libp2p/go-libp2p-quic-transport v0.17.0
github.com/libp2p/go-libp2p-resource-manager v0.2.1
github.com/libp2p/go-libp2p-swarm v0.10.2
github.com/libp2p/go-libp2p-testing v0.9.2
github.com/libp2p/go-libp2p-tls v0.4.1
github.com/libp2p/go-libp2p-transport-upgrader v0.7.1
Expand All @@ -35,12 +34,14 @@ require (
github.com/libp2p/zeroconf/v2 v2.1.1
github.com/multiformats/go-multiaddr v0.5.0
github.com/multiformats/go-multiaddr-dns v0.3.1
github.com/multiformats/go-multiaddr-fmt v0.1.0
github.com/multiformats/go-multihash v0.1.0
github.com/multiformats/go-multistream v0.3.0
github.com/multiformats/go-varint v0.0.6
github.com/raulk/go-watchdog v1.2.0
github.com/stretchr/testify v1.7.0
github.com/whyrusleeping/mdns v0.0.0-20190826153040-b9b60ed33aa9
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
)

Expand Down Expand Up @@ -76,6 +77,7 @@ require (
github.com/libp2p/go-flow-metrics v0.0.3 // indirect
github.com/libp2p/go-libp2p-blankhost v0.3.0 // indirect
github.com/libp2p/go-libp2p-pnet v0.2.0 // indirect
github.com/libp2p/go-libp2p-swarm v0.10.2 // indirect
github.com/libp2p/go-nat v0.1.0 // indirect
github.com/libp2p/go-openssl v0.0.7 // indirect
github.com/libp2p/go-reuseport v0.1.0 // indirect
Expand All @@ -96,7 +98,6 @@ require (
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.0.4 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.0.3 // indirect
github.com/multiformats/go-multicodec v0.4.1 // indirect
github.com/nxadm/tail v1.4.8 // indirect
Expand All @@ -112,7 +113,6 @@ require (
github.com/raulk/clock v1.1.0 // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
Expand Down
3 changes: 1 addition & 2 deletions p2p/discovery/backoff/backoffcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import (

"github.com/libp2p/go-libp2p/p2p/discovery/mocks"
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/libp2p/go-libp2p-core/discovery"
"github.com/libp2p/go-libp2p-core/peer"

swarmt "github.com/libp2p/go-libp2p-swarm/testing"
)

type delayedDiscovery struct {
Expand Down
3 changes: 1 addition & 2 deletions p2p/discovery/backoff/backoffconnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import (
"time"

bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"

swarmt "github.com/libp2p/go-libp2p-swarm/testing"

"github.com/stretchr/testify/require"
)

Expand Down
9 changes: 5 additions & 4 deletions p2p/discovery/mdns_legacy/mdns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"

"github.com/stretchr/testify/require"
)

type DiscoveryNotifee struct {
Expand All @@ -22,7 +23,7 @@ func (n *DiscoveryNotifee) HandlePeerFound(pi peer.AddrInfo) {
}

func TestMdnsDiscovery(t *testing.T) {
//TODO: re-enable when the new lib will get integrated
// TODO: re-enable when the new lib will get integrated
t.Skip("TestMdnsDiscovery fails randomly with current lib")

ctx, cancel := context.WithCancel(context.Background())
Expand Down
2 changes: 1 addition & 1 deletion p2p/discovery/routing/routing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"github.com/libp2p/go-libp2p/p2p/discovery/mocks"
"github.com/libp2p/go-libp2p/p2p/discovery/util"
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/discovery"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
)

type mockRoutingTable struct {
Expand Down
2 changes: 1 addition & 1 deletion p2p/host/autonat/autonat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (

pb "github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/libp2p/go-libp2p-core/event"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"

swarmt "github.com/libp2p/go-libp2p-swarm/testing"
"github.com/libp2p/go-msgio/protoio"
ma "github.com/multiformats/go-multiaddr"
"github.com/stretchr/testify/require"
Expand Down
6 changes: 4 additions & 2 deletions p2p/host/autonat/dialpolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
"net"
"testing"

blankhost "github.com/libp2p/go-libp2p/p2p/host/blank"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/transport"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
blankhost "github.com/libp2p/go-libp2p/p2p/host/blank"

"github.com/multiformats/go-multiaddr"
)

Expand Down
3 changes: 1 addition & 2 deletions p2p/host/autonat/svc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import (
"time"

bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/libp2p/go-libp2p-core/event"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"

swarmt "github.com/libp2p/go-libp2p-swarm/testing"

ma "github.com/multiformats/go-multiaddr"
"github.com/stretchr/testify/require"
)
Expand Down
9 changes: 5 additions & 4 deletions p2p/host/basic/basic_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import (
"testing"
"time"

"github.com/libp2p/go-eventbus"
"github.com/libp2p/go-libp2p/p2p/host/autonat"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
"github.com/libp2p/go-libp2p/p2p/protocol/identify"

"github.com/libp2p/go-libp2p-core/event"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/host"
Expand All @@ -21,10 +24,8 @@ import (
"github.com/libp2p/go-libp2p-core/protocol"
"github.com/libp2p/go-libp2p-core/record"
"github.com/libp2p/go-libp2p-core/test"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
"github.com/libp2p/go-libp2p/p2p/host/autonat"
"github.com/libp2p/go-libp2p/p2p/protocol/identify"

"github.com/libp2p/go-eventbus"
ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns"

Expand Down
3 changes: 2 additions & 1 deletion p2p/host/basic/peer_connectedness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"testing"
"time"

swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/libp2p/go-libp2p-core/event"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"

"github.com/stretchr/testify/require"
)
Expand Down
3 changes: 2 additions & 1 deletion p2p/host/blank/peer_connectedness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"testing"
"time"

swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/libp2p/go-libp2p-core/event"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"

"github.com/stretchr/testify/require"
)
Expand Down
35 changes: 35 additions & 0 deletions p2p/net/swarm/addrs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package swarm

import (
ma "github.com/multiformats/go-multiaddr"
mamask "github.com/whyrusleeping/multiaddr-filter"
)

// http://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
var lowTimeoutFilters = ma.NewFilters()

func init() {
for _, p := range []string{
"/ip4/10.0.0.0/ipcidr/8",
"/ip4/100.64.0.0/ipcidr/10",
"/ip4/169.254.0.0/ipcidr/16",
"/ip4/172.16.0.0/ipcidr/12",
"/ip4/192.0.0.0/ipcidr/24",
"/ip4/192.0.0.0/ipcidr/29",
"/ip4/192.0.0.8/ipcidr/32",
"/ip4/192.0.0.170/ipcidr/32",
"/ip4/192.0.0.171/ipcidr/32",
"/ip4/192.0.2.0/ipcidr/24",
"/ip4/192.168.0.0/ipcidr/16",
"/ip4/198.18.0.0/ipcidr/15",
"/ip4/198.51.100.0/ipcidr/24",
"/ip4/203.0.113.0/ipcidr/24",
"/ip4/240.0.0.0/ipcidr/4",
} {
f, err := mamask.NewMask(p)
if err != nil {
panic("error in lowTimeoutFilters init: " + err.Error())
}
lowTimeoutFilters.AddFilter(*f, ma.ActionDeny)
}
}
71 changes: 71 additions & 0 deletions p2p/net/swarm/dial_error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package swarm

import (
"fmt"
"os"
"strings"

"github.com/libp2p/go-libp2p-core/peer"

ma "github.com/multiformats/go-multiaddr"
)

// maxDialDialErrors is the maximum number of dial errors we record
const maxDialDialErrors = 16

// DialError is the error type returned when dialing.
type DialError struct {
Peer peer.ID
DialErrors []TransportError
Cause error
Skipped int
}

func (e *DialError) Timeout() bool {
return os.IsTimeout(e.Cause)
}

func (e *DialError) recordErr(addr ma.Multiaddr, err error) {
if len(e.DialErrors) >= maxDialDialErrors {
e.Skipped++
return
}
e.DialErrors = append(e.DialErrors, TransportError{
Address: addr,
Cause: err,
})
}

func (e *DialError) Error() string {
var builder strings.Builder
fmt.Fprintf(&builder, "failed to dial %s:", e.Peer)
if e.Cause != nil {
fmt.Fprintf(&builder, " %s", e.Cause)
}
for _, te := range e.DialErrors {
fmt.Fprintf(&builder, "\n * [%s] %s", te.Address, te.Cause)
}
if e.Skipped > 0 {
fmt.Fprintf(&builder, "\n ... skipping %d errors ...", e.Skipped)
}
return builder.String()
}

// Unwrap implements https://godoc.org/golang.org/x/xerrors#Wrapper.
func (e *DialError) Unwrap() error {
return e.Cause
}

var _ error = (*DialError)(nil)

// TransportError is the error returned when dialing a specific address.
type TransportError struct {
Address ma.Multiaddr
Cause error
}

func (e *TransportError) Error() string {
return fmt.Sprintf("failed to dial %s: %s", e.Address, e.Cause)
}

var _ error = (*TransportError)(nil)
Loading