local skynet = require "skynet" require "skynet.manager" local logger = require "logger" local usercenter = skynet.localname(".usercenter") local ws_watchdog = skynet.localname(".ws_watchdog") local cjson = require "cjson" local md5 = require "md5" local authz = {acc = "yytx", pwd = "lee@YY-Games.520"} local content = {acc = authz.acc, pwd = authz.pwd, sign = false} content.sign = string.sub(md5.sumhexa(content.acc .. content.pwd), 9, 24) local whitelist = { ["192.168.1.23"] = true, ["192.168.1.127"] = true, ["192.168.1.41"] = true, ["14.29.136.211"] = true, ["222.212.88.4"] = true, } --请求方式: http://服务器ip地址:端口号/notice?code=xxx&ntype=1&interval=10&content=想要发送的跑马灯内容 --示例: http://192.168.1.102:8002/notice?code=xxx&ntype=1&interval=10&content=this%20is%20a%20test local function check_server(args, ipaddr, header) logger.trace("处理来自主机 %s 查询服务器状态", ipaddr) if not whitelist[ipaddr] then -- return { "403 - Forbidden" } -- return cjson.encode({errno = 403, host = header.host, info = "不信任ip"}) end -- 验证gm账号 -- local code = string.sub(args.code, 1, 16) -- if code ~= content.sign then -- return cjson.encode({state = 403, msg = "账号或密码错误"}) -- end local sid = args.sid local account = args.account local channel = args.channel or "" local create = false if sid and account and channel then skynet.call(usercenter, "lua", "exsits", { sid = sid, account = account, channel = channel, }) end local maintain = skynet.call(ws_watchdog, "lua", "getstatus") local ret = cjson.encode({state = 0, create = create, open = maintain and false or true}) logger.trace(ret) return ret end return check_server