Support multiple sysops and bulletin comments; complete UI translations
Allow native SYSOP accounts to sign in independently, with an optional sysopUsers allow-list and isolated browser sessions. Keep station services on the configured service account. Add public bulletin comments that preserve category and distribution, alongside private replies to the author. Complete APRS and dynamic status translations and handle decorated button labels correctly. Document configuration and reply behavior. Add authentication, installer, bulletin reply and translation regression coverage.
This commit is contained in:
1 parent
33f1294405
commit
2ef3c25eb3
16 files changed
+298
-23
No files matched your search
+18
-1
@@ -2,6 +2,22 @@ import {readFile} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {timingSafeEqual} from 'node:crypto';
|
||||
|
||||
export function validateSysopUsers(value,users){
|
||||
if(value===undefined)return undefined;
|
||||
if(!Array.isArray(value)||value.some(name=>typeof name!=='string'||!name.trim()))throw new Error('sysopUsers deve essere una lista di nomi utente SYSOP');
|
||||
const known=new Set(users.map(u=>u.user.toLowerCase()));
|
||||
const names=value.map(name=>name.trim());
|
||||
if(names.some(name=>!known.has(name.toLowerCase())))throw new Error('sysopUsers contiene un utente SYSOP non rilevato in BPQ32.cfg');
|
||||
return names.filter((name,index)=>names.findIndex(other=>other.toLowerCase()===name.toLowerCase())===index);
|
||||
}
|
||||
export function authenticateSysop(users,user,password,allowedUsers){
|
||||
const equal=(a,b)=>{const aa=Buffer.from(a),bb=Buffer.from(b);return aa.length===bb.length&&timingSafeEqual(aa,bb);};
|
||||
const found=users.find(u=>equal(u.user.toLowerCase(),user.toLowerCase())&&equal(u.password,password));
|
||||
if(!found||allowedUsers!==undefined&&!allowedUsers.some(name=>name.toLowerCase()===found.user.toLowerCase()))return null;
|
||||
return {call:found.call,name:found.user};
|
||||
}
|
||||
|
||||
export function parseConfig(text){
|
||||
let inText=false,inComment=false;const lines=[];
|
||||
@@ -25,13 +41,14 @@ export async function loadConfig(){
|
||||
if(saved.language!=null&&!['it','en'].includes(saved.language))throw new Error('language deve essere it oppure en');
|
||||
const detected=parseConfig(await readFile(path.join(root,'BPQ32.cfg'),'utf8'));
|
||||
if(!detected.users.length)throw new Error('Nessun utente Telnet sysop in BPQ32.cfg');
|
||||
const sysopUsers=validateSysopUsers(saved.sysopUsers,detected.users);
|
||||
if(saved.radioPort!=null&&!detected.radioPorts.some(p=>p.id===Number(saved.radioPort)))throw new Error('Porta radio configurata non rilevata: rieseguire Install.ps1');
|
||||
if(saved.sysopUser&&!detected.users.some(u=>u.user===saved.sysopUser))throw new Error('Utente sysop configurato non rilevato: rieseguire Install.ps1');
|
||||
const radio=detected.radioPorts.find(p=>p.id===Number(saved.radioPort))||detected.radioPorts[0]||null;
|
||||
const httpPort=Number(saved.httpPort||detected.httpPort);if(!validPort(httpPort))throw new Error('HTTPPORT BPQ non valida o assente: eseguire Install.ps1');
|
||||
const port=Number(process.env.BPQ_CONSOLE_PORT||saved.port||8090);if(!validPort(port,1024)||port===httpPort)throw new Error('Porta pannello non valida o in conflitto con HTTPPORT BPQ');
|
||||
const features={terminal:!!detected.telnetPort,bbs:detected.apps.some(a=>a.command==='BBS'),chat:detected.apps.some(a=>a.command==='CHAT')&&!!detected.telnetPort,monitor:!!detected.monitorPort,winlink:detected.winlink&&detected.apps.some(a=>a.command==='BBS'),vara:!!radio&&/^VARA/i.test(radio.driver),radio:!!radio};
|
||||
return {...detected,...saved,root,httpPort,radio,features,port,sysop:detected.users.find(u=>u.user===saved.sysopUser)||detected.users[0]};
|
||||
return {...detected,...saved,...(sysopUsers===undefined?{}:{sysopUsers}),root,httpPort,radio,features,port,sysop:detected.users.find(u=>u.user===saved.sysopUser)||detected.users[0]};
|
||||
}
|
||||
export const validPort=(n,min=1)=>Number.isInteger(n)&&n>=min&&n<=65535;
|
||||
export function publicConfig(c){return {call:c.sysop.call,nodeCall:c.nodeCall,alias:c.alias,locator:c.locator,apps:c.apps,radio:c.radio,ports:c.ports,features:c.features,forwardPeer:c.forwardPeer||'',cmsPeer:c.cmsPeer||'RMS'};}
|
||||
|
||||
Reference in new issue
Block a user