123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- local skynet = require "skynet"
- require "skynet.manager"
- local logger = require "logger"
- local cjson = require "cjson"
- local queue = require "skynet.queue"
- local synchronized = queue()
- local redisdriver = require "skynet.db.redis"
- -- local namecenter = skynet.localname(".namecenter")
- -- local temp_config = mt
- local mysql = require "skynet.db.mysql"
- local util = require "util"
- local stringify = require "stringify"
- local s_guild = skynet.localname(".guild")
- local md5 = require "md5"
- -- local zlf_log = require "zlf_log"
- -- local z_trace = zlf_log.trace
- local db
- 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 = {
- ["14.29.136.211"] = true,
- ["192.168.1.41"] = true,
- ["222.212.88.4"] = true,
- }
- -- 模板
- --[[
- 请求方式: http://服务器ip:端口号/ban?code=xxx&type=操作类型&content=xxxx&sid=xxxxx
- 参数:
- type:
- 1: 封禁公会 conten=1
- 2: 解封公会 conten=2
- 3: 重置公告 conten=公告内容
- 4: 重置名称 conten=公会行名称
- 5: 解锁公会 conten=5
- sid: 公会sid
- 反馈信息内容(json格式):
- {
- state: 反馈码(0表示成功)
- msg: 反馈描述(成功的时返回success)
- }
- ]]
- local guild = function(args, ipaddr,header)
- return synchronized(function()
- logger.trace("处理来自主机 %s 的guild请求", ipaddr)
- -- 验证主机id
- if not whitelist[ipaddr] then
- -- return cjson.encode({errno = 403, msg = "不信任ip"})
- end
- -- 验证gm账号2
- local code = string.sub(args.code, 1, 16)
- if code ~= content.sign then
- return cjson.encode({state = 403, msg = "账号或密码错误"})
- end
- local ftype = tonumber(args.type) -- 操作类型
- local fcont = args.content -- 操作参数
- local sid = args.sid -- 公会sid
- logger.trace(" %s:%s:%s",ftype,fcont,sid)
- -- 封 公会
- if ftype == 1 then
- local ret1,ret2 = skynet.call(s_guild, "lua", "set_seal", _,sid,1)
- if ret1 >= 0 then
- return cjson.encode({errno = 200, msg = "封禁公会 成功"})
- else
- return cjson.encode({errno = 400, msg = ret2})
- end
- elseif ftype == 2 then
- local ret1,ret2 = skynet.call(s_guild, "lua", "set_seal", _,sid,2)
- if ret1 >= 0 then
- return cjson.encode({errno = 200, msg = "解封公会 成功"})
- else
- return cjson.encode({errno = 400, msg = ret2})
- end
- elseif ftype == 3 then -- 设置公告
- local ret1,ret2 = skynet.call(s_guild, "lua", "web_set_notice", _,sid,fcont)
- if ret1 >= 0 then
- return cjson.encode({errno = 200, msg = "设置新的公告 成功"})
- else
- return cjson.encode({errno = 400, msg = ret2})
- end
- elseif ftype == 4 then -- 公会改名
- local ret1,ret2 = skynet.call(s_guild, "lua", "web_rename", _,sid,fcont)
- if ret1 >= 0 then
- return cjson.encode({errno = 200, msg = "重新命名字 成功"})
- else
- return cjson.encode({errno = 400, msg = ret2})
- end
- else
- -- return {code = 0, msg = "type 没有找到"}
- return cjson.encode({errno = 400, msg = "type 没有找到"})
- end
- end)
- end
- return guild
|