diff --git a/README.md b/README.md
index e5af2f7..985f36a 100644
--- a/README.md
+++ b/README.md
@@ -8,9 +8,30 @@ Use the Italian / UK flag switch in the login screen or dashboard header to sele
Interface copy is maintained in `public/i18n.js`; add new UI phrases and parameterised status patterns there. Mark custom data widgets with `data-no-i18n` so their content is preserved.
+## Sysop accounts
+
+Every Telnet `USER=` account with the `SYSOP` flag in `BPQ32.cfg` can sign in with its own username and password. Usernames are case-insensitive; passwords are case-sensitive. Normal BPQ users cannot sign in. Each browser session has its own identity, cookie and CSRF token; signing out of one session leaves other sessions active. The profile shows the signed-in user's callsign.
+
+`sysopUser` in `console.config.json` selects the station's service account. Terminal connections, the shared Chat, Monitor and native BBS operations continue to use that account. All authorised sysops administer the same station, BBS and Winlink mailbox; logging in with another callsign does not create a separate mailbox or change the station identity.
+
+To restrict Console access to particular native sysops, add the optional `sysopUsers` allow-list:
+
+```json
+{
+ "sysopUser": "admin",
+ "sysopUsers": ["admin", "Marco"]
+}
+```
+
+Use existing BPQ usernames, not callsigns. Every listed account must already have the native `SYSOP` flag. Entries are case-insensitive; credentials remain exclusively in `BPQ32.cfg`. Omitting `sysopUsers` allows all native sysops; an empty array allows nobody. Invalid lists stop startup/installation instead of being ignored. Restart BPQ Console after changing the list; BPQ does not need a restart. Reinstallation preserves the list for the same station folder and resets it when installing against another station.
+
+## Bulletin comments and private replies
+
+The BBS reader offers **Comment** for bulletins: it creates a new bulletin (`B`) addressed to the original category and distribution, for example `NEWS@WW`. **Reply** creates a personal message (`P`) addressed to the author. Personal messages only show Reply. Both actions open an editable draft with the original subject prefixed by `Re:` and the quoted text; nothing is published until Save and queue is selected. Comments use BPQ's normal bulletin forwarding rules and do not modify the original message.
+
## Message deletion
-Deleting BBS or Winlink messages requires the configured Console sysop login and CSRF token. The Console opens a fresh BPQ WebMail session, issues the native delete action and verifies that the message disappeared or has status `K`. If WebMail rejects deleting another author’s bulletin, the authenticated sysop Console uses BPQ’s local administrative message action, preserving the other message fields and changing only status to `K`. BPQ updates its own database and forwarding flags. No account flags are changed. Already deleted messages are handled safely; failures are displayed inside the confirmation dialog.
+Deleting BBS or Winlink messages requires an authorised Console sysop login and that session's CSRF token. The Console opens a fresh BPQ WebMail session, issues the native delete action and verifies that the message disappeared or has status `K`. If WebMail rejects deleting another author’s bulletin, the authenticated sysop Console uses BPQ’s local administrative message action, preserving the other message fields and changing only status to `K`. BPQ updates its own database and forwarding flags. No account flags are changed. Already deleted messages are handled safely; failures are displayed inside the confirmation dialog.
## Winlink attachments
@@ -27,7 +48,7 @@ Terminal and Chat read `LOGINPROMPT` and `PASSWORDPROMPT` from the Telnet port i
- Windows and Windows PowerShell 5.1 or later.
- Node.js 20 or later. A portable `node.exe` can be selected with `-NodeExe`.
- BPQ32 installed and running, with `HTTPPORT` configured in its Telnet driver.
-- A Telnet `USER` with the `sysop` role. The panel accepts the selected sysop account; its password stays in `BPQ32.cfg`.
+- A Telnet `USER` with the `sysop` role. The panel accepts native SYSOP accounts, subject to the optional `sysopUsers` allow-list; passwords stay in `BPQ32.cfg`.
- Optional: BPQMail for BBS/Winlink, BPQChat and `TCPPORT` for chat, `FBBPORT` for the monitor. The terminal only needs `TCPPORT`.
Service detection recognises the `BBS` and `CHAT` application command names, case-insensitively. Those applications must actually be running to use their pages. The installer does not install BPQ, configure a modem, change radio frequencies or create forwarding partners.
@@ -54,7 +75,7 @@ Install and start:
.\Install.ps1
```
-Open **http://127.0.0.1:8090** and sign in with the selected BPQ Telnet sysop account. No `npm install` or build step is required.
+Open **http://127.0.0.1:8090** and sign in with an authorised BPQ Telnet SYSOP account. No `npm install` or build step is required.
Detection uses an explicit `-BpqRoot`, `BPQ_ROOT`, the previously saved data folder, `%APPDATA%\BPQ32`, or the folders of running BPQ processes. The HTTP check must identify BPQ before any configuration is written. `-CheckOnly` never saves configuration, starts the panel, registers a task or changes the firewall, even if other switches are present.
@@ -70,7 +91,7 @@ Explicit settings:
| `-Port` | Web panel port, 1024–65535; default 8090 on first install. |
| `-HttpPort` | BPQ HTTP port; defaults to the Telnet driver setting. Must differ from the panel port. |
| `-RadioPort` | Existing BPQ radio port number. The first is selected initially; multiple modems produce a warning. |
-| `-SysopUser` | Existing sysop user; defaults to the first on initial installation. |
+| `-SysopUser` | Native sysop account used by Terminal, Chat and station services; defaults to the first on initial installation. Console logins are controlled separately by `sysopUsers`. |
| `-ForwardPeer` | Existing BBS forwarding partner for the dashboard shortcut. No partner is created automatically. |
| `-CmsPeer` | Existing CMS forwarding profile; defaults to `RMS`. |
| `-NodeExe` | Full path to a Node.js 20+ `node.exe`. Saved for future startup. |
diff --git a/bpq.mjs b/bpq.mjs
index 07b7e0a..9703d38 100644
--- a/bpq.mjs
+++ b/bpq.mjs
@@ -2,6 +2,6 @@ export function decode(s){return s.replace(/(\d+);/g,(_,n)=>String.fromCodePoi
export function plain(html){return decode(html.replace(/
+
BPQ Console
BPQ Console
by IU2EUG
La tua stazione, in un unico pannello.
diff --git a/public/radio-ports.js b/public/radio-ports.js
index b2801bc..a8d9a61 100644
--- a/public/radio-ports.js
+++ b/public/radio-ports.js
@@ -16,7 +16,7 @@
function renderSelected(){const p=port();if(!p)return;const originalRadio=station.radio,originalControl=window.bpqRadioControl;station.radio={id:p.id,name:p.name,driver:p.driver};window.bpqRadioControl={txSuspended:data.global.txSuspended||p.control.txSuspended||!p.control.listening};
try{legacyRender({current:p.current,history:p.history});$('#radio-status').textContent=!p.control.listening?'PORTA FERMA':window.bpqRadioControl.txSuspended?'TX SOSPESO':!p.current.available?'OFFLINE':p.current.ptt?'TX':p.current.active?'LINK ATTIVO':'IN ASCOLTO';$('#session-detail').textContent=p.name;$('#modem-traffic').textContent=p.current.sent!=null?'TX '+size(p.current.sent)+' / RX '+size(p.current.received||0):'TX '+rate(p.current.txFrames)+' / RX '+rate(p.current.rxFrames)+' frame';$('#bps-value').textContent=p.current.txBps==null&&p.current.rxBps==null?'—':rate((p.current.txBps||0)+(p.current.rxBps||0));$('#bps-caption').textContent=p.current.txBps==null?'Statistiche frame BPQ':'TX '+rate(p.current.txBps)+' / RX '+rate(p.current.rxBps)+' bit/s';$('#radio-scan').textContent=p.current.scan?'● Scansione attiva':p.control.listening?'● Frequenza fissa':'● Porta ferma';$('#radio-modem').textContent='PORT '+p.id+' · '+p.driver;}
finally{station.radio=originalRadio;window.bpqRadioControl=originalControl;}
- document.querySelector('.modem-brand').textContent='PORTE RADIO';
+ document.querySelector('.modem-brand').textContent=BPQI18n.t('PORTE RADIO');
const packet=/KISS|AX25|AX\.25/i.test(p.driver),cards=document.querySelectorAll('.telemetry-grid article');cards[1].querySelector('header>span').textContent=packet?'FRAME AX.25':'SNR / BPQ';cards[2].querySelector('header>span').textContent=packet?'TIMEOUT L2':/VARA/i.test(p.driver)?'CPU VARA':'CPU MODEM';cards[2].querySelector('footer').textContent=packet?'Contatore BPQ':'Processo modem · ogni 5 s';
if(packet){$('#snr-value').textContent=rate(p.current.txFrames)+' / '+rate(p.current.rxFrames);$('#snr-chart').innerHTML=graph(p.history,['txFrames','rxFrames'],'frame AX25',10);$('#snr-caption').textContent='TX / RX · contatori BPQ';$('#vara-cpu-value').textContent=rate(p.current.timeouts);$('#vara-cpu-chart').innerHTML=graph(p.history,['timeouts'],'timeout L2',5);}
}
diff --git a/server.mjs b/server.mjs
index a19b5f2..fe16047 100644
--- a/server.mjs
+++ b/server.mjs
@@ -19,7 +19,7 @@ import {ManualForwarding} from './manual-forwarding.mjs';
import {forwardingHistory} from './forwarding.mjs';
import {Forwarding} from './forwarding.mjs';
import {SevenPlus} from './sevenplus.mjs';
-import {loadConfig,parseConfig,publicConfig,ownCall} from './config.mjs';
+import {loadConfig,parseConfig,publicConfig,ownCall,authenticateSysop} from './config.mjs';
import {readFile, stat,open} from 'node:fs/promises';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
@@ -68,7 +68,7 @@ function mailContext(){return mailReads.run('context',async()=>{if(mailKey&&Date
function messages(includeTimes=true){return mailReads.run(includeTimes?'full':'quick',()=>readMessages(includeTimes));}
async function readMessages(includeTimes=true){let {key}=await mailContext();let html=await bpq('/WebMail/WMALL?'+key);if(!html.includes('Message List')){mailKey=null;({key}=await mailContext());html=await bpq('/WebMail/WMALL?'+key);if(!html.includes('Message List'))throw new Error('Lista messaggi BPQ non disponibile');}const list=parseMessages(html).filter(m=>m.status!=='K');if(includeTimes)return messageMetadata.enrich(list);for(const m of list.filter(m=>m.type==='P'&&(m.to==='RMS'||m.needsMetadata))){const f=await messageFields(m.id);m.from=f.From||m.from;m.to=f.To||m.to;m.subject=f.Title||m.subject;m.via=f.VIA||m.via;}return list;}
function equal(a,b){const aa=Buffer.from(a),bb=Buffer.from(b);return aa.length===bb.length&&timingSafeEqual(aa,bb);}
-async function authenticate(user,password){const users=parseConfig(await readFile(path.join(root,'BPQ32.cfg'),'utf8')).users;const found=users.find(u=>equal(u.user.toLowerCase(),user.toLowerCase())&&equal(u.password,password)&&u.user===config.sysop.user);return found?{call:found.call,name:found.user,config:publicConfig(config)}:null;}
+async function authenticate(user,password){const users=parseConfig(await readFile(path.join(root,'BPQ32.cfg'),'utf8')).users;const identity=authenticateSysop(users,user,password,config.sysopUsers);return identity?{...identity,config:publicConfig(config)}:null;}
async function body(req){let chunks=[],size=0;for await(const chunk of req){size+=chunk.length;if(size>70000)throw new Error('Messaggio troppo grande');chunks.push(chunk)}return JSON.parse(Buffer.concat(chunks).toString()||'{}');}
function json(res,status,data){res.writeHead(status,{'Content-Type':'application/json; charset=utf-8','Cache-Control':'no-store'});res.end(JSON.stringify(data));}
function session(req){const token=req.headers.cookie?.match(/(?:^|;\s*)alnode=([a-f0-9]+)/)?.[1];const s=sessions.get(token);if(s&&s.expires>Date.now()){s.expires=Date.now()+8*3600000;return s;}if(token){s?.terminal?.close();sessions.delete(token);}return null;}
@@ -203,7 +203,7 @@ const server=http.createServer(async(req,res)=>{
if(url.pathname==='/api/winlink/sync'&&req.method==='POST'){if(Date.now()-lastCmsRequest<10000)throw new Error('Sincronizzazione già richiesta. Attendi qualche secondo.');await syncNow(config.cmsPeer||'RMS');lastCmsRequest=Date.now();json(res,200,{ok:true});return;}
const readRoute=url.pathname.match(/^\/api\/messages\/(\d+)\/read$/);if(readRoute&&req.method==='POST'){const item=(await messages()).find(m=>m.id===Number(readRoute[1]));if(!item)throw new Error('Messaggio non disponibile');json(res,200,await messageReadState.mark(item));return;}
if(/^\/api\/messages\/\d+\/delete$/.test(url.pathname)&&req.method==='POST'){json(res,200,await deleteMessage(Number(url.pathname.split('/')[3])));return;}
- if(/^\/api\/messages\/\d+$/.test(url.pathname)&&req.method==='GET'){const id=url.pathname.split('/').pop();const {key}=await mailContext();const msg=parseMessage(await bpq('/WebMail/WM?'+key+'&'+id));if(!msg)throw new Error('Messaggio non disponibile');try{const raw=await attachedMessage(Number(id));const text=b2Body(raw.bytes);if(text!==null)msg.text=text.replace(/\r\n|\r/g,'\n');}catch{}json(res,200,{id:Number(id),...msg,...await messageTimes(Number(id))});return;}
+ if(/^\/api\/messages\/\d+$/.test(url.pathname)&&req.method==='GET'){const id=url.pathname.split('/').pop();const {key}=await mailContext();const msg=parseMessage(await bpq('/WebMail/WM?'+key+'&'+id));if(!msg)throw new Error('Messaggio non disponibile');try{const raw=await attachedMessage(Number(id));const text=b2Body(raw.bytes);if(text!==null)msg.text=text.replace(/\r\n|\r/g,'\n');}catch{}const fields=await messageFields(Number(id));json(res,200,{id:Number(id),...msg,to:fields.To||msg.to,via:fields.VIA||msg.via||'',...await messageTimes(Number(id))});return;}
if(url.pathname==='/api/messages'&&req.method==='POST'){json(res,201,await sendMessage(await readSubmission(req)));return;}
if(url.pathname==='/api/sync'&&req.method==='POST'){await syncNow();json(res,200,{ok:true});return;}
json(res,404,{error:'Operazione non disponibile'});return;
diff --git a/sysop-auth.test.mjs b/sysop-auth.test.mjs
new file mode 100644
index 0000000..1439359
--- /dev/null
+++ b/sysop-auth.test.mjs
@@ -0,0 +1,73 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import fs from 'node:fs/promises';
+import path from 'node:path';
+import os from 'node:os';
+import http from 'node:http';
+import net from 'node:net';
+import {spawn} from 'node:child_process';
+import {once} from 'node:events';
+import {parseConfig,validateSysopUsers,authenticateSysop} from './config.mjs';
+
+const accountLines='USER=admin,primary-secret,N0TEST,SYSOP\nUSER=Marco,secondary-secret,N0OTHER,SYSOP\nUSER=guest,guest-secret,N0GUEST,\n';
+const users=parseConfig(accountLines).users;
+test('all native SYSOP accounts can log in with their own identity; normal users and wrong passwords cannot',()=>{
+ assert.deepEqual(authenticateSysop(users,'ADMIN','primary-secret'),{name:'admin',call:'N0TEST'});
+ assert.deepEqual(authenticateSysop(users,'marco','secondary-secret'),{name:'Marco',call:'N0OTHER'});
+ for(const [name,password]of [['guest','guest-secret'],['Marco','SECONDARY-SECRET'],['missing','primary-secret']])assert.equal(authenticateSysop(users,name,password),null);
+});
+test('optional sysopUsers restricts native SYSOP access case-insensitively and cannot grant normal users access',()=>{
+ const allow=validateSysopUsers(['mArCo','MARCO'],users);assert.deepEqual(allow,['mArCo']);
+ assert.deepEqual(authenticateSysop(users,'Marco','secondary-secret',allow),{name:'Marco',call:'N0OTHER'});
+ assert.equal(authenticateSysop(users,'admin','primary-secret',allow),null);
+ assert.equal(authenticateSysop(users,'Marco','secondary-secret',[]),null);
+ assert.equal(validateSysopUsers(undefined,users),undefined);
+ for(const bad of [null,'Marco',{},[''],[12],['guest'],['missing']])assert.throws(()=>validateSysopUsers(bad,users),/sysopUsers/);
+});
+
+const listen=server=>new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));
+test('HTTP sessions isolate multiple sysops, retain station identity, enforce the allow-list and reread native roles',async()=>{
+ const dir=await fs.mkdtemp(path.join(os.tmpdir(),'bpq-multi-sysop-')),root=path.join(dir,'station');
+ let child;
+ const upstream=http.createServer((req,res)=>res.end('BPQ Ports'));
+ const stop=async()=>{if(child&&child.exitCode===null){child.kill();await once(child,'exit');}child=null;};
+ try{
+ await fs.mkdir(root);await listen(upstream);
+ const native='NODECALL=N0TEST-7\nPORT\nDRIVER=TELNET\nHTTPPORT='+upstream.address().port+'\n'+accountLines+'ENDPORT\n';
+ await fs.writeFile(path.join(root,'BPQ32.cfg'),native);
+ await fs.writeFile(path.join(dir,'package.json'),' {"type":"module"} ');
+ for(const name of await fs.readdir('.'))if(name.endsWith('.mjs')&&!name.endsWith('.test.mjs')&&name!=='test.mjs')await fs.copyFile(name,path.join(dir,name));
+ const start=async extra=>{
+ const probe=net.createServer();await listen(probe);const port=probe.address().port;await new Promise(resolve=>probe.close(resolve));
+ await fs.writeFile(path.join(dir,'console.config.json'),JSON.stringify({bpqRoot:root,port,sysopUser:'admin',...extra}));
+ child=spawn(process.execPath,[path.join(dir,'server.mjs')],{cwd:dir,env:{...process.env,BPQ_ROOT:root,BPQ_CONSOLE_CONFIG:path.join(dir,'console.config.json'),BPQ_CONSOLE_PORT:String(port)},windowsHide:true,stdio:['ignore','pipe','pipe']});
+ let timer;try{await Promise.race([once(child.stdout,'data'),once(child,'exit').then(()=>{throw Error('Fixture server failed');}),new Promise((_,reject)=>{timer=setTimeout(()=>reject(Error('Fixture startup timeout')),8000);})]);}finally{clearTimeout(timer);}
+ const base='http://127.0.0.1:'+port;
+ return {base,login:(user,password)=>fetch(base+'/api/login',{method:'POST',headers:{origin:base,'content-type':'application/json'},body:JSON.stringify({user,password})})};
+ };
+ let client=await start({});
+ const primaryResponse=await client.login('admin','primary-secret'),secondaryResponse=await client.login('MARCO','secondary-secret');
+ assert.equal(primaryResponse.status,200);assert.equal(secondaryResponse.status,200);
+ const primary=await primaryResponse.json(),secondary=await secondaryResponse.json();
+ assert.equal(primary.call,'N0TEST');assert.equal(secondary.call,'N0OTHER');assert.equal(secondary.name,'Marco');
+ assert.equal(secondary.config.call,'N0TEST');assert.equal(secondary.config.nodeCall,'N0TEST-7');
+ assert.notEqual(primary.csrf,secondary.csrf);assert.ok(!JSON.stringify(secondary).includes('secret'));assert.ok(!('sysopUsers' in secondary.config));
+ const primaryCookie=primaryResponse.headers.get('set-cookie').split(';')[0],secondaryCookie=secondaryResponse.headers.get('set-cookie').split(';')[0];
+ assert.notEqual(primaryCookie,secondaryCookie);
+ const session=async cookie=>fetch(client.base+'/api/session',{headers:{cookie}});
+ assert.equal((await (await session(primaryCookie)).json()).call,'N0TEST');
+ assert.equal((await (await session(secondaryCookie)).json()).call,'N0OTHER');
+ const logout=csrf=>fetch(client.base+'/api/logout',{method:'POST',headers:{origin:client.base,cookie:secondaryCookie,'x-csrf-token':csrf}});
+ assert.equal((await logout(primary.csrf)).status,403);assert.equal((await session(secondaryCookie)).status,200);
+ assert.equal((await logout(secondary.csrf)).status,200);assert.equal((await session(secondaryCookie)).status,401);assert.equal((await session(primaryCookie)).status,200);
+ assert.equal((await client.login('guest','guest-secret')).status,401);assert.equal((await client.login('Marco','wrong')).status,401);
+ await stop();client=await start({sysopUsers:['MARCO']});
+ assert.equal((await client.login('admin','primary-secret')).status,401);
+ assert.equal((await client.login('Marco','secondary-secret')).status,200);
+ await fs.writeFile(path.join(root,'BPQ32.cfg'),native.replace('N0OTHER,SYSOP','N0OTHER,'));
+ assert.equal((await client.login('Marco','secondary-secret')).status,401);
+ }finally{
+ await stop();upstream.closeAllConnections();await new Promise(resolve=>upstream.close(resolve));
+ assert.ok(path.resolve(dir).startsWith(path.resolve(os.tmpdir())+path.sep));await fs.rm(dir,{recursive:true,force:true});
+ }
+});