From 46a21fb30833f12fdc81fc36451a7d00c6ce535f Mon Sep 17 00:00:00 2001 From: wanglihui <949764788@qq.com> Date: Fri, 3 Jul 2020 17:52:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E6=AD=A3=E5=88=99=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E4=B8=BA=E6=88=90=E5=91=98=E5=8F=98=E9=87=8F?= =?UTF-8?q?=EF=BC=8C=E5=88=A9=E7=94=A8Java=E9=A2=84=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BD=BF=E5=BE=97=E5=8C=B9=E9=85=8D=E6=9B=B4?= =?UTF-8?q?=E9=AB=98=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ac/iie/dao/BaseClickhouseData.java | 50 ++++++++++--------- 1 file 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>> 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 ""; + } + }