Compare commits

...

3 Commits

Author SHA1 Message Date
阿斌
69fac48479
Pre Merge pull request !36 from 阿斌/N/A 2026-01-29 22:15:15 +00:00
lin
40555d917b redis增肌连接池支持,增加设备国标严格限制设置 2026-01-30 06:14:58 +08:00
阿斌
da98101aac
update src/main/resources/civilCode.csv.
行政规划错误。江苏南通海门市,修改为海门区,浙江杭州删除下城区、江干区,新增钱塘区,临平区

Signed-off-by: 阿斌 <38912748@qq.com>
2024-12-15 08:58:42 +00:00
5 changed files with 26 additions and 4 deletions

View File

@ -405,6 +405,11 @@
<version>1.18.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View File

@ -219,4 +219,9 @@ 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

@ -4,6 +4,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.common.RemoteAddressInfo;
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
@ -88,6 +89,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);

View File

@ -861,7 +861,7 @@
320623,如东县,3206
320681,启东市,3206
320682,如皋市,3206
320684,海门,3206
320684,海门,3206
320685,海安市,3206
3207,连云港市,32
320703,连云区,3207
@ -918,8 +918,6 @@
33,浙江省,
3301,杭州市,33
330102,上城区,3301
330103,下城区,3301
330104,江干区,3301
330105,拱墅区,3301
330106,西湖区,3301
330108,滨江区,3301
@ -927,6 +925,8 @@
330110,余杭区,3301
330111,富阳区,3301
330112,临安区,3301
330113,临平区,3301
330114,钱塘区,3301
330122,桐庐县,3301
330127,淳安县,3301
330182,建德市,3301

1 编号 名称 上级
861 320623 如东县 3206
862 320681 启东市 3206
863 320682 如皋市 3206
864 320684 海门市 海门区 3206
865 320685 海安市 3206
866 3207 连云港市 32
867 320703 连云区 3207
918 33 浙江省
919 3301 杭州市 33
920 330102 上城区 3301
330103 下城区 3301
330104 江干区 3301
921 330105 拱墅区 3301
922 330106 西湖区 3301
923 330108 滨江区 3301
925 330110 余杭区 3301
926 330111 富阳区 3301
927 330112 临安区 3301
928 330113 临平区 3301
929 330114 钱塘区 3301
930 330122 桐庐县 3301
931 330127 淳安县 3301
932 330182 建德市 3301