Commit 7bdd7330 authored by Vitaly Lipatov's avatar Vitaly Lipatov

eget: add support for a new IPFS gateways

parent 51e097c4
...@@ -503,9 +503,8 @@ ipfs_api_local="/ip4/127.0.0.1/tcp/5001" ...@@ -503,9 +503,8 @@ ipfs_api_local="/ip4/127.0.0.1/tcp/5001"
ipfs_api_brave="/ip4/127.0.0.1/tcp/45005" ipfs_api_brave="/ip4/127.0.0.1/tcp/45005"
ipfs_gateway="https://cloudflare-ipfs.com/ipfs" # Public IPFS http gateways
[ -n "$EGET_IPFS_GATEWAY" ] && ipfs_gateway="$EGET_IPFS_GATEWAY" ipfs_gateways="https://cloudflare-ipfs.com/ipfs https://dweb.link/ipfs https://dhash.ru/ipfs"
IPFS_GATEWAY="$ipfs_gateway"
# Test data: https://etersoft.ru/templates/etersoft/images/logo.png # Test data: https://etersoft.ru/templates/etersoft/images/logo.png
ipfs_checkQm="QmYwf2GAMvHxfFiUFL2Mr6KUG6QrDiupqGc8ms785ktaYw" ipfs_checkQm="QmYwf2GAMvHxfFiUFL2Mr6KUG6QrDiupqGc8ms785ktaYw"
...@@ -533,6 +532,23 @@ ipfs_check() ...@@ -533,6 +532,23 @@ ipfs_check()
verdocmd $IPFS_CMD --api $IPFS_API $ipfs_diag_timeout cat "$1" >/dev/null verdocmd $IPFS_CMD --api $IPFS_API $ipfs_diag_timeout cat "$1" >/dev/null
} }
check_ipfs_gateway()
{
local ipfs_gateway="$1"
# TODO: check checksum
if docmd eget --check-url "$ipfs_gateway/$ipfs_checkQm" ; then
ipfs_mode="gateway"
return
fi
if docmd eget --check-site "$(dirname $ipfs_gateway)" ; then
info "IPFS gateway $ipfs_gateway is accessible, but can't return shared $ipfs_checkQm"
else
info "IPFS gateway $(dirname $ipfs_gateway) is not accessible"
fi
return 1
}
select_ipfs_mode() select_ipfs_mode()
...@@ -564,20 +580,23 @@ select_ipfs_mode() ...@@ -564,20 +580,23 @@ select_ipfs_mode()
fi fi
fi fi
# TODO: check checksum IPFS_GATEWAY=''
if docmd eget --check-url "$ipfs_gateway/$ipfs_checkQm" ; then
ipfs_mode="gateway" # if set some http gateway, use only it
if [ -n "$EGET_IPFS_GATEWAY" ] ; then
check_ipfs_gateway "$EGET_IPFS_GATEWAY" && IPFS_GATEWAY="$EGET_IPFS_GATEWAY" || ipfs_mode="disabled"
return return
fi fi
IPFS_GATEWAY='' # check public http gateways
if docmd eget --check-site "$(dirname $ipfs_gateway)" ; then for ipfs_gateway in $ipfs_gateways ; do
info "IPFS gateway $ipfs_gateway is accessible, but can't return shared $ipfs_checkQm" check_ipfs_gateway $ipfs_gateway || continue
else IPFS_GATEWAY="$ipfs_gateway"
info "IPFS gateway $(dirname $ipfs_gateway) is not accessible" return
fi done
ipfs_mode="disabled" ipfs_mode="disabled"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment