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>> eFqdnAddressIpMap = new HashMap<>(); private static HashMap>> 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 ""; + } + }