Commit Graph

693 Commits

Author SHA1 Message Date
Gus Eggert
e550d9e476
ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
Justin Johnson
bcaacdd6c3
feat(gateway): _redirects file support (#8890)
https://github.com/ipfs/kubo/pull/8890
https://github.com/ipfs/specs/pull/290
2022-09-23 18:44:19 +02:00
Jorropo
74aaf37cec chore: bump go-libp2p v0.23.1
This does not include any WebTransport config code in Kubo, this will be done later in an other PR.
2022-09-21 23:16:03 +02:00
Russell Dempsey
87dc8de461 feat: ipfs-webui v2.18.1 2022-09-13 23:40:49 +02:00
Russell Dempsey
007295d34d
feat: ipfs-webui v2.18.0 (#9262)
https://github.com/ipfs/ipfs-webui/releases/tag/v2.18.0
2022-09-12 15:40:46 +02:00
Jorropo
196887cbe5 chore: bump go-libp2p v0.22.0 & go1.18&go1.19
Fixes: #9225
2022-09-09 17:09:38 +02:00
Jorropo
df22205385 fix(gw): send 200 for empty files
Fixes #9238
2022-09-01 01:04:48 +02:00
Marcin Rataj
c9693edbc5 chore: remove Gateway.PathPrefixes
Closes #7702
2022-08-30 15:38:04 +02:00
Marcin Rataj
924ab0616b
Merge pull request #9070 from iand/feat-modular-gateway
feat: make corehttp a reusable component
2022-08-17 03:25:29 +02:00
Marco Munizaga
27b046f98e Move register exporter to metrics file 2022-08-15 14:12:21 -07:00
Marcin Rataj
837f6ee92b chore: switch to dist.ipfs.tech
Part of https://github.com/protocol/bifrost-infra/issues/2018
ensures the domain used for fetching migrations is not
impacted by ipfs.io being blocked at DNS level by some ISPs.
2022-08-12 23:42:17 +02:00
Seungbae Yu
cb280cbf16
docs: replace docs.ipfs.io with docs.ipfs.tech (#9158)
* docs: fix redirecting URL in README.md
* all: replace `docs.ipfs.io` with `docs.ipfs.tech`
* apply suggestions from code review

Co-authored-by: Marcin Rataj <lidel@lidel.org>
2022-08-05 19:01:10 +03:00
Marcin Rataj
7992025254 fix(gw): 404 when a valid DAG is missing link 2022-07-23 00:16:31 +02:00
Marcin Rataj
3182986151 fix(gw): ensure dir URLs have trailing slash
This fixes a regression around directory listing and index.html hosting.
Seems that during one of recent refactors code changed and we no longer
check for trailing slash in HTTP request path, but look at content path
instead.

This cleans this up and also ensures dir behavior is the same for
both index.html hosting and dir-index-html (generated listing).

It also adds more tests so we catch any future regressions.
2022-07-21 21:06:18 +02:00
Ian Davis
f8cdd96c2a
Clarify offlineApi argument 2022-07-21 15:14:52 +01:00
Ian Davis
2ece5556f0
Change AccessControlHeaders funtion to modify an existing set of headers 2022-07-21 15:09:09 +01:00
Ian Davis
f4d87419ce
feat: make corehttp a reusable component 2022-07-21 15:09:06 +01:00
Marcin Rataj
e832cc2c1d fix(gw): cache-control of index.html websites
This fixes a regression introduced in 0.13.0, where websites hosted via
index.html placed in UnixFS directory were always returned with
Cache-Control: public, max-age=29030400, immutable
even when loaded from mutable /ipns/ contentPath.
2022-07-21 02:02:21 +00:00
Marcin Rataj
a6687744c7 fix(gw): no backlink when listing root dir
Closes #9071
2022-07-18 23:35:44 +00:00
Marcin Rataj
58aaee00f8 feat(gw): Cache-Control: only-if-cached
This implements the only-if-cached behavior documented in specs:
https://github.com/ipfs/specs/blob/main/http-gateways/PATH_GATEWAY.md#cache-control-request-header
https://github.com/ipfs/specs/blob/main/http-gateways/PATH_GATEWAY.md#only-if-cached-head-behavior
2022-07-07 08:49:26 +02:00
Russell Dempsey
fbd65e0c8d chore(deps): webui v2.15.1
https://github.com/ipfs/ipfs-webui/releases/tag/v2.15.1
2022-07-07 01:45:19 +02:00
Marcin Rataj
9dbc9dfeb2 fix(cmds): use kubo in CheckVersionOption
Using both names to avoid dev problems during the transition from go-ipfs 0.13 to kubo 0.14
2022-07-06 23:08:31 +02:00
Marcin Rataj
82467bc936 refactor: rename to kubo 2022-07-06 18:40:37 +02:00
Marcin Rataj
289e465f05 fix: correct cache-control in car responses
Context: https://github.com/ipfs/specs/pull/295
2022-07-06 18:34:12 +02:00
Jorropo
cbf5fdae55 chore: update go-car 2022-07-06 15:30:29 +02:00
Adin Schmahmann
123f1f61e0
Merge pull request #9038 from ipfs/update-libp2p-v020
update go-libp2p to v0.20.3
2022-06-30 15:21:23 -04:00
Marten Seemann
ec61dd410d update go-libp2p to v0.20.2 2022-06-24 19:48:11 +02:00
Jorropo
a433064d72
chore: replace ioutil with io and os (#8969)
Co-authored-by: Håvard Anda Estensen <haavard.ae@gmail.com>
2022-06-14 12:37:02 -04:00
Henrique Dias
33843bfe3a fix: honor url filename when downloading as CAR/BLOCK 2022-06-10 00:07:55 +02:00
Marcin Rataj
650bc246ab
fix: JS caching via Access-Control-Expose-Headers (#8984)
This fix safelists additional headers allowing JS running on websites to
read them when IPFS resource is downloaded via Fetch API.

These headers provide metadata necessary for making smart caching
decisions when IPFS resources are downloaded via Service Worker or a
similar middleware on the edge.
2022-05-19 14:11:19 -04:00
Antonio Navarro Perez
afd11f1019
chore: fix linting errors (#8930) 2022-05-04 11:02:07 -04:00
Lucas Molas
25cc85fa93
feat(gateway): Gateway.FastDirIndexThreshold (#8853)
* fix(core/gateway): option to limit directory size listing

* feat(gw): HTMLDirListingLimit

This is alternative take on the way we limit the HTML listing output.
Instead of a hard cut-off, we list up to HTMLDirListingLimit.
When a directory has more items than HTMLDirListingLimit we show
additional header and footer informing user that only $HTMLDirListingLimit
items are listed. This is a better UX.

* fix: 0 disables Gateway.HTMLDirListingLimit

* refactor: Gateway.FastDirIndexThreshold

see explainer in docs/config.md

* refactor: prealoc slices

* docs: Gateway.FastDirIndexThreshold

* refactor: core/corehttp/gateway_handler.go

https://github.com/ipfs/go-ipfs/pull/8853#discussion_r851437088

* docs: apply suggestions from code review

Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>

Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
2022-04-28 19:36:57 +02:00
Marcin Rataj
67fdb6efcd
feat(gw): improved If-None-Match support (#8891)
Improves the way we handle If-None-Match header:
- Support for more than one Etag passed in If-None-Match
- Match both strong and weak Etags to maximize caching across
  various HTTP clients and libraries (some send weak Etags by default)
- Support for wildcard '*'
- Tests for If-None-Match behavior
2022-04-19 20:57:11 +02:00
Justin Johnson
e07baf5835
chore(gw): extract logical functions to improve readability (#8885)
* Extract functions from getOrHeadHandler to improve readability and prepare for later refactorings

* Address PR feedback on when to return errors or booleans

* Be explicit about use of *requestError vs error
2022-04-15 16:06:43 +02:00
Franky W
70398d275c Change assets.Asset from a func to the embed.FS
This removes the delegation to the function and requires all callers
that used the `asset.Asset` func to access to asset via the `embed.FS`
2022-04-12 02:36:19 +02:00
Franky W
9210c08fa6 Remove gobindata
Since go1.16, there are built in tools that allow for embeding
filesystem inside the binary. We now make use of the `embed` package to
have all files put into the binary, removing the need to generate the
files and removes dependencies

Co-authored-by: Jorropo <jorropo.pgm@gmail.com>
2022-04-12 02:36:19 +02:00
Gus Eggert
9bd346e250
fix: fix context plumbing in gateway handlers (#8871)
This ensures that child contexts are passed around between
the handlers so that traces show the call hierarchy correctly.
2022-04-11 23:09:00 +02:00
makeworld
52bf133946
fix(gw): missing return if dir fails to finalize (#8806) 2022-04-08 23:09:23 +02:00
Ian Davis
fbf76663f4
fix(gw): update metrics only when payload data sent (#8827)
* fix: report gateway http metrics only when response is successful
* fix(gw): 304 Not Modified as no-op

This fix ensures we don't do any additional work when Etag match
what user already has in their own cache.

Co-authored-by: Marcin Rataj <lidel@lidel.org>
2022-04-08 22:07:44 +02:00
Gus Eggert
f855bfe6ef
feat: add basic gateway tracing (#8595)
* add deprecation warning when tracer plugins are loaded
* add response format attribute to span in gateway handler
* add note about tracing's experimental status in godoc
* add nil check for TTL when adding name span attrs
* add basic sharness test for integration with otel collector
* add nil check in UnixFSAPI.processLink
* test: sharness check all json objs for swarm span
* add env var docs to docs/environment-variables.md
* chore: pin the otel collector version
* add tracing spans per response type (#8841)
* docs: tracing with jaeger-ui

Co-authored-by: Marcin Rataj <lidel@lidel.org>
2022-04-04 19:24:05 +02:00
Marcin Rataj
5fa556945e
fix(gw): validate requested CAR version (#8835)
* fix(gw): validate requested CAR version

This adds validation of 'application/vnd.ipld.car;version=n' passed
in the Accept header by HTTP clients to align Gateway behavior with
the spec submitted to IANA.

* test: fix comment in test/sharness/t0118-gateway-car.sh

Co-authored-by: Gus Eggert <gus@gus.dev>

Co-authored-by: Gus Eggert <gus@gus.dev>
2022-04-01 09:12:46 -07:00
Adin Schmahmann
beaa8fc29b
feat: add gateway histogram metrics (#8443)
* feat(gw): response type histogram metrics

- response-type agnostic firstContentBlockGetMetric which counts the
  latency til the first content block.

- car/block/file/gen-dir-index duration histogram metrics that show how
  long each response type takes

* docs: improve metrics descriptions
* feat: more gw histogram buckets

0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 30, 60 secs
as suggested in reviews at https://github.com/ipfs/go-ipfs/pull/8443

Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Gus Eggert <gus@gus.dev>
2022-03-21 15:57:08 +01:00
Marcin Rataj
4cabdfefbf
feat(gateway): Block and CAR response formats (#8758)
* feat: serveRawBlock implements ?format=block
* feat: serveCar implements ?format=car
* feat(gw): ?format= or Accept HTTP header

- extracted file-like content type responses to separate .go files
- Accept HTTP header with support for application/vnd.ipld.* types

* fix: use .bin for raw block content-disposition

.raw may be handled by something, depending on OS, and .bin
seems to be universally "binary file" across all systems:
https://en.wikipedia.org/wiki/List_of_filename_extensions_(A%E2%80%93E)

* refactor: gateway_handler_unixfs.go

- Moved UnixFS response handling to gateway_handler_unixfs*.go files.
- Removed support for X-Ipfs-Gateway-Prefix (Closes #7702)

* refactor: prefix cleanup and readable paths

- removed dead code after X-Ipfs-Gateway-Prefix is gone
  (https://github.com/ipfs/go-ipfs/issues/7702)
- escaped special characters in content paths returned with http.Error
  making them both safer and easier to reason about (e.g. when invisible
  whitespace Unicode is used)
2022-03-17 17:15:24 +01:00
Dave Justice
6774ef9dfd
fix: allow ipfs-companion browser extension to access RPC API (#8690)
* fix: add companion ids to allow origins

- fixes #8689
- Adds the chrome-extension ids for ipfs-companion and
ipfs-companion-beta to the allowed origins list, this
allows us to accesss ipfs api from a manifest v3 extension.
- added tests in t0401-api-browser-security.sh

* fix: companion when custom CORS *-Origin is set

Companion extension should be able to access RPC API even when custom
Access-Control-Allow-Origin is set

Co-authored-by: Marcin Rataj <lidel@lidel.org>
2022-03-17 00:07:52 +01:00
Gus Eggert
0487f03eae
feat: add endpoint for enabling block profiling (#8469) 2022-03-11 14:32:59 -05:00
Laurent Senta
8d549f03f3 fix: rewrite dependencies over the go-ipfs-config package 2022-03-04 09:45:16 +01:00
Marcin Rataj
d5ad847e05
feat: ipfs-webui v2.15 (#8712)
Release Notes:
https://github.com/ipfs/ipfs-webui/releases/tag/v2.15.0
2022-03-01 19:03:06 +01:00
Marcin Rataj
caba3b2643
feat: X-Ipfs-Roots for smarter HTTP caches (#8720) 2022-03-01 09:04:31 -08:00
Manuel Alonso
edb32ac3d7
chore(gateway): debug logging for the http requests (#8518)
* chore(gateway): better logging for the http requests

* chore(gateway): removed defer and add more data to the final log

* chore(gateway): debug logging refactor

* chore(gateway): use debug w/o context when only msg

* doc: add cmd for log level

* chore: add more logs and address fedback

* chore(gateway): log subdomains and from=requestURI, refactor

* chore(gateway): fix debug redirect
2022-02-15 17:13:09 -05:00
Lucas Molas
9d197ca732
fix(corehttp): adjust peer counting metrics (#8577) 2021-12-02 17:03:00 -08:00