From bc6bee15857b3ca24d319c2d8eb62b75a245b0df Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Thu, 31 Aug 2023 03:51:48 -0400 Subject: [PATCH] rename Libp2pGatewayOption and hard code its gateway configuration --- cmd/ipfs/daemon.go | 2 +- core/corehttp/gateway.go | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index b28b59764..f11d86952 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -911,7 +911,7 @@ const gatewayProtocolID protocol.ID = "/ipfs/gateway" // FIXME: specify https:// func serveTrustlessGatewayOverLibp2p(cctx *oldcmds.Context) (<-chan error, error) { opts := []corehttp.ServeOption{ corehttp.MetricsCollectionOption("libp2p-gateway"), - corehttp.TrustlessGatewayOption(), + corehttp.Libp2pGatewayOption(), corehttp.VersionOption(), } diff --git a/core/corehttp/gateway.go b/core/corehttp/gateway.go index a954c92f3..4a4f08780 100644 --- a/core/corehttp/gateway.go +++ b/core/corehttp/gateway.go @@ -76,13 +76,8 @@ func VersionOption() ServeOption { } } -func TrustlessGatewayOption() ServeOption { +func Libp2pGatewayOption() ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - config, err := getGatewayConfig(n) - if err != nil { - return nil, err - } - bserv := blockservice.New(n.Blocks.Blockstore(), offline.Exchange(n.Blocks.Blockstore())) backend, err := gateway.NewBlocksBackend(bserv) @@ -90,7 +85,14 @@ func TrustlessGatewayOption() ServeOption { return nil, err } - handler := gateway.NewHandler(config, &offlineGatewayErrWrapper{gwimpl: backend}) + gwConfig := gateway.Config{ + DeserializedResponses: false, + NoDNSLink: true, + PublicGateways: nil, + Menu: nil, + } + + handler := gateway.NewHandler(gwConfig, &offlineGatewayErrWrapper{gwimpl: backend}) handler = otelhttp.NewHandler(handler, "Libp2p-Gateway") mux.Handle("/ipfs/", handler)