mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-29 16:06:36 +08:00
增加日志输出
This commit is contained in:
@@ -57,7 +57,7 @@ public class EncryptionConfig {
|
||||
public static void clearCrypto(String secret) {
|
||||
if (secret != null) {
|
||||
CRYPTO_CACHE.remove(secret);
|
||||
log.debug("已清理密钥对应的加密器实例");
|
||||
log.info("已清理密钥对应的加密器实例");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.admin.config;
|
||||
|
||||
|
||||
import com.admin.common.utils.IpUtils;
|
||||
import com.admin.common.utils.JwtUtil;
|
||||
import com.admin.entity.Node;
|
||||
import com.admin.service.NodeService;
|
||||
@@ -14,6 +15,7 @@ import org.springframework.web.socket.WebSocketHandler;
|
||||
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -37,9 +39,10 @@ public class WebSocketInterceptor extends HttpSessionHandshakeInterceptor {
|
||||
String type = serverHttpRequest.getServletRequest().getParameter("type");
|
||||
String version = serverHttpRequest.getServletRequest().getParameter("version");
|
||||
if (Objects.equals(type, "1")) {
|
||||
System.out.println("type: " + type + " - version: " + version + " - secret: " + secret + " - IP: " + getClientIp(request));
|
||||
Node node = nodeService.getOne(new QueryWrapper<Node>().eq("secret", secret));
|
||||
if (node == null) {
|
||||
log.warn("节点验证失败:未找到匹配的secret");
|
||||
log.info("节点验证失败:未找到匹配的secret");
|
||||
return false;
|
||||
}
|
||||
attributes.put("id", node.getId());
|
||||
@@ -56,5 +59,13 @@ public class WebSocketInterceptor extends HttpSessionHandshakeInterceptor {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getClientIp(ServerHttpRequest request) {
|
||||
InetSocketAddress remoteAddress = request.getRemoteAddress();
|
||||
if (remoteAddress != null) {
|
||||
return remoteAddress.getAddress().getHostAddress();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user