diagnostics: correlate duplicate guest addresses with live traffic and DHCP
This commit is contained in:
1 parent
f8235b55b0
commit
64add2bc68
1 file changed
+17
-10
@@ -25,14 +25,21 @@ try {
|
|||||||
console.log('TEMP-RECORDS',JSON.stringify((db.tempAccess||[]).map(t=>({device:hash(t.mac),createdAt:t.createdAt,expiresAt:t.expiresAt,revoked:t.revoked}))));
|
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));}
|
} catch(e){console.log('DB-ERROR',redact(e.message));}
|
||||||
|
|
||||||
console.log('DEPLOYMENT-OBSERVATION',JSON.stringify({clientProbesInstalled:fs.readFileSync('/app/public/index.html','utf8').includes('verifyClientInternet'),startOnPixInstalled:fs.readFileSync('/app/public/index.html','utf8').includes("sessionStorage.setItem('pendingPix'")}));
|
const hosts=(await rosCommand(['/ip/hotspot/host/print','=.proplist=.id,address,to-address,mac-address,server,authorized,bypassed,uptime,idle-time,bytes-in,bytes-out,packets-in,packets-out'])).map(object).filter(h=>h.server===config.mikrotik.server);
|
||||||
const database=JSON.parse(fs.readFileSync(config.dataDir+'/db.json','utf8'));
|
const macs=[...new Set(hosts.map(h=>h['mac-address']))];
|
||||||
console.log('CLIENT-OBSERVATIONS',JSON.stringify((database.tempAccess||[]).map(t=>({device:hash(t.mac),expiresAt:t.expiresAt,probe:t.clientProbe||null}))));
|
for(const mac of macs){
|
||||||
const garden=(await rosCommand(['/ip/hotspot/walled-garden/ip/print','=.proplist=comment,dst-address,dst-port,protocol,disabled'])).map(object).filter(r=>r.comment==='pix: portal pagamento');
|
const rows=hosts.filter(h=>h['mac-address']===mac);
|
||||||
console.log('LOCAL-PORTAL-EXCEPTION',JSON.stringify(garden));
|
console.log('HOST-ALIASES',redact(JSON.stringify(rows.map(r=>({...r,addressHash:hash(r.address),toAddressHash:hash(r['to-address'])})))));
|
||||||
for(const hostname of ['www.gstatic.com','www.apple.com']){
|
for(const [label,path] of [['LEASES','/ip/dhcp-server/lease/print'],['ARP','/ip/arp/print']]){
|
||||||
try {
|
try{console.log(label,redact(JSON.stringify((await rosCommand([path,'?mac-address='+mac,'=.proplist=address,active-address,status,server,last-seen,interface,complete'])).map(object))));}
|
||||||
const result=(await rosCommand(['/ping','=address='+hostname,'=count=1'])).map(object);
|
catch(e){console.log(label+'-ERROR',redact(e.message));}
|
||||||
console.log('ROUTER-DNS-TEST',JSON.stringify({hostname,resolved:result.some(r=>/^[0-9a-f:.]+$/i.test(r.host||'')),received:result.at(-1)?.received||'0'}));
|
}
|
||||||
}catch(e){console.log('ROUTER-DNS-ERROR',hostname,redact(e.message));}
|
|
||||||
}
|
}
|
||||||
|
const connections=(await rosCommand(['/ip/firewall/connection/print','=.proplist=src-address,dst-address,seen-reply,protocol,tcp-state'])).map(object);
|
||||||
|
for(const h of hosts){
|
||||||
|
const c=connections.filter(c=>(c['src-address']||'').split(':')[0]===h.address);
|
||||||
|
const external=c.filter(c=>!/^(10\\.|192\\.168\\.|172\\.(1[6-9]|2\\d|3[01])\\.)/.test(c['dst-address']||''));
|
||||||
|
console.log('ALIAS-CONNECTIONS',JSON.stringify({addressHash:hash(h.address),device:hash(h['mac-address']),count:c.length,external:external.length,withReplies:external.filter(c=>c['seen-reply']==='true').length,dnsReplies:external.filter(c=>(c['dst-address']||'').endsWith(':53')&&c['seen-reply']==='true').length}));
|
||||||
|
}
|
||||||
|
console.log('DHCP-SERVERS',redact(JSON.stringify((await rosCommand(['/ip/dhcp-server/print','=.proplist=name,interface,disabled,address-pool'])).map(object))));
|
||||||
|
console.log('HOTSPOT-SETTINGS',JSON.stringify((await rosCommand(['/ip/hotspot/print','=.proplist=name,addresses-per-mac,idle-timeout,keepalive-timeout,interface'])).map(object)));
|
||||||
Reference in new issue
Block a user