Skip to content

Allow different zebra-network apps to use different user agents #2375

Closed

Description

Motivation

  1. We want zebrad to have a different user agent from the ECC's DNS seeder, and other apps that use zebra-network

  2. We'd like to simplify Zebra's release process, by automatically using a zebrad version in the zebra-network user agent.

Specifications

https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki

Solution

  • Add a user_agent argument to zebra_network::init, and pass it to the handshaker
  • In zebrad::commands::start, pass application::app_version() to zebra_network::init
    • Use the BIP-14 format: "/Zebra:1.0.0-alpha.11/"
  • Add the supplied user agent to the front of the zebra-network user agent string, using the BIP-14 syntax

pub fn connect_isolated(
conn: TcpStream,
user_agent: String,
) -> impl Future<
Output = Result<
BoxService<Request, Response, Box<dyn std::error::Error + Send + Sync + 'static>>,
Box<dyn std::error::Error + Send + Sync + 'static>,
>,
> {
let handshake = peer::Handshake::builder()
.with_config(Config::default())
.with_inbound_service(tower::service_fn(|_req| async move {
Ok::<Response, Box<dyn std::error::Error + Send + Sync + 'static>>(Response::Nil)
}))
.with_user_agent(user_agent)
.finish()
.expect("provided mandatory builder parameters");

Related Work

Make sure custom user agents conform to BIP-14 #794

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-networkArea: Network protocol updates or fixesA-rustArea: Updates to Rust codeC-enhancementCategory: This is an improvement

Type

No type

Projects

  • Status

    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions