mirror of
https://github.com/lone-cloud/prism
synced 2026-06-03 08:43:10 -07:00
18 lines
385 B
TypeScript
18 lines
385 B
TypeScript
import { networkInterfaces } from 'node:os';
|
|
|
|
export const getLanIP = () => {
|
|
const nets = networkInterfaces();
|
|
|
|
for (const name of Object.keys(nets)) {
|
|
const interfaces = nets[name];
|
|
if (!interfaces) continue;
|
|
|
|
for (const iface of interfaces) {
|
|
if (iface.family === 'IPv4' && !iface.internal) {
|
|
return iface.address;
|
|
}
|
|
}
|
|
}
|
|
|
|
return null;
|
|
};
|