diff --git a/.github/workflows/gateway-conformance.yml b/.github/workflows/gateway-conformance.yml index 0ae6141..586f545 100644 --- a/.github/workflows/gateway-conformance.yml +++ b/.github/workflows/gateway-conformance.yml @@ -18,7 +18,7 @@ jobs: # 2. Download the gateway-conformance fixtures - name: Download gateway-conformance fixtures - uses: ipfs/gateway-conformance/.github/actions/extract-fixtures@v0.2 + uses: ipfs/gateway-conformance/.github/actions/extract-fixtures@v0.3 with: output: fixtures @@ -26,7 +26,15 @@ jobs: - name: Import fixtures run: | # Import car files - find ./fixtures -name '*.car' -exec ipfs dag import --pin-roots=false {} \; + find ./fixtures -name '*.car' -exec ipfs dag import --pin-roots=false --offline {} \; + + # Import ipns records + records=$(find ./fixtures -name '*.ipns-record') + for record in $records + do + key=$(basename -s .ipns-record "$record" | cut -d'_' -f1) + ipfs routing put --allow-offline --offline "/ipns/$key" "$record" + done # Import dnslink records # the IPFS_NS_MAP env will be used by the daemon @@ -57,15 +65,16 @@ jobs: # 6. Run the gateway-conformance tests - name: Run gateway-conformance tests - uses: ipfs/gateway-conformance/.github/actions/test@v0.2 + uses: ipfs/gateway-conformance/.github/actions/test@v0.3 with: gateway-url: http://127.0.0.1:8081 json: output.json xml: output.xml html: output.html markdown: output.md - specs: +trustless-gateway,-trustless-ipns-gateway,+path-gateway,-path-ipns-gateway,+subdomain-gateway,-subdomain-ipns-gateway,+dnslink-gateway - args: -skip 'TestGatewayCar/GET_response_for_application/vnd.ipld.car/Header_Content-Length' + specs: +trustless-gateway,+path-gateway,+subdomain-gateway,+dnslink-gateway,+redirects-file + # use below to skip specific test if needed + # args: -skip 'TestFooBr/GET_response_for_something' # 7. Upload the results - name: Upload MD summary diff --git a/go.mod b/go.mod index 3a93870..f7c9f89 100644 --- a/go.mod +++ b/go.mod @@ -6,12 +6,14 @@ require ( github.com/cskr/pubsub v1.0.2 github.com/filecoin-saturn/caboose v0.0.3 github.com/hashicorp/golang-lru/v2 v2.0.1 - github.com/ipfs/boxo v0.10.2-0.20230627114119-8424cf4e020a + github.com/ipfs/boxo v0.11.0 github.com/ipfs/go-block-format v0.1.2 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-ipld-format v0.5.0 github.com/ipfs/go-log/v2 v2.5.1 github.com/ipfs/go-unixfsnode v1.7.1 + github.com/ipld/go-car v0.6.0 + github.com/ipld/go-car/v2 v2.10.2-0.20230622090957-499d0c909d33 github.com/ipld/go-codec-dagpb v1.6.0 github.com/ipld/go-ipld-prime v0.20.0 github.com/libp2p/go-libp2p v0.26.3 @@ -23,7 +25,7 @@ require ( github.com/prometheus/client_golang v1.15.1 github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417 github.com/spf13/cobra v1.6.1 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 github.com/willscott/go-requestcontext v0.0.1 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0 go.opentelemetry.io/contrib/propagators/autoprop v0.40.0 @@ -86,10 +88,9 @@ require ( github.com/ipfs/go-ipld-legacy v0.2.1 // indirect github.com/ipfs/go-libipfs v0.6.0 // indirect github.com/ipfs/go-log v1.0.5 // indirect - github.com/ipfs/go-merkledag v0.10.1-0.20230601163447-eceea556e7d4 // indirect + github.com/ipfs/go-merkledag v0.11.0 // indirect github.com/ipfs/go-metrics-interface v0.0.1 // indirect github.com/ipfs/go-verifcid v0.0.2 // indirect - github.com/ipld/go-car v0.6.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/jbenet/goprocess v0.1.4 // indirect diff --git a/go.sum b/go.sum index f910226..643ffbf 100644 --- a/go.sum +++ b/go.sum @@ -272,8 +272,8 @@ github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7P github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.10.2-0.20230627114119-8424cf4e020a h1:Yiy9cuIbazoTzjcRer4NNWeSv3qPJfsZUX9rHQEBe08= -github.com/ipfs/boxo v0.10.2-0.20230627114119-8424cf4e020a/go.mod h1:eVXIkLOG+fTJSuXtkANlwLllV1CEayOZnbDClK8ZOQY= +github.com/ipfs/boxo v0.11.0 h1:urMxhZ3xoF4HssJVD3+0ssGT9pptEfHfbL8DYdoWFlg= +github.com/ipfs/boxo v0.11.0/go.mod h1:8IfDmp+FzFGcF4zjAgHMVPpwYw4AjN9ePEzDfkaYJ1w= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ= @@ -326,8 +326,8 @@ github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JP github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= -github.com/ipfs/go-merkledag v0.10.1-0.20230601163447-eceea556e7d4 h1:qOnP2EUTr5QJqxW5xhB5XiuOyr9/G5UC5P981qBNnb8= -github.com/ipfs/go-merkledag v0.10.1-0.20230601163447-eceea556e7d4/go.mod h1:GO+7K3Ez1L+/JAnFDYRWdOyD5ZXUuqy4SFdfOBudkiw= +github.com/ipfs/go-merkledag v0.11.0 h1:DgzwK5hprESOzS4O1t/wi6JDpyVQdvm9Bs59N/jqfBY= +github.com/ipfs/go-merkledag v0.11.0/go.mod h1:Q4f/1ezvBiJV0YCIXvt51W/9/kqJGH4I1LsA7+djsM4= github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= github.com/ipfs/go-peertaskqueue v0.8.1 h1:YhxAs1+wxb5jk7RvS0LHdyiILpNmRIRnZVztekOF0pg= @@ -338,7 +338,8 @@ github.com/ipfs/go-verifcid v0.0.2 h1:XPnUv0XmdH+ZIhLGKg6U2vaPaRDXb9urMyNVCE7uvT github.com/ipfs/go-verifcid v0.0.2/go.mod h1:40cD9x1y4OWnFXbLNJYRe7MpNvWlMn3LZAG5Wb4xnPU= github.com/ipld/go-car v0.6.0 h1:d5QrGLnHAxiNLHor+DKGrLdqnM0dQJh2whfSXRDq6J0= github.com/ipld/go-car v0.6.0/go.mod h1:tBrW1XZ3L2XipLxA69RnTVGW3rve6VX4TbaTYkq8aEA= -github.com/ipld/go-car/v2 v2.9.1-0.20230325062757-fff0e4397a3d h1:22g+x1tgWSXK34i25qjs+afr7basaneEkHaglBshd2g= +github.com/ipld/go-car/v2 v2.10.2-0.20230622090957-499d0c909d33 h1:0OZwzSYWIuiKEOXd/2vm5cMcEmmGLFn+1h6lHELCm3s= +github.com/ipld/go-car/v2 v2.10.2-0.20230622090957-499d0c909d33/go.mod h1:sQEkXVM3csejlb1kCCb+vQ/pWBKX9QtvsrysMQjOgOg= github.com/ipld/go-codec-dagpb v1.6.0 h1:9nYazfyu9B1p3NAgfVdpRco3Fs2nFC72DqVsMj6rOcc= github.com/ipld/go-codec-dagpb v1.6.0/go.mod h1:ANzFhfP2uMJxRBr8CE+WQWs5UsNa0pYtmKZ+agnUw9s= github.com/ipld/go-ipld-prime v0.20.0 h1:Ud3VwE9ClxpO2LkCYP7vWPc0Fo+dYdYzgxUJZ3uRG4g= @@ -602,8 +603,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tcnksm/go-httpstat v0.2.0 h1:rP7T5e5U2HfmOBmZzGgGZjBQ5/GluWUylujl0tJ04I0= github.com/tcnksm/go-httpstat v0.2.0/go.mod h1:s3JVJFtQxtBEBC9dwcdTTXS9xFnM3SXAZwPG41aurT8= diff --git a/handlers.go b/handlers.go index 2463d72..0397a39 100644 --- a/handlers.go +++ b/handlers.go @@ -119,16 +119,20 @@ func makeGatewayHandler(bs bstore.Blockstore, kuboRPC []string, port int, blockC // Note: in the future we may want to make this more configurable. noDNSLink := false + + // TODO: allow appending hostnames to this list via ENV variable (separate PATH_GATEWAY_HOSTS & SUBDOMAIN_GATEWAY_HOSTS) publicGateways := map[string]*gateway.PublicGateway{ "localhost": { Paths: []string{"/ipfs", "/ipns"}, NoDNSLink: noDNSLink, + InlineDNSLink: false, DeserializedResponses: true, UseSubdomains: true, }, "dweb.link": { Paths: []string{"/ipfs", "/ipns"}, NoDNSLink: noDNSLink, + InlineDNSLink: true, DeserializedResponses: true, UseSubdomains: true, }, @@ -139,9 +143,13 @@ func makeGatewayHandler(bs bstore.Blockstore, kuboRPC []string, port int, blockC publicGateways["example.com"] = &gateway.PublicGateway{ Paths: []string{"/ipfs", "/ipns"}, NoDNSLink: noDNSLink, + InlineDNSLink: true, DeserializedResponses: true, UseSubdomains: true, } + + // TODO: revisit the below once we clarify desired behavior in https://specs.ipfs.tech/http-gateways/subdomain-gateway/ + publicGateways["localhost"].InlineDNSLink = true } gwConf.NoDNSLink = noDNSLink diff --git a/lib/graph_gateway.go b/lib/graph_gateway.go index a0da38a..21fc287 100644 --- a/lib/graph_gateway.go +++ b/lib/graph_gateway.go @@ -21,7 +21,6 @@ import ( exchange "github.com/ipfs/boxo/exchange" "github.com/ipfs/boxo/files" "github.com/ipfs/boxo/gateway" - "github.com/ipfs/boxo/ipld/car" "github.com/ipfs/boxo/namesys" "github.com/ipfs/boxo/namesys/resolve" ipfspath "github.com/ipfs/boxo/path" @@ -29,6 +28,7 @@ import ( "github.com/ipfs/go-cid" format "github.com/ipfs/go-ipld-format" golog "github.com/ipfs/go-log/v2" + "github.com/ipld/go-car" routinghelpers "github.com/libp2p/go-libp2p-routing-helpers" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/routing" diff --git a/test-backend/handlers.go b/test-backend/handlers.go index ad81d40..231583e 100644 --- a/test-backend/handlers.go +++ b/test-backend/handlers.go @@ -16,8 +16,6 @@ import ( "github.com/ipfs/boxo/fetcher" "github.com/ipfs/boxo/files" "github.com/ipfs/boxo/gateway" - "github.com/ipfs/boxo/ipld/car" - "github.com/ipfs/boxo/ipld/car/util" "github.com/ipfs/boxo/ipld/merkledag" unixfile "github.com/ipfs/boxo/ipld/unixfs/file" "github.com/ipfs/boxo/path" @@ -25,6 +23,8 @@ import ( blocks "github.com/ipfs/go-block-format" format "github.com/ipfs/go-ipld-format" "github.com/ipfs/go-unixfsnode" + "github.com/ipld/go-car" + "github.com/ipld/go-car/util" dagpb "github.com/ipld/go-codec-dagpb" "github.com/ipld/go-ipld-prime" cidlink "github.com/ipld/go-ipld-prime/linking/cid" diff --git a/test-backend/main.go b/test-backend/main.go index 0a31870..a61b27f 100644 --- a/test-backend/main.go +++ b/test-backend/main.go @@ -14,8 +14,8 @@ import ( "github.com/ipfs/boxo/bitswap/network" "github.com/ipfs/boxo/blockservice" offline "github.com/ipfs/boxo/exchange/offline" - carbs "github.com/ipfs/boxo/ipld/car/v2/blockstore" golog "github.com/ipfs/go-log/v2" + carbs "github.com/ipld/go-car/v2/blockstore" "github.com/libp2p/go-libp2p" dht "github.com/libp2p/go-libp2p-kad-dht" "github.com/libp2p/go-libp2p/core/host"