Skip to content

Omodaka9375/peerweb

Repository files navigation

πŸͺ PeerWeb πŸͺ

🌏 Decentralized website hosting powered by WebTorrent 🌏

PeerWeb enables truly decentralized, censorship-resistant website hosting through peer-to-peer networks. Upload your static websites and share them globally without relying on centralized servers or paying hosting fees.

image

Link demos

✨ Features

πŸš€ Core Features

  • Drag & Drop Upload - Simply drag your website folder
  • Instant Sharing - Get a shareable PeerWeb link immediately
  • Zero Hosting Costs - No servers, no monthly fees, completely free
  • Censorship Resistant - Distributed across peer-to-peer networks
  • Always Available - Works as long as there are online peers

πŸ’Ύ Smart Technology

  • Intelligent Caching - Lightning-fast loading with IndexedDB storage
  • Service Worker Magic - Seamless resource loading and offline support
  • Progress Tracking - Real-time download progress and peer statistics
  • Auto Cleanup - Expired cache automatically cleaned after 7 days

πŸ›‘οΈ Security & Safety

  • XSS Protection - All HTML sanitized with DOMPurify
  • Hash Sanitization - Torrent hashes sanitized to prevent XSS attacks
  • Sandboxed Execution - Sites run in isolated iframe environments
  • Content Validation - All resources validated before display
  • External Link Preservation - Social media and external links work normally
  • Memory Leak Prevention - Automatic cleanup of timeouts and object URLs

🎯 User Experience

  • Toast Notifications - Non-blocking, user-friendly notifications
  • Quick Upload Interface - Prominent drag-and-drop area
  • Advanced Torrent Creator - Full-featured torrent creation tools
  • Debug Mode - Detailed logging for developers and troubleshooting
  • PWA Support - Install as a Progressive Web App on any device
  • Mobile Friendly - Responsive design works on all devices

πŸš€ Quick Start

1. Host a Website

  1. Open PeerWeb.lol in your browser
  2. Drag your website folder to the upload area
  3. Get your unique PeerWeb URL, and keep the tab open
  4. Share the link with anyone, anywhere!

2. Load a Website

  1. Enter a torrent hash in the load field
  2. Or use a PeerWeb URL: https://peerweb.lol?orc=HASH
  3. Website loads directly from the peer network

3. Debug & Develop

Add &debug=true to any PeerWeb URL for detailed logging:

https://peerweb.lol?orc=ABC123...&debug=true

πŸ“‹ Website Requirements

Your websites should be:

  • βœ… Static content only (HTML, CSS, JS, images, fonts, etc.)
  • βœ… Include index.html (in root)
  • βœ… Use relative paths for all internal resources
  • βœ… Responsive design recommended for best experience

πŸ—οΈ Project Structure

peerweb/
β”œβ”€β”€ index.html          # Main application interface
β”œβ”€β”€ peerweb.js          # Core PeerWeb functionality
β”œβ”€β”€ peerweb.min.js      # Minified version
β”œβ”€β”€ peerweb-sw.js       # Service Worker for resource handling
β”œβ”€β”€ manifest.json       # PWA manifest for installable web app
└── README.md           # This file

🌐 How It Works

The Magic Behind PeerWeb

  1. Upload Process

    • Your website files are packaged into a BitTorrent torrent
    • A unique hash identifies your site across the network
    • Files are seeded from your browser to the peer network
  2. Loading Process

    • Service Worker intercepts resource requests
    • Files are downloaded via WebTorrent from multiple peers
    • Content is cached locally for instant future access
  3. Security Layer

    • All HTML content sanitized with DOMPurify
    • Torrent hashes sanitized to prevent XSS
    • Sites run in sandboxed iframe
    • External links preserved and functional
    • Automatic memory cleanup on page unload

πŸš€ Advanced Usage

Debug Mode

Enable detailed logging by adding &debug=true to any URL:

// Example debug output
[PeerWeb:DEBUG] Loading site with hash: abc123...
[PeerWeb:INFO] Found 15 files in torrent
[PeerWeb:DEBUG] Processing site early (95% complete)
[PeerWeb SW] Serving file: styles.css (2.4KB)

Production vs Development

PeerWeb automatically detects the environment:

  • Production (peerweb.lol): Only shows warnings and errors
  • Development (localhost): Shows all debug information

Progressive Web App

Install PeerWeb on any device:

  1. Visit PeerWeb.lol
  2. Look for "Install" or "Add to Home Screen" in your browser
  3. Use PeerWeb like a native application

Features when installed:

  • Standalone app window
  • App icon on home screen/desktop
  • Faster loading with caching
  • Offline access to cached sites

🀝 Contributing

We welcome contributions! Here's how you can help:

