Merge branch 'master' into dev/压力测试

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
This commit is contained in:
lin 2026-01-30 06:15:34 +08:00
commit 6a1f2887e5
3 changed files with 18 additions and 1 deletions

View File

@ -219,6 +219,11 @@ public class UserSetting {
*/
private boolean useAliasForGroupSync = false;
/**
* 设备ID严格模式开启后设备注册时如果设备ID不符合规范则拒绝注册, 默认开启
*/
private boolean deviceIdStrict = true;
/**
* 对于识别为设备的国标设备的是否默认开启位置订阅
*/

View File

@ -29,7 +29,7 @@ public class GbCode {
* 解析国标编号
*/
public static GbCode decode(String code){
if (code == null || code.trim().length() != 20) {
if (code == null || code.trim().length() != 20 || !code.matches("\\d{20}")) {
return null;
}
code = code.trim();

View File

@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.GbCode;
import com.genersoft.iot.vmp.gb28181.bean.GbSipDate;
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
@ -93,6 +94,17 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
AddressImpl address = (AddressImpl) fromHeader.getAddress();
SipUri uri = (SipUri) address.getURI();
String deviceId = uri.getUser();
if (userSetting.isDeviceIdStrict()) {
// 严格模式下非20位设备ID不予处理
GbCode decode = GbCode.decode(deviceId);
if (decode == null) {
// 注册失败
response = getMessageFactory().createResponse(Response.FORBIDDEN, request);
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
return;
}
}
// 调整逻辑如果为设置公共密码那么就必须要预设用户信息否则无法注册
Device device = deviceService.getDeviceByDeviceId(deviceId);