支持传递网卡参数
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
编码猿
2025-09-09 23:45:53 +08:00
parent b13ce0e795
commit 4a2ba95d02
2 changed files with 10 additions and 3 deletions

View File

@@ -14,9 +14,14 @@ app.use((req, res, next) => {
next();
});
// 提供接口查询ubuntu server上的ipv6地址处理字符串后序列化为json返回.
/**
* 提供接口查询ubuntu server上的ipv6地址处理字符串后序列化为json返回.
* 案例: https://ip.bmycode.help/ip?interface=enp3s0
* 参数: interface 网卡名称
*/
app.get('/ip', async (req, res) => {
let output = execSync(command, { encoding: "utf8" });
let interface = req.query.interface || "enp3s0"
let output = execSync(command(interface), { encoding: "utf8" });
res.json(await ip.parseNetworkInfo(output))
})