mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-06-27 21:09:28 +00:00
Update libp2p to introduce enableDialableCandidates
This commit is contained in:
parent
17155488a2
commit
b33031cdef
@ -302,6 +302,7 @@ proc new*(
|
||||
numPeersToAsk = config.natNumPeersToAsk,
|
||||
maxQueueSize = config.natMaxQueueSize,
|
||||
minConfidence = config.natMinConfidence,
|
||||
enableDialableCandidates = true,
|
||||
)
|
||||
)
|
||||
# At the first AutoNAT probe, the only identify observations available come
|
||||
|
||||
@ -40,9 +40,9 @@ suite "addrutils - hasPublicRelayTransport":
|
||||
const relayId = "16Uiu2HAkyRvHo1AyyQY1xiHC8QbYjXCHkZbneVC8dBtJjp1SZcGD"
|
||||
|
||||
proc circuitAddr(relayIp: string): MultiAddress =
|
||||
MultiAddress.init("/ip4/" & relayIp & "/tcp/8070/p2p/" & relayId & "/p2p-circuit").expect(
|
||||
"valid"
|
||||
)
|
||||
MultiAddress
|
||||
.init("/ip4/" & relayIp & "/tcp/8070/p2p/" & relayId & "/p2p-circuit")
|
||||
.expect("valid")
|
||||
|
||||
test "true when the relay has a public ip":
|
||||
check circuitAddr("204.168.234.45").hasPublicRelayTransport()
|
||||
@ -57,18 +57,27 @@ suite "addrutils - dialableAddressPolicy":
|
||||
const relayId = "16Uiu2HAkyRvHo1AyyQY1xiHC8QbYjXCHkZbneVC8dBtJjp1SZcGD"
|
||||
|
||||
proc circuitAddr(relayIp: string): MultiAddress =
|
||||
MultiAddress.init("/ip4/" & relayIp & "/tcp/8070/p2p/" & relayId & "/p2p-circuit").expect(
|
||||
"valid"
|
||||
)
|
||||
MultiAddress
|
||||
.init("/ip4/" & relayIp & "/tcp/8070/p2p/" & relayId & "/p2p-circuit")
|
||||
.expect("valid")
|
||||
|
||||
test "keeps a public direct address":
|
||||
check MultiAddress.init("/ip4/204.168.234.45/tcp/8070").expect("valid").dialableAddressPolicy()
|
||||
check MultiAddress
|
||||
.init("/ip4/204.168.234.45/tcp/8070")
|
||||
.expect("valid")
|
||||
.dialableAddressPolicy()
|
||||
|
||||
test "drops a loopback direct address":
|
||||
check not MultiAddress.init("/ip4/127.0.0.1/tcp/8070").expect("valid").dialableAddressPolicy()
|
||||
check not MultiAddress
|
||||
.init("/ip4/127.0.0.1/tcp/8070")
|
||||
.expect("valid")
|
||||
.dialableAddressPolicy()
|
||||
|
||||
test "drops a private direct address":
|
||||
check not MultiAddress.init("/ip4/192.168.100.103/tcp/8070").expect("valid").dialableAddressPolicy()
|
||||
check not MultiAddress
|
||||
.init("/ip4/192.168.100.103/tcp/8070")
|
||||
.expect("valid")
|
||||
.dialableAddressPolicy()
|
||||
|
||||
test "keeps a circuit address through a public relay":
|
||||
check circuitAddr("204.168.234.45").dialableAddressPolicy()
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
import std/net
|
||||
import pkg/questionable/results
|
||||
|
||||
import ../asynctest
|
||||
import ./helpers
|
||||
import ../../storage/conf
|
||||
|
||||
@ -194,11 +194,14 @@ asyncchecksuite "NAT - handleNatStatus":
|
||||
check disc.announceAddrs == newSeq[MultiAddress]()
|
||||
|
||||
test "autonat dial request includes the observed addresses as candidates":
|
||||
# Reproduces vacp2p/nim-libp2p#2600: until that fix is vendored, the
|
||||
# dial request only contains peerInfo.addrs (private listen addrs), so
|
||||
# a NATed node never submits a dialable candidate.
|
||||
# The dial request includes the addresses observed by other peers, so a NATed node submits
|
||||
# a dialable candidate even though its listen addrs are private.
|
||||
let client = MockAutonatV2Client()
|
||||
let autonat = AutonatV2Service.new(Rng.instance(), client)
|
||||
let autonat = AutonatV2Service.new(
|
||||
Rng.instance(),
|
||||
client,
|
||||
AutonatV2ServiceConfig.new(enableDialableCandidates = true),
|
||||
)
|
||||
service.setup(autonat, sw)
|
||||
await autonat.start(sw)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user