Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract Gateway Code From Kubo #65

Merged
merged 981 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
981 commits
Select commit Hold shift + click to select a range
ac6b82a
fix: migrate from deprecated warning function
Stebalien Jan 16, 2020
5a0b56d
fix(tracing): remove event tracing
Stebalien Jan 17, 2020
7ffb0b2
Merge pull request ipfs/kubo#6832 from ipfs/chore/update-deps
Stebalien Jan 29, 2020
1818da6
Merge tag 'v0.4.23' into release
Stebalien Feb 8, 2020
5f8bf3a
rename ProxyOption to P2PProxyOption
Stebalien Mar 14, 2019
5429ceb
gateway: simplify/improve dnslink rewrite handling
Stebalien Mar 14, 2019
df09179
feat(gateway): subdomain and proxy gateway
lidel Mar 15, 2019
6ac0716
fix(gateway): curl without redirect on localhost
lidel Mar 11, 2020
a31c796
Merge pull request ipfs/kubo#6096 from ipfs/feat/gateway-subdomains
Stebalien Mar 18, 2020
7ce444a
HTTP API: Disallow GET requests on API
hsanjuan Apr 3, 2020
ecb855b
corehttp: Gateway handler: add Allow headers when returning MethodNot…
hsanjuan Apr 4, 2020
eb70087
Merge pull request ipfs/kubo#7097 from ipfs/fix/api-post
Stebalien Apr 5, 2020
4764185
feat: webui v2.7.4
lidel Apr 14, 2020
859c22d
Merge pull request ipfs/kubo#7159 from ipfs/feat/webui-v2.7.4
Stebalien Apr 14, 2020
e1dd5d9
fix: subdomain redirect for dir CIDs
lidel Apr 15, 2020
b11009b
Merge pull request ipfs/kubo#7165 from ipfs/fix/subdomain-dir-redirect
Stebalien Apr 15, 2020
0431eec
feat: webui 2.7.5
hacdias Apr 17, 2020
b60396a
Merge pull request ipfs/kubo#7176 from ipfs/webui-2.7.5
Stebalien Apr 17, 2020
df6d11f
Fix typos and cleanup
rex4539 Apr 18, 2020
18d90d8
feat: always show the hash
Stebalien Apr 26, 2020
6161b22
feat: show the absolute path every time
Stebalien Apr 26, 2020
daface2
Merge branch 'master' into release
Stebalien Apr 28, 2020
b2899d7
Merge pull request ipfs/kubo#7243 from ipfs/release
Stebalien Apr 29, 2020
c30b301
Merge pull request ipfs/kubo#7219 from ipfs/fix/listing-header
Stebalien Apr 29, 2020
d6424eb
Fixes #7252 - Uses gabriel-vasile/mimetype to support additional cont…
gowthamgts May 1, 2020
91707d7
#7252 - read content directly instead of sending 512bytes
gowthamgts May 1, 2020
d9b8483
#7252 - print error message
gowthamgts May 1, 2020
973bcef
optimize import order
gowthamgts May 2, 2020
b3a59a1
Merge pull request ipfs/kubo#7262 from gowthamgts/fix/http/content-type
Stebalien May 4, 2020
156284e
Gateway renders pretty 404 pages if available
jphastings May 8, 2020
184edbb
Merge pull request ipfs/kubo#4233 from jphastings/feat/gateway/pretty…
Stebalien May 19, 2020
85cba15
fix(gateway): fix status code for HEAD on redirects
Lekensteyn May 20, 2020
c6fc093
fix(gateway): ensure directory listings have Content-Type text/html
Lekensteyn May 18, 2020
8a01dd5
Merge pull request ipfs/kubo#7330 from cloudflare/fix/dir-listing-con…
Stebalien May 20, 2020
12f186a
fix: support directory listings even if a 404 page is present
Stebalien May 21, 2020
a16c116
Merge pull request ipfs/kubo#7339 from ipfs/fix/dir-listing-404
Stebalien May 21, 2020
de69041
Include the git blob id of the dir-index bundle in the ETag
ribasushi Jun 23, 2019
20eab31
chore: update WebUI to 2.8.0
sinkuu May 28, 2020
37169d1
Merge pull request ipfs/kubo#7380 from sinkuu/chore/webui
Stebalien May 28, 2020
7875812
feat: webui v2.9.0
lidel May 28, 2020
23e7e5b
Merge pull request ipfs/kubo#7387 from ipfs/feat/webui-v2.9.0
Stebalien May 28, 2020
4e3488c
chore: update WebUI to 2.8.0
sinkuu May 28, 2020
2af18ac
feat: webui v2.9.0
lidel May 28, 2020
43e80e3
Merge pull request ipfs/kubo#7405 from ipfs/backports
Stebalien Jun 3, 2020
67db99d
fix: use the correct context when resolving dnsaddr links
Stebalien Jun 18, 2020
ff0c91e
Merge pull request ipfs/kubo#7491 from ipfs/fix/ipns-resolve-leak
Stebalien Jun 19, 2020
c5ee923
Merge pull request ipfs/kubo#7366 from ipfs/release-v0.6.0
aschmahmann Jun 19, 2020
78ced57
Merge branch 'release' into master
aschmahmann Jun 20, 2020
b2c1ae6
chore: bump webui version
rafaelramalho19 Jun 22, 2020
a8f3b1f
Merge pull request ipfs/kubo#7501 from rafaelramalho19/chore/bump-web…
Stebalien Jun 22, 2020
b6d36d9
chore:bump webui version to 2.10.1
rafaelramalho19 Jun 23, 2020
badbd0c
Merge pull request ipfs/kubo#7504 from rafaelramalho19/chore/bump-web…
Stebalien Jul 1, 2020
84e3c22
feat: support X-Forwarded-Host when doing gateway redirect
MichaelMure Jul 1, 2020
c1cfe2f
feat: support ED25519 libp2p-key in subdomains
lidel May 25, 2020
3937f1f
use t.Cleanup() to reduce the need to clean up servers
trashhalo Jul 18, 2020
4030f32
chore: bump webui version
rafaelramalho19 Jul 16, 2020
542242c
feat: wildcard support for public gateways
MichaelMure May 14, 2020
c0b7f3f
test(gateway): IPNS cleanup and implicit defaults fix
lidel Aug 6, 2020
c37f055
refactor: cleanup/comment
lidel Aug 19, 2020
529c172
feat: Directory page UI improvements
Jul 10, 2020
000ac7f
test: update gateway tests for dir-index-html v1.1.0
Jul 26, 2020
3ed88d1
Merge pull request ipfs/kubo#7536 from neatonk/master
aschmahmann Aug 20, 2020
3a9fca1
Merge pull request ipfs/kubo#7550 from trashhalo/dry-up-close
aschmahmann Aug 25, 2020
030025e
chore: update go-multiaddr and go-multiaddr-net
aschmahmann Aug 20, 2020
61ea246
Merge pull request ipfs/kubo#7610 from ipfs/chore/update-deps
aschmahmann Aug 26, 2020
95182c2
feat(gateway): ?filename with download=true
lidel Sep 16, 2020
d92fd64
feat(gateway): Content-Disposition for legacy clients
lidel Sep 16, 2020
17ef979
chore: bump webui version
rafaelramalho19 Sep 10, 2020
f6b3ba2
chore: bump webui version
rafaelramalho19 Sep 10, 2020
75a9aa6
Merge pull request ipfs/kubo#7692 from ipfs/release-v0.7.0
aschmahmann Sep 22, 2020
9614114
Merge branch 'release' into feat/merge-v0.7.0-master
aschmahmann Sep 22, 2020
d29bc1a
fix(gateway): correct breadcrumbs on dnslink site
lidel Sep 25, 2020
543a726
chore: bump webui version
rafaelramalho19 Sep 28, 2020
0872de9
fix(gw): links in CID column on dir listing
lidel Sep 28, 2020
60703d4
test(gw): add t0115-gateway-dir-listing.sh to sharness
lidel Sep 29, 2020
8a6f4fe
Merge pull request ipfs/kubo#7693 from ipfs/feat/merge-v0.7.0-master
aschmahmann Sep 29, 2020
20aa771
Merge pull request ipfs/kubo#7677 from ipfs/feat/content-disposition-…
aschmahmann Oct 2, 2020
1c373e1
Merge pull request ipfs/kubo#7703 from rafaelramalho19/chore/bump-go-…
aschmahmann Oct 2, 2020
b6e1ee9
feat: ipfs-webui v2.11.3
lidel Oct 6, 2020
3fa5b9e
feat: ipfs-webui v2.11.4
lidel Oct 7, 2020
ce0319c
fix(gw): preserve query on website redirect
lidel Oct 13, 2020
28276f8
fix: localhost API access via ipv6
lidel Oct 19, 2020
26d7864
Merge pull request ipfs/kubo#7731 from ipfs/fix/http-api-cors-allowlist
Stebalien Oct 26, 2020
529cdf2
Merge pull request ipfs/kubo#7716 from ipfs/feat/webui-v2.11.3
aschmahmann Nov 10, 2020
c258442
Merge pull request ipfs/kubo#7727 from ipfs/fix/preserver-query-on-we…
aschmahmann Nov 10, 2020
a721e5d
Merge pull request ipfs/kubo#7699 from ipfs/fix/dnslink-dir-listing
aschmahmann Nov 10, 2020
a91aef2
p2p-proxy: better request length checking
aschmahmann Dec 1, 2020
83dca91
p2p-proxy: earlier peerID validation check
aschmahmann Dec 1, 2020
d9719f1
register quic opencensus metrics
lanzafame Jul 24, 2020
aca5504
change the scraping url
lanzafame Sep 29, 2020
1e0ccb6
fix: decrease log level of opencensus initialization
aschmahmann Dec 9, 2020
7c7e576
Merge pull request ipfs/kubo#7815 from ipfs/fix/decrease-oc-init-log
aschmahmann Dec 9, 2020
9da8851
feat(gw): support inlined DNSLink names with TLS
lidel Jan 1, 2021
f554a8b
test: false for isHTTPSRequest
lidel Jan 7, 2021
5ff1d82
fix: check if rootID has DNSLink before uninlining
lidel Jan 14, 2021
3820d16
feat: support requests from registerProtocolHandler
dennis-tra Dec 5, 2020
1def9d8
fix: ?uri= url-decode and preserve query
lidel Dec 12, 2020
ed06bc0
refactor: remove redundant urlescape
lidel Dec 12, 2020
8582496
test: cover 2 remaining lines
lidel Jan 14, 2021
7a56ba7
Merge pull request ipfs/kubo#7802 from dennis-tra/issue-7686
aschmahmann Jan 14, 2021
cd00521
fix: remove use of Clear-Site-Data
lidel Jan 29, 2021
e90fd62
Merge pull request ipfs/kubo#7924 from ipfs/release-v0.8.0
aschmahmann Feb 18, 2021
326de7a
feat(gw): /ipfs/ipfs/{cid} → /ipfs/{cid}
lidel Feb 19, 2021
9cb5821
refactor: show error, delay redirect
lidel Feb 26, 2021
0c39f74
Extract the namesys and the keystore submodules
hsanjuan Feb 18, 2021
86742cd
revert registration of metrics against unexposed prom registry
lanzafame Mar 17, 2021
774ccd7
Merge pull request ipfs/kubo#7986 from ipfs/fix/prom-registry
Stebalien Mar 17, 2021
0eca026
refactor: addressing review
lidel Mar 18, 2021
9e5f7ba
refactor: explicit prefix check
lidel Mar 18, 2021
b3e5c1f
refactor: safer query handling
lidel Mar 18, 2021
609ddbc
fix: no fixup if X-Ipfs-Gateway-Prefix is present
lidel Mar 19, 2021
dd1f10c
Merge pull request ipfs/kubo#7930 from ipfs/fix/redundant-ns-on-gateway
Stebalien Mar 24, 2021
8736ffc
chore: deprecate Gateway.PathPrefixes
lidel Mar 19, 2021
d39e618
Merge pull request ipfs/kubo#7994 from ipfs/chore/deprecate-pathprefixes
Stebalien Mar 30, 2021
69fdff0
Merge pull request ipfs/kubo#7890 from ipfs/fix/remove-clear-site-data
Stebalien Mar 31, 2021
0d301bd
fix(gw): remove hardcoded hostnames
lidel Apr 12, 2021
a1ebcb3
chore: update webui to 2.12.1
Stebalien Apr 28, 2021
e6f6c42
feat: ipfs-webui v2.12.2
lidel Apr 30, 2021
3255dd9
update quic-go to v0.21.0-rc.1
marten-seemann Mar 20, 2021
c5b259e
Merge pull request ipfs/kubo#8125 from ipfs/update-quic-go
aschmahmann May 13, 2021
37f4857
feat support non-ICANN DNS
cong-or Apr 13, 2021
f1c5bb9
refactor: add isDomainNameAndNotPeerID
lidel Apr 21, 2021
6cb184a
fix: webui-2.12.3
lidel May 21, 2021
6fe1b17
fix: webui-2.12.3
lidel May 21, 2021
b0e7891
Merge pull request ipfs/kubo#8208 from ipfs/release-v0.9.0
aschmahmann Jun 22, 2021
16ad079
Merge branch 'release'
aschmahmann Jun 22, 2021
0fb688d
feat: webui v2.12.4
lidel Jul 5, 2021
9f8876e
feat: webui v2.12.4
lidel Jul 5, 2021
a1059b0
Merge pull request ipfs/kubo#8267 from ipfs/release-v0.9.1
aschmahmann Jul 21, 2021
47e71f0
Merge branch 'release'
aschmahmann Jul 22, 2021
ffd5714
fix: avoid panic on short hash
Stebalien Jul 30, 2021
e52ba61
fix: abort when we fail to resolve CIDs
Stebalien Jul 30, 2021
f0caf2e
feat: register first block metric by default
lanzafame Jul 30, 2019
628b0a4
Merge pull request ipfs/kubo#8332 from ipfs/feat/first-block-metric
guseggert Aug 9, 2021
978ac9b
Merge pull request ipfs/kubo#8318 from ipfs/fix/path-panic
Stebalien Aug 13, 2021
b47513a
update go-libp2p to v0.15.0-rc.1
marten-seemann Aug 18, 2021
282bece
Merge pull request ipfs/kubo#8354 from ipfs/udpate-libp2p
aschmahmann Aug 19, 2021
c613879
feat(cli): add daemon option --agent-version-suffix (#8419)
schomatis Sep 21, 2021
99e0fae
feat: ipfs-webui v2.13.0 (#8430)
lidel Sep 21, 2021
b894270
feat(cli): add daemon option --agent-version-suffix (#8419)
schomatis Sep 21, 2021
722feb9
feat: ipfs-webui v2.13.0 (#8430)
lidel Sep 21, 2021
f05b646
Merge pull request ipfs/kubo#8474 from ipfs/release-v0.10.0
aschmahmann Sep 30, 2021
8e0b08d
Merge branch 'release'
aschmahmann Sep 30, 2021
aa3a074
add more logging to flaky TestPeersTotal
petar Oct 4, 2021
0191d6a
chore: update dir-index-html to v1.2.2
lidel Oct 1, 2021
7f30fb7
Fix typos (#8548)
rex4539 Nov 17, 2021
6fc0de9
fix: multiple subdomain gateways on same domain (#8556)
mathew-cf Nov 23, 2021
718dd1c
feat: go-libp2p 0.16, UnixFS autosharding and go-datastore with conte…
aschmahmann Nov 29, 2021
4e07839
fix(corehttp): adjust peer counting metrics (#8577)
schomatis Dec 3, 2021
7358d05
fix(corehttp): adjust peer counting metrics (#8577)
schomatis Dec 3, 2021
c12ff17
Merge pull request ipfs/kubo#8597 from ipfs/release-v0.11.0
aschmahmann Dec 8, 2021
48c2bc0
Merge branch 'master' into release
guseggert Dec 9, 2021
c228a68
Merge branch 'release'
guseggert Dec 9, 2021
d967309
chore(gateway): debug logging for the http requests (#8518)
Feb 15, 2022
2f94345
Merge pull request ipfs/kubo#8743 from ipfs/release-v0.12.0
aschmahmann Feb 18, 2022
156b7c8
Merge branch 'release'
aschmahmann Feb 18, 2022
085c3fd
feat: X-Ipfs-Roots for smarter HTTP caches (#8720)
lidel Mar 1, 2022
de094cb
feat: ipfs-webui v2.15 (#8712)
lidel Mar 1, 2022
10692b9
fix: rewrite dependencies over the go-ipfs-config package
laurentsenta Mar 2, 2022
ee714da
Merge pull request ipfs/kubo#8756 from laurentsenta/feat/add-back-ipf…
lidel Mar 9, 2022
20807cd
feat: add endpoint for enabling block profiling (#8469)
guseggert Mar 11, 2022
8fc128f
fix: allow ipfs-companion browser extension to access RPC API (#8690)
meandavejustice Mar 16, 2022
3a09cab
feat(gateway): Block and CAR response formats (#8758)
lidel Mar 17, 2022
7927c02
feat: add gateway histogram metrics (#8443)
aschmahmann Mar 21, 2022
97a5888
fix(gw): validate requested CAR version (#8835)
lidel Apr 1, 2022
57bfeae
feat: add basic gateway tracing (#8595)
guseggert Apr 4, 2022
c2c9c1e
fix(gw): update metrics only when payload data sent (#8827)
iand Apr 8, 2022
3be8c5a
fix(gw): missing return if dir fails to finalize (#8806)
makew0rld Apr 8, 2022
03c0187
fix: fix context plumbing in gateway handlers (#8871)
guseggert Apr 11, 2022
e01550b
Remove gobindata
frankywahl Mar 31, 2022
2703c9a
Change `assets.Asset` from a `func` to the embed.FS
frankywahl Apr 11, 2022
177ce46
chore(gw): extract logical functions to improve readability (#8885)
Apr 15, 2022
88cc0da
feat(gw): improved If-None-Match support (#8891)
lidel Apr 19, 2022
e433566
feat(gateway): Gateway.FastDirIndexThreshold (#8853)
schomatis Apr 28, 2022
ba03bd8
chore: fix linting errors (#8930)
ajnavarro May 4, 2022
e195b35
fix: JS caching via Access-Control-Expose-Headers (#8984)
lidel May 19, 2022
0f6329e
fix: JS caching via Access-Control-Expose-Headers (#8984)
lidel May 19, 2022
444e066
Merge pull request ipfs/kubo#9023 from ipfs/release-v0.13.0
guseggert Jun 9, 2022
ca21029
Merge branch 'release'
aschmahmann Jun 9, 2022
c94a766
fix: honor url filename when downloading as CAR/BLOCK
hacdias Jun 9, 2022
b1186fa
chore: replace ioutil with io and os (#8969)
Jorropo Jun 14, 2022
aedec6f
update go-libp2p to v0.20.2
marten-seemann Jun 12, 2022
5761ed1
Merge pull request ipfs/kubo#9038 from ipfs/update-libp2p-v020
aschmahmann Jun 30, 2022
857f12b
chore: update go-car
Jorropo Jul 6, 2022
55c3d88
Merge pull request ipfs/kubo#9089 from Jorropo/chore/update-car
aschmahmann Jul 6, 2022
add052c
chore: update go-car
Jorropo Jul 6, 2022
4ae48d6
Merge pull request ipfs/kubo#9092 from ipfs/release-v0.13.1
aschmahmann Jul 6, 2022
6704be1
chore: resolve go.mod conflicts with master
Jorropo Jul 6, 2022
2871589
fix: correct cache-control in car responses
lidel Jul 4, 2022
727a167
refactor: rename to kubo
lidel May 9, 2022
1826a07
Merge pull request ipfs/kubo#8958 from ipfs/chore/rename-to-kubo
lidel Jul 6, 2022
65a77e8
fix(cmds): use kubo in CheckVersionOption
lidel Jul 6, 2022
0e15789
Merge pull request ipfs/kubo#9098 from ipfs/fix/post-rename-papercuts
lidel Jul 6, 2022
dd6c933
chore(deps): webui v2.15.1
SgtPooki Jun 29, 2022
77f4da3
feat(gw): Cache-Control: only-if-cached
lidel Jul 5, 2022
a4632a6
fix(gw): no backlink when listing root dir
lidel Jul 18, 2022
8478dbc
fix(gw): cache-control of index.html websites
lidel Jul 21, 2022
6b88d07
fix(gw): cache-control of index.html websites
lidel Jul 21, 2022
2c37162
Merge pull request ipfs/kubo#9133 from ipfs/release-v0.14.0
Jorropo Jul 21, 2022
68b1274
Merge v0.14.0 back into master
Jorropo Jul 21, 2022
c92ba64
feat: make corehttp a reusable component
iand Jun 30, 2022
7693baa
Change AccessControlHeaders funtion to modify an existing set of headers
iand Jul 1, 2022
974dfcb
Clarify offlineApi argument
iand Jul 21, 2022
a53a3ee
fix(gw): ensure dir URLs have trailing slash
lidel Jul 18, 2022
36819c9
Merge pull request ipfs/kubo#9123 from ipfs/fix/gw-trailing-slash-uni…
lidel Jul 21, 2022
37bc760
fix(gw): 404 when a valid DAG is missing link
lidel Jul 19, 2022
ca97743
docs: replace `docs.ipfs.io` with `docs.ipfs.tech` (#9158)
dbadoy Aug 5, 2022
5b7d96e
chore: switch to dist.ipfs.tech
lidel Aug 12, 2022
bb0912a
Move register exporter to metrics file
MarcoPolo Aug 12, 2022
05c6458
Merge pull request ipfs/kubo#9070 from iand/feat-modular-gateway
lidel Aug 17, 2022
d112b2e
Merge pull request ipfs/kubo#9234 from ipfs/release-v0.15.0
Jorropo Aug 30, 2022
64e68a5
Merge pull request ipfs/kubo#9236 from ipfs/release-merge-master
Jorropo Aug 30, 2022
b4f4ce8
chore: remove Gateway.PathPrefixes
lidel Apr 21, 2022
a434e7c
fix(gw): send 200 for empty files
Jorropo Aug 31, 2022
c1b76cd
chore: bump go-libp2p v0.22.0 & go1.18&go1.19
Jorropo Aug 29, 2022
ced2e3a
feat: ipfs-webui v2.18.0 (#9262)
SgtPooki Sep 12, 2022
93a90fa
feat: ipfs-webui v2.18.1
SgtPooki Sep 13, 2022
146e8d0
chore: bump go-libp2p v0.23.1
Jorropo Sep 20, 2022
e243beb
Merge pull request ipfs/kubo#9285 from Jorropo/chore/go-libp2p-v0.23.1
Jorropo Sep 21, 2022
59b3312
feat(gateway): _redirects file support (#8890)
Sep 23, 2022
134f098
Merge pull request ipfs/kubo#9306 from ipfs/release-v0.16.0
galargh Oct 4, 2022
7d12bb8
Merge pull request ipfs/kubo#9324 from ipfs/merge-release-v0.16.0
galargh Oct 5, 2022
637ed0f
ci: add stylecheck to golangci-lint (#9334)
guseggert Oct 6, 2022
84f396d
fix: add InlineDNSLink flag to PublicGateways config (#9328)
hacdias Oct 11, 2022
e010084
feat: [email protected]
SgtPooki Oct 3, 2022
772fab3
feat(gateway): TAR response format (#9029)
hacdias Nov 9, 2022
9abf081
feat: ipfs-webui 2.20.0
lidel Nov 9, 2022
95af22a
Merge pull request ipfs/kubo#9395 from ipfs/release-v0.17.0
galargh Nov 22, 2022
53e5c20
Merge pull request ipfs/kubo#9431 from ipfs/merge-release-v0.17.0
galargh Nov 25, 2022
79843b4
feat(gateway): JSON and CBOR response formats (IPIP-328) (#9335)
hacdias Dec 5, 2022
1be1cac
fix: support /quic-v1 in webui v0.21
lidel Dec 9, 2022
0293d8c
feat: fast directory listings with DAG Size column (#9481)
hacdias Dec 12, 2022
b5822ac
fix(gateway): JSON when Accept is a list
lidel Jan 11, 2023
1c03980
chore: migrate from go-ipfs-files to go-libipfs/files (#9535)
hacdias Jan 13, 2023
1d99d71
fix(gateway): undesired conversions to dag-json and friends (#9566)
hacdias Jan 21, 2023
1e4d1b0
fix(gateway): JSON when Accept is a list
lidel Jan 11, 2023
b10c4d9
chore: migrate from go-ipfs-files to go-libipfs/files (#9535)
hacdias Jan 13, 2023
4b0b73c
fix(gateway): undesired conversions to dag-json and friends (#9566)
hacdias Jan 21, 2023
3d2bf0d
Merge pull request ipfs/kubo#9498 from ipfs/release-v0.18
galargh Jan 23, 2023
4d487e7
Merge branch 'master' into merge-kubo-v0.18
galargh Jan 24, 2023
4be0abd
Merge pull request ipfs/kubo#9581 from ipfs/merge-kubo-v0.18
galargh Jan 25, 2023
64b4f66
chore: bump go-libipfs to replace go-block-format
Jorropo Jan 26, 2023
9a451ff
fix(ipns): honour --ttl flag in 'ipfs name publish' (#9471)
hacdias Jan 27, 2023
41f6bbf
feat(gateway): IPNS record response format (IPIP-351) (#9399)
hacdias Jan 27, 2023
35c75a7
refactor: prepare gateway for extraction
hacdias Jan 25, 2023
8e32707
Merge commits from ipfs/kubo/prepare-gateway-extraction
hacdias Jan 27, 2023
29da615
refactor: move gateway to go-libipfs
hacdias Jan 27, 2023
bad0cf0
Merge branch 'main' into migrate-gateway
hacdias Jan 30, 2023
eaea27b
chore: run Kubo gateway sharness if gateway/ is changed
hacdias Jan 30, 2023
4436ebf
docs(gateway): link to specs
lidel Jan 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Code owners are automatically requested for review when someone opens a pull
# request that modifies code that they own. Code owners are not automatically
# requested to review draft pull requests.

# HTTP Gateway
gateway/ @lidel @hacdias
48 changes: 48 additions & 0 deletions .github/workflows/gateway-sharness.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Gateway Sharness

on:
workflow_dispatch:
pull_request:
paths: ['gateway/**']
push:
branches: ['main']
paths: ['gateway/**']

jobs:
sharness:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.1
- name: Checkout go-libipfs
uses: actions/checkout@v3
with:
path: go-libipfs
- name: Checkout Kubo
uses: actions/checkout@v3
with:
repository: ipfs/kubo
path: kubo
- name: Install Missing Tools
run: sudo apt install -y socat net-tools fish libxml2-utils
- name: Restore Go Cache
hacdias marked this conversation as resolved.
Show resolved Hide resolved
uses: protocol/cache-go-action@v1
with:
name: ${{ github.job }}
- name: Replace go-libipfs in Kubo go.mod
run: |
go mod edit -replace=github.com/ipfs/go-libipfs=../go-libipfs
go mod tidy
cat go.mod
Comment on lines +37 to +41
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 this will probably break when we work on #61 but after we stabilize GO API, it will be ok

working-directory: kubo
- name: Install sharness dependencies
run: make test_sharness_deps
working-directory: kubo
- name: Run Sharness Tests
run: find . -maxdepth 1 -name "*gateway*.sh" -print0 | xargs -0 -I {} bash -c "echo {}; {}"
working-directory: kubo/test/sharness
35 changes: 35 additions & 0 deletions gateway/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# IPFS Gateway

> IPFS Gateway HTTP handler.
lidel marked this conversation as resolved.
Show resolved Hide resolved

## Documentation

* Go Documentation: https://pkg.go.dev/github.com/ipfs/go-libipfs/gateway

lidel marked this conversation as resolved.
Show resolved Hide resolved
## Example

```go
// Initialize your headers and apply the default headers.
headers := map[string][]string{}
gateway.AddAccessControlHeaders(headers)

conf := gateway.Config{
Writable: false,
Headers: headers,
}

// Initialize a NodeAPI interface for both an online and offline versions.
// The offline version should not make any network request for missing content.
ipfs := ...
offlineIPFS := ...

// Create http mux and setup gateway handler.
lidel marked this conversation as resolved.
Show resolved Hide resolved
mux := http.NewServeMux()
gwHandler := gateway.NewHandler(conf, ipfs, offlineIPFS)
mux.Handle("/ipfs/", gwHandler)
mux.Handle("/ipns/", gwHandler)

// Start the server on :8080 and voilá! You have an IPFS gateway running
lidel marked this conversation as resolved.
Show resolved Hide resolved
// in http://localhost:8080.
_ = http.ListenAndServe(":8080", mux)
```
27 changes: 27 additions & 0 deletions gateway/assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Required Assets for the Gateway

> DAG and Directory HTML for HTTP gateway

## Updating

When making updates to the templates, please note the following:

1. Make your changes to the (human-friendly) source documents in the `src` directory.
2. Before testing or releasing, go to `assets/` and run `go generate .`.

## Testing

1. Make sure you have [Go](https://golang.org/dl/) installed
2. Start the test server, which lives in its own directory:

```bash
> cd test
> go run .
```

This will listen on [`localhost:3000`](http://localhost:3000/) and reload the template every time you refresh the page. Here you have two pages:

- [`localhost:3000/dag`](http://localhost:3000/dag) for the DAG template preview; and
- [`localhost:3000/directory`](http://localhost:3000/directory) for the Directory template preview.

If you get a "no such file or directory" error upon trying `go run .`, make sure you ran `go generate .` to generate the minified artifact that the test is looking for.
203 changes: 203 additions & 0 deletions gateway/assets/assets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
//go:generate ./build.sh
package assets

import (
"embed"
"io"
"io/fs"
"net"
"strconv"

"html/template"
"net/url"
"path"
"strings"

"github.com/cespare/xxhash"

ipfspath "github.com/ipfs/go-path"
)

//go:embed dag-index.html directory-index.html knownIcons.txt
var asset embed.FS

// AssetHash a non-cryptographic hash of all embedded assets
var AssetHash string

var (
DirectoryTemplate *template.Template
DagTemplate *template.Template
)

func init() {
initAssetsHash()
initTemplates()
}

func initAssetsHash() {
sum := xxhash.New()
err := fs.WalkDir(asset, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}

if d.IsDir() {
return nil
}

file, err := asset.Open(path)
if err != nil {
return err
}
defer file.Close()
_, err = io.Copy(sum, file)
return err
})
if err != nil {
panic("error creating asset sum: " + err.Error())
}

AssetHash = strconv.FormatUint(sum.Sum64(), 32)
}

func initTemplates() {
knownIconsBytes, err := asset.ReadFile("knownIcons.txt")
if err != nil {
panic(err)
}
knownIcons := make(map[string]struct{})
for _, ext := range strings.Split(strings.TrimSuffix(string(knownIconsBytes), "\n"), "\n") {
knownIcons[ext] = struct{}{}
}

// helper to guess the type/icon for it by the extension name
iconFromExt := func(name string) string {
ext := path.Ext(name)
_, ok := knownIcons[ext]
if !ok {
// default blank icon
return "ipfs-_blank"
}
return "ipfs-" + ext[1:] // slice of the first dot
}

// custom template-escaping function to escape a full path, including '#' and '?'
urlEscape := func(rawUrl string) string {
pathURL := url.URL{Path: rawUrl}
return pathURL.String()
}

// Directory listing template
dirIndexBytes, err := asset.ReadFile("directory-index.html")
if err != nil {
panic(err)
}

DirectoryTemplate = template.Must(template.New("dir").Funcs(template.FuncMap{
"iconFromExt": iconFromExt,
"urlEscape": urlEscape,
}).Parse(string(dirIndexBytes)))

// DAG Index template
dagIndexBytes, err := asset.ReadFile("dag-index.html")
if err != nil {
panic(err)
}

DagTemplate = template.Must(template.New("dir").Parse(string(dagIndexBytes)))
}

type DagTemplateData struct {
Path string
CID string
CodecName string
CodecHex string
}

type DirectoryTemplateData struct {
GatewayURL string
DNSLink bool
Listing []DirectoryItem
Size string
Path string
Breadcrumbs []Breadcrumb
BackLink string
Hash string
}

type DirectoryItem struct {
Size string
Name string
Path string
Hash string
ShortHash string
}

type Breadcrumb struct {
Name string
Path string
}

func Breadcrumbs(urlPath string, dnslinkOrigin bool) []Breadcrumb {
var ret []Breadcrumb

p, err := ipfspath.ParsePath(urlPath)
if err != nil {
// No assets.Breadcrumbs, fallback to bare Path in template
return ret
}
segs := p.Segments()
contentRoot := segs[1]
for i, seg := range segs {
if i == 0 {
ret = append(ret, Breadcrumb{Name: seg})
} else {
ret = append(ret, Breadcrumb{
Name: seg,
Path: "/" + strings.Join(segs[0:i+1], "/"),
})
}
}

// Drop the /ipns/<fqdn> prefix from assets.Breadcrumb Paths when directory
// listing on a DNSLink website (loaded due to Host header in HTTP
// request). Necessary because the hostname most likely won't have a
// public gateway mounted.
if dnslinkOrigin {
prefix := "/ipns/" + contentRoot
for i, crumb := range ret {
if strings.HasPrefix(crumb.Path, prefix) {
ret[i].Path = strings.Replace(crumb.Path, prefix, "", 1)
}
}
// Make contentRoot assets.Breadcrumb link to the website root
ret[1].Path = "/"
}

return ret
}

func ShortHash(hash string) string {
if len(hash) <= 8 {
return hash
}
return (hash[0:4] + "\u2026" + hash[len(hash)-4:])
}

// helper to detect DNSLink website context
// (when hostname from gwURL is matching /ipns/<fqdn> in path)
func HasDNSLinkOrigin(gwURL string, path string) bool {
if gwURL != "" {
fqdn := stripPort(strings.TrimPrefix(gwURL, "//"))
return strings.HasPrefix(path, "/ipns/"+fqdn)
}
return false
}

func stripPort(hostname string) string {
host, _, err := net.SplitHostPort(hostname)
if err == nil {
return host
}
return hostname
}
14 changes: 14 additions & 0 deletions gateway/assets/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

set -euo pipefail

function build() {
rm -f $1
sed '/<link rel=\"stylesheet\"/d' ./src/$1 > ./base-html.html
(echo "<style>" && cat ./src/icons.css ./src/style.css | tr -d "\t\n\r" && echo && echo "</style>") > ./minified-wrapped-style.html
sed '/<\/title>/ r ./minified-wrapped-style.html' ./base-html.html > ./$1
rm ./base-html.html && rm ./minified-wrapped-style.html
}

build "directory-index.html"
build "dag-index.html"
67 changes: 67 additions & 0 deletions gateway/assets/dag-index.html

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions gateway/assets/directory-index.html

Large diffs are not rendered by default.

Loading