update
This commit is contained in:
17
assistant/src/module/ip/get-ip.ts
Normal file
17
assistant/src/module/ip/get-ip.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import os from 'node:os';
|
||||
export const getIpv4 = (): string => {
|
||||
const interfaces = os.networkInterfaces();
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
const iface = interfaces[name];
|
||||
if (iface) {
|
||||
for (const alias of iface) {
|
||||
if (alias.family === 'IPv4' && !alias.internal) {
|
||||
return alias.address;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return '0.0.0.0';
|
||||
}
|
||||
|
||||
console.log('本机IPv4地址:', getIpv4());
|
||||
@@ -83,7 +83,7 @@ program
|
||||
console.log('启动服务', chalk.green(assistantConfig.configDir));
|
||||
const config = assistantConfig.getCacheAssistantConfig();
|
||||
const listenPort = options.port || config?.server?.port;
|
||||
const listenPath = config?.server?.path || '127.0.0.1';
|
||||
const listenPath = config?.server?.path || '::';
|
||||
const server = await runServer(listenPort, listenPath);
|
||||
} else {
|
||||
console.log('请使用 -s 参数启动服务');
|
||||
|
||||
Reference in New Issue
Block a user