v1.0.2 #2

Merged
thepetric merged 2 commits from v1.0.2 into main 2025-11-11 14:49:07 +00:00
Showing only changes of commit 570d527309 - Show all commits

View File

@@ -22,7 +22,6 @@ auth_require();
Tor Relay Panel Tor Relay Panel
</span> </span>
<div class="ms-auto d-flex align-items-center gap-2"> <div class="ms-auto d-flex align-items-center gap-2">
<!-- NEW: Tor Log button -->
<button id="btnTorLog" class="btn btn-sm btn-outline-light">View Tor Log</button> <button id="btnTorLog" class="btn btn-sm btn-outline-light">View Tor Log</button>
<button id="btnTheme" class="btn btn-sm btn-outline-light">Theme</button> <button id="btnTheme" class="btn btn-sm btn-outline-light">Theme</button>
<a class="btn btn-sm btn-outline-light" href="/logout.php">Logout</a> <a class="btn btn-sm btn-outline-light" href="/logout.php">Logout</a>
@@ -391,29 +390,41 @@ async function refreshChart(){
setChartData(labels, rx, tx); setChartData(labels, rx, tx);
} }
async function loadReach(){
const r = await fetch('api/reach.php');
const j = await r.json();
if (!j.ok) return;
if (el.reachNick) el.reachNick.textContent = j.nickname || '—';
if (el.reachFP) el.reachFP.textContent = j.fingerprint || '—';
if (el.reachPort) el.reachPort.textContent = j.orport || '—';
if (el.reachLAN) el.reachLAN.textContent = j.lan_ip || '—';
if (el.hintPort) el.hintPort.textContent = j.orport || '—';
if (el.hintLAN) el.hintLAN.textContent = j.lan_ip || '—';
if (el.reachAddr) el.reachAddr.textContent = j.tor_address || '—';
let flagStr = '—', seenStr = '—'; async function loadReach(){
if (j.onionoo && j.onionoo.found) { try{
flagStr = (j.onionoo.flags || []).join(', ') || '—'; const r = await fetch('api/reach.php', {cache:'no-store'});
if (j.onionoo.last_seen) seenStr = 'Last seen: ' + new Date(j.onionoo.last_seen).toLocaleString(); const j = await r.json();
if (!j.ok) return false;
if (el.reachNick) el.reachNick.textContent = j.nickname || '—';
if (el.reachFP) el.reachFP.textContent = j.fingerprint || '—';
if (el.reachPort) el.reachPort.textContent = j.orport || '—';
if (el.reachLAN) el.reachLAN.textContent = j.lan_ip || '—';
if (el.hintPort) el.hintPort.textContent = j.orport || '—';
if (el.hintLAN) el.hintLAN.textContent = j.lan_ip || '—';
if (el.reachAddr) el.reachAddr.textContent = j.tor_address || '—';
let flagStr = '—', seenStr = '—';
if (j.onionoo && j.onionoo.found) {
flagStr = (j.onionoo.flags || []).join(', ') || '—';
if (j.onionoo.last_seen) seenStr = 'Last seen: ' + new Date(j.onionoo.last_seen).toLocaleString();
}
const running = !!(j.onionoo && j.onionoo.running);
if (el.reachBadge){
el.reachBadge.textContent = running ? 'Running (publicly reachable)' : (j.onionoo && j.onionoo.found ? 'Not Running yet' : 'Not in consensus yet');
el.reachBadge.className = 'badge ' + (running ? 'bg-success' : (j.onionoo && j.onionoo.found ? 'bg-warning' : 'bg-danger'));
el.reachBadge.title = 'Last checked: ' + new Date().toLocaleString();
}
if (el.reachFlags) el.reachFlags.textContent = flagStr;
if (el.reachSeen) el.reachSeen.textContent = seenStr;
if (el.reachHelp) el.reachHelp.style.display = running ? 'none' : 'block';
return running;
}catch(e){
return false;
} }
const running = !!(j.onionoo && j.onionoo.running);
if (el.reachBadge){
el.reachBadge.textContent = running ? 'Running (publicly reachable)' : (j.onionoo && j.onionoo.found ? 'Not Running yet' : 'Not in consensus yet');
el.reachBadge.className = 'badge ' + (running ? 'bg-success' : (j.onionoo && j.onionoo.found ? 'bg-warning' : 'bg-danger'));
}
if (el.reachHelp) el.reachHelp.style.display = running ? 'none' : 'block';
} }
if (el.btnEditCfg){ if (el.btnEditCfg){
@@ -454,6 +465,26 @@ if (el.cfgForm){
}); });
} }
if (el.reachRefresh){
el.reachRefresh.addEventListener('click', async ()=>{
const btn = el.reachRefresh;
const originalClasses = btn.className;
btn.disabled = true;
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-1" role="status" aria-hidden="true"></span>Checking…';
const running = await loadReach();
btn.className = running ? 'btn btn-sm btn-success' : 'btn btn-sm btn-danger';
btn.innerHTML = running ? 'Reachable ✓' : 'Not reachable ✗';
setTimeout(()=>{
btn.className = originalClasses;
btn.innerHTML = 'Check status';
btn.disabled = false;
}, 1500);
});
}
(function initTheme(){ (function initTheme(){
const t = preferredTheme(); const t = preferredTheme();
document.documentElement.setAttribute('data-theme', t); document.documentElement.setAttribute('data-theme', t);