summaryrefslogtreecommitdiff
path: root/IP-learning-graph
diff options
context:
space:
mode:
authorwanglihui <[email protected]>2020-07-03 17:52:56 +0800
committerwanglihui <[email protected]>2020-07-03 17:52:56 +0800
commit46a21fb30833f12fdc81fc36451a7d00c6ce535f (patch)
tree6661abb2d565fc095cba69e5c4521463fa834ea6 /IP-learning-graph
parent2d543b3df93f7e806611af506b7559fb2dd23033 (diff)
提取正则表达式为成员变量,利用Java预编译功能使得匹配更高效
Diffstat (limited to 'IP-learning-graph')
-rw-r--r--IP-learning-graph/src/main/java/cn/ac/iie/dao/BaseClickhouseData.java50
1 files changed, 26 insertions, 24 deletions
diff --git a/IP-learning-graph/src/main/java/cn/ac/iie/dao/BaseClickhouseData.java b/IP-learning-graph/src/main/java/cn/ac/iie/dao/BaseClickhouseData.java
index 89518c7..6c358e7 100644
--- a/IP-learning-graph/src/main/java/cn/ac/iie/dao/BaseClickhouseData.java
+++ b/IP-learning-graph/src/main/java/cn/ac/iie/dao/BaseClickhouseData.java
@@ -28,6 +28,8 @@ public class BaseClickhouseData {
private static HashMap<Integer, HashMap<String, HashMap<String, BaseEdgeDocument>>> eFqdnAddressIpMap = new HashMap<>();
private static HashMap<Integer, HashMap<String, HashMap<String, BaseEdgeDocument>>> eIpVisitFqdnMap = new HashMap<>();
+ private static Pattern pattern = Pattern.compile("^[\\d]*$");
+
private static long[] getTimeLimit() {
long maxTime = System.currentTimeMillis() / 1000;
long minTime = maxTime - 3600;
@@ -237,36 +239,13 @@ public class BaseClickhouseData {
}
}
- @Deprecated
- private static String commonSchemaGetFqdn(String commonSchemaType, ResultSet resultSet) {
- String vFqdn = "";
- try {
- switch (commonSchemaType) {
- case "HTTP":
- vFqdn = resultSet.getString("http_host");
- break;
- case "SSL":
- vFqdn = resultSet.getString("ssl_sni");
- break;
- default:
- LOG.warn("不支持该类型common_schema_type:" + commonSchemaType);
- }
- } catch (Exception e) {
- LOG.error(e.getMessage());
- }
- if (isDomain(vFqdn)) {
- return vFqdn;
- }
- return "";
- }
-
private static boolean isDomain(String fqdn) {
try {
String[] fqdnArr = fqdn.split("\\.");
if (fqdnArr.length < 4 || fqdnArr.length > 4) {
return true;
}
- Pattern pattern = Pattern.compile("^[\\d]*$");
+
for (String f : fqdnArr) {
if (pattern.matcher(f).matches()) {
int i = Integer.parseInt(f);
@@ -323,4 +302,27 @@ public class BaseClickhouseData {
return "SELECT * FROM ((" + sslSql + ") UNION ALL (" + httpSql + "))WHERE FQDN != ''";
}
+ @Deprecated
+ private static String commonSchemaGetFqdn(String commonSchemaType, ResultSet resultSet) {
+ String vFqdn = "";
+ try {
+ switch (commonSchemaType) {
+ case "HTTP":
+ vFqdn = resultSet.getString("http_host");
+ break;
+ case "SSL":
+ vFqdn = resultSet.getString("ssl_sni");
+ break;
+ default:
+ LOG.warn("不支持该类型common_schema_type:" + commonSchemaType);
+ }
+ } catch (Exception e) {
+ LOG.error(e.getMessage());
+ }
+ if (isDomain(vFqdn)) {
+ return vFqdn;
+ }
+ return "";
+ }
+
}