zebra
zebra copied to clipboard
Return peer metadata from `connect_isolated` functions
Motivation
We want to support development of an alternate DNS seeder based on zebra-network
.
Requirements
There's some peer metadata which we need access to (from the connect_isolated
-style functions) in order to reproduce the seeder filtering algorithms and I'm unsure how to make that happen:
- The value of the
PeerServices
bitset - The numeric protocol version number (the stuff that looks like
170100
) - The textual user-agent string (the stuff that looks like
/MagicBean:5.0.0/
)
I see there's a negotiate_version
in handshake.rs
that seems to do the version handshaking and it returns a tuple (remote_version, remote_services, remote_canonical_addr)
(which is almost all we want, it's missing the text user-agent string).
The place where negotiate_version
is called is impl<S, PeerTransport, C> Service<HandshakeRequest<PeerTransport>> for Handshake<S, C>
; but I'm not sure how the latter gets called exactly, and it doesn't return/pass through the remote version/services info.
Originally posted by @superbaud in https://github.com/zcash/zcash/issues/3881#issuecomment-1162096689
Copied from https://github.com/zcash/zcash/issues/3881#issuecomment-1163762182
The current design is roughly:
-
AddrV1
andAddrV2
- serialized outbound connection address inaddr
andaddr2
messages -
MetaAddr
- outbound peer connection addresses and last connection status, serialized fromAddrV1
andAddrV2
-
LoadTrackedClient
- contains current protocol version for an active inbound or outbound connection
So I think we might want to do something like:
- split the
Version
out ofLoadTrackedClient
into a newPeerConnectionInfo
struct - add whatever other fields we want
- add
PeerConnectionInfo
toLoadTrackedClient
andMetaAddr
(aslast_connection_info
) - return
LoadTrackedClient
fromconnect_isolated*
(and rename that struct toConnectedClient
)