Why is it so hard for web browsers to open IPFS links? - ipfs

Why is it so hard for web browsers to open IPFS links?
For instance, this is an IPFS blog page link, https://ipfs.io/ipfs/bafybeic3y6oc2dai3uypyyuaggp4xx3krocpgzbwst2z4ha73jdh7y6nea/index.html
, and the loading page is tremendously slow on Safari or Chrome/Edge, and it's stuck into Error 504 from time to time. Is there any way to browse IPFS pages smoothly? Or are IPFSs just internally incapable of smooth browsing without third-party helps?

You're loading the page through a gateway. So effectively, you're asking another (quite popular) IPFS node to fetch the info over IPFS, then serve it to you over HTTP. If the gateway is slowed down for any reason, all IPFS resources will seem slow to you. If a gateway is your only option for whatever reason, check out the IPFS Gateway Checker for a list of active ones.
Alternatively, you could run your own IPFS node via something like IPFS Desktop then connect it to IPFS Companion (Chrome | Firefox). IPFS Companion can be configured to redirect all IPFS gateway links to your own IPFS node, then you'll be limited by just how quickly your node can find/retrieve the data, which you'll likely find to be the superior IPFS experience.
The Brave browser also includes an integrated IPFS node. They have an article about it here.

Related

IPFS Companion - How to NOT load content from my node?

If files have been PINNED and I want to test them I need to turn off IPFS Companion
as otherwise files get served from my node. Wondering if I could set it somehow that by default I am not redirected to my node in browser?
I found it in IPFS companion config
"Redirect requests for IPFS resources to your local gateway."
simple, didn't realize it has also preferences, it is on cog wheel of popup in the upper right corner.

View/export localstorage locally in Chrome for a domain that has been 301 redirected?

