diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f3718e1..8a51dcbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ The minor version will be incremented upon a breaking change and the patch versi - proto: add `entries_count` to block meta message ([#283](https://github.com/rpcpool/yellowstone-grpc/pull/283)) - geyser: use `Vec::binary_search` instead of `HashSet::contains` in the filters ([#284](https://github.com/rpcpool/yellowstone-grpc/pull/284)) - proto: add `starting_transaction_index` to entry message ([#289](https://github.com/rpcpool/yellowstone-grpc/pull/289)) +- geyser: add `hostname` to version response ([#291](https://github.com/rpcpool/yellowstone-grpc/pull/291)) ### Breaking diff --git a/Cargo.lock b/Cargo.lock index 674af690..1bc0f68e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1690,6 +1690,17 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + [[package]] name = "http" version = "0.2.9" @@ -2082,6 +2093,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + [[package]] name = "matchers" version = "0.1.0" @@ -5081,6 +5098,7 @@ dependencies = [ "crossbeam-channel", "futures", "git-version", + "hostname", "hyper", "lazy_static", "log", diff --git a/Cargo.toml b/Cargo.toml index 5899cb89..ed173b87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ git-version = "0.3.5" google-cloud-googleapis = "0.11.0" google-cloud-pubsub = "0.21.0" hex = "0.4.3" +hostname = "0.3.1" http = "0.2.8" hyper = "0.14.27" json5 = "0.4.1" diff --git a/yellowstone-grpc-geyser/Cargo.toml b/yellowstone-grpc-geyser/Cargo.toml index 3f62c0e2..093b29ed 100644 --- a/yellowstone-grpc-geyser/Cargo.toml +++ b/yellowstone-grpc-geyser/Cargo.toml @@ -24,6 +24,7 @@ bs58 = { workspace = true } clap = { workspace = true, features = ["derive"] } crossbeam-channel = { workspace = true } futures = { workspace = true } +hostname = { workspace = true } hyper = { workspace = true } lazy_static = { workspace = true } log = { workspace = true } diff --git a/yellowstone-grpc-geyser/src/grpc.rs b/yellowstone-grpc-geyser/src/grpc.rs index 2b0720cf..288451bf 100644 --- a/yellowstone-grpc-geyser/src/grpc.rs +++ b/yellowstone-grpc-geyser/src/grpc.rs @@ -3,7 +3,7 @@ use { config::{ConfigBlockFailAction, ConfigGrpc}, filters::{Filter, FilterAccountsDataSlice}, prom::{self, CONNECTIONS_TOTAL, MESSAGE_QUEUE_SIZE}, - version::VERSION, + version::GrpcVersionInfo, }, log::{error, info}, solana_geyser_plugin_interface::geyser_plugin_interface::{ @@ -1398,7 +1398,7 @@ impl Geyser for GrpcService { _request: Request, ) -> Result, Status> { Ok(Response::new(GetVersionResponse { - version: serde_json::to_string(&VERSION).unwrap(), + version: serde_json::to_string(&GrpcVersionInfo::default()).unwrap(), })) } } diff --git a/yellowstone-grpc-geyser/src/version.rs b/yellowstone-grpc-geyser/src/version.rs index b9da6284..f9b8c8ca 100644 --- a/yellowstone-grpc-geyser/src/version.rs +++ b/yellowstone-grpc-geyser/src/version.rs @@ -20,3 +20,27 @@ pub const VERSION: Version = Version { rustc: env!("VERGEN_RUSTC_SEMVER"), buildts: env!("VERGEN_BUILD_TIMESTAMP"), }; + +#[derive(Debug, Serialize)] +pub struct GrpcVersionInfoExtra { + hostname: Option, +} + +#[derive(Debug, Serialize)] +pub struct GrpcVersionInfo { + version: Version, + extra: GrpcVersionInfoExtra, +} + +impl Default for GrpcVersionInfo { + fn default() -> Self { + Self { + version: VERSION, + extra: GrpcVersionInfoExtra { + hostname: hostname::get() + .ok() + .and_then(|name| name.into_string().ok()), + }, + } + } +}