diff --git a/README.md b/README.md index 3b817ad..6413430 100644 --- a/README.md +++ b/README.md @@ -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. 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. diff --git a/manual-forwarding.mjs b/manual-forwarding.mjs index abfd5b2..26df378 100644 --- a/manual-forwarding.mjs +++ b/manual-forwarding.mjs @@ -2,7 +2,7 @@ import {readFile,writeFile,rename,mkdir,copyFile} from 'node:fs/promises'; import path from 'node:path'; import {reservePacketSlot,releasePacketSlot} from './radio-slot.mjs'; import {WinlinkRadio,rawProfile,activeMailStreams} from './winlink-radio.mjs'; -import {safeScript} from './forwarding.mjs'; +import {safeScript,parseForwarding} from './forwarding.mjs'; export function manualRoutes(config){ 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'); @@ -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}];});} async prepare(route){await reservePacketSlot(this,route.controller,route.frequencyMHz,route.port);} 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()=>{ 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'); diff --git a/manual-forwarding.test.mjs b/manual-forwarding.test.mjs index cc1ede2..319569a 100644 --- a/manual-forwarding.test.mjs +++ b/manual-forwarding.test.mjs @@ -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); }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); +}); diff --git a/public/forwarding.js b/public/forwarding.js index b5f518d..49bc1b2 100644 --- a/public/forwarding.js +++ b/public/forwarding.js @@ -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'; 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])=>'
| Partner / percorso | Stato | Coda | Ultimo scambio | TX / RX | Programmazione | Prossimo · stima | Azioni |
|---|---|---|---|---|---|---|---|
| ${esc(status)} | ${p.queued??'—'} | ${esc(time(last?.startedAt).replace(/:\d{2}$/,''))}${esc(last?state(last.status):'Nessuna sessione recente')} | ${last?last.sent+' / '+last.received:'—'} | ${p.manualOnly?'Solo manuale':esc(interval(p.interval))}${p.manualOnly?esc(p.frequency.join(' MHz ')):esc(bands(p))+' · '+(p.timesLocal?'locale BPQ':'UTC')} | ${esc(next)}${p.nextEstimated?esc(mailTimezone()):''} | ${p.transport==='Radio'&&(data.radio?.active||data.radio?.connecting)&&!p.active?'Modem impegnato':''} | |
${isOpen?details(p):''} | |||||||
Nessun partner di forwarding configurato in BPQ.
':'')+'