summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangwei <[email protected]>2023-02-10 19:14:48 +0800
committerwangwei <[email protected]>2023-02-10 19:14:48 +0800
commitf8180791f1a9553afe26bc9e1b3d6c35087c5397 (patch)
tree19767b06f1984b0396fdb99ff267094e0e1ed95d
parent52a763590a611d6d9029d33a3f589ea4d4349c5a (diff)
1. 定时任务新增开关 2.提取psiphon客户端获取方式至配置
-rw-r--r--src/main/java/com/example/nis/Scheduled/Entity.java4
-rw-r--r--src/main/java/com/example/nis/controller/IpController.java8
-rw-r--r--src/main/resources/application.yml3
3 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/com/example/nis/Scheduled/Entity.java b/src/main/java/com/example/nis/Scheduled/Entity.java
index 92dfc43..4f172d0 100644
--- a/src/main/java/com/example/nis/Scheduled/Entity.java
+++ b/src/main/java/com/example/nis/Scheduled/Entity.java
@@ -45,6 +45,8 @@ public class Entity {
private String psiphonIpObjectName;
@Value("${entity.psiphon.enable}")
private Boolean psiphonEnable;
+ @Value("${entity.psiphon.sql}")
+ private String sql;
@Scheduled(cron = "${entity.psiphon.cron}")
public ResponseData scheduledExecutorOfPsiphon() {
@@ -59,7 +61,7 @@ public class Entity {
return ResponseData.error(msg);
}
- String sql = "select distinct client_ip from psiphon_client_detection_event where event_time >= now()-600 AND event_time < now() AND notEmpty(client_ip)";
+ //String sql = "select distinct client_ip from psiphon_client_detection_event where event_time >= now()-600 AND event_time < now() AND notEmpty(client_ip)";
HttpResponse httpResponse = ToCKDBUtil.exeQuery(sql);
if (httpResponse.getStatus() != Code.SUCCESS.getCode()) {
String msg = String.valueOf(httpResponse);
diff --git a/src/main/java/com/example/nis/controller/IpController.java b/src/main/java/com/example/nis/controller/IpController.java
index db80225..69783b9 100644
--- a/src/main/java/com/example/nis/controller/IpController.java
+++ b/src/main/java/com/example/nis/controller/IpController.java
@@ -1,6 +1,7 @@
package com.example.nis.controller;
import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
@@ -38,6 +39,9 @@ public class IpController {
@Value("${ip.filePath}")
private String ipFilePath;
+ @Value("${ip.enable}")
+ private Boolean enable;
+
@Value("${ip.excludeValue}")
public void setExcludeList(String values) {
if (StrUtil.isBlank(values)) {
@@ -57,6 +61,10 @@ public class IpController {
@Scheduled(cron = "${ip.cron}")
@PutMapping("/dynamic-learning")
public ResponseData scheduledExecutor() {
+ if (BooleanUtil.isFalse(enable)) {
+ log.warn("server ip schedule disable");
+ return ResponseData.ok();
+ }
ResponseData responseData = getAll();
if (!Code.SUCCESS.getCode().equals(responseData.get("code"))) {
String msg = String.valueOf(responseData.get("msg"));
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 429e4bb..5d75b3c 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -12,6 +12,7 @@ ip:
#指定排除的IP. 1.如果没有可不写值,2.若有多个用英文逗号,分隔如: 127.0.0.1,127.0.0.2
excludeValue: 0.0.0.0
cron: 0 0 0/1 * * ?
+ enable: true
# TSG 账号
tsg:
system:
@@ -32,6 +33,8 @@ entity:
psiphon:
cron: 0 0/1 * * * ?
enable: true
+ #Plan B sql: SELECT common_client_ip as client_ip, count(DISTINCT common_server_ip) as num FROM security_event WHERE common_recv_time > now() - 10 * 60 AND common_recv_time <= now() AND notEmpty(common_client_ip) AND common_policy_id = '97810' GROUP BY client_ip HAVING num >= 10
+ sql: SELECT DISTINCT client_ip FROM psiphon_client_detection_event WHERE event_time >= now()-600 AND event_time < now() AND notEmpty(client_ip)
ipObjectId: 8533
ipObjectName: Psiphon_Client_IP
## ClickhHouse configuration