Add manual alternate radio forwarding paths with profile recovery
This commit is contained in:
1 parent
7b5be2b9f0
commit
bf8c3a5146
9 files changed
+120
-13
No files matched your search
+6
-2
@@ -4,6 +4,7 @@ import http from 'node:http';
|
||||
import {Journal} from './journal.mjs';
|
||||
import {GatewayDirectory,modemFamily} from './winlink-gateways.mjs';
|
||||
import {WinlinkRadio} from './winlink-radio.mjs';
|
||||
import {ManualForwarding} from './manual-forwarding.mjs';
|
||||
import {forwardingHistory} from './forwarding.mjs';
|
||||
import {Forwarding} from './forwarding.mjs';
|
||||
import {SevenPlus} from './sevenplus.mjs';
|
||||
@@ -75,6 +76,8 @@ const forwarding=new Forwarding(config,bpq,()=>telemetry.current);
|
||||
const gatewayDirectory=new GatewayDirectory(config,dir);
|
||||
const winlinkRadio=new WinlinkRadio(config,dir,forwarding,gatewayDirectory);
|
||||
await winlinkRadio.init;
|
||||
const manualForwarding=new ManualForwarding(config,dir,forwarding);
|
||||
await manualForwarding.init;
|
||||
async function syncNow(peer=config.forwardPeer){if(!config.features.bbs)throw new Error('BBS non configurata');return forwarding.start(peer);}
|
||||
const timestampCache=new Map();
|
||||
async function messageTimes(id){if(timestampCache.has(id))return timestampCache.get(id);const pending=(async()=>{const f=await messageFields(id);let reference=new Date();try{reference=(await stat(path.join(root,'BPQMailChat','Mail','m_'+String(id).padStart(6,'0')+'.mes'))).mtime;}catch{}const receivedAt=bpqTimestamp(f.RX,reference);return {receivedAt,createdAt:bpqTimestamp(f.Sent,receivedAt?new Date(receivedAt):reference)};})().catch(()=>{timestampCache.delete(id);return {receivedAt:null,createdAt:null};});timestampCache.set(id,pending);return pending;}
|
||||
@@ -137,8 +140,9 @@ const server=http.createServer(async(req,res)=>{
|
||||
if(url.pathname==='/api/logout'&&req.method==='POST'){const token=req.headers.cookie.match(/alnode=([a-f0-9]+)/)?.[1];user.terminal?.close();sessions.delete(token);res.setHeader('Set-Cookie','alnode=; HttpOnly; SameSite=Strict; Path=/; Max-Age=0');json(res,200,{ok:true});return;}
|
||||
if(url.pathname==='/api/journal'&&req.method==='GET'){json(res,200,await journal.snapshot());return;}
|
||||
if(url.pathname==='/api/stations/location'&&req.method==='POST'){const data=await body(req);json(res,200,await journal.saveLocation(String(data.call||''),String(data.locator||'')));return;}
|
||||
if(url.pathname==='/api/forwarding'&&req.method==='GET'){json(res,200,await forwarding.snapshot());return;}
|
||||
const fwdStart=url.pathname.match(/^\/api\/forwarding\/([A-Z0-9-]{1,12})\/sync$/);if(fwdStart&&req.method==='POST'){json(res,200,await forwarding.start(fwdStart[1]));return;}
|
||||
if(url.pathname==='/api/forwarding'&&req.method==='GET'){const data=await forwarding.snapshot();json(res,200,{...data,manualSession:manualForwarding.snapshot(),profiles:[...data.profiles,...manualForwarding.profiles(data.profiles)]});return;}
|
||||
if(url.pathname==='/api/forwarding/manual/restore'&&req.method==='POST'){json(res,200,await manualForwarding.restore());return;}
|
||||
const fwdStart=url.pathname.match(/^\/api\/forwarding\/([A-Z0-9-]{1,32})\/sync$/);if(fwdStart&&req.method==='POST'){const peer=fwdStart[1];json(res,200,manualForwarding.routes.some(r=>r.id===peer)?await manualForwarding.startRoute(peer):await forwarding.start(peer));return;}
|
||||
if(url.pathname==='/api/dashboard'){json(res,200,await dashboard());return;}
|
||||
if(url.pathname==='/api/telemetry'&&req.method==='GET'){json(res,200,telemetry);return;}
|
||||
if(url.pathname==='/api/messages'&&req.method==='GET'){json(res,200,await messages());return;}
|
||||
|
||||
Reference in new issue
Block a user