Skip to content

Commit c20ca3a

Browse files
authored
feat(http-routers): filter-protocols from IPIP-484 (#173)
1 parent 59af74b commit c20ca3a

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

CHANGELOG.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ The following emojis are used to highlight certain changes:
1414
## [Unreleased]
1515

1616
### Added
17-
- 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)
18-
- 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`).
17+
18+
- 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`.
1919

2020
### Changed
2121

@@ -25,6 +25,13 @@ The following emojis are used to highlight certain changes:
2525

2626
### Security
2727

28+
## [v1.7.0]
29+
30+
### Added
31+
32+
- 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)
33+
- 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`).
34+
2835
## [v1.6.0]
2936

3037
### Added

main.go

+7
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ Generate an identity seed and launch a gateway:
204204
EnvVars: []string{"RAINBOW_HTTP_ROUTERS"},
205205
Usage: "HTTP servers with /routing/v1 endpoints to use for delegated routing (comma-separated)",
206206
},
207+
&cli.StringSliceFlag{
208+
Name: "http-routers-filter-protocols",
209+
Value: cli.NewStringSlice(httpRoutersFilterProtocols...),
210+
EnvVars: []string{"RAINBOW_HTTP_ROUTERS_FILTER_PROTOCOLS"},
211+
Usage: "IPIP-484 filter-protocols to apply to delegated routing requests (comma-separated)",
212+
},
207213
&cli.StringFlag{
208214
Name: "dht-routing",
209215
Value: "accelerated",
@@ -502,6 +508,7 @@ share the same seed as long as the indexes are different.
502508
MaxFD: cctx.Int("libp2p-max-fd"),
503509
InMemBlockCache: cctx.Int64("inmem-block-cache"),
504510
RoutingV1Endpoints: cctx.StringSlice("http-routers"),
511+
RoutingV1FilterProtocols: cctx.StringSlice("http-routers-filter-protocols"),
505512
DHTRouting: dhtRouting,
506513
DHTSharedHost: cctx.Bool("dht-shared-host"),
507514
Bitswap: bitswap,

setup.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ func init() {
5151

5252
const cidContactEndpoint = "https://cid.contact"
5353

54+
var httpRoutersFilterProtocols = []string{"unknown", "transport-bitswap"} // IPIP-484
55+
5456
type DHTRouting string
5557

5658
const (
@@ -100,14 +102,15 @@ type Config struct {
100102
MaxMemory uint64
101103
MaxFD int
102104

103-
GatewayDomains []string
104-
SubdomainGatewayDomains []string
105-
TrustlessGatewayDomains []string
106-
RoutingV1Endpoints []string
107-
DHTRouting DHTRouting
108-
DHTSharedHost bool
109-
IpnsMaxCacheTTL time.Duration
110-
Bitswap bool
105+
GatewayDomains []string
106+
SubdomainGatewayDomains []string
107+
TrustlessGatewayDomains []string
108+
RoutingV1Endpoints []string
109+
RoutingV1FilterProtocols []string
110+
DHTRouting DHTRouting
111+
DHTSharedHost bool
112+
IpnsMaxCacheTTL time.Duration
113+
Bitswap bool
111114

112115
// BitswapWantHaveReplaceSize tells the bitswap server to replace WantHave
113116
// with WantBlock responses when the block size less then or equal to this

setup_routing.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ func setupDelegatedRouting(cfg Config, dnsCache *cachedDNS) ([]routing.Routing,
5252
)
5353

5454
for _, endpoint := range cfg.RoutingV1Endpoints {
55-
rv1Opts := []routingv1client.Option{routingv1client.WithHTTPClient(httpClient)}
56-
if endpoint != cidContactEndpoint {
57-
rv1Opts = append(rv1Opts, routingv1client.WithStreamResultsRequired())
58-
}
59-
delegatedRouter, err := delegatedHTTPContentRouter(endpoint, rv1Opts...)
55+
delegatedRouter, err := delegatedHTTPContentRouter(endpoint,
56+
routingv1client.WithHTTPClient(httpClient),
57+
routingv1client.WithProtocolFilter(cfg.RoutingV1FilterProtocols), // IPIP-484
58+
routingv1client.WithStreamResultsRequired(), // https://specs.ipfs.tech/routing/http-routing-v1/#streaming
59+
routingv1client.WithDisabledLocalFiltering(false), // force local filtering in case remote server does not support IPIP-484
60+
)
6061
if err != nil {
6162
return nil, err
6263
}
@@ -276,7 +277,7 @@ func delegatedHTTPContentRouter(endpoint string, rv1Opts ...routingv1client.Opti
276277
cli, err := routingv1client.New(
277278
endpoint,
278279
append([]routingv1client.Option{
279-
routingv1client.WithUserAgent(buildVersion()),
280+
routingv1client.WithUserAgent("rainbow/" + buildVersion()),
280281
}, rv1Opts...)...,
281282
)
282283
if err != nil {

0 commit comments

Comments
 (0)