feat: add built-in Moon I2P start page to Firefox and Android
- Firefox extension: add start.html/css/js as homepage and new-tab page (manifest bumped to 0.1.5, .xpi rebuilt). Shows router readiness, tunnel/NetDB/DHT tiles, torrents, and a .i2p/magnet address bar. - openManager message now accepts an optional hash and reuses any open manager tab. - Android: default page is file:///android_asset/start.html, backed by a MoonI2pStart JS bridge (status, torrents, open URL, diagnostics, copy .b32). Blocks file: navigation from the WebView. - RouterService: add fetchLocalApiJsonOrNull for bounded local API reads. - Built-in .i2p destinations reordered (NotBob, Postman first); README updated to match.
This commit is contained in:
1 parent
9d3df6e100
commit
7139a64544
11 files changed
+1355
-37
No files matched your search
@@ -68,11 +68,11 @@ just proxy
|
||||
# Or launch via just (starts --public --http-proxy 127.0.0.1:4444 --torrent-api 127.0.0.1:4445):
|
||||
just proxy
|
||||
|
||||
# Build a standalone zero-setup Firefox + moon-i2p router AppImage (insulaocculta.i2p homepage):
|
||||
# Build a standalone zero-setup Firefox + moon-i2p router AppImage (built-in Moon I2P Start Page):
|
||||
just appimage
|
||||
./dist/MoonI2P-Browser-x86_64.AppImage
|
||||
|
||||
# Build a standalone zero-setup Android APK (arm64-v8a + x86_64, insulaocculta.i2p homepage):
|
||||
# Build a standalone zero-setup Android APK (arm64-v8a + x86_64, built-in Moon I2P Start Page):
|
||||
just apk
|
||||
# Install dist/MoonI2P-Browser-android.apk via `adb install -r dist/MoonI2P-Browser-android.apk`
|
||||
|
||||
|
||||
@@ -0,0 +1,496 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>Moon I2P Start Page</title>
|
||||
<style>
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--bg: #0b1120;
|
||||
--card: #131c31;
|
||||
--border: #23304d;
|
||||
--text: #e2e8f0;
|
||||
--muted: #94a3b8;
|
||||
--accent: #6d5dfc;
|
||||
--teal: #14b8a6;
|
||||
--warn: #f59e0b;
|
||||
--danger: #ef4444;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
padding: 16px 14px 28px;
|
||||
background:
|
||||
radial-gradient(640px 280px at 50% -60px, rgba(109, 93, 252, 0.22), transparent 72%),
|
||||
var(--bg);
|
||||
color: var(--text);
|
||||
font-family: system-ui, -apple-system, sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.wrap { max-width: 680px; margin: 0 auto; }
|
||||
header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.brand { display: flex; align-items: center; gap: 10px; }
|
||||
.brand svg { width: 28px; height: 28px; flex-shrink: 0; }
|
||||
.brand-title { font-size: 16px; font-weight: 700; }
|
||||
.brand-sub { font-size: 11px; color: var(--muted); }
|
||||
.pill {
|
||||
display: inline-block;
|
||||
padding: 3px 9px;
|
||||
border-radius: 999px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
background: #1e293b;
|
||||
color: var(--muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.pill.online { background: rgba(20, 184, 166, 0.2); color: #5eead4; }
|
||||
.pill.booting { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
|
||||
.pill.offline { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
|
||||
.card {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
padding: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.banner.booting {
|
||||
border-color: rgba(245, 158, 11, 0.55);
|
||||
background: linear-gradient(90deg, rgba(245, 158, 11, 0.1), var(--card) 60%);
|
||||
}
|
||||
.banner.ready {
|
||||
border-color: rgba(20, 184, 166, 0.45);
|
||||
background: linear-gradient(90deg, rgba(20, 184, 166, 0.1), var(--card) 60%);
|
||||
}
|
||||
.banner-title { font-weight: 700; font-size: 13px; }
|
||||
.banner-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }
|
||||
.row { display: flex; gap: 8px; align-items: center; }
|
||||
input[type="text"] {
|
||||
width: 100%;
|
||||
background: #0b1222;
|
||||
color: var(--text);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 10px 11px;
|
||||
font-size: 14px;
|
||||
}
|
||||
button {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
padding: 10px 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
button.secondary {
|
||||
background: #1e293b;
|
||||
color: var(--text);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
.msg { font-size: 12px; margin-top: 6px; min-height: 16px; color: #5eead4; }
|
||||
.msg.err { color: #fca5a5; }
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.stat {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 9px 10px;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
.stat-label { font-size: 11px; color: var(--muted); }
|
||||
.stat-val { font-size: 14px; font-weight: 700; margin-top: 2px; }
|
||||
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.actions button { flex: 1; }
|
||||
h2 {
|
||||
margin: 0 0 8px 0;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
color: var(--muted);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.sites {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.site {
|
||||
display: block;
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 11px 12px;
|
||||
text-decoration: none;
|
||||
color: var(--text);
|
||||
}
|
||||
.site-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.site-title { font-weight: 700; font-size: 14px; }
|
||||
.tag {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
padding: 2px 7px;
|
||||
border-radius: 999px;
|
||||
background: rgba(109, 93, 252, 0.2);
|
||||
color: #c4b5fd;
|
||||
}
|
||||
.mono { font-family: ui-monospace, monospace; font-size: 11px; }
|
||||
.site-host { color: #5eead4; margin-top: 4px; }
|
||||
.site-desc { color: var(--muted); font-size: 12px; margin-top: 4px; }
|
||||
.torrent-item {
|
||||
padding: 8px 0;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
.torrent-item:first-child { border-top: 0; padding-top: 0; }
|
||||
.track {
|
||||
width: 100%;
|
||||
height: 6px;
|
||||
background: #0b1222;
|
||||
border-radius: 999px;
|
||||
overflow: hidden;
|
||||
margin: 5px 0;
|
||||
}
|
||||
.fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, var(--accent), var(--teal));
|
||||
}
|
||||
.footer {
|
||||
border-top: 1px solid var(--border);
|
||||
padding-top: 10px;
|
||||
margin-top: 14px;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.b32-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.b32-text {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--text);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
<header>
|
||||
<div class="brand">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#6d5dfc" />
|
||||
<stop offset="100%" stop-color="#14b8a6" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="96" height="96" rx="22" fill="#0f172a" />
|
||||
<circle cx="48" cy="48" r="34" fill="none" stroke="url(#g)" stroke-width="6" />
|
||||
<path d="M48 25v29m0 0-12-12m12 12 12-12" fill="none" stroke="#f8fafc" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" />
|
||||
<path d="M29 64h38" stroke="#14b8a6" stroke-width="6" stroke-linecap="round" />
|
||||
</svg>
|
||||
<div>
|
||||
<div class="brand-title">Moon I2P</div>
|
||||
<div class="brand-sub">Private .i2p Browser & BitTorrent/DHT Router</div>
|
||||
</div>
|
||||
</div>
|
||||
<span id="status-pill" class="pill offline">Starting...</span>
|
||||
</header>
|
||||
|
||||
<section id="warmup-banner" class="card banner booting">
|
||||
<div id="warmup-title" class="banner-title">Bootstrapping I2P router & tunnels...</div>
|
||||
<div id="warmup-detail" class="banner-detail">Waiting for local moon-i2p service.</div>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<form id="nav-form" class="row">
|
||||
<input id="nav-input" type="text" autocomplete="off" spellcheck="false" placeholder="Enter .i2p domain, .b32.i2p, or magnet:..." />
|
||||
<button type="submit">Go</button>
|
||||
</form>
|
||||
<div id="nav-msg" class="msg"></div>
|
||||
</section>
|
||||
|
||||
<section class="grid" aria-label="Router Telemetry">
|
||||
<div class="stat">
|
||||
<div class="stat-label">Tunnels</div>
|
||||
<div id="tile-tunnels-val" class="stat-val">--</div>
|
||||
<div id="tile-tunnels-sub" class="stat-sub">Building pool...</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<div class="stat-label">NetDB Peers</div>
|
||||
<div id="tile-netdb-val" class="stat-val">--</div>
|
||||
<div id="tile-netdb-sub" class="stat-sub">-- floodfills</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<div class="stat-label">I2P DHT</div>
|
||||
<div id="tile-dht-val" class="stat-val">--</div>
|
||||
<div id="tile-dht-sub" class="stat-sub">Proto 17 / 18</div>
|
||||
</div>
|
||||
<button id="torrents-tile" class="stat" type="button">
|
||||
<div class="stat-label">Torrents</div>
|
||||
<div id="tile-torrents-val" class="stat-val">0 total</div>
|
||||
<div id="tile-torrents-sub" class="stat-sub">Tap to open manager</div>
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section class="actions">
|
||||
<button id="open-torrents-btn" type="button">Torrents & DHT</button>
|
||||
<button id="open-diag-btn" class="secondary" type="button">Diagnostics</button>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2><span>Built-in .i2p Destinations</span><span>Ready</span></h2>
|
||||
<div class="sites">
|
||||
<a class="site" href="http://notbob.i2p/">
|
||||
<div class="site-top"><span class="site-title">NotBob Directory</span><span class="tag">Directory</span></div>
|
||||
<div class="site-host mono">notbob.i2p</div>
|
||||
<div class="site-desc">Uptime-monitored directory of live .i2p eepsites</div>
|
||||
</a>
|
||||
<a class="site" href="http://tracker2.postman.i2p/">
|
||||
<div class="site-top"><span class="site-title">Postman Tracker</span><span class="tag">Torrents</span></div>
|
||||
<div class="site-host mono">tracker2.postman.i2p</div>
|
||||
<div class="site-desc">Public I2P BitTorrent tracker & torrent index</div>
|
||||
</a>
|
||||
<a class="site" href="http://insulaocculta.i2p/">
|
||||
<div class="site-top"><span class="site-title">Insula Occulta</span><span class="tag">Torrents</span></div>
|
||||
<div class="site-host mono">insulaocculta.i2p</div>
|
||||
<div class="site-desc">I2P music & media torrent tracker</div>
|
||||
</a>
|
||||
<a class="site" href="http://stats.i2p/">
|
||||
<div class="site-top"><span class="site-title">I2P Stats</span><span class="tag">Network</span></div>
|
||||
<div class="site-host mono">stats.i2p</div>
|
||||
<div class="site-desc">Network health, router stats & hosts.txt addressbook</div>
|
||||
</a>
|
||||
<a class="site" href="http://zzz.i2p/">
|
||||
<div class="site-top"><span class="site-title">zzz.i2p</span><span class="tag">Community</span></div>
|
||||
<div class="site-host mono">zzz.i2p</div>
|
||||
<div class="site-desc">I2P developer forums & protocol proposals</div>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="active-torrents-card" class="card" style="display:none;">
|
||||
<h2><span>Active Torrents (<span id="active-torrents-count">0</span>)</span></h2>
|
||||
<div id="active-torrents-list"></div>
|
||||
</section>
|
||||
|
||||
<footer class="footer">
|
||||
<div id="footer-proxy" class="mono">Proxy: starting...</div>
|
||||
<div class="b32-row">
|
||||
<span class="stat-label">Torrent .b32:</span>
|
||||
<span id="footer-b32" class="mono b32-text">--</span>
|
||||
<button id="copy-b32-btn" class="secondary" type="button">Copy</button>
|
||||
</div>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
const $ = (id) => document.getElementById(id);
|
||||
let currentB32 = "";
|
||||
|
||||
function fmtBytes(n) {
|
||||
if (!n || n <= 0) return "0 B";
|
||||
const units = ["B", "KiB", "MiB", "GiB"];
|
||||
let u = 0;
|
||||
let v = n;
|
||||
while (v >= 1024 && u < units.length - 1) {
|
||||
v /= 1024;
|
||||
u++;
|
||||
}
|
||||
return v.toFixed(u === 0 ? 0 : 1) + " " + units[u];
|
||||
}
|
||||
|
||||
function escapeHtml(s) {
|
||||
return String(s || "").replace(/[&<>"']/g, (c) => ({
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
'"': """,
|
||||
"'": "'",
|
||||
})[c]);
|
||||
}
|
||||
|
||||
function setNavMsg(text, isErr) {
|
||||
const el = $("nav-msg");
|
||||
el.textContent = text;
|
||||
el.className = isErr ? "msg err" : "msg";
|
||||
}
|
||||
|
||||
function refreshStatus() {
|
||||
if (document.hidden || !window.MoonI2pStart || !window.MoonI2pStart.getStatusJson) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const data = JSON.parse(window.MoonI2pStart.getStatusJson() || "{}");
|
||||
const pPort = Number(data.proxy_port || 0);
|
||||
$("footer-proxy").textContent = pPort > 0 ? "HTTP Proxy: 127.0.0.1:" + pPort : "HTTP Proxy: starting...";
|
||||
|
||||
const rs = data.status || {};
|
||||
const torrents = Array.isArray(data.torrents) ? data.torrents : [];
|
||||
const pill = $("status-pill");
|
||||
const banner = $("warmup-banner");
|
||||
const title = $("warmup-title");
|
||||
const detail = $("warmup-detail");
|
||||
|
||||
if (!data.api_ready || !rs.ok) {
|
||||
pill.textContent = "Bootstrapping...";
|
||||
pill.className = "pill booting";
|
||||
banner.className = "card banner booting";
|
||||
title.textContent = data.status_text || "Starting bundled moon-i2p router...";
|
||||
detail.textContent = "Reseeding public I2P peers and preparing HTTP proxy.";
|
||||
$("tile-tunnels-val").textContent = "--";
|
||||
$("tile-tunnels-sub").textContent = "Router starting";
|
||||
$("tile-netdb-val").textContent = "--";
|
||||
$("tile-netdb-sub").textContent = "-- floodfills";
|
||||
$("tile-dht-val").textContent = "--";
|
||||
$("tile-dht-sub").textContent = "Proto 17 / 18";
|
||||
currentB32 = "";
|
||||
$("footer-b32").textContent = "--";
|
||||
} else {
|
||||
const inT = Number(rs.inbound_tunnels || 0);
|
||||
const outT = Number(rs.outbound_tunnels || 0);
|
||||
const peers = Number(rs.netdb_routers || 0);
|
||||
const ff = Number(rs.netdb_floodfills || 0);
|
||||
const dht = rs.dht || {};
|
||||
|
||||
$("tile-tunnels-val").textContent = inT + "in / " + outT + "out";
|
||||
$("tile-tunnels-sub").textContent = inT > 0 && outT > 0 ? "Tunnels active" : "Building client tunnels";
|
||||
$("tile-netdb-val").textContent = String(peers);
|
||||
$("tile-netdb-sub").textContent = ff + " floodfills";
|
||||
$("tile-dht-val").textContent = (dht.routing_table_nodes || 0) + " nodes";
|
||||
$("tile-dht-sub").textContent = (dht.queries_sent || 0) + " sent / " + (dht.peers_discovered || 0) + " peers";
|
||||
currentB32 = rs.torrent_b32 || "";
|
||||
$("footer-b32").textContent = currentB32 || "--";
|
||||
|
||||
if (inT === 0 || outT === 0) {
|
||||
pill.textContent = "Bootstrapping...";
|
||||
pill.className = "pill booting";
|
||||
banner.className = "card banner booting";
|
||||
title.textContent = "Bootstrapping I2P tunnels (typically 15–30s)...";
|
||||
detail.textContent = "NetDB: " + peers + " peers (" + ff + " floodfills) · " + inT + "in/" + outT + "out tunnels.";
|
||||
} else {
|
||||
pill.textContent = rs.public_mode ? "Public Online" : "I2P Ready";
|
||||
pill.className = "pill online";
|
||||
banner.className = "card banner ready";
|
||||
title.textContent = "I2P tunnels active and ready";
|
||||
detail.textContent = inT + " inbound / " + outT + " outbound tunnels · " + peers + " NetDB peers.";
|
||||
}
|
||||
}
|
||||
|
||||
const active = torrents.filter((t) => !t.completed && !t.paused).length;
|
||||
$("tile-torrents-val").textContent = torrents.length + " total";
|
||||
$("tile-torrents-sub").textContent = active > 0 ? active + " downloading · Tap to view" : "Tap to open manager";
|
||||
|
||||
const card = $("active-torrents-card");
|
||||
const list = $("active-torrents-list");
|
||||
$("active-torrents-count").textContent = String(torrents.length);
|
||||
if (torrents.length === 0) {
|
||||
card.style.display = "none";
|
||||
list.innerHTML = "";
|
||||
} else {
|
||||
card.style.display = "";
|
||||
list.innerHTML = torrents.slice(0, 6).map((t) => {
|
||||
const pct = Math.max(0, Math.min(100, Number(t.progress_pct || 0)));
|
||||
return (
|
||||
'<div class="torrent-item">' +
|
||||
'<div class="row" style="justify-content:space-between;">' +
|
||||
"<strong>" + escapeHtml(t.name) + "</strong>" +
|
||||
'<span class="pill ' + (t.completed ? "online" : "") + '">' + escapeHtml(t.state) + " · " + pct + "%</span>" +
|
||||
"</div>" +
|
||||
'<div class="track"><div class="fill" style="width:' + pct + '%"></div></div>' +
|
||||
'<div style="color:var(--muted);font-size:11px;">' +
|
||||
fmtBytes(t.downloaded_bytes) + " / " + fmtBytes(t.total_length) + " · " +
|
||||
(t.connected_peers || 0) + "/" + (t.known_peers || 0) + " peers" +
|
||||
"</div>" +
|
||||
"</div>"
|
||||
);
|
||||
}).join("");
|
||||
}
|
||||
} catch (_e) {
|
||||
// Ignore transient parse/bridge errors
|
||||
}
|
||||
}
|
||||
|
||||
$("nav-form").addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
const raw = String($("nav-input").value || "").trim();
|
||||
if (!raw) {
|
||||
setNavMsg("");
|
||||
return;
|
||||
}
|
||||
if (!/^magnet:/i.test(raw) && /\s/.test(raw)) {
|
||||
setNavMsg("Enter a .i2p domain (e.g. notbob.i2p), .b32.i2p address, or magnet: link.", true);
|
||||
return;
|
||||
}
|
||||
setNavMsg("");
|
||||
if (window.MoonI2pStart && window.MoonI2pStart.openUrl) {
|
||||
window.MoonI2pStart.openUrl(raw);
|
||||
} else {
|
||||
window.location.href = /^https?:\/\//i.test(raw) ? raw : "http://" + raw;
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll("a.site").forEach((a) => {
|
||||
a.addEventListener("click", (e) => {
|
||||
if (window.MoonI2pStart && window.MoonI2pStart.openUrl) {
|
||||
e.preventDefault();
|
||||
window.MoonI2pStart.openUrl(a.getAttribute("href"));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const openTorrents = () => window.MoonI2pStart && window.MoonI2pStart.openTorrents();
|
||||
$("torrents-tile").addEventListener("click", openTorrents);
|
||||
$("open-torrents-btn").addEventListener("click", openTorrents);
|
||||
$("open-diag-btn").addEventListener("click", () => window.MoonI2pStart && window.MoonI2pStart.openDiagnostics());
|
||||
$("copy-b32-btn").addEventListener("click", () => {
|
||||
if (!currentB32) {
|
||||
setNavMsg("Router has not published a .b32.i2p address yet.", true);
|
||||
return;
|
||||
}
|
||||
if (window.MoonI2pStart && window.MoonI2pStart.copyText) {
|
||||
window.MoonI2pStart.copyText(currentB32);
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
if (!document.hidden) refreshStatus();
|
||||
});
|
||||
|
||||
refreshStatus();
|
||||
setInterval(refreshStatus, 1500);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -36,6 +36,7 @@ import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -52,23 +53,25 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Embedded I2P WebView browser defaulting to http://insulaocculta.i2p/ paired
|
||||
* with a same-origin Torrents & I2P DHT management dashboard tab and full
|
||||
* Embedded I2P WebView browser defaulting to the built-in Moon I2P Start Page
|
||||
* paired with a same-origin Torrents & I2P DHT management dashboard tab and full
|
||||
* diagnostics report export.
|
||||
*/
|
||||
public class MainActivity extends Activity {
|
||||
private static final String HOMEPAGE = "http://insulaocculta.i2p/";
|
||||
private static final String HOMEPAGE = "file:///android_asset/start.html";
|
||||
private static final int REQ_PICK_TORRENT = 2001;
|
||||
private static final int REQ_NOTIF_PERM = 2002;
|
||||
|
||||
private static final String[][] BOOKMARKS = new String[][] {
|
||||
{ "NotBob Directory", "http://notbob.i2p/" },
|
||||
{ "Postman Tracker", "http://tracker2.postman.i2p/" },
|
||||
{ "Insula Occulta", "http://insulaocculta.i2p/" },
|
||||
{ "I2P Stats", "http://stats.i2p/" },
|
||||
{ "zzz.i2p", "http://zzz.i2p/" },
|
||||
{ "Postman Tracker", "http://tracker2.postman.i2p/" },
|
||||
{ "NotBob Directory", "http://notbob.i2p/" },
|
||||
};
|
||||
|
||||
private LinearLayout mTopBar;
|
||||
@@ -104,7 +107,7 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
|
||||
buildUi();
|
||||
mBrowserView.loadUrl(HOMEPAGE);
|
||||
navigateBrowser(HOMEPAGE);
|
||||
handleIntent(getIntent());
|
||||
startStatusPoll();
|
||||
}
|
||||
@@ -167,7 +170,8 @@ public class MainActivity extends Activity {
|
||||
mTopBar.addView(makeIconBtn("R", v -> mBrowserView.reload()));
|
||||
|
||||
mUrlInput = new EditText(this);
|
||||
mUrlInput.setText(HOMEPAGE);
|
||||
mUrlInput.setHint("Enter .i2p address or magnet: URI...");
|
||||
mUrlInput.setText("");
|
||||
mUrlInput.setTextColor(Color.parseColor("#F8FAFC"));
|
||||
mUrlInput.setHintTextColor(Color.parseColor("#94A3B8"));
|
||||
mUrlInput.setBackgroundColor(Color.parseColor("#0B1222"));
|
||||
@@ -211,6 +215,7 @@ public class MainActivity extends Activity {
|
||||
mBrowserView = new WebView(this);
|
||||
configureWebView(mBrowserView);
|
||||
mBrowserView.addJavascriptInterface(new BrowserLinkBridge(), "MoonI2pPage");
|
||||
mBrowserView.addJavascriptInterface(new StartPageBridge(), "MoonI2pStart");
|
||||
mBrowserView.setWebViewClient(new I2pWebViewClient());
|
||||
mBrowserView.setDownloadListener((dlUrl, userAgent, contentDisposition, mimetype, contentLength) -> {
|
||||
if (dlUrl == null) return;
|
||||
@@ -338,16 +343,25 @@ public class MainActivity extends Activity {
|
||||
|
||||
private void navigateBrowser(String raw) {
|
||||
String s = raw == null ? "" : raw.trim();
|
||||
if (s.isEmpty()) s = HOMEPAGE;
|
||||
if (!s.contains("://") && !s.startsWith("magnet:")) {
|
||||
s = "http://" + s;
|
||||
if (s.isEmpty() || HOMEPAGE.equals(s)) {
|
||||
mUrlInput.setText("");
|
||||
switchTab(false);
|
||||
mBrowserView.loadUrl(HOMEPAGE);
|
||||
return;
|
||||
}
|
||||
if (!s.contains("://") && !s.toLowerCase(Locale.ROOT).startsWith("magnet:")) {
|
||||
if (!s.contains(".") && !s.contains("/") && !s.contains(":") && !s.contains(" ")) {
|
||||
s = "http://" + s + ".i2p/";
|
||||
} else {
|
||||
s = "http://" + s;
|
||||
}
|
||||
}
|
||||
mUrlInput.setText(s);
|
||||
if (s.toLowerCase(Locale.ROOT).startsWith("magnet:")) {
|
||||
submitMagnetAsync(s);
|
||||
switchTab(true);
|
||||
return;
|
||||
}
|
||||
mUrlInput.setText(s);
|
||||
switchTab(false);
|
||||
mBrowserView.loadUrl(s);
|
||||
}
|
||||
@@ -653,11 +667,88 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCurrentBrowserPageStart() {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
return HOMEPAGE.equals(mBrowserView.getUrl());
|
||||
}
|
||||
final boolean[] result = new boolean[] { false };
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
runOnUiThread(() -> {
|
||||
try {
|
||||
result[0] = HOMEPAGE.equals(mBrowserView.getUrl());
|
||||
} finally {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
try {
|
||||
latch.await(250, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException ignored) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return result[0];
|
||||
}
|
||||
|
||||
private class StartPageBridge {
|
||||
@JavascriptInterface
|
||||
public String getStatusJson() {
|
||||
if (!isCurrentBrowserPageStart()) return "{}";
|
||||
try {
|
||||
JSONObject out = new JSONObject();
|
||||
boolean apiReady = RouterService.isApiReady();
|
||||
out.put("api_ready", apiReady);
|
||||
out.put("status_text", RouterService.getStatusText());
|
||||
out.put("proxy_port", RouterService.getProxyPort());
|
||||
out.put("api_port", RouterService.getApiPort());
|
||||
if (apiReady) {
|
||||
String stRaw = RouterService.fetchLocalApiJsonOrNull("/api/status");
|
||||
if (stRaw != null) {
|
||||
out.put("status", new JSONObject(stRaw));
|
||||
}
|
||||
String tlRaw = RouterService.fetchLocalApiJsonOrNull("/api/torrents");
|
||||
if (tlRaw != null) {
|
||||
JSONObject tlObj = new JSONObject(tlRaw);
|
||||
JSONArray arr = tlObj.optJSONArray("torrents");
|
||||
out.put("torrents", arr != null ? arr : new JSONArray());
|
||||
}
|
||||
}
|
||||
return out.toString();
|
||||
} catch (Exception e) {
|
||||
return "{\"api_ready\":false}";
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void openUrl(String url) {
|
||||
if (!isCurrentBrowserPageStart()) return;
|
||||
runOnUiThread(() -> navigateBrowser(url));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void openTorrents() {
|
||||
if (!isCurrentBrowserPageStart()) return;
|
||||
runOnUiThread(() -> switchTab(true));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void openDiagnostics() {
|
||||
if (!isCurrentBrowserPageStart()) return;
|
||||
runOnUiThread(() -> showDiagnosticsDialog());
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void copyText(String text) {
|
||||
if (!isCurrentBrowserPageStart()) return;
|
||||
runOnUiThread(() -> copyToClipboard(text != null ? text : "", "Copied to clipboard"));
|
||||
}
|
||||
}
|
||||
|
||||
private class I2pWebViewClient extends WebViewClient {
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
if (url != null && !url.startsWith("about:")) {
|
||||
if (HOMEPAGE.equals(url)) {
|
||||
mUrlInput.setText("");
|
||||
} else if (url != null && !url.startsWith("about:")) {
|
||||
mUrlInput.setText(url);
|
||||
try {
|
||||
Uri u = Uri.parse(url);
|
||||
@@ -692,6 +783,9 @@ public class MainActivity extends Activity {
|
||||
Uri uri = request.getUrl();
|
||||
String url = uri.toString();
|
||||
String lower = url.toLowerCase(Locale.ROOT);
|
||||
if (lower.startsWith("file:")) {
|
||||
return true;
|
||||
}
|
||||
if (lower.startsWith("magnet:")) {
|
||||
submitMagnetAsync(url);
|
||||
switchTab(true);
|
||||
|
||||
@@ -177,6 +177,37 @@ public class RouterService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
public static String fetchLocalApiJsonOrNull(String path) {
|
||||
int port = sApiPort;
|
||||
if (!sApiReady || port <= 0) return null;
|
||||
HttpURLConnection conn = null;
|
||||
try {
|
||||
URL u = new URL("http://127.0.0.1:" + port + path);
|
||||
conn = (HttpURLConnection) u.openConnection();
|
||||
conn.setConnectTimeout(1000);
|
||||
conn.setReadTimeout(1500);
|
||||
if (conn.getResponseCode() != 200) {
|
||||
return null;
|
||||
}
|
||||
InputStream in = conn.getInputStream();
|
||||
if (in == null) return null;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
byte[] buf = new byte[4096];
|
||||
int total = 0;
|
||||
int n;
|
||||
while (total < 128 * 1024 && (n = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, n);
|
||||
total += n;
|
||||
}
|
||||
String body = new String(out.toByteArray(), StandardCharsets.UTF_8).trim();
|
||||
return body.startsWith("{") ? body : null;
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
} finally {
|
||||
if (conn != null) conn.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects device info, service state, router API snapshots, Android proxy events,
|
||||
* and the verbose moon-i2p router log. Call from a background thread.
|
||||
|
||||
Binary file not shown.
@@ -416,12 +416,14 @@ browser.runtime.onMessage.addListener(async (msg) => {
|
||||
10000
|
||||
);
|
||||
case "openManager": {
|
||||
const url = browser.runtime.getURL("manager.html");
|
||||
const existing = await browser.tabs.query({ url });
|
||||
const baseUrl = browser.runtime.getURL("manager.html");
|
||||
const hash = typeof msg.hash === "string" && msg.hash ? msg.hash : "";
|
||||
const targetUrl = hash ? `${baseUrl}${hash}` : baseUrl;
|
||||
const existing = await browser.tabs.query({ url: `${baseUrl}*` });
|
||||
if (existing.length > 0) {
|
||||
await browser.tabs.update(existing[0].id, { active: true });
|
||||
await browser.tabs.update(existing[0].id, { active: true, url: targetUrl });
|
||||
} else {
|
||||
await browser.tabs.create({ url });
|
||||
await browser.tabs.create({ url: targetUrl });
|
||||
}
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Moon I2P Torrent & Proxy",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"description": "Route .i2p browsing through moon-i2p and manage I2P BitTorrent + I2P DHT torrents from Firefox.",
|
||||
"icons": {
|
||||
"48": "icon.svg",
|
||||
@@ -13,6 +13,12 @@
|
||||
"strict_min_version": "109.0"
|
||||
}
|
||||
},
|
||||
"chrome_settings_overrides": {
|
||||
"homepage": "start.html"
|
||||
},
|
||||
"chrome_url_overrides": {
|
||||
"newtab": "start.html"
|
||||
},
|
||||
"permissions": [
|
||||
"proxy",
|
||||
"storage",
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
body.start-page {
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
padding: 28px 18px 40px;
|
||||
background:
|
||||
radial-gradient(900px 420px at 50% -80px, rgba(109, 93, 252, 0.2), transparent 70%),
|
||||
radial-gradient(640px 320px at 85% 0%, rgba(20, 184, 166, 0.12), transparent 65%),
|
||||
var(--bg);
|
||||
}
|
||||
|
||||
.start-wrap {
|
||||
max-width: 920px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.start-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.brand-sub {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.pill.booting {
|
||||
background: rgba(245, 158, 11, 0.18);
|
||||
color: #fcd34d;
|
||||
}
|
||||
|
||||
.warmup-banner {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 12px 14px;
|
||||
margin-bottom: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.warmup-banner.is-booting {
|
||||
border-color: rgba(245, 158, 11, 0.55);
|
||||
background: linear-gradient(90deg, rgba(245, 158, 11, 0.1), var(--card) 55%);
|
||||
}
|
||||
|
||||
.warmup-banner.is-ready {
|
||||
border-color: rgba(20, 184, 166, 0.45);
|
||||
background: linear-gradient(90deg, rgba(20, 184, 166, 0.1), var(--card) 55%);
|
||||
}
|
||||
|
||||
.warmup-banner.is-offline {
|
||||
border-color: rgba(239, 68, 68, 0.45);
|
||||
}
|
||||
|
||||
.warmup-title {
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.warmup-detail {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.nav-card {
|
||||
padding: 14px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.nav-form {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-form input[type="text"] {
|
||||
padding: 10px 12px;
|
||||
font-size: 14px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.nav-form button {
|
||||
padding: 10px 18px;
|
||||
font-size: 14px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.telemetry-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.tile {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 11px 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.tile-btn {
|
||||
width: 100%;
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s ease, transform 0.15s ease;
|
||||
}
|
||||
|
||||
.tile-btn:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.tile-sub {
|
||||
margin-top: 3px;
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.action-strip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.section-heading {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
color: var(--muted);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sites-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
||||
gap: 10px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.site-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 12px 14px;
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
transition: border-color 0.15s ease, background 0.15s ease;
|
||||
}
|
||||
|
||||
.site-card:hover,
|
||||
.site-card:focus-visible {
|
||||
border-color: var(--accent);
|
||||
background: #17213a;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.site-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.site-title {
|
||||
font-weight: 700;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.tag-pill {
|
||||
display: inline-block;
|
||||
padding: 2px 7px;
|
||||
border-radius: 999px;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
background: rgba(109, 93, 252, 0.18);
|
||||
color: #c4b5fd;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.site-host {
|
||||
color: #5eead4;
|
||||
}
|
||||
|
||||
.site-desc {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.start-footer {
|
||||
margin-top: 16px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.b32-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.b32-text {
|
||||
max-width: 420px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.telemetry-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 460px) {
|
||||
.nav-form {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Moon I2P Start Page</title>
|
||||
<link rel="stylesheet" href="ui.css" />
|
||||
<link rel="stylesheet" href="start.css" />
|
||||
</head>
|
||||
<body class="start-page">
|
||||
<main class="start-wrap">
|
||||
<header class="start-header">
|
||||
<div class="brand">
|
||||
<img src="icon.svg" alt="" />
|
||||
<div>
|
||||
<div>Moon I2P</div>
|
||||
<div class="brand-sub">Private .i2p Browser & BitTorrent/DHT Router</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span id="status-pill" class="pill offline">Checking...</span>
|
||||
<button id="start-router-btn" type="button" style="display:none;">Start Router</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section id="warmup-banner" class="warmup-banner">
|
||||
<div>
|
||||
<div id="warmup-title" class="warmup-title">Connecting to bundled moon-i2p router...</div>
|
||||
<div id="warmup-detail" class="warmup-detail">
|
||||
Checking tunnel pool and NetDB readiness. .i2p browsing works automatically once tunnels are up.
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="card nav-card">
|
||||
<form id="nav-form" class="nav-form">
|
||||
<input
|
||||
id="nav-input"
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
autofocus
|
||||
placeholder="Enter .i2p domain (e.g. notbob.i2p), .b32.i2p address, or magnet: link..."
|
||||
/>
|
||||
<button type="submit">Go</button>
|
||||
</form>
|
||||
<div id="nav-msg" class="msg"></div>
|
||||
</section>
|
||||
|
||||
<section class="telemetry-grid" aria-label="Router Telemetry">
|
||||
<div class="tile">
|
||||
<div class="stat-label">Tunnels</div>
|
||||
<div id="tile-tunnels-val" class="stat-val">--</div>
|
||||
<div id="tile-tunnels-sub" class="tile-sub">Waiting for router</div>
|
||||
</div>
|
||||
<div class="tile">
|
||||
<div class="stat-label">NetDB Peers</div>
|
||||
<div id="tile-netdb-val" class="stat-val">--</div>
|
||||
<div id="tile-netdb-sub" class="tile-sub">-- floodfills</div>
|
||||
</div>
|
||||
<div class="tile">
|
||||
<div class="stat-label">I2P DHT</div>
|
||||
<div id="tile-dht-val" class="stat-val">--</div>
|
||||
<div id="tile-dht-sub" class="tile-sub">Proto 17 / 18</div>
|
||||
</div>
|
||||
<button id="torrents-tile" class="tile tile-btn" type="button">
|
||||
<div class="stat-label">Torrents</div>
|
||||
<div id="tile-torrents-val" class="stat-val">0 active</div>
|
||||
<div id="tile-torrents-sub" class="tile-sub">Open manager</div>
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section class="action-strip">
|
||||
<div class="action-buttons">
|
||||
<button id="open-manager-btn" type="button">Torrents & DHT Manager</button>
|
||||
<button id="open-diag-btn" class="secondary" type="button">Diagnostics & Logs</button>
|
||||
</div>
|
||||
<span id="proxy-pill" class="pill">Proxy: 127.0.0.1:4444</span>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2 class="section-heading">
|
||||
<span>Built-in .i2p Destinations</span>
|
||||
<span>Zero-lookup aliases ready</span>
|
||||
</h2>
|
||||
<div class="sites-grid">
|
||||
<a class="site-card" href="http://notbob.i2p/">
|
||||
<div class="site-top">
|
||||
<span class="site-title">NotBob Directory</span>
|
||||
<span class="tag-pill">Directory</span>
|
||||
</div>
|
||||
<div class="site-host mono">notbob.i2p</div>
|
||||
<div class="site-desc">Uptime-monitored directory of live .i2p eepsites</div>
|
||||
</a>
|
||||
|
||||
<a class="site-card" href="http://tracker2.postman.i2p/">
|
||||
<div class="site-top">
|
||||
<span class="site-title">Postman Tracker</span>
|
||||
<span class="tag-pill">Torrents</span>
|
||||
</div>
|
||||
<div class="site-host mono">tracker2.postman.i2p</div>
|
||||
<div class="site-desc">Public I2P BitTorrent tracker & torrent index</div>
|
||||
</a>
|
||||
|
||||
<a class="site-card" href="http://insulaocculta.i2p/">
|
||||
<div class="site-top">
|
||||
<span class="site-title">Insula Occulta</span>
|
||||
<span class="tag-pill">Torrents</span>
|
||||
</div>
|
||||
<div class="site-host mono">insulaocculta.i2p</div>
|
||||
<div class="site-desc">I2P music & media torrent tracker</div>
|
||||
</a>
|
||||
|
||||
<a class="site-card" href="http://stats.i2p/">
|
||||
<div class="site-top">
|
||||
<span class="site-title">I2P Stats</span>
|
||||
<span class="tag-pill">Network</span>
|
||||
</div>
|
||||
<div class="site-host mono">stats.i2p</div>
|
||||
<div class="site-desc">Network health, router stats & hosts.txt addressbook</div>
|
||||
</a>
|
||||
|
||||
<a class="site-card" href="http://zzz.i2p/">
|
||||
<div class="site-top">
|
||||
<span class="site-title">zzz.i2p</span>
|
||||
<span class="tag-pill">Community</span>
|
||||
</div>
|
||||
<div class="site-host mono">zzz.i2p</div>
|
||||
<div class="site-desc">I2P developer forums & protocol proposals</div>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="active-torrents-card" class="card" style="display:none;">
|
||||
<h2>
|
||||
<span>Active Torrents (<span id="active-torrents-count">0</span>)</span>
|
||||
<button id="open-manager-btn-2" class="secondary" type="button">Open Manager</button>
|
||||
</h2>
|
||||
<div id="active-torrents-list"></div>
|
||||
</section>
|
||||
|
||||
<footer class="start-footer">
|
||||
<div id="footer-proxy" class="mono">Proxy: 127.0.0.1:4444</div>
|
||||
<div class="b32-wrap">
|
||||
<span class="stat-label">Torrent .b32.i2p:</span>
|
||||
<span id="footer-b32" class="mono b32-text" title="--">--</span>
|
||||
<button id="copy-b32-btn" class="secondary" type="button">Copy .b32</button>
|
||||
</div>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
<script src="start.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,281 @@
|
||||
"use strict";
|
||||
|
||||
function normalizeNavigationInput(raw) {
|
||||
const trimmed = String(raw || "").trim();
|
||||
if (!trimmed) {
|
||||
return { kind: "empty" };
|
||||
}
|
||||
if (/^magnet:/i.test(trimmed)) {
|
||||
return { kind: "magnet", value: trimmed };
|
||||
}
|
||||
if (/\s/.test(trimmed)) {
|
||||
return {
|
||||
kind: "invalid",
|
||||
error: "Enter a .i2p domain (e.g. notbob.i2p), .b32.i2p address, or magnet: link.",
|
||||
};
|
||||
}
|
||||
if (/^https?:\/\//i.test(trimmed)) {
|
||||
return { kind: "url", value: trimmed };
|
||||
}
|
||||
if (!/[./:]/.test(trimmed)) {
|
||||
return { kind: "url", value: "http://" + trimmed + ".i2p/" };
|
||||
}
|
||||
return { kind: "url", value: "http://" + trimmed };
|
||||
}
|
||||
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
module.exports = { normalizeNavigationInput };
|
||||
}
|
||||
|
||||
if (typeof document !== "undefined" && typeof browser !== "undefined") {
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
function fmtBytes(n) {
|
||||
if (!n || n <= 0) return "0 B";
|
||||
const units = ["B", "KiB", "MiB", "GiB"];
|
||||
let u = 0;
|
||||
let v = n;
|
||||
while (v >= 1024 && u < units.length - 1) {
|
||||
v /= 1024;
|
||||
u++;
|
||||
}
|
||||
return `${v.toFixed(u === 0 ? 0 : 1)} ${units[u]}`;
|
||||
}
|
||||
|
||||
function escapeHtml(s) {
|
||||
return String(s || "").replace(/[&<>"']/g, (c) => ({
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
'"': """,
|
||||
"'": "'",
|
||||
})[c]);
|
||||
}
|
||||
|
||||
function setNavMsg(text, isErr = false) {
|
||||
const el = $("nav-msg");
|
||||
if (!el) return;
|
||||
el.textContent = text;
|
||||
el.className = isErr ? "msg err" : "msg";
|
||||
}
|
||||
|
||||
async function copyTextToClipboard(text) {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return true;
|
||||
} catch (_e) {
|
||||
// Fall through to textarea + execCommand fallback
|
||||
}
|
||||
}
|
||||
const ta = document.createElement("textarea");
|
||||
ta.value = text;
|
||||
ta.setAttribute("readonly", "");
|
||||
ta.style.position = "fixed";
|
||||
ta.style.top = "-9999px";
|
||||
ta.style.left = "-9999px";
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
let ok = false;
|
||||
try {
|
||||
ok = document.execCommand("copy");
|
||||
} finally {
|
||||
document.body.removeChild(ta);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
let currentB32 = "";
|
||||
let copyTimer = null;
|
||||
let refreshInFlight = false;
|
||||
|
||||
async function refreshStatus() {
|
||||
if (refreshInFlight || document.hidden) return;
|
||||
refreshInFlight = true;
|
||||
try {
|
||||
const st = await browser.runtime.sendMessage({ type: "getState" });
|
||||
if (!st) return;
|
||||
|
||||
const cfg = st.settings || {};
|
||||
const rs = st.routerStatus || {};
|
||||
const torrents = Array.isArray(st.torrents) ? st.torrents : [];
|
||||
const dhtNodes = (st.dht && Array.isArray(st.dht.nodes) ? st.dht.nodes.length : 0);
|
||||
|
||||
const proxyAddr = `${cfg.proxyHost || "127.0.0.1"}:${cfg.proxyPort || 4444}`;
|
||||
const proxyEnabled = cfg.proxyEnabled !== false;
|
||||
$("proxy-pill").textContent = proxyEnabled ? `Proxy: ${proxyAddr}` : `Proxy Disabled (${proxyAddr})`;
|
||||
$("proxy-pill").className = proxyEnabled ? "pill online" : "pill offline";
|
||||
$("footer-proxy").textContent = `Proxy: ${proxyAddr} (${proxyEnabled ? "enabled" : "disabled"})`;
|
||||
|
||||
const pill = $("status-pill");
|
||||
const startBtn = $("start-router-btn");
|
||||
const banner = $("warmup-banner");
|
||||
const bannerTitle = $("warmup-title");
|
||||
const bannerDetail = $("warmup-detail");
|
||||
|
||||
if (!rs.ok) {
|
||||
pill.textContent = "Offline";
|
||||
pill.className = "pill offline";
|
||||
startBtn.style.display = "";
|
||||
banner.className = "warmup-banner is-offline";
|
||||
bannerTitle.textContent = "moon-i2p router is offline or starting";
|
||||
bannerDetail.textContent = "Click Start Router above or wait for the bundled router to finish launching.";
|
||||
|
||||
$("tile-tunnels-val").textContent = "--";
|
||||
$("tile-tunnels-sub").textContent = "Router unreachable";
|
||||
$("tile-netdb-val").textContent = "--";
|
||||
$("tile-netdb-sub").textContent = "-- floodfills";
|
||||
$("tile-dht-val").textContent = "--";
|
||||
$("tile-dht-sub").textContent = "Proto 17 / 18";
|
||||
currentB32 = "";
|
||||
$("footer-b32").textContent = "--";
|
||||
$("footer-b32").title = "--";
|
||||
} else {
|
||||
startBtn.style.display = "none";
|
||||
const inTunnels = Number(rs.inbound_tunnels || 0);
|
||||
const outTunnels = Number(rs.outbound_tunnels || 0);
|
||||
const routers = Number(rs.netdb_routers || 0);
|
||||
const floodfills = Number(rs.netdb_floodfills || 0);
|
||||
const dhtInfo = rs.dht || {};
|
||||
const dhtCount = Number(dhtInfo.routing_table_nodes ?? dhtNodes ?? 0);
|
||||
|
||||
$("tile-tunnels-val").textContent = `${inTunnels}in / ${outTunnels}out`;
|
||||
$("tile-tunnels-sub").textContent = inTunnels > 0 && outTunnels > 0 ? "Tunnels established" : "Building client tunnels";
|
||||
$("tile-netdb-val").textContent = `${routers}`;
|
||||
$("tile-netdb-sub").textContent = `${floodfills} floodfills`;
|
||||
$("tile-dht-val").textContent = `${dhtCount} nodes`;
|
||||
$("tile-dht-sub").textContent = `${dhtInfo.queries_sent || 0} sent / ${dhtInfo.peers_discovered || 0} peers`;
|
||||
|
||||
currentB32 = rs.torrent_b32 || "";
|
||||
$("footer-b32").textContent = currentB32 || "--";
|
||||
$("footer-b32").title = currentB32 || "--";
|
||||
|
||||
if (inTunnels === 0 || outTunnels === 0) {
|
||||
pill.textContent = "Bootstrapping...";
|
||||
pill.className = "pill booting";
|
||||
banner.className = "warmup-banner is-booting";
|
||||
bannerTitle.textContent = "Bootstrapping I2P tunnels (typically 15–30s)...";
|
||||
bannerDetail.textContent = `NetDB has ${routers} peers (${floodfills} floodfills), ${inTunnels}in/${outTunnels}out tunnels built. .i2p sites will load once tunnels come up.`;
|
||||
} else {
|
||||
pill.textContent = rs.public_mode ? "Public Online" : "I2P Ready";
|
||||
pill.className = "pill online";
|
||||
banner.className = "warmup-banner is-ready";
|
||||
bannerTitle.textContent = "I2P tunnels active and ready";
|
||||
bannerDetail.textContent = `${inTunnels} inbound / ${outTunnels} outbound tunnels · ${routers} NetDB peers · Ready to browse .i2p and download torrents.`;
|
||||
}
|
||||
}
|
||||
|
||||
const activeCount = torrents.filter((t) => !t.completed && !t.paused).length;
|
||||
$("tile-torrents-val").textContent = `${torrents.length} total`;
|
||||
$("tile-torrents-sub").textContent = activeCount > 0 ? `${activeCount} downloading · Open manager` : "Open manager";
|
||||
|
||||
const tCard = $("active-torrents-card");
|
||||
const tList = $("active-torrents-list");
|
||||
$("active-torrents-count").textContent = String(torrents.length);
|
||||
if (torrents.length === 0) {
|
||||
tCard.style.display = "none";
|
||||
tList.innerHTML = "";
|
||||
} else {
|
||||
tCard.style.display = "";
|
||||
tList.innerHTML = torrents
|
||||
.slice(0, 6)
|
||||
.map((t) => {
|
||||
const pct = Math.max(0, Math.min(100, Number(t.progress_pct || 0)));
|
||||
return `
|
||||
<div class="torrent-item">
|
||||
<div class="row" style="justify-content:space-between;">
|
||||
<strong>${escapeHtml(t.name)}</strong>
|
||||
<span class="pill ${t.completed ? "online" : ""}">${escapeHtml(t.state)} · ${pct}%</span>
|
||||
</div>
|
||||
<div class="progress-track"><div class="progress-fill" style="width:${pct}%"></div></div>
|
||||
<div style="color:var(--muted);font-size:11px;">
|
||||
${fmtBytes(t.downloaded_bytes)} / ${fmtBytes(t.total_length)} · ${t.connected_peers || 0}/${t.known_peers || 0} peers
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
})
|
||||
.join("");
|
||||
}
|
||||
} catch (_e) {
|
||||
// Ignore transient polling errors while background wakes up
|
||||
} finally {
|
||||
refreshInFlight = false;
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
$("nav-form").addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
const parsed = normalizeNavigationInput($("nav-input").value);
|
||||
if (parsed.kind === "empty") {
|
||||
setNavMsg("");
|
||||
return;
|
||||
}
|
||||
if (parsed.kind === "invalid") {
|
||||
setNavMsg(parsed.error, true);
|
||||
return;
|
||||
}
|
||||
if (parsed.kind === "magnet") {
|
||||
setNavMsg("Submitting magnet URI to moon-i2p...");
|
||||
const res = await browser.runtime.sendMessage({ type: "addMagnet", uri: parsed.value });
|
||||
if (res && res.ok) {
|
||||
$("nav-input").value = "";
|
||||
setNavMsg(`Added magnet ${(res.info_hash || "").slice(0, 12)}...`);
|
||||
await browser.runtime.sendMessage({ type: "openManager" });
|
||||
} else {
|
||||
setNavMsg(`Magnet failed: ${(res && res.error) || "router offline"}`, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
setNavMsg("");
|
||||
window.location.href = parsed.value;
|
||||
});
|
||||
|
||||
const openManager = () => browser.runtime.sendMessage({ type: "openManager" });
|
||||
$("open-manager-btn").addEventListener("click", openManager);
|
||||
$("torrents-tile").addEventListener("click", openManager);
|
||||
$("open-manager-btn-2").addEventListener("click", openManager);
|
||||
$("open-diag-btn").addEventListener("click", () =>
|
||||
browser.runtime.sendMessage({ type: "openManager", hash: "#diagnostics-card" })
|
||||
);
|
||||
|
||||
$("start-router-btn").addEventListener("click", async () => {
|
||||
setNavMsg("Starting moon-i2p router via native host...");
|
||||
const res = await browser.runtime.sendMessage({ type: "startRouter" });
|
||||
if (res && res.ok) {
|
||||
setNavMsg("Router starting (waiting for API & tunnels)...");
|
||||
} else {
|
||||
setNavMsg(`Failed to start router: ${(res && res.error) || "unavailable"}`, true);
|
||||
}
|
||||
setTimeout(() => refreshStatus(), 700);
|
||||
});
|
||||
|
||||
$("copy-b32-btn").addEventListener("click", async () => {
|
||||
if (!currentB32) {
|
||||
setNavMsg("Router has not published a .b32.i2p address yet.", true);
|
||||
return;
|
||||
}
|
||||
const btn = $("copy-b32-btn");
|
||||
const ok = await copyTextToClipboard(currentB32);
|
||||
if (ok) {
|
||||
btn.textContent = "Copied!";
|
||||
if (copyTimer) clearTimeout(copyTimer);
|
||||
copyTimer = setTimeout(() => {
|
||||
btn.textContent = "Copy .b32";
|
||||
copyTimer = null;
|
||||
}, 1500);
|
||||
} else {
|
||||
setNavMsg("Clipboard copy blocked by browser.", true);
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
if (!document.hidden) {
|
||||
refreshStatus();
|
||||
}
|
||||
});
|
||||
|
||||
refreshStatus();
|
||||
setInterval(() => refreshStatus(), 2000);
|
||||
});
|
||||
}
|
||||
+19
-18
@@ -5,7 +5,7 @@ Bundles:
|
||||
- Official Mozilla Firefox ESR (x86_64)
|
||||
- Native moon-i2p router (--public, HTTP proxy, BitTorrent + I2P DHT API)
|
||||
- Pre-installed moon-i2p-torrent@local Firefox WebExtension & Native Messaging host
|
||||
- Pre-configured homepage http://insulaocculta.i2p/, I2P PAC routing, and HTTPS-First disabled for .i2p
|
||||
- Pre-configured Moon I2P Start Page, I2P PAC routing, and HTTPS-First disabled for .i2p
|
||||
"""
|
||||
|
||||
import json
|
||||
@@ -105,7 +105,6 @@ def write_firefox_configs(firefox_dir: Path):
|
||||
'pref("extensions.sideloadScopes", 15);\n'
|
||||
'pref("extensions.startupScanScopes", 15);\n'
|
||||
'pref("extensions.installDistroAddons", true);\n'
|
||||
'defaultPref("browser.startup.homepage", "http://insulaocculta.i2p/");\n'
|
||||
'defaultPref("browser.startup.page", 1);\n'
|
||||
'defaultPref("dom.security.https_only_mode", false);\n'
|
||||
'defaultPref("dom.security.https_only_mode_pbm", false);\n'
|
||||
@@ -126,11 +125,6 @@ def write_firefox_configs(firefox_dir: Path):
|
||||
dist_dir.mkdir(parents=True, exist_ok=True)
|
||||
policies = {
|
||||
"policies": {
|
||||
"Homepage": {
|
||||
"URL": "http://insulaocculta.i2p/",
|
||||
"StartPage": "homepage",
|
||||
"Locked": False,
|
||||
},
|
||||
"OverrideFirstRunPage": "",
|
||||
"OverridePostUpdatePage": "",
|
||||
"DontCheckDefaultBrowser": True,
|
||||
@@ -140,6 +134,16 @@ def write_firefox_configs(firefox_dir: Path):
|
||||
"DisableFirefoxStudies": True,
|
||||
"DNSOverHTTPS": {"Enabled": False},
|
||||
"Bookmarks": [
|
||||
{
|
||||
"Title": "NotBob Directory",
|
||||
"URL": "http://notbob.i2p/",
|
||||
"Placement": "toolbar",
|
||||
},
|
||||
{
|
||||
"Title": "Postman Tracker",
|
||||
"URL": "http://tracker2.postman.i2p/",
|
||||
"Placement": "toolbar",
|
||||
},
|
||||
{
|
||||
"Title": "Insula Occulta",
|
||||
"URL": "http://insulaocculta.i2p/",
|
||||
@@ -155,16 +159,6 @@ def write_firefox_configs(firefox_dir: Path):
|
||||
"URL": "http://zzz.i2p/",
|
||||
"Placement": "toolbar",
|
||||
},
|
||||
{
|
||||
"Title": "Postman Tracker",
|
||||
"URL": "http://tracker2.postman.i2p/",
|
||||
"Placement": "toolbar",
|
||||
},
|
||||
{
|
||||
"Title": "NotBob Directory",
|
||||
"URL": "http://notbob.i2p/",
|
||||
"Placement": "toolbar",
|
||||
},
|
||||
],
|
||||
"ExtensionSettings": {
|
||||
"moon-i2p-torrent@local": {
|
||||
@@ -321,7 +315,6 @@ function FindProxyForURL(url, host) {
|
||||
EOF
|
||||
|
||||
cat > "$PROFILE_DIR/user.js" <<EOF
|
||||
user_pref("browser.startup.homepage", "http://insulaocculta.i2p/");
|
||||
user_pref("browser.startup.page", 1);
|
||||
user_pref("network.proxy.type", 2);
|
||||
user_pref("network.proxy.autoconfig_url", "file://$PROFILE_DIR/i2p.pac");
|
||||
@@ -339,6 +332,14 @@ user_pref("network.captive-portal-service.enabled", false);
|
||||
user_pref("browser.shell.checkDefaultBrowser", false);
|
||||
EOF
|
||||
|
||||
# One-time migration: clear only the legacy insulaocculta.i2p default from prefs.js
|
||||
# so the extension's Start Page takes over without touching any custom homepage.
|
||||
if [[ -f "$PROFILE_DIR/prefs.js" ]] && grep -Fqx 'user_pref("browser.startup.homepage", "http://insulaocculta.i2p/");' "$PROFILE_DIR/prefs.js"; then
|
||||
PREFS_TMP="$PROFILE_DIR/prefs.js.tmp.$$"
|
||||
grep -Fvx 'user_pref("browser.startup.homepage", "http://insulaocculta.i2p/");' "$PROFILE_DIR/prefs.js" > "$PREFS_TMP" || true
|
||||
mv -f "$PREFS_TMP" "$PROFILE_DIR/prefs.js"
|
||||
fi
|
||||
|
||||
ROUTER_BIN="$APPDIR/usr/bin/moon-i2p-router"
|
||||
ROUTER_PID=""
|
||||
FF_PID=""
|
||||
|
||||
Reference in new issue
Block a user