You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
3.3 KiB
124 lines
3.3 KiB
using System;
|
|
using LitJson;
|
|
using ProtoCSStruct;
|
|
using SimpleHttpServer;
|
|
using Sog;
|
|
|
|
namespace Operation;
|
|
|
|
[MenuMapping(refc = typeof(ServerMonitor))]
|
|
public static class Limit
|
|
{
|
|
[RequestMapping("白名单管理", PermissionCode.LIMIT_IP, true)]
|
|
public static int OnSelectLimitIpHttpReq(string httpApiCmd, JsonData jsonData, HttpResponse rsp,
|
|
HttpRequest request, HttpQueryParams query, uint httpContextId)
|
|
{
|
|
SSGetLimitReq req = new SSGetLimitReq();
|
|
req.Id = (int)httpContextId;
|
|
var opType = query.GetValue("op_type").Toint32(0);
|
|
var args = query.GetValue("args");
|
|
if (opType == 0)
|
|
{
|
|
FindLimit(jsonData);
|
|
rsp.IsWaitFor = false;
|
|
return 0;
|
|
}
|
|
|
|
req.Op_type = opType;
|
|
req.Args.SetString(args);
|
|
OperationServerUtils.GetPacketSender().SendToRealmlistServer((int)SSGameMsgID.OperationLimitReq, ref req, 0);
|
|
rsp.IsWaitFor = true;
|
|
return -1;
|
|
}
|
|
|
|
private static void FindLimit(JsonData jsonData)
|
|
{
|
|
jsonData["code"] = 0;
|
|
jsonData["ret"] = 0;
|
|
JsonData data = new JsonData();
|
|
|
|
var whiteList = LimitIpDevice.GetWhiteList();
|
|
|
|
if (whiteList != null)
|
|
{
|
|
JsonData json = new JsonData();
|
|
foreach (var item in whiteList)
|
|
{
|
|
json.Add(item);
|
|
}
|
|
|
|
data["ip"] = json;
|
|
}
|
|
|
|
var whiteDeviceIdList = LimitIpDevice.GetWhiteDeviceList();
|
|
if (whiteDeviceIdList != null)
|
|
{
|
|
JsonData json = new JsonData();
|
|
foreach (var item in whiteDeviceIdList)
|
|
{
|
|
json.Add(item);
|
|
}
|
|
|
|
data["device"] = json;
|
|
}
|
|
|
|
var blackList = LimitIpDevice.GetBlackList();
|
|
if (blackList != null)
|
|
{
|
|
JsonData json = new JsonData();
|
|
foreach (var item in blackList)
|
|
{
|
|
json.Add(item);
|
|
}
|
|
|
|
data["bip"] = json;
|
|
}
|
|
|
|
var blackDeviceIdList = LimitIpDevice.GetBlackDeviceList();
|
|
if (blackDeviceIdList != null)
|
|
{
|
|
JsonData json = new JsonData();
|
|
foreach (var item in blackDeviceIdList)
|
|
{
|
|
json.Add(item);
|
|
}
|
|
|
|
data["bdevice"] = json;
|
|
}
|
|
|
|
jsonData["data"] = data;
|
|
}
|
|
|
|
public static void OnSelectLimitIpRes(uint serverId, StructPacket packet)
|
|
{
|
|
HttpRequestInfo m_request = null;
|
|
try
|
|
{
|
|
ref var res = ref packet.GetMessage<SSGetLimitRes>();
|
|
var id = res.Id;
|
|
TraceLog.Debug("Limit.OnSelectLimitIpRes uid {0} ", id);
|
|
m_request = OperationServer.m_httpService.m_requestList.Find(f => f.Http.id == id);
|
|
LitJson.JsonData builder = new LitJson.JsonData();
|
|
builder["code"] = 0;
|
|
builder["ret"] = 0;
|
|
switch (res.Op_type)
|
|
{
|
|
case 0:
|
|
break;
|
|
}
|
|
|
|
m_request.Http.httpResponse.ContentAsUTF8 = builder.ToJson();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
TraceLog.Error("Limit.OnSelectLimitIpRes Error Msg {0}", ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (m_request != null)
|
|
{
|
|
m_request.ProcessEnd = true;
|
|
}
|
|
}
|
|
}
|
|
}
|