修改参数

This commit is contained in:
=
2023-11-14 17:04:10 +08:00
parent 4569165993
commit f2005b3e74
7 changed files with 42 additions and 28 deletions
@@ -94,7 +94,7 @@ public class ProxyMessageConnectHandler implements ProxyMessageHandler {
}
// 设置加密
ProxyUtil.setChannelSecurity(licenseDO.getId(), visitorChannel);
ProxyUtil.setChannelSecurity(licenseDO.getId(), ctx.channel());
}
@Override
@@ -66,11 +66,6 @@ public class ProxyMessageSecureKeyHandler implements ProxyMessageHandler {
Integer licenseId = ctx.attr(Constants.LICENSE_ID).get();
ProxyUtil.setSecureKey(licenseId, secureKey);
ProxyUtil.setChannelSecurity(licenseId, ctx.channel());
Map<String, Channel> channelMap = ProxyUtil.getVisitorChannels(ctx.channel());
channelMap.values().forEach(channel -> ProxyUtil.setChannelSecurity(licenseId, channel));
if (licenseId != null) {
ProxyUtil.setLicenseIdRelativeChannelSecurity(licenseId);
}
}
@Override
@@ -38,15 +38,15 @@ public class ProxyUtil {
/**
* 服务端口 -> 指令通道映射
*/
private static Map<Integer, Channel> serverPortToCmdChannelMap = new ConcurrentHashMap<>();
private static final Map<Integer, Channel> serverPortToCmdChannelMap = new ConcurrentHashMap<>();
/**
* license -> 指令通道映射
*/
private static Map<Integer, Channel> licenseToCmdChannelMap = new ConcurrentHashMap<>();
private static final Map<Integer, Channel> licenseToCmdChannelMap = new ConcurrentHashMap<>();
/**
* 服务端口 -> 访问通道映射
*/
private static Map<Integer, Channel> serverPortToVisitorChannel = new ConcurrentHashMap<>();
private static final Map<Integer, Channel> serverPortToVisitorChannel = new ConcurrentHashMap<>();
/**
* cmdChannelAttachInfo.getUserChannelMap() 读写锁
@@ -55,21 +55,21 @@ public class ProxyUtil {
/**
* 访问者ID生成器
*/
private static AtomicLong visitorIdProducer = new AtomicLong(0);
private static final AtomicLong visitorIdProducer = new AtomicLong(0);
/**
* 代理 - connect附加映射
*/
private static Map<String, ProxyAttachment> proxyConnectAttachmentMap = new HashMap<>();
private static final Map<String, ProxyAttachment> proxyConnectAttachmentMap = new HashMap<>();
/**
* 子域名 - 服务端端口映射
*/
private static Map<String, Integer> subdomainToServerPort = new HashMap<>();
private static final Map<String, Integer> subdomainToServerPort = new HashMap<>();
/**
* licenseId - 客户端Id映射
*/
private static Map<Integer, String> licenseIdToClientIdMap = new HashMap<>();
private static final Map<Integer, String> licenseIdToClientIdMap = new HashMap<>();
private static Map<Integer, byte[]> licenseIdToSecureKeyMap = new ConcurrentHashMap<>();
private static final Map<Integer, byte[]> licenseIdToSecureKeyMap = new ConcurrentHashMap<>();
/**
* 初始化代理信息
@@ -146,9 +146,6 @@ public class ProxyUtil {
cmdChannelAttachInfo.getServerPorts().addAll(serverPorts);
}
// 添加安全信息
setChannelSecurity(licenseId, cmdChannel);
licenseToCmdChannelMap.put(licenseId, cmdChannel);
}
@@ -431,13 +428,10 @@ public class ProxyUtil {
licenseIdToSecureKeyMap.put(licenseId, key);
}
public static void setLicenseIdRelativeChannelSecurity(Integer licenseId) {
public static void setLicenseIdRelativeProxyChannelSecurity(Integer licenseId) {
Set<Integer> portSet = licenseToServerPortMap.get(licenseId);
for(Integer port : portSet) {
Channel cmdChannel = serverPortToCmdChannelMap.get(port);
setChannelSecurity(licenseId, cmdChannel);
Channel visitorChannel = serverPortToVisitorChannel.get(port);
setChannelSecurity(licenseId,visitorChannel);
// TODO 代理客户端
}
}