2026-02-10 09:53:46 +01:00
|
|
|
import { networkInterfaces } from 'os'
|
|
|
|
|
|
|
|
|
|
export function getNetworkIPs() {
|
|
|
|
|
const nets = networkInterfaces()
|
|
|
|
|
const networkIPs = []
|
|
|
|
|
|
|
|
|
|
for (const name of Object.keys(nets)) {
|
|
|
|
|
for (const net of nets[name]) {
|
|
|
|
|
if (net.family === 'IPv4' &&
|
2026-02-10 23:45:58 +01:00
|
|
|
!net.internal &&
|
|
|
|
|
!net.address.startsWith('172.17.') &&
|
|
|
|
|
!net.address.startsWith('172.18.')) {
|
2026-02-10 09:53:46 +01:00
|
|
|
networkIPs.push(net.address)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return networkIPs
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-12 12:22:43 +02:00
|
|
|
export function printServerInfo(port = 3000) {
|
2026-02-10 09:53:46 +01:00
|
|
|
const networkIPs = getNetworkIPs()
|
|
|
|
|
|
|
|
|
|
console.log(`\nSegnapunti Server`)
|
2026-05-12 12:22:43 +02:00
|
|
|
console.log(` Display: http://127.0.0.1:${port}/display`)
|
|
|
|
|
console.log(` Controller: http://127.0.0.1:${port}/controller`)
|
2026-02-10 09:53:46 +01:00
|
|
|
|
|
|
|
|
if (networkIPs.length > 0) {
|
2026-02-10 23:45:58 +01:00
|
|
|
console.log(`\n Controller da dispositivi remoti:`)
|
2026-02-10 09:53:46 +01:00
|
|
|
networkIPs.forEach(ip => {
|
2026-05-12 12:22:43 +02:00
|
|
|
console.log(` http://${ip}:${port}/controller`)
|
2026-02-10 09:53:46 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log()
|
|
|
|
|
}
|