ginepro
ginepro copied to clipboard
Unexpected blocked when custom lookup service returns ipv6 addresses
Bug description
If we registered a custom lookup service that returns ipv6 addresses, grpc client request would block forever. After tracking source code, I guess the bug exists in build_endpoint
method:
fn build_endpoint(&self, ip_address: &SocketAddr) -> Option<Endpoint> {
let uri = format!(
"{}://{}:{}",
self.scheme,
ip_address.ip(),
ip_address.port()
);
// ...
}
If the type of ip_address
is SocketAddr::V6, the correct patten should be {}://[{}]:{}
instead of {}://{}:{}
which would fail the endpoint building. Then the create_changeset
method would always report nothing because build_endpoint returns None
:
changeset.extend(
add_set
.into_iter()
.filter_map(|addr| self.build_endpoint(&addr).map(|endpoint| (addr, endpoint)))
.map(|(addr, endpoint)| Change::Insert(addr, endpoint)),
);
To Reproduce
Implement a custom lookup service that returns ipv6 addresses and register it.
Expected behavior
Custom lookup service returns either ipv4 or ipv6 addresses should work correctly.
Environment
Environment independent