InterPlanetary File System (IPFS)
What is it?
Essentially IPFS is like a central git repo being served over Bit Torrent. I won't really attempt to explain it in great depth, the explanation on their github page can do that best, but I'll show how I am using it. Some nitty gritty config details, conceptual aspects, and terminology are outlined on my wiki.
What makes IPFS unique is how content is handled and how nodes peer with each other. With Bit Torrent you have a bunch of individual torrents, hashing is used to verify integrity and you can choose to seed a file as well. While Bit Torrent works well, it's really has only a singular application, IPFS is flexible in how it's used. You can retrieve data right in your browser, but most importantly the API can be implemented wherever you want. When you add a resource to the IPFS network, you create a unique hashed name for the file and add that to the network. Then anyone, anywhere can request that hash, your content is identified this way amongst all peers. Other nodes can choose to host some of your content, likewise you can host content from other nodes.
Each node on the network is uniquely identified by a public key and peer id, this allows me to publish content with the expectation that it is mutable, otherwise a single bit in the file changes and you can never find it again. This also means that content I publish can be directly attributed to me, as it's located under my public key. Now it can still be hosted by other nodes, the public key will simply resolve to the latest (hashed) name of the resource it's looking for
I'm mirroring bvd.io, benvandoren.com, and wiki.bvd.io and hosting them on the IPFS network. In order to access them from the IPFS network you need to go through an IPFS gateway. You can run your own personal gateway, or you can have a gateway for anyone to use. What the gateway does is request the content that you have requested, finds the closest node hosting the content, and serves it to you.
Since I point my own peer id to these files they can always be found even if the individual hashes change because my peer id will never change.
The format becomes something like this: ipns/Qmddo22M89tRZWBznXaSMPH4TMH2X57vzWSnuZSNf8csVc/
Note 2 things:
- I didn't specify a domain name, in this case the hostname will be what you intend to use as the gateway. You can use the gateway at ipfs.io or you can run your own client in which case the gateway will be localhost:8080.
- The hash is prefixed by "ipns" instead of "ipfs", this is because I am pointing towards my personal namespace. Like a domain name this must be resolved, first to a specific file/folder to retrieve and then next to a node which is hosting it.
My URLs then become:
- My personal namespace, this is like my ipfs root directory (although I can have other files stored elsewhere they won't be found under the namespace)
Now without anyone else hosting those files it's like a self hosted site, if my node goes offline those urls will fail to work. The guiding principal here would be "I'll host yours if you host mine" mentality and then redundancy happens. Even if a single node drops offline the files are still easily retrievable on the network. As you may have noticed this can really only facilitate static sites, else who controls the central database, although people are implementig some neat things and it will be interesting to see where this goes.