guerrerocarlos / CacheP2P

"More users = More capacity"
http://www.cachep2p.com/
MIT License
865 stars 52 forks source link

Create ExpressJS middleware #4

Open extensionsapp opened 8 years ago

extensionsapp commented 8 years ago

Hello.

How to use CacheP2P on ExpressJS 4? It's possible?

guerrerocarlos commented 8 years ago

Haven't thought about it, sounds interesting.

But the middleware would only need to add the javascript file at the end of the pages, is that what you mean?

extensionsapp commented 8 years ago

https://github.com/PixelsCommander/ViralJS

I think ViralJS has similar functionality.

goatandsheep commented 8 years ago

@extensionsapp yes, but ViralJS is susceptible to man-in-the-middle attacks. WebTorrent is encrypted and far more secure a technology than ViralJS

extensionsapp commented 8 years ago

@goatandsheep this is fine, make ExpressJS middleware CacheP2P.

var CacheP2P = require('cachep2p');
var CacheP2PContainer = new CacheP2P();
myExpressApp.use(CacheP2PContainer.middleware);
goatandsheep commented 8 years ago

@extensionsapp so the middleware would generate the security file based on the routes?

extensionsapp commented 8 years ago

@goatandsheep I have a two million pages on my site, need create it's list atomaticly.

document.security_sha1 = {
  'http://cachep2p.com/':                   '8a01e1d8c19294d6ad9a4af20cdab1798e4111b2',
  'http://cachep2p.com/documentation.html': 'c49db33e97c4f81d8fd7b705e707031a37fbdb1c',
  'http://cachep2p.com/contact.html':       '299e74db8950463efa30fb5f30bc17d2fcb5b801',
}
goatandsheep commented 8 years ago

@extensionsapp perhaps a webpack plugin

extensionsapp commented 8 years ago

@goatandsheep for the system to become popular, I think it would be good to work in "2 clicks".

  1. npm install cachep2p
  2. Add in code
var CacheP2P = require('cachep2p');
var CacheP2PContainer = new CacheP2P();
myExpressApp.use(CacheP2PContainer.middleware);

So it would be very good.

goatandsheep commented 8 years ago

@extensionsapp the only way you could to that is with a dynamic security.js file, such that the user's security file is only as big as the number of pages it has cached. When you send your response for each page, you'd send the magnet link. There's no way any user would want to store a 1 million line security file on their computer. and that would kinda defeat the purpose.

guerrerocarlos commented 8 years ago

We could modify CacheP2P to check the checksum of a specific from the server by opening something like for http://www.example.com/content1 check http://www.example.com/content1.checksum and from there, include only the checksum of the links in that page in the HTML it self, so from there on, it can rely on Caches and have the verifications to ensure all those caches are valid.

tjingrant commented 7 years ago

Any update for this matter? I have implemented something similar in Python and would be glad to work on a pull request for this feature.