A site I use has suddenly moved to a new domain. The old site 301 redirects to the new site. All my settings for the site have been lost, because they are stored in localstorage on the old domain.
Normally, if I need to view everything in localstorage, I go to the site and open developer tools, and there it is.
However, if I try that now, I can only see the new empty localstorage on the new origin, which does not help me at all.
How do I view the localstorage of a site that I cannot load?
I tried interrupting the redirect by:
Disabling redirects in Chrome settings for this domain (no effect)
Hitting ESC while it loads (failed after repeated attempts)
Writing a Tampermonkey script (never runs)
window.addEventListener("beforeunload", function() { debugger; }, false) (stops, but devtools localstorage never shows old domain, even if I step through)
At no point am I stopped on the previous domain, allowing me to view the associated localstorage.
But I can see that it still exists if I go to Chrome's settings | All cookies and site data, and filter for the domain. But, unlike cookies (whose contents are viewable from this settings page), the only things localstorage tells me here are the origin, the size on disk, and the last modified date. Not the contents. But this IS something stored on my computer somehow, and I should be able to access it, right?
How do I browse the contents of localstorage locally, on my local machine?
Is there a way to redirect dev tools to a specific domain?
Is there a way of "tricking" the browser into thinking I'm on a specific domain, so that I can then open dev tools and view the localstorage like normal?
Or is there an obvious way to browse localstorage that I'm just overlooking?
Expanding on wOxxOm's solution:
For context, I'm on Ubuntu 22.04 with Python3 and mkcert already installed.
Edit the hosts file
sudo gedit /etc/hosts
I add a new line at the bottom: 127.0.0.1 (the domain I'm trying to recover)
Now, I don't have anything running on port 80, so for a regular website I could have run:
sudo python3 -m http.server 80
(sudo because Ubuntu will complain that I don't have permissions to use that port otherwise)
But here's the twist: Nothing showed up in localstorage when I did that. Why? Because the original site wasn't on http, it was on https.
Move to a folder you can leave files in.
I moved to my development folder
Generate local certificate
mkcert (target domain)
mkcert -install
This makes a couple files in this folder, whateverdomain.pem and whateverdomain-key.pem.
Write a small python wrapper (from this StackOverflow)
import http.server, ssl
server_address = ('localhost', 443)
httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket(httpd.socket,
server_side=True,
certfile='whatever.pem',
keyfile='whatever-key.pem',
ssl_version=ssl.PROTOCOL_TLS)
httpd.serve_forever()
Server address is 443 for https, keyfile is included with certfile.
Run the new script
sudo python3 simpleserver.py
Sudo again, because of using a main port.
Open the target domain in the browser.
Open dev tools. Right-click on the page and choose "Inspect" or use the keyboard shortcut ctrl-shift-i
Go to the Application tab.
Success! My localstorage is finally viewable. From here I was able to copy out the values I needed.
We're done, so clean up:
Stop python script.
Finally, re-edit /etc/hosts and remove or comment out the redirect line.
Was there a simpler way I could have run https? Maybe. But this wasn't difficult to set up, and I did recover my inaccessible localstorage, and that's the important thing.

My IPFS node doesn't seem to be storing data, why is that? I wanna contribute to the network

My IPFS node has been running all day and it's storing 6MiB according to the web UI... how come?
I've set the Gateway address in the config as such:
"Gateway": "/ip6/2a01:e34:ecb8:d540:dacb:8aff:fee4:74a0/tcp/8081"
And I have started the daemon with ipfs daemon --writable, it says it's ready.
The UI says it has discovered about 900 nodes, so why is mine not participating more actively in the network?
other nodes can't store content into your node automatically. There is public ipfs gateway list somewhere, submit your node to it.
run DHT server
ipfs config Routing.Type dhtserver
more information here https://github.com/ipfs/go-ipfs/blob/master/docs/config.md

IPFS file upload and view

I uploaded a pdf file to the IPFS de-centralised network. My question here. When I have the IPFS console and I couldn't view the pdf file anymore through the https://ipfs.io/gateway. Why is that? My understanding is once the file is uploaded to the IPFS network and the file will be distributed to the nodes.
Adding a file to IPFS via ipfs add <file> does not distribute it to the network (that would be free hosting!), it only puts the file into the standard format (IPLD) and makes it possible to access over the network (IPFS) as long as someone connected to the network has the file. When you first add something, that's only you. So if you close your laptop, suddenly the file is no longer available. UNLESS someone else has downloaded it since then, because then they can distribute it while your computer is off. There are many "pinning services" which do just that, for a small fee.
Hi Your understanding is correct,But can you tell me how are you uploading files to ipfs network there are number of ways to add data to ipfs network,
if you are able to add data to ipfs you will get the hash of the data, condition is daemon is running locally so that your data can be broadcasted to other peers you are attached to, you can check it by command: ipfs swarm peers
if above conditions are fulfilled you view/get data from https://ipfs.io/ipfs/<replace with hash you will get after adding>
if daemon is not running you can able to add you file and get the hash but you files will be saved locally, you wont be able to access it from web.
please let me know if you need other information

How to create a hyperlink to shared network directory or file?

I've checked the following two related discussions:
1. How do I make a hyperlink to a local executable?
2. An URL to a Windows shared folder
3. File Url Cross Domain Issue in Chrome- Unexpected
4. Firefox Links to local or network pages do not work
The following links work when I visited the website on localhost. That is, http://localhost.
A Shared Network Directory
A Shared Network Directory
A Shared Network Directory
But when I visited with http://172.21.1.123, all of above links have no response.
The debug console shows that Not allowed to load local resource: file://172.21.1.123/DIR.
Test Environment (Both of them have the same result.):
- Chrome 28.0.1500
- IE 10
If it is due to the security reason, any configuration to turn off? Or any idea?
The reason that you cannot link to a network share from an external/hosted/live site is because of security features of latest browsers like Firefox.
You can only open local network shares from a local HTML document.
The only way around this is to install a plugin for your browser that removes or disables this security feature as far as I know.