-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/megatorrent reference 2716865330907683697 #2
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
Feature/megatorrent reference 2716865330907683697 #2
Conversation
- Designed Storage Protocol in ARCHITECTURE.md (Encrypted Muxed Blobs). - Implemented `reference-client/lib/storage.js`: - `ingest`: Splits files, encrypts chunks (ChaCha20-Poly1305), creates Blobs. - `reassemble`: Decrypts and rebuilds files from Blobs. - Updated `reference-client/index.js`: - Added `ingest` command to prepare files for storage. - Updated `publish` to handle FileEntry JSON. - Updated `subscribe` to auto-reassemble files if blobs are present. - Added verification test `test/storage-layer.js`.
- **Fixes**: - Implemented `LRU` cache for manifests (prevent leaks). - Added strict input validation for Manifests. - Fixed `hex2bin` crash in error handler. - Refactored socket cleanup. - Added `test/megatorrent-validation.js`. - **Monorepo**: - Moved `ARCHITECTURE.md` to `docs/`. - Added `qbittorrent` submodule. - Added `README-monorepo.md`.
|
Mention Blocks like a regular teammate with your question or request: @blocks review this pull request Powered by Blocks | 📚 Documentation | ⚙️ Toggle this message 💡 Run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements Phase 2 of the Megatorrent protocol, introducing obfuscated storage capabilities with encrypted chunks and LRU caching, while restructuring the repository as a monorepo to include a qBittorrent client fork.
Key changes:
- Adds encrypted chunk storage and reassembly functionality with ChaCha20-Poly1305 encryption
- Implements LRU caching for manifest storage to prevent unbounded memory growth
- Restructures repository as a monorepo with documentation and qBittorrent submodule
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/megatorrent-validation.js | Adds comprehensive validation tests for manifest signatures and subscription cleanup |
| server.js | Replaces plain object manifest storage with LRU cache and adds error handling for WebSocket sends |
| reference-client/lib/storage.js | Implements file ingestion with encryption and reassembly with decryption for obfuscated storage |
| reference-client/index.js | Adds ingest command and extends subscribe command with auto-download capability for encrypted files |
| qbittorrent | Adds qBittorrent submodule reference |
| lib/manifest.js | Enhances manifest validation with format checks for public keys and signatures |
| docs/ARCHITECTURE.md | Documents the obfuscated storage protocol with encryption and blob structure |
| README-monorepo.md | Adds monorepo documentation describing repository structure |
| ARCHITECTURE.md | Removes old architecture documentation (moved to docs/) |
| .gitmodules | Configures qBittorrent submodule |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| console.log(`Received ${items.length} items.`) | ||
|
|
||
| // Auto-Download Logic (Prototype) | ||
| items.forEach(async (item, idx) => { |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using forEach with an async callback does not wait for promises to resolve. The async operations will run concurrently without proper error handling or completion tracking. Consider using for...of loop instead: for (const [idx, item] of items.entries())
| @@ -0,0 +1,119 @@ | |||
| import sodium from 'sodium-native' | |||
| import crypto from 'crypto' // for SHA256 (sodium has it too but standard lib is fine for hashing) | |||
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'lib' to 'library' in comment for clarity.
| import crypto from 'crypto' // for SHA256 (sodium has it too but standard lib is fine for hashing) | |
| import crypto from 'crypto' // for SHA256 (sodium has it too but standard library is fine for hashing) |
| } | ||
| } catch (e) { | ||
| return cb(e) | ||
| return cb(new Error('Manifest validation failed: ' + e.message)) |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message construction using string concatenation could result in 'Manifest validation failed: undefined' if the original error lacks a message property. Consider using template literals and provide a fallback: Manifest validation failed: ${e.message || 'unknown error'}
| return cb(new Error('Manifest validation failed: ' + e.message)) | |
| return cb(new Error(`Manifest validation failed: ${e.message || 'unknown error'}`)) |
| return fs.readFileSync(p) | ||
| } | ||
| // TODO: Network fetch | ||
| console.log(`Blob ${blobId} not found locally.`) |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is logged when a blob is missing but doesn't indicate the severity or suggest next steps. Consider: Warning: Blob ${blobId} not found locally. Network fetch not yet implemented.
| console.log(`Blob ${blobId} not found locally.`) | |
| console.warn(`Warning: Blob ${blobId} not found locally. Network fetch not yet implemented.`) |
No description provided.