πŸ› Report Bugs

  • Use the Issues tab
  • Include browser version, steps to reproduce, and error messages
  • Enable debug mode for detailed logs

πŸ’‘ Suggest Features

  • Open a Feature Request
  • Describe the use case and expected behavior
  • Check existing issues to avoid duplicates

πŸ”§ Submit Code

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and test thoroughly
  4. Submit a Pull Request with detailed description

πŸ“ Improve Documentation

  • Fix typos or unclear instructions
  • Add examples and use cases
  • Translate to other languages

πŸ“– Documentation

Browser Support

  • βœ… Chrome/Chromium 60+ (Recommended)
  • βœ… Firefox 55+
  • βœ… Safari 11+
  • βœ… Edge 79+
  • ❌ Internet Explorer (Not supported)

WebTorrent Compatibility

  • Uses WebTorrent for browser-based torrenting
  • Compatible with standard BitTorrent protocol
  • Supports DHT, PEX, and WebRTC connections

Limitations

  • Static sites only - No server-side processing
  • Browser hosting - Sites available while browser tab is open
  • Peer dependency - Requires active peers for availability
  • Large files - May be slow for sites with many large assets

πŸ”’ Security

Content Sanitization

Multi-layer XSS protection:

  • HTML Sanitization - All HTML content sanitized with DOMPurify
  • Hash Sanitization - Torrent hashes stripped of non-hex characters
  • Script Injection Prevention - Malicious scripts blocked
  • Dangerous Elements - Unsafe HTML elements and attributes removed

Sandboxed Execution

Websites run in sandboxed iframes with restrictions:

<iframe sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-modals"></iframe>

External Resource Handling

  • External links (social media, email, etc.) work normally
  • CDN resources and external stylesheets load properly
  • Only internal site resources are processed through PeerWeb

🌟 Use Cases

πŸ“ Personal Websites

  • Portfolio sites
  • Blogs and documentation
  • Landing pages
  • Resume/CV sites

🎨 Creative Projects

  • Art galleries
  • Photography portfolios
  • Interactive demos
  • Games and experiments

πŸ“š Educational Content

  • Course materials
  • Tutorials and guides
  • Research publications
  • Student projects

🌍 Censorship Resistance

  • News and journalism
  • Political content
  • Whistleblowing platforms
  • Freedom of speech tools

πŸ† Desktop Clients

For permanent hosting without keeping browser tabs open:

  • πŸͺŸ Windows - PeerWeb Desktop (Coming Soon)
  • 🍎 macOS - PeerWeb Desktop (Coming Soon)
  • 🐧 Linux - PeerWeb Desktop (Coming Soon)

πŸ“Š Technical Specifications

Supported File Types

  • Documents: HTML, CSS, JavaScript, JSON, XML
  • Images: PNG, JPEG, GIF, SVG, WebP, ICO
  • Fonts: WOFF, WOFF2, TTF, OTF, EOT
  • Media: MP4, WebM, MP3, WAV
  • Other: PDF and various binary formats

Performance

  • Caching: IndexedDB with 7-day expiration
  • Loading: Progressive loading with 95% threshold
  • Piece Size: Optimized based on total site size
  • Timeout: 5-second request timeout with fallbacks
  • Memory Management: Automatic cleanup of timeouts and object URLs
  • Resource Tracking: All setTimeout calls tracked and cleaned up

Network

  • Trackers: 7+ built-in BitTorrent trackers
  • Protocols: WebRTC, WebSocket, HTTP fallback
  • DHT: Distributed Hash Table support
  • PEX: Peer Exchange for discovery

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • WebTorrent - Browser-based BitTorrent implementation
  • DOMPurify - XSS sanitizer for HTML
  • BitTorrent Protocol - Peer-to-peer file sharing foundation
  • Service Workers - Enabling offline-first web applications

πŸ“ž Support

Getting Help

  • πŸ“– Documentation: Check this README and inline code comments
  • πŸ› Bug Reports: Use GitHub Issues with debug logs
  • πŸ’¬ Community: Join discussions in GitHub Discussions
  • πŸ“§ Contact: Create an issue for direct support

Frequently Asked Questions

Q: How long do sites stay available? A: Sites remain available as long as at least one peer is seeding them.

Q: Can I update my website? A: Create a new torrent for updates. The hash will change with new content.

Q: Is there a file size limit? A: No hard limits, but larger sites may load slower due to peer availability.

Q: Can I use custom domains? A: Yes! Deploy PeerWeb to your domain and use ?orc=HASH parameters.

Q: Does it work offline? A: Cached sites work offline. New sites require internet for initial download.


🌟 Star this project if you find it useful! 🌟

Made with ❀️ for the decentralized web