-
Notifications
You must be signed in to change notification settings - Fork 30
Recognize IPFS gateways on arbitrary websites #92
Comments
We already have a handy DNS query API (provided by go-ipfs) which returns
{"Path":"/ipfs/QmSrk8wCZ9oUgSCxJq4TXyJnPBYfoLDpKLGn7hLPNzauVX"} and for site without
{"Message":"could not resolve name.","Code":0} Quick idea/brain dump: Perhaps if
It would be (kinda) reverse of |
Point of my request is to provide some tag that could have very long TTL and could be cached. TTL of dnslink is limited as you need update it if you want to change the site (is use 60s TTL on most my dnslinks). Latency of DNS resolution can be anything from 100ms to +1s. As decision if site is to be shown normally or redirected to IPFS should be taken quickly it would be best if we could achieve high cache hit rate for this operation. Also it would allow sites that host gateways for themselves (or use ipfs.io under the hood) to say that it is safe to redirect it to other gateway. |
Ok, how about a separate
Related idea: this new TXT record could additionally provide a hint if this is a Use case for DNS hint would simply indicate that although some resources can be loaded from IPFS, it should not be used as a public gateway. |
I like the idea of Also do we want, and how, to cover sites like http://ipfs.pics that are gateways but the root site has to be accessed directly? (It might also happen that they won't work if we redirect gateway traffic to local gateway as for CORS and other magic). EDIT: If site defines EDIT2: Sites that want to stay under their own domain should just not define EDIT3: There are really three cases:
|
i don't understand this-- what does this mean?
Why isn't this figured out from the
Why should this be in DNS and not under a route in the gateway, such as
All
Natural consequence of the above.
No if the site has an ipfs gateway and uses ipfs links |
This DNS record would say if site wants to move under local/client gateway and how. There are many reasons for including something like this, I will try sum it up here:
|
Do you mean domains like for normal sites, i'd just assume http until the A record points to known ipfs gateways. but i get that it may not work as well. this could be something you opt to do for the extension only but is not meant to stick around or be broader. I'm very wary of explosion of asking users to setup a bunch of records.
Could the use of the backing gateway be detected without pre-checking dns yourslef? (i.e. use the result of the A or CNAME records the browser gets on its own)
right
right (but keep the scope in mind when creating tools + standard practices)
which site wants to call to which home. If a site at a
I don't think it does. There's a misunderstanding here:
True. this is one reson in support of gateway having friendly CORS (ipfs.io has it).
I'm not convinced yet. So far, I think this can be figured out from the otherwise available information. I do not want to make lots of tools have to follow this until i'm sure it's necessary. |
I mean that site
The XHR problem is with site staying under its own domain but under the ipfs.io A records when add-on redirects
Problem is also that you can't redirect all |
Port still would be a problem (you can't bind 80 from normal user) but redirecting Problem is with discovering all of those sites that might be using |
Generally Firefox is in the process of “refactoring” addon ecosystem. The only “future-proof” SDK does not provide high level API for accessing this part of GUI (we can only add a toolbar button etc). It is possible to access all GUI elements via low level APIs called XUL/XPCOM but it will be deprecated in 12-18 months and I would avoid any new work that requires it. In future there will be a new SDK called WebExtensions and I plan to migrate the addon to it as soon as it is mature enough (not supported by release FF yet). It is a mess at the moment :) Anyway, back to the topic ⏫ To put the problem and idea in simpler words:
|
I agree with jbenet that we can infer this info from what's already there. Not from the dnslink record (which is a totally different use case, imo), but from the URL of these assets. You mention github.com/ipfs/foobar and /ipfs/Qm as an example of how this is problematic, but maybe we can make /ipfs and /ipns path validation part of js-multiaddr, and use that in the addon? For /ipfs it must be a multihash, for /ipns it must be a multihash or domain name (see jbenet/go-is-domain). Whether the /ipfs or /ipns path can be resolved is a whole other issue of course, and you can only ever reliably say if it does resolve. |
cc @diasdavid |
Multiaddr validation can apply to other schemes just as well, e.g. /ip4/1000.0.0.0 is clearly invalid. |
Just had another idea, could the addon expose a simple API to pages, so that a page can just tell the addon to regard it as an ipfs gateway? |
Using JavaScript Now to the next question: is it always safe to load a remote IPFS resource from a local IPFS gate? In an ideal world it should always be safe (that's what a P2P-distributed filesystem should be, that's what a P2P-distributed filesystem should do). However, in the real world some sites are facing XHR failures (because of CORS) such as ipfs/ipfs-companion#45 and ipfs/kubo#934 and ipfs/kubo#1215. Of course these sites' owners would wish for their sites to be not recognized as gateways (even when the URL parts clearly indicate the use of IPFS) to prevent such failures, and thus they would advocate their desire for some additional (and opt-in) feature (such as DNS TXT or other API). I am quite tempted to say that these CORS-related problems deserve to be fixed eventually (not only worked around) and thus the proposed workaround should be designed as a temporary opt-out (not a permanent opt-in) so that most IPFS sites do not require additional configuration initially (until they eventually try XHR and cease to work and only then they need DNS TXT or other API to prevent rerouting to local IPFS gates). Here I write “most sites” because I honestly expect most IPFS sites to be more static (i.e. not trying to use XHR) and thus never encountering any need to opt out. I have to add that most cases of such opt-out (currently and in the future) would be caused by very specific bugs (or lack of features) in IPFS implementations. Therefore DNS TXT (or other API) should be designed to convey some more specific message: not only “this site opts out of local IPFS rerouting”, but also “this site opts out of local IPFS rerouting unless the local IPFS gate is XHR failure is such a bug, gateway CORS is such a feature. Here's another good example: I expect IPFS POST to become such a feature as well. The sites that start using IPFS POST (when it's implemented) would want an interface to opt out of the previous IPFS implementations. If that interface is designed differently, it may harm the network:
|
We could, but it is too late: javascript-based API could be accessed only after first page load. That is why we suggested DNS record: it can be read before any HTTP request is sent.
I really like this idea! 👍
This is a very good point. Opt-out would effectively be a blacklisting of specific daemon/protocol versions
|
This would replace my currently very crappy solution to detect if the app is running on a gateway. Take it as an example of what not to do 😄 |
Cross-posting from ipfs/in-web-browsers#9 (comment):
|
Alas, that proposal has been WONTFIXed. |
An update from browser extension front (ipfs/ipfs-companion#16 (comment)):
There is also somehow related discussion about keeping |
Small updates from browser extension (landed in v2.4.3):
|
Currently looking for dnslink is a way to check if site is hosted on IPFS via gateway.
I propose that we use other TXT entry specifying that this domain should be served under IPFS/NS.
It could be
TXT IPFS-Gateway=true
. Simpler nature of this entry means that it can have much longer TTL and can be cached for much longer time.As workaround of lack of TXT record support in browsers we would need API endpoint for checking it.
Also it would be great if we could have agree on some sane default TTL in case of
dnslink
and this entry are missing thus increasing cache hits even more.EDIT: Also as
dnslink
gets support for_dnslink.
prefix something similar might be done in case of this also.The text was updated successfully, but these errors were encountered: