【fix】服务端内网渗透

This commit is contained in:
wujiawei
2024-09-17 15:19:07 +08:00
parent 5852aad88a
commit 234613a76a
30 changed files with 1772 additions and 68 deletions

View File

@ -0,0 +1,46 @@
package org.framework.lazy.cloud.network.heartbeat.common;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
/**
* 渗透端口对应访客上下文
*/
public class NettyPermeateVisitorContext {
protected static final ConcurrentHashMap<Integer/*permeatePort*/, Object/*NettyPermeateVisitorSocket*/> PERMEATE_VISITOR_SOCKET = new ConcurrentHashMap<>();
/**
* 添加访客
*
* @param permeatePort 渗透端口
* @param permeateVisitorSocket 渗透访客socket
*/
public static <T> void pushPermeateVisitorSocket(Integer permeatePort, T permeateVisitorSocket) {
PERMEATE_VISITOR_SOCKET.put(permeatePort, permeateVisitorSocket);
}
/**
* 通过客户端ID获取客户端使用的访客socket
*
* @param <T> 渗透访客socket
* @param permeatePort 渗透端口
* @return 访客
*/
public static <T> T getPermeateVisitorSocket(Integer permeatePort) {
return (T) PERMEATE_VISITOR_SOCKET.getOrDefault(permeatePort, null);
}
/**
* 移除 渗透访客socket
*
* @param permeatePort 渗透端口
*/
public static void removePermeateVisitorSockets(Integer permeatePort) {
PERMEATE_VISITOR_SOCKET.remove(permeatePort);
}
}