init
This commit is contained in:
@@ -18,7 +18,6 @@ package org.nl.common.aspect;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
@@ -26,7 +25,7 @@ import org.aspectj.lang.annotation.Pointcut;
|
|||||||
import org.aspectj.lang.reflect.MethodSignature;
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
|
||||||
import org.nl.common.aspect.exception.BadRequestException;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
@@ -70,7 +69,7 @@ public class LimitAspect {
|
|||||||
String key = limit.key();
|
String key = limit.key();
|
||||||
if (StrUtil.isEmpty(key)) {
|
if (StrUtil.isEmpty(key)) {
|
||||||
if (limitType == LimitType.IP) {
|
if (limitType == LimitType.IP) {
|
||||||
key = InetAddressUtil.getIp(request);
|
key = InetAddUtil.getIp(request);
|
||||||
} else {
|
} else {
|
||||||
key = signatureMethod.getName();
|
key = signatureMethod.getName();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,11 @@ package org.nl.common.utils;
|
|||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
||||||
import net.dreamlu.mica.ip2region.core.IpInfo;
|
import net.dreamlu.mica.ip2region.core.IpInfo;
|
||||||
import nl.basjes.parse.useragent.UserAgent;
|
import nl.basjes.parse.useragent.UserAgent;
|
||||||
import nl.basjes.parse.useragent.UserAgentAnalyzer;
|
import nl.basjes.parse.useragent.UserAgentAnalyzer;
|
||||||
import org.nl.config.other.ElAdminProperties;
|
import org.nl.config.other.ElAdminProperties;
|
||||||
import org.omg.CORBA.UNKNOWN;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -26,7 +24,11 @@ import java.util.Enumeration;
|
|||||||
* @author hengyunabc 2020-10-27
|
* @author hengyunabc 2020-10-27
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class InetAddressUtil {
|
public class InetAddUtil {
|
||||||
|
|
||||||
|
static {
|
||||||
|
System.out.println("InetAddressUtil loading");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于IP定位转换
|
* 用于IP定位转换
|
||||||
@@ -52,7 +54,7 @@ public class InetAddressUtil {
|
|||||||
|
|
||||||
private static final char SEPARATOR = '_';
|
private static final char SEPARATOR = '_';
|
||||||
private static final String UNKNOWN = "unknown";
|
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。
|
* 获得本机IP。
|
||||||
@@ -234,7 +236,7 @@ public class InetAddressUtil {
|
|||||||
* 根据ip获取详细地址
|
* 根据ip获取详细地址
|
||||||
*/
|
*/
|
||||||
public static String getHttpCityInfo(String 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));
|
JSONObject object = JSONUtil.parseObj(HttpUtil.get(api));
|
||||||
return object.get("addr", String.class);
|
return object.get("addr", String.class);
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
package org.nl.config.arthas;
|
package org.nl.config.arthas;
|
||||||
|
|
||||||
import com.alibaba.arthas.spring.ArthasProperties;
|
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.TunnelServer;
|
||||||
import org.nl.monitor.server.arthas.cluster.TunnelClusterStore;
|
import org.nl.monitor.server.arthas.cluster.TunnelClusterStore;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
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.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@@ -34,10 +32,8 @@ public class TunnelServerConfiguration {
|
|||||||
tunnelServer.setPort(arthasProperties.getHttpPort());
|
tunnelServer.setPort(arthasProperties.getHttpPort());
|
||||||
tunnelServer.setSsl(false);
|
tunnelServer.setSsl(false);
|
||||||
tunnelServer.setPath(ArthasConstants.DEFAULT_WEBSOCKET_PATH);
|
tunnelServer.setPath(ArthasConstants.DEFAULT_WEBSOCKET_PATH);
|
||||||
/**
|
|
||||||
* chushihua
|
tunnelServer.setClientConnectHost(InetAddUtil.getInetAddress());
|
||||||
*/
|
|
||||||
tunnelServer.setClientConnectHost(InetAddressUtil.getInetAddress());
|
|
||||||
if (tunnelClusterStore != null) {
|
if (tunnelClusterStore != null) {
|
||||||
tunnelServer.setTunnelClusterStore(tunnelClusterStore);
|
tunnelServer.setTunnelClusterStore(tunnelClusterStore);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
package org.nl.config.other;
|
package org.nl.config.other;
|
||||||
|
|
||||||
import lombok.Data;
|
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.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@@ -42,9 +42,9 @@ public class FileProperties {
|
|||||||
|
|
||||||
public ElPath getPath(){
|
public ElPath getPath(){
|
||||||
String os = System.getProperty("os.name");
|
String os = System.getProperty("os.name");
|
||||||
if(os.toLowerCase().startsWith(InetAddressUtil.WIN)) {
|
if(os.toLowerCase().startsWith(InetAddUtil.WIN)) {
|
||||||
return windows;
|
return windows;
|
||||||
} else if(os.toLowerCase().startsWith(InetAddressUtil.MAC)){
|
} else if(os.toLowerCase().startsWith(InetAddUtil.MAC)){
|
||||||
return mac;
|
return mac;
|
||||||
}
|
}
|
||||||
return linux;
|
return linux;
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ public class OnlineUserService {
|
|||||||
public void save(UserDto userDto, String token, HttpServletRequest request){
|
public void save(UserDto userDto, String token, HttpServletRequest request){
|
||||||
// String dept = userDto.getDept().getName();
|
// String dept = userDto.getDept().getName();
|
||||||
String dept = "";
|
String dept = "";
|
||||||
String ip = InetAddressUtil.getIp(request);
|
String ip = InetAddUtil.getIp(request);
|
||||||
String browser = InetAddressUtil.getBrowser(request);
|
String browser = InetAddUtil.getBrowser(request);
|
||||||
// String address = StringUtils.getCityInfo(ip);
|
// String address = StringUtils.getCityInfo(ip);
|
||||||
String address = "局域网";
|
String address = "局域网";
|
||||||
OnlineUserDto onlineUserDto = null;
|
OnlineUserDto onlineUserDto = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user