Address issues with IPv6 and QUIC protocol addresses.
This commit is contained in:
parent
a9e53a4a84
commit
2f0580faf3
|
@ -132,37 +132,44 @@ proc getLastSeenAddress(node: BeaconNode, id: PeerId): string =
|
||||||
var temp: seq[tuple[address: MultiAddress, position: int]]
|
var temp: seq[tuple[address: MultiAddress, position: int]]
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
let res =
|
let res =
|
||||||
if IP4.matchPartial(address):
|
if TCP.matchPartial(address):
|
||||||
let address4 = address.getProtocolArgument(multiCodec("ip4")).valueOr:
|
# TODO (cheatfate): We match TCP here because `nim-libp2p` do not have
|
||||||
continue
|
# QUIC support yet. So we give TCP addresses priority.
|
||||||
var ta4 = TransportAddress(family: AddressFamily.IPv4)
|
if IP4.matchPartial(address):
|
||||||
ta4.address_v4[0 .. 3] = address4[0 .. 3]
|
let address4 = address.getProtocolArgument(multiCodec("ip4")).valueOr:
|
||||||
if ta4.isLoopback():
|
continue
|
||||||
(address, 9)
|
var ta4 = TransportAddress(family: AddressFamily.IPv4)
|
||||||
elif ta4.isLinkLocal():
|
ta4.address_v4[0 .. 3] = address4[0 .. 3]
|
||||||
(address, 7)
|
if ta4.isLoopback():
|
||||||
elif ta4.isSiteLocal():
|
(address, 9)
|
||||||
(address, 5)
|
elif ta4.isLinkLocal():
|
||||||
elif ta4.isGlobal():
|
(address, 7)
|
||||||
(address, 2)
|
elif ta4.isSiteLocal():
|
||||||
|
(address, 5)
|
||||||
|
elif ta4.isGlobal():
|
||||||
|
(address, 2)
|
||||||
|
else:
|
||||||
|
(address, 11)
|
||||||
|
elif IP6.matchPartial(address):
|
||||||
|
let address6 = address.getProtocolArgument(multiCodec("ip6")).valueOr:
|
||||||
|
continue
|
||||||
|
var ta6 = TransportAddress(family: AddressFamily.IPv4)
|
||||||
|
ta6.address_v6[0 .. 15] = address6[0 .. 15]
|
||||||
|
if ta6.isLoopback():
|
||||||
|
(address, 8)
|
||||||
|
elif ta6.isLinkLocal():
|
||||||
|
(address, 6)
|
||||||
|
elif ta6.isSiteLocal():
|
||||||
|
(address, 4)
|
||||||
|
elif ta6.isGlobal():
|
||||||
|
(address, 1)
|
||||||
|
else:
|
||||||
|
(address, 10)
|
||||||
else:
|
else:
|
||||||
(address, 11)
|
(address, 3)
|
||||||
elif IP6.matchPartial(address):
|
|
||||||
let address6 = address.getProtocolArgument(multiCodec("ip4")).valueOr:
|
|
||||||
continue
|
|
||||||
var ta6 = TransportAddress(family: AddressFamily.IPv4)
|
|
||||||
ta6.address_v6[0 .. 15] = address6[0 .. 15]
|
|
||||||
if ta6.isLoopback():
|
|
||||||
(address, 8)
|
|
||||||
elif ta6.isLinkLocal():
|
|
||||||
(address, 6)
|
|
||||||
elif ta6.isSiteLocal():
|
|
||||||
(address, 4)
|
|
||||||
elif ta6.isGlobal():
|
|
||||||
(address, 1)
|
|
||||||
else:
|
|
||||||
(address, 10)
|
|
||||||
else:
|
else:
|
||||||
|
# TODO (chatfate): As soon as QUIC protocol will be implemented in
|
||||||
|
# `nim-libp2p` - TCP prioritization should be dropped
|
||||||
(address, 3)
|
(address, 3)
|
||||||
temp.add(res)
|
temp.add(res)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue