feat: add I2P BitTorrent engine, DHT, and Firefox torrent extension
- Add pure-MoonBit bittorrent package: bencode codec, metainfo/magnet parsing with path traversal checks, peer wire protocol (BEP 10/9), and I2P Kademlia DHT with KRPC and 54-byte compact nodes - Add SHA-1 primitive in crypto for torrent info hashes - Add router torrent API and engine, enabled with --torrent-api (default 127.0.0.1:4445) and --download-dir - Add Firefox WebExtension torrent manager with native messaging host and packed .xpi - Add scripts to build a standalone Firefox + router AppImage and install the native host - Add just targets (proxy, appimage, extension), README docs, and ignore .cache/ and dist/
This commit is contained in:
1 parent
14eae00f5c
commit
fbe6818c4e
37 files changed
+8543
-9
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Install Firefox Native Messaging manifest and build unsigned .xpi bundle."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import stat
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
HOST_SCRIPT = REPO_ROOT / "scripts" / "moon_i2p_native_host.py"
|
||||
EXT_DIR = REPO_ROOT / "extensions" / "firefox-i2p-torrent"
|
||||
XPI_PATH = REPO_ROOT / "extensions" / "firefox-i2p-torrent.xpi"
|
||||
|
||||
MANIFEST_DIRS = [
|
||||
Path.home() / ".mozilla" / "native-messaging-hosts",
|
||||
Path.home() / ".config" / "mozilla" / "native-messaging-hosts",
|
||||
]
|
||||
|
||||
HOST_MANIFEST = {
|
||||
"name": "moon_i2p_torrent",
|
||||
"description": "moon-i2p native I2P router & BitTorrent/DHT controller",
|
||||
"path": str(HOST_SCRIPT),
|
||||
"type": "stdio",
|
||||
"allowed_extensions": ["moon-i2p-torrent@local"],
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
mode = os.stat(HOST_SCRIPT).st_mode
|
||||
os.chmod(HOST_SCRIPT, mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
||||
|
||||
for target_dir in MANIFEST_DIRS:
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
dest = target_dir / "moon_i2p_torrent.json"
|
||||
dest.write_text(json.dumps(HOST_MANIFEST, indent=2) + "\n", encoding="utf-8")
|
||||
print(f"Installed native messaging manifest: {dest}")
|
||||
|
||||
XPI_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||
with zipfile.ZipFile(XPI_PATH, "w", compression=zipfile.ZIP_DEFLATED) as zf:
|
||||
for path in sorted(EXT_DIR.rglob("*")):
|
||||
if path.is_file():
|
||||
arcname = path.relative_to(EXT_DIR).as_posix()
|
||||
zf.write(path, arcname)
|
||||
print(f"Built Firefox extension bundle: {XPI_PATH}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user