Verify packet PTT readiness and isolate manual VHF forwarding status

This commit is contained in:
alberto committed 2026-10-17 00:54:46 +02:00
1 parent 9bb62cf731
commit abfc8be078
7 files changed
+16 -7

No files matched your search

+2
View File
@@ -193,3 +193,5 @@ Tests cover protocol parsing, mail/attachments, journal, gateway validation, pro
- **Script/task policy blocks execution:** review the files and your Windows policy; organisation restrictions cannot be overridden by the installer. - **Script/task policy blocks execution:** review the files and your Windows policy; organisation restrictions cannot be overridden by the installer.
Third-party PDF.js, font and CMap licences are retained under `public/vendor/pdfjs`; map attribution is in `public/WORLD-MAP-LICENSE.txt`. Third-party PDF.js, font and CMap licences are retained under `public/vendor/pdfjs`; map attribution is in `public/WORLD-MAP-LICENSE.txt`.
Packet controller integrations must acknowledge a reserved slot with `pttReady: true`, after checking that their BPQ PTT backend responds. A modem TCP connection alone is insufficient. The slot status must also contain the matching request ID, frequency, VHF phase and a fresh timestamp. Manual alternate routes share the partner queue; their native HF row is reserved during use and is not counted as a second active session.
+2 -1
View File
@@ -2,7 +2,7 @@ import {readFile,writeFile,rename,mkdir,copyFile} from 'node:fs/promises';
import path from 'node:path'; import path from 'node:path';
import {reservePacketSlot,releasePacketSlot} from './radio-slot.mjs'; import {reservePacketSlot,releasePacketSlot} from './radio-slot.mjs';
import {WinlinkRadio,rawProfile,activeMailStreams} from './winlink-radio.mjs'; import {WinlinkRadio,rawProfile,activeMailStreams} from './winlink-radio.mjs';
import {safeScript} from './forwarding.mjs'; import {safeScript,parseForwarding} from './forwarding.mjs';
export function manualRoutes(config){ export function manualRoutes(config){
const ids=new Set();return (config.manualForwardingRoutes||[]).map(route=>{ const ids=new Set();return (config.manualForwardingRoutes||[]).map(route=>{
if(!/^[A-Z0-9-]{1,32}$/.test(route.id)||route.id===route.peer||ids.has(route.id)||! /^[A-Z0-9]{1,6}$/.test(route.peer)||! /^[A-Z0-9]{3,7}(?:-\d{1,2})?$/.test(route.connectCall)||!Number.isFinite(route.frequencyMHz)||route.frequencyMHz<1||route.frequencyMHz>500||! /^(USB|LSB|FM|DATA-FM)$/.test(route.mode)||!config.ports.some(p=>p.id===route.port&&!/TELNET|AXIP/i.test(p.driver)))throw Error('Percorso manuale di forwarding non valido'); if(!/^[A-Z0-9-]{1,32}$/.test(route.id)||route.id===route.peer||ids.has(route.id)||! /^[A-Z0-9]{1,6}$/.test(route.peer)||! /^[A-Z0-9]{3,7}(?:-\d{1,2})?$/.test(route.connectCall)||!Number.isFinite(route.frequencyMHz)||route.frequencyMHz<1||route.frequencyMHz>500||! /^(USB|LSB|FM|DATA-FM)$/.test(route.mode)||!config.ports.some(p=>p.id===route.port&&!/TELNET|AXIP/i.test(p.driver)))throw Error('Percorso manuale di forwarding non valido');
@@ -17,6 +17,7 @@ export class ManualForwarding extends WinlinkRadio{
profiles(native){return this.routes.flatMap(route=>{const p=native.find(p=>p.call===route.peer);if(!p)return [];const j=this.job?.channel?.id===route.id?this.job:null;const history=j?p.history.filter(s=>Date.parse(s.startedAt)>=Date.parse(j.startedAt)-1500&&(!j.endedAt||Date.parse(s.startedAt)<=Date.parse(j.endedAt))):[];return [{...p,call:route.id,label:route.label,peer:route.peer,manualOnly:true,enabled:false,interval:0,immediate:false,reverseInterval:0,times:[],configured:true,port:route.port,driver:this.config.ports.find(p=>p.id===route.port)?.driver||'',transport:'Radio',frequency:[String(route.frequencyMHz),route.mode],script:safeScript(route.script),history,last:history[0]||null,active:Boolean(j?.restoring),preparing:j?.state==='preparing',requestedAt:j?.startedAt||null,nextEstimated:null}];});} profiles(native){return this.routes.flatMap(route=>{const p=native.find(p=>p.call===route.peer);if(!p)return [];const j=this.job?.channel?.id===route.id?this.job:null;const history=j?p.history.filter(s=>Date.parse(s.startedAt)>=Date.parse(j.startedAt)-1500&&(!j.endedAt||Date.parse(s.startedAt)<=Date.parse(j.endedAt))):[];return [{...p,call:route.id,label:route.label,peer:route.peer,manualOnly:true,enabled:false,interval:0,immediate:false,reverseInterval:0,times:[],configured:true,port:route.port,driver:this.config.ports.find(p=>p.id===route.port)?.driver||'',transport:'Radio',frequency:[String(route.frequencyMHz),route.mode],script:safeScript(route.script),history,last:history[0]||null,active:Boolean(j?.restoring),preparing:j?.state==='preparing',requestedAt:j?.startedAt||null,nextEstimated:null}];});}
async prepare(route){await reservePacketSlot(this,route.controller,route.frequencyMHz,route.port);} async prepare(route){await reservePacketSlot(this,route.controller,route.frequencyMHz,route.port);}
async release(){await releasePacketSlot(this);} async release(){await releasePacketSlot(this);}
displayProfiles(native){const j=this.job;const base=native.map(p=>{if(!j||j.peer!==p.call)return p;const history=p.history.filter(s=>!(Date.parse(s.startedAt)>=Date.parse(j.startedAt)-1500&&(!j.endedAt||Date.parse(s.startedAt)<=Date.parse(j.endedAt))));const original=parseForwarding('BBSForwarding : { '+p.call+' : { '+Object.entries(j.original||{}).map(([k,v])=>k+' = "'+String(v).replaceAll('"','')+'";').join(' ')+' } }',this.config.ports)[0];return {...p,...(j.restoring?original:{}),history,last:history[0]||null,active:j.restoring?false:p.active,reservedBy:j.restoring?j.channel.id:null};});return [...base,...this.profiles(native)];}
async startRoute(id){await this.init;return this.fwd.exclusive(async()=>{ async startRoute(id){await this.init;return this.fwd.exclusive(async()=>{
const route=this.routes.find(r=>r.id===id);if(!route)throw Error('Percorso manuale non configurato'); const route=this.routes.find(r=>r.id===id);if(!route)throw Error('Percorso manuale non configurato');
if(this.job?.restoring||this.fwd.lockedPeers.has(route.peer))throw Error('Un inoltro per questo partner è già in corso'); if(this.job?.restoring||this.fwd.lockedPeers.has(route.peer))throw Error('Un inoltro per questo partner è già in corso');
+6
View File
@@ -37,3 +37,9 @@ test('manual forwarding shares the queue, disables timers only during use and re
assert.equal(client.job.restoring,false);assert.deepEqual(rawProfile(await readFile(file,'utf8'),'N0TEST'),original);assert.equal(fw.lockedPeers.has('N0TEST'),false); assert.equal(client.job.restoring,false);assert.deepEqual(rawProfile(await readFile(file,'utf8'),'N0TEST'),original);assert.equal(fw.lockedPeers.has('N0TEST'),false);
}finally{clearInterval(client.timer);await rm(dir,{recursive:true,force:true});} }finally{clearInterval(client.timer);await rm(dir,{recursive:true,force:true});}
}); });
test('a manual VHF session occupies one route and reserves its HF partner',()=>{
const client={job:{peer:'N0TEST',channel:{id:'N0TEST-VHF'},original,startedAt:'2026-10-16T22:00:00Z',restoring:true},config:{ports:[{id:1,driver:'VARA'}]},profiles:()=>[{call:'N0TEST-VHF',active:true}]};
const rows=ManualForwarding.prototype.displayProfiles.call(client,[{call:'N0TEST',active:true,history:[{startedAt:'2026-10-16T22:00:01Z'}]}]);
assert.equal(rows.filter(p=>p.active).length,1);assert.equal(rows[0].port,1);assert.equal(rows[0].reservedBy,'N0TEST-VHF');assert.equal(rows[0].history.length,0);
});
+3 -3
View File
@@ -10,9 +10,9 @@ const rules=(values,kind)=>!values.length?'Nessuna regola esplicita':values.incl
const bands=p=>p.times.length?p.times.map(t=>t.replace(/^(\d{2})(\d{2})-(\d{2})(\d{2})$/,'$1:$2–$3:$4')).join(' · '):'00:00–23:59'; const bands=p=>p.times.length?p.times.map(t=>t.replace(/^(\d{2})(\d{2})-(\d{2})(\d{2})$/,'$1:$2–$3:$4')).join(' · '):'00:00–23:59';
function render(){if(!data)return;$('#forward-restore').hidden=!(data.manualSession?.restoring&&data.manualSession?.error);const focused=document.activeElement,focusPeer=focused.closest?.('[data-forward-row]')?.dataset.forwardRow,focusKind=focused.matches?.('[data-forward-start]')?'[data-forward-start]':focused.matches?.('.forward-toggle')?'.forward-toggle':null;const profiles=[...data.profiles].sort((a,b)=>Number(b.enabled&&b.configured)-Number(a.enabled&&a.configured)||Number(b.transport==='Radio')-Number(a.transport==='Radio')||a.call.localeCompare(b.call)),total=profiles.reduce((a,p)=>a+(p.manualOnly?0:p.queued||0),0);$('#forward-summary').innerHTML=[['Percorsi',profiles.length],['Automatici',profiles.filter(p=>p.enabled&&p.configured).length],['Messaggi in coda',total+(profiles.some(p=>p.queued===null)?' + ?':'')],['Sessioni attive',profiles.filter(p=>p.active).length]].map(([label,n])=>'<div><span>'+label+'</span><strong>'+n+'</strong></div>').join('');const errors=[...data.errors,...(data.manualSession?.error?[data.manualSession.error]:[])];$('#forward-error').hidden=!errors.length;$('#forward-error').textContent=errors.join(' · ');$('#forward-updated').textContent='Aggiornato '+time(data.updatedAt)+' · '+mailTimezone(); function render(){if(!data)return;$('#forward-restore').hidden=!(data.manualSession?.restoring&&data.manualSession?.error);const focused=document.activeElement,focusPeer=focused.closest?.('[data-forward-row]')?.dataset.forwardRow,focusKind=focused.matches?.('[data-forward-start]')?'[data-forward-start]':focused.matches?.('.forward-toggle')?'.forward-toggle':null;const profiles=[...data.profiles].sort((a,b)=>Number(b.enabled&&b.configured)-Number(a.enabled&&a.configured)||Number(b.transport==='Radio')-Number(a.transport==='Radio')||a.call.localeCompare(b.call)),total=profiles.reduce((a,p)=>a+(p.manualOnly?0:p.queued||0),0);$('#forward-summary').innerHTML=[['Percorsi',profiles.length],['Automatici',profiles.filter(p=>p.enabled&&p.configured).length],['Messaggi in coda',total+(profiles.some(p=>p.queued===null)?' + ?':'')],['Sessioni attive',profiles.filter(p=>p.active).length]].map(([label,n])=>'<div><span>'+label+'</span><strong>'+n+'</strong></div>').join('');const errors=[...data.errors,...(data.manualSession?.error?[data.manualSession.error]:[])];$('#forward-error').hidden=!errors.length;$('#forward-error').textContent=errors.join(' · ');$('#forward-updated').textContent='Aggiornato '+time(data.updatedAt)+' · '+mailTimezone();
$('#forward-partners').innerHTML='<div class="card forward-table-wrap"><table class="forward-table"><thead><tr><th>Partner / percorso</th><th>Stato</th><th>Coda</th><th>Ultimo scambio</th><th>TX / RX</th><th>Programmazione</th><th>Prossimo · stima</th><th>Azioni</th></tr></thead><tbody>'+profiles.map(p=>{ $('#forward-partners').innerHTML='<div class="card forward-table-wrap"><table class="forward-table"><thead><tr><th>Partner / percorso</th><th>Stato</th><th>Coda</th><th>Ultimo scambio</th><th>TX / RX</th><th>Programmazione</th><th>Prossimo · stima</th><th>Azioni</th></tr></thead><tbody>'+profiles.map(p=>{
const requested=pending.get(p.call),requestWaiting=requested&&Date.now()-requested<30000,blocked=p.active||requestWaiting||(p.transport==='Radio'&&(data.radio?.active||data.radio?.connecting)),last=p.last; const requested=pending.get(p.call),requestWaiting=requested&&Date.now()-requested<30000,blocked=p.reservedBy||p.active||requestWaiting||(p.transport==='Radio'&&(data.radio?.active||data.radio?.connecting)),last=p.last;
const status=p.active?(p.preparing?'Preparazione radio':state(last?.status)):requestWaiting?'Richiesta inviata':!p.configured?'Non configurato':p.manualOnly?'Solo manuale':p.enabled?'Automatico':'Disattivato'; const status=p.reservedBy?'Riservato al percorso VHF':p.active?(p.preparing?'Preparazione radio':state(last?.status)):requestWaiting?'Richiesta inviata':!p.configured?'Non configurato':p.manualOnly?'Solo manuale':p.enabled?'Automatico':'Disattivato';
const next=p.active?'Sessione in corso':p.manualOnly?'Solo su richiesta':!p.enabled?'Automatico disattivo':!p.configured?'Script assente':p.nextEstimated?time(p.nextEstimated):!p.reverse&&p.queued===0?'In attesa di messaggi':'Timer non disponibile'; const next=p.reservedBy?'Attende fine percorso VHF':p.active?'Sessione in corso':p.manualOnly?'Solo su richiesta':!p.enabled?'Automatico disattivo':!p.configured?'Script assente':p.nextEstimated?time(p.nextEstimated):!p.reverse&&p.queued===0?'In attesa di messaggi':'Timer non disponibile';
const isOpen=expanded===p.call; const isOpen=expanded===p.call;
return `<tr class="forward-row ${isOpen?'expanded':''}" data-forward-row="${esc(p.call)}" tabindex="0" aria-expanded="${isOpen}"><td><button class="forward-toggle" aria-expanded="${isOpen}" aria-controls="forward-detail-${esc(p.call)}" aria-label="Dettagli ${esc(p.call)}"><span class="forward-chevron" aria-hidden="true">›</span><span><b>${esc(p.label||p.call)}</b><small>${esc(p.transport)}${p.driver?' · '+esc(p.driver):''}</small></span></button></td><td><span class="forward-status ${p.active?'live':!p.configured?'muted':''}">${esc(status)}</span></td><td class="forward-queue">${p.queued??'—'}</td><td>${esc(time(last?.startedAt).replace(/:\d{2}$/,''))}<small class="forward-outcome ${last?.status==='failed'?'failed':''}">${esc(last?state(last.status):'Nessuna sessione recente')}</small></td><td>${last?last.sent+' / '+last.received:'—'}</td><td>${p.manualOnly?'Solo manuale':esc(interval(p.interval))}<small>${p.manualOnly?esc(p.frequency.join(' MHz ')):esc(bands(p))+' · '+(p.timesLocal?'locale BPQ':'UTC')}</small></td><td>${esc(next)}<small>${p.nextEstimated?esc(mailTimezone()):''}</small></td><td class="forward-sync-cell"><button class="secondary" data-forward-start="${esc(p.call)}" ${!p.configured||blocked?'disabled':''}>${p.active?'In corso':requestWaiting?'Richiesta inviata…':p.manualOnly?'Avvia manualmente':'↻ Sincronizza ora'}</button>${p.transport==='Radio'&&(data.radio?.active||data.radio?.connecting)&&!p.active?'<small>Modem impegnato</small>':''}<span class="forward-feedback" role="status" data-feedback="${esc(p.call)}"></span></td></tr><tr class="forward-detail-row" ${isOpen?'':'hidden'}><td colspan="8"><div id="forward-detail-${esc(p.call)}" role="region" aria-label="Dettagli ${esc(p.call)}" class="forward-details">${isOpen?details(p):''}</div></td></tr>`; return `<tr class="forward-row ${isOpen?'expanded':''}" data-forward-row="${esc(p.call)}" tabindex="0" aria-expanded="${isOpen}"><td><button class="forward-toggle" aria-expanded="${isOpen}" aria-controls="forward-detail-${esc(p.call)}" aria-label="Dettagli ${esc(p.call)}"><span class="forward-chevron" aria-hidden="true">›</span><span><b>${esc(p.label||p.call)}</b><small>${esc(p.transport)}${p.driver?' · '+esc(p.driver):''}</small></span></button></td><td><span class="forward-status ${p.active?'live':!p.configured?'muted':''}">${esc(status)}</span></td><td class="forward-queue">${p.queued??'—'}</td><td>${esc(time(last?.startedAt).replace(/:\d{2}$/,''))}<small class="forward-outcome ${last?.status==='failed'?'failed':''}">${esc(last?state(last.status):'Nessuna sessione recente')}</small></td><td>${last?last.sent+' / '+last.received:'—'}</td><td>${p.manualOnly?'Solo manuale':esc(interval(p.interval))}<small>${p.manualOnly?esc(p.frequency.join(' MHz ')):esc(bands(p))+' · '+(p.timesLocal?'locale BPQ':'UTC')}</small></td><td>${esc(next)}<small>${p.nextEstimated?esc(mailTimezone()):''}</small></td><td class="forward-sync-cell"><button class="secondary" data-forward-start="${esc(p.call)}" ${!p.configured||blocked?'disabled':''}>${p.active?'In corso':requestWaiting?'Richiesta inviata…':p.manualOnly?'Avvia manualmente':'↻ Sincronizza ora'}</button>${p.transport==='Radio'&&(data.radio?.active||data.radio?.connecting)&&!p.active?'<small>Modem impegnato</small>':''}<span class="forward-feedback" role="status" data-feedback="${esc(p.call)}"></span></td></tr><tr class="forward-detail-row" ${isOpen?'':'hidden'}><td colspan="8"><div id="forward-detail-${esc(p.call)}" role="region" aria-label="Dettagli ${esc(p.call)}" class="forward-details">${isOpen?details(p):''}</div></td></tr>`;
}).join('')+'</tbody></table>'+(!profiles.length?'<p class="empty">Nessun partner di forwarding configurato in BPQ.</p>':'')+'</div>'; }).join('')+'</tbody></table>'+(!profiles.length?'<p class="empty">Nessun partner di forwarding configurato in BPQ.</p>':'')+'</div>';
+1 -1
View File
@@ -5,7 +5,7 @@ export async function reservePacketSlot(client,controller,frequencyMHz,port){
const request={id:randomUUID(),frequencyMHz,expiresAt:Date.now()+90000};client.job.controller={...controller,id:request.id};await client.persist(); const request={id:randomUUID(),frequencyMHz,expiresAt:Date.now()+90000};client.job.controller={...controller,id:request.id};await client.persist();
await writeFile(controller.requestFile+'.tmp',JSON.stringify(request));await rename(controller.requestFile+'.tmp',controller.requestFile); await writeFile(controller.requestFile+'.tmp',JSON.stringify(request));await rename(controller.requestFile+'.tmp',controller.requestFile);
const deadline=Date.now()+65000; const deadline=Date.now()+65000;
while(Date.now()<deadline){try{const state=JSON.parse(await readFile(controller.statusFile,'utf8'));if(state.manualRequestId===request.id&&state.phase==='vhf'&&Math.abs(Number(state.frequency)-frequencyMHz)<0.0001&&Date.now()-Date.parse(state.at)<5000){const html=await client.fwd.bpq('/Node/Port?'+port);if(/Connected to TNC/.test(html)&&/1200bd/.test(html))return;}}catch{}await new Promise(resolve=>setTimeout(resolve,300));} while(Date.now()<deadline){try{const state=JSON.parse(await readFile(controller.statusFile,'utf8'));if(state.manualRequestId===request.id&&state.phase==='vhf'&&state.pttReady===true&&Math.abs(Number(state.frequency)-frequencyMHz)<0.0001&&Date.now()-Date.parse(state.at)<5000){const html=await client.fwd.bpq('/Node/Port?'+port);if(/Connected to TNC/.test(html)&&/1200bd/.test(html))return;}}catch{}await new Promise(resolve=>setTimeout(resolve,300));}
throw Error('Modem packet non pronto: nessuna chiamata avviata'); throw Error('Modem packet non pronto: nessuna chiamata avviata');
} }
export async function releasePacketSlot(client){ export async function releasePacketSlot(client){
+1 -1
View File
@@ -143,7 +143,7 @@ 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/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/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/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'){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'&&req.method==='GET'){const data=await forwarding.snapshot();json(res,200,{...data,manualSession:manualForwarding.snapshot(),profiles:manualForwarding.displayProfiles(data.profiles)});return;}
if(url.pathname==='/api/forwarding/manual/restore'&&req.method==='POST'){json(res,200,await manualForwarding.restore());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;} 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/dashboard'){json(res,200,await dashboard());return;}
+1 -1
View File
@@ -25,7 +25,7 @@ test('directory merges independent HF and Packet downloads and marks incompatibl
test('packet controller reservation verifies acknowledgement and releases its own request',async()=>{ test('packet controller reservation verifies acknowledgement and releases its own request',async()=>{
const dir=await mkdtemp(path.join(os.tmpdir(),'wl-slot-'));const controller={requestFile:path.join(dir,'request.json'),statusFile:path.join(dir,'status.json')};const urls=[]; const dir=await mkdtemp(path.join(os.tmpdir(),'wl-slot-'));const controller={requestFile:path.join(dir,'request.json'),statusFile:path.join(dir,'status.json')};const urls=[];
const client={job:{},persist:async()=>writeFile(controller.statusFile,JSON.stringify({manualRequestId:client.job.controller.id,phase:'vhf',frequency:'433.750',at:new Date().toISOString()})),fwd:{bpq:async url=>{urls.push(url);return 'Connected to TNC AFSK AX.25 1200bd';}}}; const client={job:{},persist:async()=>writeFile(controller.statusFile,JSON.stringify({manualRequestId:client.job.controller.id,phase:'vhf',pttReady:true,frequency:'433.750',at:new Date().toISOString()})),fwd:{bpq:async url=>{urls.push(url);return 'Connected to TNC AFSK AX.25 1200bd';}}};
try{await reservePacketSlot(client,controller,433.750,3);assert.deepEqual(urls,['/Node/Port?3']);const request=JSON.parse(await readFile(controller.requestFile));assert.equal(request.frequencyMHz,433.750);assert.ok(request.expiresAt>Date.now());await releasePacketSlot(client);assert.equal(JSON.parse(await readFile(controller.requestFile)).expiresAt,0);}finally{await rm(dir,{recursive:true,force:true});} try{await reservePacketSlot(client,controller,433.750,3);assert.deepEqual(urls,['/Node/Port?3']);const request=JSON.parse(await readFile(controller.requestFile));assert.equal(request.frequencyMHz,433.750);assert.ok(request.expiresAt>Date.now());await releasePacketSlot(client);assert.equal(JSON.parse(await readFile(controller.requestFile)).expiresAt,0);}finally{await rm(dir,{recursive:true,force:true});}
}); });
test('temporary RMS profile preserves routing, disables timers and never overrides busy channel',()=>{const p=radioProfile(original,channel,3);assert.equal(p.Enabled,'0');assert.equal(p.ConnectScript,'ATTACH 3|RADIO 14.122000 USB|PAUSE 2|C N0TEST');assert.ok(!p.ConnectScript.includes('OVERRIDEBUSY'));assert.equal(p.UseB2Protocol,'1');assert.equal(p.HRoutes,original.HRoutes);assert.equal(p.TOCalls,original.TOCalls);assert.deepEqual(rawProfile(configText(original),'RMS'),original);assert.equal(profilePayload(original).split('|').length,21);assert.throws(()=>radioProfile(original,{...channel,call:'N0TEST|C EVIL'},3));assert.throws(()=>radioProfile(original,{...channel,dialHz:0},3));assert.deepEqual(activeMailStreams('<option value=1>Idle&nbsp; </option>'),[]);assert.equal(activeMailStreams('<option value=1>RMS N0TEST Connected</option>').length,1);assert.throws(()=>activeMailStreams('signin page'));}); test('temporary RMS profile preserves routing, disables timers and never overrides busy channel',()=>{const p=radioProfile(original,channel,3);assert.equal(p.Enabled,'0');assert.equal(p.ConnectScript,'ATTACH 3|RADIO 14.122000 USB|PAUSE 2|C N0TEST');assert.ok(!p.ConnectScript.includes('OVERRIDEBUSY'));assert.equal(p.UseB2Protocol,'1');assert.equal(p.HRoutes,original.HRoutes);assert.equal(p.TOCalls,original.TOCalls);assert.deepEqual(rawProfile(configText(original),'RMS'),original);assert.equal(profilePayload(original).split('|').length,21);assert.throws(()=>radioProfile(original,{...channel,call:'N0TEST|C EVIL'},3));assert.throws(()=>radioProfile(original,{...channel,dialHz:0},3));assert.deepEqual(activeMailStreams('<option value=1>Idle&nbsp; </option>'),[]);assert.equal(activeMailStreams('<option value=1>RMS N0TEST Connected</option>').length,1);assert.throws(()=>activeMailStreams('signin page'));});