123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- local skynet = require "skynet"
- require "skynet.manager"
- local logger = require "logger"
- local stringify = require "stringify"
- local usercenter = skynet.localname(".usercenter")
- local logind = skynet.localname(".loginserver")
- local redisdriver = require "skynet.db.redis"
- local namecenter = skynet.localname(".namecenter")
- 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,
- ["222.212.88.4"] = true,
- }
- local pipeline = require "pipeline"
- function getgameinfo(redis)
- local accounts = {}
- local block = pipeline(1024)
- local keys = redis:keys("character:*")
- if #keys > 0 then
- for _, k in ipairs(keys) do
- block.add("hmget", k, "nickname", "uid", "level","sex","vip", "mission", "dress","title","forbidden","silent" ,"power")
- end
- end
- local resp = block.execute(redis, {})
- for i, v in ipairs(resp) do
- assert(v.ok)
- local rs = v.out
- if rs[2] then
- local namecgf = {name = rs[1], uid = rs[2],level = tonumber(rs[3]),sex = tonumber(rs[4]),vip = tonumber(rs[5])}
- if rs[6] then
- namecgf.mission = tonumber(rs[6])
- end
- if rs[7] then
- local dress = unpack(rs[7])
- namecgf.dress = dress.carry or nil
- end
- if rs[8] then
- local title = unpack(rs[8])
- namecgf.title = title.settitle or nil
- end
- if rs[9] then
- namecgf.forbidden =rs[9]
- end
- if rs[10] then
- namecgf.silent=rs[10]
- end
- if rs[11] then
- namecgf.power = tonumber(rs[11])
- end
- accounts[namecgf.uid] = namecgf
- end
- end
- return accounts
- end
- local function query_forbit(args, ipaddr, header)
- logger.trace("处理来自主机 %s 的 获取 玩家指定key--%s的数据", ipaddr,args.key)
- if not whitelist[ipaddr] then
-
-
- end
-
- local code = string.sub(args.code, 1, 16)
- if code ~= content.sign then
- return cjson.encode({state = 403, msg = "账号或密码错误"})
- end
- local conf = assert(option.redis)
- local redis
- redis = redisdriver.connect(conf)
- redis:select(0)
- local myacc=getgameinfo(redis)
- redis:disconnect()
- logger.trace("===================myacc=%s",stringify(myacc))
- local list_all={}
- local list_forbidden={}
- local list_silent={}
- for k,v in pairs(myacc) do
- if v.forbidden or v.silent then
- table.insert( list_all,v)
- end
- if v.forbidden then
- table.insert( list_forbidden,v)
- end
- if v.silent then
- table.insert( list_silent,v)
- end
- end
- if args.cmd=="*" then
- return cjson.encode({state = 0, msg = "成功",list=list_all})
- elseif args.cmd=="forbidden" then
- return cjson.encode({state = 0, msg = "成功",list=list_forbidden})
- elseif args.cmd=="silent" then
- return cjson.encode({state = 0, msg = "成功",list=list_silent})
- else
- return cjson.encode({state = 400, msg = "错误的cmd参数"})
- end
- end
- return query_forbit
|