查看: 2409|回复: 1

[问题反馈] 主机监控的IP查询功能失效

[复制链接]

16

主题

753

帖子

4373

积分

骨灰法师

Rank: 8Rank: 8

积分
4373
发表于 2025-4-24 04:29:09 | 显示全部楼层 |阅读模式
高恪AK系列硬件AP隆重上市
错误情况:

错误

错误


建议增加自定义IP查询功能

菜单项

菜单项

页面

页面


回复

使用道具 举报

16

主题

753

帖子

4373

积分

骨灰法师

Rank: 8Rank: 8

积分
4373
 楼主| 发表于 昨天 16:29 | 显示全部楼层
高恪AK系列硬件AP隆重上市
  1. function M.getipinfo(_, params)
  2.     local ip = type(params) == "table" and params.ip or nil
  3.     if not ip then
  4.         return nil
  5.     end

  6.     local cjson = require("cjson")
  7.     local ipinfo = nil
  8.     local cmd = string.format("curl -sk https://ip9.com.cn/get?ip=%s", ip)
  9.     local raw = sh.read(cmd)
  10.     if not raw or raw == "" then
  11.         return nil
  12.     end

  13.     local ok, decoded = pcall(cjson.decode, raw)
  14.     if not ok or type(decoded) ~= "table" or decoded.ret ~= 200 then
  15.         return nil
  16.     end

  17.     local data = decoded.data
  18.     if not data then
  19.         return nil
  20.     end

  21.     -- 组装 info 字段,过滤空值
  22.     local parts = {}
  23.     if data.prov and data.prov ~= "" then table.insert(parts, data.prov) end
  24.     if data.city and data.city ~= "" then table.insert(parts, data.city) end
  25.     if data.isp and data.isp ~= "" then table.insert(parts, data.isp) end
  26.     local info = table.concat(parts, " ")

  27.     if info == "" then
  28.         return nil
  29.     end

  30.     return info
  31. end
复制代码



回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表