其他相关函数 本文简述其他章节不包含的功能函数的语法、作用、入参、返回值、示例。 ctyun.getiplocation 函数信息详见下表: 项目 描述 语法 vender, province, city ctyun.getiplocation(remoteip) 作用 返回ip的归属运营商,归属省,归属地市。 入参 ip地址,可以是ipv4,也可以是ipv6。 返回值 依次为ip归属运营商,归属省,归属地市。如果没有找到则返回nil。 示例: reasonml local vender, province, city ctyun.getiplocation("183.38.147.155") if vender ~ nil then ctyun.resp.setoutput(vender..":"..province..":"..city.."n") else ctyun.resp.setoutput("unknown ipn") end 输出结果: CNdianxin:CNguangdong:CNguangdongfoshan ctyun.splitstring 函数信息详见下表: 项目 描述 语法 array ctyun.splitstring(str, splittoken) 作用 根据分隔符,分割字符串。将结果保存到数组中。 入参 str为被分割的字符串,splittoken为分割符。 返回值 返回分割后的结果放到数组中,可以通过ipairs遍历。 示例: applescript local result ctyun.splitstring("aaa,bbb,ccc,ddd", ",") for k,v in ipairs(result) do ctyun.resp.setoutput(v.."n") end 输出结果: aaa bbb ccc ddd ctyun.refreshmode 函数信息详见下表: 项目 描述 语法 isrefreshmode ctyun.refreshmode() 作用 查询该请求是否处于刷新模式。 入参 无。 返回值 返回是否处于刷新模式,bool类型。 示例: awk 设置缓存 local cachekey ctyun.var('uri') ctyun.req.setcache(cachekey, "follow", 3600) 刷新模式下跳过远程鉴权 local isrefreshmode ctyun.refreshmode() if not isrefreshmode then local res, err ctyun.queryremote(" + ctyun.var('uri')) if err then ctyun.exit(403) end if res.status ~ 200 then ctyun.exit(res.status) end end