From c52022e4a8623f33e93fc5cbbc88e2764a322541 Mon Sep 17 00:00:00 2001 From: zhangzhiqiang Date: Wed, 18 Jan 2023 11:19:39 +0800 Subject: [PATCH] init --- .../main/java/org/nl/common/aspect/LimitAspect.java | 5 ++--- .../utils/{InetAddressUtil.java => InetAddUtil.java} | 12 +++++++----- .../nl/config/arthas/TunnelServerConfiguration.java | 10 +++------- .../java/org/nl/config/other/FileProperties.java | 6 +++--- .../service/secutiry/impl/OnlineUserService.java | 4 ++-- 5 files changed, 17 insertions(+), 20 deletions(-) rename nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/{InetAddressUtil.java => InetAddUtil.java} (98%) diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/common/aspect/LimitAspect.java b/nladmin-system/nlsso-server/src/main/java/org/nl/common/aspect/LimitAspect.java index eb41718..25d0cdf 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/common/aspect/LimitAspect.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/common/aspect/LimitAspect.java @@ -18,7 +18,6 @@ package org.nl.common.aspect; import cn.hutool.core.util.StrUtil; import com.google.common.collect.ImmutableList; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -26,7 +25,7 @@ import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import org.nl.common.aspect.exception.BadRequestException; -import org.nl.common.utils.InetAddressUtil; +import org.nl.common.utils.InetAddUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.redis.core.RedisTemplate; @@ -70,7 +69,7 @@ public class LimitAspect { String key = limit.key(); if (StrUtil.isEmpty(key)) { if (limitType == LimitType.IP) { - key = InetAddressUtil.getIp(request); + key = InetAddUtil.getIp(request); } else { key = signatureMethod.getName(); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddressUtil.java b/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddUtil.java similarity index 98% rename from nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddressUtil.java rename to nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddUtil.java index c9d4d39..4e1d4e4 100755 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddressUtil.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddUtil.java @@ -3,13 +3,11 @@ package org.nl.common.utils; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; -import lombok.extern.slf4j.Slf4j; import net.dreamlu.mica.ip2region.core.Ip2regionSearcher; import net.dreamlu.mica.ip2region.core.IpInfo; import nl.basjes.parse.useragent.UserAgent; import nl.basjes.parse.useragent.UserAgentAnalyzer; import org.nl.config.other.ElAdminProperties; -import org.omg.CORBA.UNKNOWN; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,7 +24,11 @@ import java.util.Enumeration; * @author hengyunabc 2020-10-27 * */ -public class InetAddressUtil { +public class InetAddUtil { + + static { + System.out.println("InetAddressUtil loading"); + } /** * 用于IP定位转换 @@ -52,7 +54,7 @@ public class InetAddressUtil { private static final char SEPARATOR = '_'; private static final String UNKNOWN = "unknown"; - private final static Logger logger = LoggerFactory.getLogger(InetAddressUtil.class); + private final static Logger logger = LoggerFactory.getLogger(InetAddUtil.class); /** * 获得本机IP。 @@ -234,7 +236,7 @@ public class InetAddressUtil { * 根据ip获取详细地址 */ public static String getHttpCityInfo(String ip) { - String api = String.format(InetAddressUtil.Url.IP_URL, ip); + String api = String.format(InetAddUtil.Url.IP_URL, ip); JSONObject object = JSONUtil.parseObj(HttpUtil.get(api)); return object.get("addr", String.class); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelServerConfiguration.java b/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelServerConfiguration.java index 896743f..9e7eef2 100755 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelServerConfiguration.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelServerConfiguration.java @@ -1,15 +1,13 @@ package org.nl.config.arthas; import com.alibaba.arthas.spring.ArthasProperties; -import org.nl.common.utils.InetAddressUtil; +import org.nl.common.utils.InetAddUtil; import org.nl.monitor.server.arthas.TunnelServer; import org.nl.monitor.server.arthas.cluster.TunnelClusterStore; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,10 +32,8 @@ public class TunnelServerConfiguration { tunnelServer.setPort(arthasProperties.getHttpPort()); tunnelServer.setSsl(false); tunnelServer.setPath(ArthasConstants.DEFAULT_WEBSOCKET_PATH); - /** - * chushihua - */ - tunnelServer.setClientConnectHost(InetAddressUtil.getInetAddress()); + + tunnelServer.setClientConnectHost(InetAddUtil.getInetAddress()); if (tunnelClusterStore != null) { tunnelServer.setTunnelClusterStore(tunnelClusterStore); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/config/other/FileProperties.java b/nladmin-system/nlsso-server/src/main/java/org/nl/config/other/FileProperties.java index 4dc564e..5e783a7 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/config/other/FileProperties.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/config/other/FileProperties.java @@ -16,7 +16,7 @@ package org.nl.config.other; import lombok.Data; -import org.nl.common.utils.InetAddressUtil; +import org.nl.common.utils.InetAddUtil; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; @@ -42,9 +42,9 @@ public class FileProperties { public ElPath getPath(){ String os = System.getProperty("os.name"); - if(os.toLowerCase().startsWith(InetAddressUtil.WIN)) { + if(os.toLowerCase().startsWith(InetAddUtil.WIN)) { return windows; - } else if(os.toLowerCase().startsWith(InetAddressUtil.MAC)){ + } else if(os.toLowerCase().startsWith(InetAddUtil.MAC)){ return mac; } return linux; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/secutiry/impl/OnlineUserService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/secutiry/impl/OnlineUserService.java index 33c66cd..e4cffa2 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/secutiry/impl/OnlineUserService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/secutiry/impl/OnlineUserService.java @@ -75,8 +75,8 @@ public class OnlineUserService { public void save(UserDto userDto, String token, HttpServletRequest request){ // String dept = userDto.getDept().getName(); String dept = ""; - String ip = InetAddressUtil.getIp(request); - String browser = InetAddressUtil.getBrowser(request); + String ip = InetAddUtil.getIp(request); + String browser = InetAddUtil.getBrowser(request); // String address = StringUtils.getCityInfo(ip); String address = "局域网"; OnlineUserDto onlineUserDto = null;