From 228afc59ceab4e8769524beb70148436f48c5b03 Mon Sep 17 00:00:00 2001 From: Jorge Fernando dos Santos Date: Thu, 22 Oct 2026 16:12:16 +0000 Subject: [PATCH] fix: align legacy walled garden destination with verified ZimaOS portal --- backend/diagnose-hotspot.mjs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/diagnose-hotspot.mjs b/backend/diagnose-hotspot.mjs index 37465c0..690c8d5 100644 --- a/backend/diagnose-hotspot.mjs +++ b/backend/diagnose-hotspot.mjs @@ -25,5 +25,15 @@ try { console.log('TEMP-RECORDS',JSON.stringify((db.tempAccess||[]).map(t=>({device:hash(t.mac),createdAt:t.createdAt,expiresAt:t.expiresAt,revoked:t.revoked})))); } catch(e){console.log('DB-ERROR',redact(e.message));} -console.log('WALLED-GARDEN',redact(JSON.stringify((await rosCommand(['/ip/hotspot/walled-garden/ip/print','=.proplist=.id,server,dst-address,dst-port,protocol,action,comment,disabled'])).map(object)))); -console.log('CLIENT-PROBES',JSON.stringify((JSON.parse(fs.readFileSync(config.dataDir+'/db.json','utf8')).tempAccess||[]).map(t=>({device:hash(t.mac),expiresAt:t.expiresAt,clientProbe:t.clientProbe||null})))); +const rows=(await rosCommand(['/ip/hotspot/walled-garden/ip/print','=.proplist=.id,dst-address,dst-port,protocol,action,comment,disabled'])).map(object); +const targets=rows.filter(r=>r.comment==='pix: portal pagamento'&&r.action==='accept'&&r.protocol==='tcp'&&r['dst-port']==='3000'); +if(targets.length>1)throw new Error('Ambiguous legacy portal walled garden rules'); +if(targets.length===1){ + const old=targets[0];const file=config.dataDir+'/walled-garden-before-port-fix-'+Date.now()+'.json'; + fs.writeFileSync(file,JSON.stringify(old,null,2),{mode:0o600});if(process.getuid?.()===0)fs.chownSync(file,1000,1000); + await rosCommand(['/ip/hotspot/walled-garden/ip/set','=numbers='+old['.id'],'=dst-address=192.168.3.100','=dst-port=8905']); + console.log('WALLED-GARDEN-FIX',JSON.stringify({id:old['.id'],previousAddress:old['dst-address'],previousPort:old['dst-port'],address:'192.168.3.100',port:'8905',backup:file})); +} +const verify=(await rosCommand(['/ip/hotspot/walled-garden/ip/print','=.proplist=.id,dst-address,dst-port,protocol,action,comment,disabled'])).map(object).filter(r=>r.comment==='pix: portal pagamento'); +console.log('WALLED-GARDEN-VERIFIED',JSON.stringify(verify)); +if(!verify.some(r=>r['dst-address'].replace('/32','')==='192.168.3.100'&&r['dst-port']==='8905'))throw new Error('Local portal walled garden verification failed');