跳转至

25 httpdns-使用HTTP进行域名解析

作者:拓毅恒 | 最后修改:2026-07-02

示例

-- 通过阿里DNS获取结果
local ip = httpdns.ali("air32.cn")
log.info("httpdns", "air32.cn", ip)

-- 通过腾讯DNS获取结果
local ip = httpdns.tx("air32.cn")
log.info("httpdns", "air32.cn", ip)

httpdns.ali(domain_name, opts)

通过阿里DNS获取结果

参数

传入值类型 解释
string 域名
table opts 可选参数, 与http.request的opts参数一致

返回值

返回值类型 解释
string ip地址

例子

local ip = httpdns.ali("air32.cn")
log.info("httpdns", "air32.cn", ip)
-- 指定网络适配器
local ip = httpdns.ali("air32.cn", {adapter=socket.LWIP_STA, timeout=3000})
log.info("httpdns", "air32.cn", ip)

httpdns.tx(domain_name, opts)

通过腾讯DNS获取结果

参数

传入值类型 解释
string 域名
table opts 可选参数, 与http.request的opts参数一致

返回值

返回值类型 解释
string ip地址

例子

local ip = httpdns.tx("air32.cn")
log.info("httpdns", "air32.cn", ip)

-- 指定网络适配器
local ip = httpdns.tx("air32.cn", {adapter=socket.LWIP_STA, timeout=3000})
log.info("httpdns", "air32.cn", ip)

httpdns.version()

功能 获取库文件版本信息

参数

无参数

返回值

local version= httpdns.version()

log.info("httpdns", "version -> " .. version)

version

含义说明:库文件版本信息,string类型的年月日时分;
数据类型:string;
取值范围:12位数字;
返回示例:"202607021200"

示例

--返回string类型的年月日时分,例如:"202607021200"
httpdns.version()

版本更新说明

版本号:202607021200

1、更新时间:2026-07-02 12:00

2、更新内容

  • 新增httpdns.version()接口
  • 支持httpdns库文件版本号管理功能,版本号的格式为:yyyymmddhhmm,表示yyyy年mm月dd日hh时mm分发布的版本
问一下 AI