123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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 = {
- }
- function getgameinfo(redis)
- local accounts = {}
- local keys = redis:keys("character:*")
-
-
-
-
-
- return accounts
- end
- local account_record = {
- }
- local account_key = "account:*:*:%s"
- local character_key = "character:%s"
- local function query_facebook(args, ipaddr, header)
-
- if not whitelist[ipaddr] then
- return cjson.encode({errno = 3, host = header.host, note = "不信任ip"})
- end
- if account_record[args.account] then
- if account_record[args.account] + 60 >= os.time() then
- return cjson.encode({errno = 2, note = "过于频繁的查询请求"})
- end
- end
-
- local conf = assert(option.redis)
- local redis
- redis = redisdriver.connect(conf)
- redis:select(0)
- local ret = {}
-
- logger.trace("######### string.format(account_key, args.account) %s", string.format(account_key, args.account))
- local keys = redis:keys(string.format(account_key, args.account))
- logger.trace("######### keys %s", stringify(keys))
-
- for _, key in pairs(keys) do
- local uid = redis:GET(key)
-
-
- local ret2 = redis:hmget(string.format(character_key, uid), "nickname", "uid", "level","vip", "sid")
-
- table.insert(ret, {
- nickname = ret2[1],
- uid = ret2[2],
- level = ret2[3] or 0,
- vip = ret2[4] or 0,
- sid = ret2[5],
- })
- end
- redis:disconnect()
- account_record[args.account] = os.time()
- return cjson.encode({errno = 0, showinfo = ret})
- end
- return query_facebook
|