From f763f8dc62d07cbfbd00fd5bf794b292503b4619 Mon Sep 17 00:00:00 2001 From: Anton Grigorev Date: Thu, 14 Dec 2023 08:51:53 +0400 Subject: [PATCH] Fix graph IPFS connection failure due to the unsupported /api/v0/files/stat HTTP API --- core/src/link_resolver.rs | 17 +++++------------ docker/start | 7 ++++--- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/core/src/link_resolver.rs b/core/src/link_resolver.rs index 9b2be6f107c..d05a7e76840 100644 --- a/core/src/link_resolver.rs +++ b/core/src/link_resolver.rs @@ -170,10 +170,10 @@ impl LinkResolverTrait for LinkResolver { } trace!(logger, "IPFS cache miss"; "hash" => &path); - let (size, client) = select_fastest_client_with_stat( + let (_size, client) = select_fastest_client_with_stat( self.clients.cheap_clone(), logger.cheap_clone(), - StatApi::Files, + StatApi::Block, path.clone(), self.timeout, self.retry, @@ -182,7 +182,6 @@ impl LinkResolverTrait for LinkResolver { let max_cache_file_size = self.env_vars.mappings.max_ipfs_cache_file_size; let max_file_size = self.env_vars.mappings.max_ipfs_file_bytes; - restrict_file_size(&path, size, max_file_size)?; let req_path = path.clone(); let timeout = self.timeout; @@ -215,7 +214,7 @@ impl LinkResolverTrait for LinkResolver { async fn get_block(&self, logger: &Logger, link: &Link) -> Result, Error> { trace!(logger, "IPFS block get"; "hash" => &link.link); - let (size, client) = select_fastest_client_with_stat( + let (_size, client) = select_fastest_client_with_stat( self.clients.cheap_clone(), logger.cheap_clone(), StatApi::Block, @@ -225,9 +224,6 @@ impl LinkResolverTrait for LinkResolver { ) .await?; - let max_file_size = self.env_vars.mappings.max_ipfs_file_bytes; - restrict_file_size(&link.link, size, max_file_size)?; - let link = link.link.clone(); let data = retry_policy(self.retry, "ipfs.getBlock", &logger) .run(move || { @@ -247,19 +243,16 @@ impl LinkResolverTrait for LinkResolver { // Discard the `/ipfs/` prefix (if present) to get the hash. let path = link.link.trim_start_matches("/ipfs/"); - let (size, client) = select_fastest_client_with_stat( + let (_size, client) = select_fastest_client_with_stat( self.clients.cheap_clone(), logger.cheap_clone(), - StatApi::Files, + StatApi::Block, path.to_string(), self.timeout, self.retry, ) .await?; - let max_file_size = self.env_vars.mappings.max_ipfs_map_file_size; - restrict_file_size(path, size, max_file_size)?; - let mut stream = client.cat(path, None).await?.fuse().boxed().compat(); let mut buf = BytesMut::with_capacity(1024); diff --git a/docker/start b/docker/start index d7729a252de..5b664eb45f4 100755 --- a/docker/start +++ b/docker/start @@ -33,11 +33,12 @@ save_coredumps() { wait_for_ipfs() { # Take the IPFS URL in $1 apart and extract host and port. If no explicit # host is given, use 443 for https, and 80 otherwise - if [[ "$1" =~ ^((https?)://)?([^:/]+)(:([0-9]+))? ]] + if [[ "$1" =~ ^((https?)://)?(([^@]+)@)?([^:/]+)(:([0-9]+))? ]] then proto=${BASH_REMATCH[2]:-http} - host=${BASH_REMATCH[3]} - port=${BASH_REMATCH[5]} + user=${BASH_REMATCH[4]} + host=${BASH_REMATCH[5]} + port=${BASH_REMATCH[7]} if [ -z "$port" ] then [ "$proto" = "https" ] && port=443 || port=80