Commit Graph

665 Commits

Author SHA1 Message Date
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
Adin Schmahmann
52c177ced9
feat: go-libp2p 0.16, UnixFS autosharding and go-datastore with contexts (#8563)
* plumb through go-datastore context changes

* update go-libp2p to v0.16.0
* use LIBP2P_TCP_REUSEPORT instead of IPFS_REUSEPORT
* use relay config
* making deprecation notice match the go-ipfs-config key
* docs(config): circuit relay v2
* docs(config): fix links and headers
* feat(config): Internal.Libp2pForceReachability

This switches to config that supports setting and reading
Internal.Libp2pForceReachability OptionalString flag

* use configuration option for static relays

* chore: go-ipfs-config v0.18.0

https://github.com/ipfs/go-ipfs-config/releases/tag/v0.18.0

* feat: circuit v1 migration prompt when Swarm.EnableRelayHop is set (#8559)
* exit when Swarm.EnableRelayHop is set
* docs: Experimental.ShardingEnabled migration

This ensures existing users of global sharding experiment get notified
that the flag no longer works + that autosharding happens automatically.

For people who NEED to keep the old behavior (eg. have no time to
migrate today) there is a note about restoring it with
`UnixFSShardingSizeThreshold`.

* chore: add dag-jose code to the cid command output

* add support for setting automatic unixfs sharding threshold from the config
* test: have tests use low cutoff for sharding to mimic old behavior
* test: change error message to match the current error
* test: Add automatic sharding/unsharding tests (#8547)
* test: refactored naming in the sharding sharness tests to make more sense

* ci: set interop test executor to convenience image for Go1.16 + Node
* ci: use interop master

Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Gus Eggert <gus@gus.dev>
Co-authored-by: Lucas Molas <schomatis@gmail.com>
2021-11-29 19:58:05 +01:00
mathew-cf
11404a9a03
fix: multiple subdomain gateways on same domain (#8556) 2021-11-23 18:11:37 +01:00
Dimitris Apostolou
0c2f9d5950
Fix typos (#8548) 2021-11-17 21:16:06 +01:00
Marcin Rataj
0b923b7951 chore: update dir-index-html to v1.2.2
https://github.com/ipfs/dir-index-html/releases/tag/1.2.2
2021-10-07 12:42:17 -04:00
Petar Maymounkov
f50d43eb0d
add more logging to flaky TestPeersTotal
Cannot reproduce the flakiness at the moment. The report suggests that connections are established on different transports. Adding logging to show what these transports are.
2021-10-04 08:49:39 -07:00
Marcin Rataj
6a10c1df81
feat: ipfs-webui v2.13.0 (#8430)
Release Notes: https://github.com/ipfs/ipfs-webui/releases/tag/v2.13.0
2021-09-21 20:36:27 +02:00
Lucas Molas
3a84352f18
feat(cli): add daemon option --agent-version-suffix (#8419)
* feat(cli): add daemon option --agent-version-suffix
* fix sharness test when commit is empty (release)
2021-09-21 20:31:08 +02:00
Marten Seemann
c95d6ca08c update go-libp2p to v0.15.0-rc.1 2021-08-19 18:05:04 +02:00
Steven Allen
7c76118b0b
Merge pull request #8318 from ipfs/fix/path-panic
fix: avoid out of bounds error when rendering short hashes
2021-08-13 14:54:25 -07:00
Adrian Lanzafame
02823935aa feat: register first block metric by default 2021-08-07 15:48:22 -04:00
Steven Allen
66a76d27f3 fix: abort when we fail to resolve CIDs
I believe we figured that these were for "informational purposes", but
really, we _should_ always be able to resolve names to CIDs. If we
can't, there's probably something wrong with the directory.
2021-07-30 11:36:23 -07:00
Steven Allen
0858dc62aa fix: avoid panic on short hash
(caught higher up but should still be fixed)
2021-07-30 11:33:53 -07:00
Marcin Rataj
c7444fb61a feat: webui v2.12.4 2021-07-15 08:21:50 -07:00
Marcin Rataj
2c431eb825 fix: webui-2.12.3
This bumps webui to bugfix release based on feedback from 0.9.0-rc1:
https://github.com/ipfs/ipfs-webui/releases/tag/v2.12.3
2021-05-24 08:25:40 -07:00
Marcin Rataj
28d4d9b327 refactor: add isDomainNameAndNotPeerID
This ensures we exclude valid PeerIDs from code paths that require
DNSLink names.

Ref.
https://github.com/ipfs/go-ipfs/pull/8071#pullrequestreview-639409245
2021-05-13 10:54:40 -04:00
divingpetrel
24dd662d38 feat support non-ICANN DNS 2021-05-13 10:54:38 -04:00
Marten Seemann
473d7d5851 update quic-go to v0.21.0-rc.1 2021-05-12 19:17:52 -04:00
Marcin Rataj
a9868105f0
feat: ipfs-webui v2.12.2
https://github.com/ipfs/ipfs-webui/releases/tag/v2.12.2
2021-04-30 16:12:21 +02:00
Steven Allen
a006ded010 chore: update webui to 2.12.1 2021-04-28 11:00:45 -07:00
Marcin Rataj
9f8964e6f9
fix(gw): remove hardcoded hostnames
This closes #7317 by removing hardcoded PL hostnames from default
config, making the localhost the only implicit gateway hostname.
2021-04-12 18:03:44 +02:00
Steven Allen
4cdb67f37d
Merge pull request #7890 from ipfs/fix/remove-clear-site-data
fix(gw): remove use of Clear-Site-Data in subdomain router
2021-03-31 16:24:24 -07:00
Steven Allen
0a3f88823c
Merge pull request #7994 from ipfs/chore/deprecate-pathprefixes
chore: deprecate Gateway.PathPrefixes
2021-03-30 15:52:02 -07:00
Marcin Rataj
2f105f79b9
chore: deprecate Gateway.PathPrefixes
Context:
https://github.com/ipfs/go-ipfs/issues/7702#issuecomment-803136077
2021-03-30 21:17:41 +02:00
Steven Allen
d30f1e5d44
Merge pull request #7930 from ipfs/fix/redundant-ns-on-gateway
feat(gw): /ipfs/ipfs/{cid} → /ipfs/{cid}
2021-03-24 13:12:16 -07:00
Marcin Rataj
763a120ed2
fix: no fixup if X-Ipfs-Gateway-Prefix is present
https://github.com/ipfs/go-ipfs/pull/7930#discussion_r597976690
2021-03-20 00:00:58 +01:00
Marcin Rataj
a35ffee136
refactor: safer query handling
https://github.com/ipfs/go-ipfs/pull/7930#discussion_r597246135
2021-03-18 23:48:53 +01:00
Marcin Rataj
450baef0e9
refactor: explicit prefix check
https://github.com/ipfs/go-ipfs/pull/7930#discussion_r584001161
2021-03-18 21:48:04 +01:00
Marcin Rataj
b81b7549d3
refactor: addressing review
- moved to separate utility function
- return Bad Request error
- improved escaping of values passed via URL path
2021-03-18 21:22:07 +01:00