feat: 增加密码连接
This commit is contained in:
@@ -189,6 +189,21 @@ public class SignalWebSocketHandler extends TextWebSocketHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// 鉴权类型分类:动态验证码(CODE) / 固定密码(PASSWORD)。
|
||||
// 服务器只做分类与转发,真实校验在被控端完成(服务器不保存任何密钥)。
|
||||
String authType = message.getAuthType();
|
||||
if (authType != null && !authType.trim().isEmpty()) {
|
||||
if ("CODE".equalsIgnoreCase(authType)) {
|
||||
logger.info("连接请求 {} -> {} 使用【动态验证码】鉴权", fromDeviceId, toDeviceId);
|
||||
} else if ("PASSWORD".equalsIgnoreCase(authType)) {
|
||||
logger.info("连接请求 {} -> {} 使用【固定密码】鉴权", fromDeviceId, toDeviceId);
|
||||
} else {
|
||||
logger.warn("连接请求 {} -> {} 携带未知鉴权类型 authType={}", fromDeviceId, toDeviceId, authType);
|
||||
}
|
||||
} else {
|
||||
logger.info("连接请求 {} -> {} 未携带鉴权(走被控端手动确认)", fromDeviceId, toDeviceId);
|
||||
}
|
||||
|
||||
// 2. 去重:短时间内重复 OFFER 直接忽略,避免被控端反复弹窗
|
||||
if (connectionRequestManager.isDuplicateOffer(fromDeviceId, toDeviceId)) {
|
||||
logger.info("Duplicate connection request {} -> {} ignored", fromDeviceId, toDeviceId);
|
||||
|
||||
@@ -10,6 +10,8 @@ public class SignalMessage {
|
||||
private String toDeviceId; // 目标设备ID
|
||||
private String deviceType; // CONTROLLER 或 CONTROLLED
|
||||
private String payload; // JSON格式的信令数据(SDP/ICE/控制指令)
|
||||
private String authType; // 鉴权类型:CODE(动态验证码)/ PASSWORD(固定密码)
|
||||
private String authValue; // 鉴权值:动态验证码或固定密码
|
||||
|
||||
public SignalMessage() {}
|
||||
|
||||
@@ -27,4 +29,10 @@ public class SignalMessage {
|
||||
|
||||
public String getPayload() { return payload; }
|
||||
public void setPayload(String payload) { this.payload = payload; }
|
||||
|
||||
public String getAuthType() { return authType; }
|
||||
public void setAuthType(String authType) { this.authType = authType; }
|
||||
|
||||
public String getAuthValue() { return authValue; }
|
||||
public void setAuthValue(String authValue) { this.authValue = authValue; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user