feat: 支持免密连接模式及允许免密连接开关

This commit is contained in:
2026-07-23 10:50:31 +08:00
parent a1c29246d7
commit 6ef18dd287
13 changed files with 206 additions and 53 deletions

View File

@@ -189,7 +189,7 @@ public class SignalWebSocketHandler extends TextWebSocketHandler {
return;
}
// 鉴权类型分类:动态验证码(CODE) / 固定密码(PASSWORD)。
// 鉴权类型分类:动态验证码(CODE) / 固定密码(PASSWORD) / 免密(NONE)
// 服务器只做分类与转发,真实校验在被控端完成(服务器不保存任何密钥)。
String authType = message.getAuthType();
if (authType != null && !authType.trim().isEmpty()) {
@@ -197,11 +197,17 @@ public class SignalWebSocketHandler extends TextWebSocketHandler {
logger.info("连接请求 {} -> {} 使用【动态验证码】鉴权", fromDeviceId, toDeviceId);
} else if ("PASSWORD".equalsIgnoreCase(authType)) {
logger.info("连接请求 {} -> {} 使用【固定密码】鉴权", fromDeviceId, toDeviceId);
} else if ("NONE".equalsIgnoreCase(authType)) {
// 显式标记为免密,便于被控端识别
message.setAuthType("NONE");
logger.info("连接请求 {} -> {} 使用【免密连接】鉴权(被控端手动确认)", fromDeviceId, toDeviceId);
} else {
logger.warn("连接请求 {} -> {} 携带未知鉴权类型 authType={}", fromDeviceId, toDeviceId, authType);
}
} else {
logger.info("连接请求 {} -> {} 未携带鉴权(走被控端手动确认)", fromDeviceId, toDeviceId);
// 未携带 authType 也视为免密连接(向后兼容),规范化为 NONE
message.setAuthType("NONE");
logger.info("连接请求 {} -> {} 未携带鉴权,按【免密连接】处理(被控端手动确认)", fromDeviceId, toDeviceId);
}
// 2. 去重:短时间内重复 OFFER 直接忽略,避免被控端反复弹窗