@cryptotaxi247 / kubo / commits / bc6bee158

rename Libp2pGatewayOption and hard code its gateway configuration

Adin Schmahmann committed Aug 31, 2023 at 03:51 UTC bc6bee15857b3ca24d319c2d8eb62b75a245b0df
2 files changed +10 -8
cmd/ipfs/daemon.go
+1 -1
@@ -911,7 +911,7 @@ const gatewayProtocolID protocol.ID = "/ipfs/gateway" // FIXME: specify https://
911 func serveTrustlessGatewayOverLibp2p(cctx *oldcmds.Context) (<-chan error, error) {
912 opts := []corehttp.ServeOption{
913 corehttp.MetricsCollectionOption("libp2p-gateway"),
914 - corehttp.TrustlessGatewayOption(),
914 + corehttp.Libp2pGatewayOption(),
915 corehttp.VersionOption(),
916 }
917
core/corehttp/gateway.go
+9 -7
@@ -76,13 +76,8 @@ func VersionOption() ServeOption {
76 }
77 }
78
79 -func TrustlessGatewayOption() ServeOption {
79 +func Libp2pGatewayOption() ServeOption {
80 return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
81 - config, err := getGatewayConfig(n)
82 - if err != nil {
83 - return nil, err
84 - }
85 -
81 bserv := blockservice.New(n.Blocks.Blockstore(), offline.Exchange(n.Blocks.Blockstore()))
82
83 backend, err := gateway.NewBlocksBackend(bserv)
@@ -90,7 +85,14 @@ func TrustlessGatewayOption() ServeOption {
85 return nil, err
86 }
87
93 - handler := gateway.NewHandler(config, &offlineGatewayErrWrapper{gwimpl: backend})
88 + gwConfig := gateway.Config{
89 + DeserializedResponses: false,
90 + NoDNSLink: true,
91 + PublicGateways: nil,
92 + Menu: nil,
93 + }
94 +
95 + handler := gateway.NewHandler(gwConfig, &offlineGatewayErrWrapper{gwimpl: backend})
96 handler = otelhttp.NewHandler(handler, "Libp2p-Gateway")
97
98 mux.Handle("/ipfs/", handler)