diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e0598b..5ee40e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,8 +14,8 @@ The following emojis are used to highlight certain changes: ## [Unreleased] ### Added -- Ability to specify the maximum blocksize that bitswap will replace WantHave with WantBlock responses, and to disable replacement when set to zero. [#165](https://github.com/ipfs/rainbow/pull/165) -- Support use and configuration of pebble as [datastore](https://github.com/ipfs/rainbow/blob/main/docs/blockstores.md). Pebble provides a high-performance alternative to badger. Options are available to configure key tuning parameters (`pebble-*` in `rainbow --help`). + +- Support implicit default list for `filter-protocols` from [IPIP-484](https://github.com/ipfs/specs/pull/484) and customizing them via `--http-routers-filter-protocols`. ### Changed @@ -25,6 +25,13 @@ The following emojis are used to highlight certain changes: ### Security +## [v1.7.0] + +### Added + +- Ability to specify the maximum blocksize that bitswap will replace WantHave with WantBlock responses, and to disable replacement when set to zero. [#165](https://github.com/ipfs/rainbow/pull/165) +- Support use and configuration of pebble as [datastore](https://github.com/ipfs/rainbow/blob/main/docs/blockstores.md). Pebble provides a high-performance alternative to badger. Options are available to configure key tuning parameters (`pebble-*` in `rainbow --help`). + ## [v1.6.0] ### Added diff --git a/main.go b/main.go index 816a3c1..be37c14 100644 --- a/main.go +++ b/main.go @@ -204,6 +204,12 @@ Generate an identity seed and launch a gateway: EnvVars: []string{"RAINBOW_HTTP_ROUTERS"}, Usage: "HTTP servers with /routing/v1 endpoints to use for delegated routing (comma-separated)", }, + &cli.StringSliceFlag{ + Name: "http-routers-filter-protocols", + Value: cli.NewStringSlice(httpRoutersFilterProtocols...), + EnvVars: []string{"RAINBOW_HTTP_ROUTERS_FILTER_PROTOCOLS"}, + Usage: "IPIP-484 filter-protocols to apply to delegated routing requests (comma-separated)", + }, &cli.StringFlag{ Name: "dht-routing", Value: "accelerated", @@ -502,6 +508,7 @@ share the same seed as long as the indexes are different. MaxFD: cctx.Int("libp2p-max-fd"), InMemBlockCache: cctx.Int64("inmem-block-cache"), RoutingV1Endpoints: cctx.StringSlice("http-routers"), + RoutingV1FilterProtocols: cctx.StringSlice("http-routers-filter-protocols"), DHTRouting: dhtRouting, DHTSharedHost: cctx.Bool("dht-shared-host"), Bitswap: bitswap, diff --git a/setup.go b/setup.go index 877d978..6261c59 100644 --- a/setup.go +++ b/setup.go @@ -51,6 +51,8 @@ func init() { const cidContactEndpoint = "https://cid.contact" +var httpRoutersFilterProtocols = []string{"unknown", "transport-bitswap"} // IPIP-484 + type DHTRouting string const ( @@ -100,14 +102,15 @@ type Config struct { MaxMemory uint64 MaxFD int - GatewayDomains []string - SubdomainGatewayDomains []string - TrustlessGatewayDomains []string - RoutingV1Endpoints []string - DHTRouting DHTRouting - DHTSharedHost bool - IpnsMaxCacheTTL time.Duration - Bitswap bool + GatewayDomains []string + SubdomainGatewayDomains []string + TrustlessGatewayDomains []string + RoutingV1Endpoints []string + RoutingV1FilterProtocols []string + DHTRouting DHTRouting + DHTSharedHost bool + IpnsMaxCacheTTL time.Duration + Bitswap bool // BitswapWantHaveReplaceSize tells the bitswap server to replace WantHave // with WantBlock responses when the block size less then or equal to this diff --git a/setup_routing.go b/setup_routing.go index 89a5615..3121730 100644 --- a/setup_routing.go +++ b/setup_routing.go @@ -52,11 +52,12 @@ func setupDelegatedRouting(cfg Config, dnsCache *cachedDNS) ([]routing.Routing, ) for _, endpoint := range cfg.RoutingV1Endpoints { - rv1Opts := []routingv1client.Option{routingv1client.WithHTTPClient(httpClient)} - if endpoint != cidContactEndpoint { - rv1Opts = append(rv1Opts, routingv1client.WithStreamResultsRequired()) - } - delegatedRouter, err := delegatedHTTPContentRouter(endpoint, rv1Opts...) + delegatedRouter, err := delegatedHTTPContentRouter(endpoint, + routingv1client.WithHTTPClient(httpClient), + routingv1client.WithProtocolFilter(cfg.RoutingV1FilterProtocols), // IPIP-484 + routingv1client.WithStreamResultsRequired(), // https://specs.ipfs.tech/routing/http-routing-v1/#streaming + routingv1client.WithDisabledLocalFiltering(false), // force local filtering in case remote server does not support IPIP-484 + ) if err != nil { return nil, err } @@ -276,7 +277,7 @@ func delegatedHTTPContentRouter(endpoint string, rv1Opts ...routingv1client.Opti cli, err := routingv1client.New( endpoint, append([]routingv1client.Option{ - routingv1client.WithUserAgent(buildVersion()), + routingv1client.WithUserAgent("rainbow/" + buildVersion()), }, rv1Opts...)..., ) if err != nil {