1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- --[[
- 彩票奖励库测试接口
- ]]
- local skynet = require "skynet"
- local codecache = require "skynet.codecache"
- require "skynet.manager"
- local logger = require "logger"
- local stringify = require "stringify"
- local cjson = require "cjson"
- local assetcenter
- local watchdog
- local traceback = debug.traceback
- local md5 = require "md5"
- local authz = {
- acc="yytx",
- pwd="lee@YY-Games.520"
- }
- -- Generate request data
- 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.50"] = true,
- ["14.29.136.211"] = true,
- ["192.168.1.41"] = true,
- ["222.212.88.4"] = true,
- }
- --[[
- example:
- 参数说明:
- sid 奖励id
- times 奖励生成多少份
- begin 第几次生成奖励
- nameconf 具体使用那个彩票奖励库
- http://192.168.1.102:9002/produce?code=xxx&vjson=[
- sid = 701003,
- nameconf = "lottery_proto",
- begin = 1,
- times = 3,
- ]
- ]]
- local function produce(args, ipaddr, header)
- logger.warn("处理来自主机 %s 的 produce 请求,:%s", ipaddr,stringify(args))
- -- 验证gm账号
- local code = string.sub(args.code, 1, 16)
- if code ~= content.sign then
- return cjson.encode({state = 403, msg = "账号或密码错误"})
- end
- logger.trace(" === %s", cjson.encode({
- sid = 701003,
- nameconf = "lottery_proto",
- begin = 1,
- times = 3,
- }))
- local para = cjson.decode(args.vjson)
- local produce_award = require "produce_award"
- local ok, info = xpcall(produce_award, traceback, tonumber(para.sid), tonumber(para.times), tonumber(para.begin), para.nameconf)
- if not ok then
- logger.trace(" 奖励库生成异常 %s:%s", stringify(para), info)
- return cjson.encode({state = 403, info = info})
- end
- logger.warn("hotfix (%s, %s)", args.user, ipaddr)
- return cjson.encode({errno = 0, info = info})
- end
- return produce
|