Browse Source

init

master
zhangzhiqiang 2 years ago
parent
commit
c52022e4a8
  1. 5
      nladmin-system/nlsso-server/src/main/java/org/nl/common/aspect/LimitAspect.java
  2. 12
      nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddUtil.java
  3. 10
      nladmin-system/nlsso-server/src/main/java/org/nl/config/arthas/TunnelServerConfiguration.java
  4. 6
      nladmin-system/nlsso-server/src/main/java/org/nl/config/other/FileProperties.java
  5. 4
      nladmin-system/nlsso-server/src/main/java/org/nl/system/service/secutiry/impl/OnlineUserService.java

5
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();
}

12
nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/InetAddressUtil.java → 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);
}

10
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);
}

6
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;

4
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;

Loading…
Cancel
Save