Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ExpressJS middleware #4

Open
extensionsapp opened this issue Oct 21, 2016 · 11 comments
Open

Create ExpressJS middleware #4

extensionsapp opened this issue Oct 21, 2016 · 11 comments

Comments

@extensionsapp
Copy link

Hello.

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

@guerrerocarlos
Copy link
Owner

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
Copy link
Author

https://github.com/PixelsCommander/ViralJS

I think ViralJS has similar functionality.

@goatandsheep
Copy link

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

@extensionsapp
Copy link
Author

@goatandsheep this is fine, make ExpressJS middleware CacheP2P.

var CacheP2P = require('cachep2p');
var CacheP2PContainer = new CacheP2P();
myExpressApp.use(CacheP2PContainer.middleware);

@goatandsheep
Copy link

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

@extensionsapp
Copy link
Author

extensionsapp commented Oct 21, 2016

@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
Copy link

@extensionsapp perhaps a webpack plugin

@extensionsapp
Copy link
Author

@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
Copy link

@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
Copy link
Owner

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
Copy link

tjingrant commented Sep 9, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants