GithubHelp home page GithubHelp logo

delokman / ipfs-cdn-mapper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from d10r/ipfs-cdn-mapper

0.0 1.0 0.0 7 KB

Tool for mirroring CDNs to IPFS using IPNS to replicate directory layouts

Shell 100.00%

ipfs-cdn-mapper's Introduction

ipfs-cdn-mapper

This is a collection of simple shell scripts which make it easy to mirror conventional CDNs on ipfs.
It can import a given list of files to an IPFS node and replicate the directory stucture of the source CDN using IPNS.

Since this was intended for experimentation, only a single source CDN is supported out of the box: googleapis.
But it should be pretty easy to replicate the workflow for arbitrary CDNs.

Example deployment: https://ipfs.io/ipns/QmfJ4cFrE5NHwqqsAtwWW3uP2n1emVJQf6H6g71f7ZHs8T (update: this was shut down because of persisting high bandwidth usage of ~20Gb/day. I can't afford to offer actual CDN services for free. May become viabe once Filecoin is ready.)

How to use

  • browse to https://developers.google.com/speed/libraries and choose a lib
  • copy the list of versions to a text file, e.g. to versions/js_jquery.txt
  • remove the commas, e.g. ./remove_commas.sh versions/js_jquery.txt
  • run the download script, e.g. ./download.sh js_jquery.txt jquery root/js/jquery/ jquery googleapis (see ./download.sh --help)
  • run ./push_to_ipfs.sh. This adds the directory root recursively and updates ipns.

Note that currently ipfs supports only one ipns mapping per node. If you're not yet using ipns on your node, that's not a problem. Otherwise your exising mapping would be replaced.

Replication

A real CDN requires replication throughout many machines in different locations.
This code's purpose is to easily create an organized directory structure and map the root to ipns in order to allow static URLs while keeping the possibility to add files to the directory tree. It doesn't deal with replication.
However, because of content addressing of ipfs, replication may be achieved even without people consciously contributing to this CDN. Whenever somebody adds the same file as contained in the root directory to their node, that node automatically becomes a mirror for that file. That's true even if the file is added with a different filename, it just needs to have the exact same content. That's the beauty of content addressing.

In order to check the replication status of a specific file, run the script check_file_replication.sh. For example:

./check_file_replication.sh root/js/jquery/jquery-2.2.1.min.js 
file hash is QmXxcr6T2mX9SLeTmLxS5qivVPkbeVfnV6rULrXcV7DXE9 - looking for nodes having it...

QmfJ4cFrE5NHwqqsAtwWW3uP2n1emVJQf6H6g71f7ZHs8T
QmPMrzG3XdTGarMzQ6ozJXTjbgyQB2ZNUaH8QytMsfykX9
QmP6TAKVDCziLmx9NV8QGekwtf7ZMuJnmbeHMjcfoZbRMd
QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3
QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
QmfHWdVuMdCAywXhGqQ5YWqoK5hn2SeGW8zM9Dx4HhnLhW
QmfPZcnVAEjXABiA7StETRUKkS8FzNt968Z8HynbJR7oci

Found on 7 nodes

You can also use an ipns/ipfs paths instead of local files as argument, e.g.

./check_file_replication.sh /ipns/QmfJ4cFrE5NHwqqsAtwWW3uP2n1emVJQf6H6g71f7ZHs8T/js/jquery/jquery-2.2.1.min.js
...

ipfs-cdn-mapper's People

Contributors

d10r avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.