|
@@ -408,32 +408,62 @@ namespace molilian.core
|
|
|
return Task.CompletedTask;
|
|
return Task.CompletedTask;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- private static void saveClientRequestTotal(TkChannelEnum channel, string ip, string oaid)
|
|
|
|
|
|
|
+ private async static Task saveClientRequestTotal(TkChannelEnum channel, string ip, string oaid)
|
|
|
{
|
|
{
|
|
|
- string cacheKey = $":cache:{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
|
|
|
|
|
- RedisHelper.IncrBy(cacheKey);
|
|
|
|
|
- RedisHelper.Expire(cacheKey, 86400);
|
|
|
|
|
-
|
|
|
|
|
- if (!string.IsNullOrEmpty(oaid))
|
|
|
|
|
|
|
+ await saveClientRequestTotal(channel.ToString(), ip, oaid);
|
|
|
|
|
+ }
|
|
|
|
|
+ private static async Task saveClientRequestTotal(string channel, string ip, string oaid)
|
|
|
|
|
+ {
|
|
|
|
|
+ await EndPointCore.ProcessEndPointNodesAsync(node =>
|
|
|
{
|
|
{
|
|
|
- cacheKey = $":cache:{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
|
|
|
|
|
- RedisHelper.IncrBy(cacheKey);
|
|
|
|
|
- RedisHelper.Expire(cacheKey, 86400);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (string.IsNullOrEmpty(node.redis_server)) return Task.CompletedTask;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+#if DEBUG
|
|
|
|
|
+ switch (node.name)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ case "bj":
|
|
|
|
|
+ node.redis_server = "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "gz":
|
|
|
|
|
+ node.redis_server = "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "coupon1":
|
|
|
|
|
+ node.redis_server = "c1api.molilian.com:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
|
|
|
|
|
+ break;
|
|
|
|
|
+ default: return Task.CompletedTask;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ var redis = RedisClientManager.GetRedisClient(node.redis_server);
|
|
|
|
|
+
|
|
|
|
|
+ string cacheKey = $":cache:{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
|
|
|
|
|
+ redis.IncrBy(cacheKey);
|
|
|
|
|
+ redis.Expire(cacheKey, 86400);
|
|
|
|
|
+
|
|
|
|
|
+ if (!string.IsNullOrEmpty(oaid))
|
|
|
|
|
+ {
|
|
|
|
|
+ cacheKey = $":cache:{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
|
|
|
|
|
+ redis.IncrBy(cacheKey);
|
|
|
|
|
+ redis.Expire(cacheKey, 86400);
|
|
|
|
|
+ }
|
|
|
|
|
+ return Task.CompletedTask;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- private static void saveClientRequestTotal(string channel, string ip, string oaid)
|
|
|
|
|
|
|
+ public static bool InBlacklist(string blacklist, string oaid)
|
|
|
{
|
|
{
|
|
|
- string cacheKey = $":cache:{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
|
|
|
|
|
- RedisHelper.IncrBy(cacheKey);
|
|
|
|
|
- RedisHelper.Expire(cacheKey, 86400);
|
|
|
|
|
|
|
+ if (string.IsNullOrEmpty(blacklist)) return false;
|
|
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(oaid))
|
|
|
|
|
- {
|
|
|
|
|
- cacheKey = $":cache:{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
|
|
|
|
|
- RedisHelper.IncrBy(cacheKey);
|
|
|
|
|
- RedisHelper.Expire(cacheKey, 86400);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ var arr = blacklist.Split(new[] { "\r\n" }, StringSplitOptions.None)
|
|
|
|
|
+ .Select(s => s.Trim()).ToArray();
|
|
|
|
|
+ return arr.Contains(oaid);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public static int getClientRequestTotalByOAID(TkChannelEnum channel, string oaid)
|
|
public static int getClientRequestTotalByOAID(TkChannelEnum channel, string oaid)
|
|
|
{
|
|
{
|
|
|
if (string.IsNullOrEmpty(oaid)) return 0;
|
|
if (string.IsNullOrEmpty(oaid)) return 0;
|