From bac19f583c60f86fd15a13230ea70bfc3a6645b1 Mon Sep 17 00:00:00 2001 From: chenghong <24211317@qq.com> Date: Mon, 14 Aug 2023 11:44:41 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E5=9B=BD=E6=A0=87=E5=B9=B3=E5=8F=B0=E7=9B=B8=E4=BA=92=E7=BA=A7?= =?UTF-8?q?=E8=81=94=E6=97=B6=EF=BC=8C=E4=B8=8A=E7=BA=A7=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=9B=AE=E5=BD=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/message/MessageHandlerAbstract.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java index afaa7cb3..6dcefa72 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java @@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; +import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd.CatalogQueryMessageHandler; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.dom4j.Element; import org.springframework.beans.factory.annotation.Autowired; @@ -16,6 +18,9 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i public Map messageHandlerMap = new ConcurrentHashMap<>(); + @Autowired + private IVideoManagerStorage storage; + public void addHandler(String cmdType, IMessageHandler messageHandler) { messageHandlerMap.put(cmdType, messageHandler); } @@ -24,7 +29,15 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i public void handForDevice(RequestEvent evt, Device device, Element element) { String cmd = getText(element, "CmdType"); IMessageHandler messageHandler = messageHandlerMap.get(cmd); + if (messageHandler != null) { + //两个国标平台互相级联时由于上一步判断导致本该在平台处理的消息 放到了设备的处理逻辑 + //所以对目录查询单独做了校验 + if(messageHandler instanceof CatalogQueryMessageHandler){ + ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(device.getDeviceId()); + messageHandler.handForPlatform(evt, parentPlatform, element); + return; + } messageHandler.handForDevice(evt, device, element); } } From 1b81080f6f7da35d2af7d194a5aa7be720d1eaa4 Mon Sep 17 00:00:00 2001 From: yangjunyi Date: Tue, 29 Aug 2023 14:23:28 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=9A=E9=81=93?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=90=8C=E6=AD=A5=E5=BC=82=E5=B8=B8=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/cmd/CatalogResponseMessageHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index 8648dc45..5c977a50 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicBoolean; /** * 目录查询的回复 @@ -60,6 +61,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp @Autowired private SipConfig sipConfig; + private AtomicBoolean processing = new AtomicBoolean(false); @Override public void afterPropertiesSet() throws Exception { @@ -68,7 +70,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp @Override public void handForDevice(RequestEvent evt, Device device, Element element) { - boolean isEmpty = taskQueue.isEmpty(); taskQueue.offer(new HandlerCatchData(evt, device, element)); // 回复200 OK try { @@ -76,8 +77,8 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp } catch (SipException | InvalidArgumentException | ParseException e) { logger.error("[命令发送失败] 目录查询回复: {}", e.getMessage()); } - // 如果不为空则说明已经开启消息处理 - if (isEmpty) { + // 已经开启消息处理则跳过 + if (processing.compareAndSet(false, true)) { taskExecutor.execute(() -> { while (!taskQueue.isEmpty()) { // 全局异常捕获,保证下一条可以得到处理 @@ -146,11 +147,12 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp } } - }catch (Exception e) { + } catch (Exception e) { logger.warn("[收到通道] 发现未处理的异常, \r\n{}", evt.getRequest()); logger.error("[收到通道] 异常内容: ", e); } } + processing.set(false); }); } From e8b2ca46862565b7b6d2f05c3f45f7873afe044e Mon Sep 17 00:00:00 2001 From: xubinbin <1323875150@qq.com> Date: Thu, 31 Aug 2023 16:39:18 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E5=B0=86=E7=94=9F=E6=88=90jwt=E4=BB=A4?= =?UTF-8?q?=E7=89=8C=E5=92=8C=E9=AA=8C=E8=AF=81jwt=E4=BB=A4=E7=89=8C?= =?UTF-8?q?=E6=97=B6=E4=BD=BF=E7=94=A8=E7=9A=84=E5=85=AC=E9=92=A5=E7=A7=81?= =?UTF-8?q?=E9=92=A5=E7=94=B1=E5=9B=BA=E5=AE=9A=E5=80=BC=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=AF=8F=E6=AC=A1=E5=90=AF=E5=8A=A8=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=97=B6=E5=8A=A8=E6=80=81=E7=94=9F=E4=BA=A7=EF=BC=9B=E5=89=94?= =?UTF-8?q?=E9=99=A4jwt=20token=E4=B8=AD=E5=8C=85=E5=90=AB=E7=9A=84passwor?= =?UTF-8?q?d=E5=92=8CroleId=EF=BC=8C=E9=98=B2=E6=AD=A2=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E6=B3=84=E9=9C=B2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/conf/security/JwtUtils.java | 85 ++++++++++++------- .../iot/vmp/vmanager/user/UserController.java | 2 +- 2 files changed, 54 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java index 05faba56..65e9de37 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java @@ -1,8 +1,10 @@ package com.genersoft.iot.vmp.conf.security; import com.genersoft.iot.vmp.conf.security.dto.JwtUser; -import org.jose4j.json.JsonUtil; +import com.genersoft.iot.vmp.service.IUserService; +import com.genersoft.iot.vmp.storager.dao.dto.User; import org.jose4j.jwk.RsaJsonWebKey; +import org.jose4j.jwk.RsaJwkGenerator; import org.jose4j.jws.AlgorithmIdentifiers; import org.jose4j.jws.JsonWebSignature; import org.jose4j.jwt.JwtClaims; @@ -14,45 +16,69 @@ import org.jose4j.jwt.consumer.JwtConsumerBuilder; import org.jose4j.lang.JoseException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Component; -import java.security.PrivateKey; +import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneOffset; -public class JwtUtils { +@Component +public class JwtUtils implements InitializingBean { private static final Logger logger = LoggerFactory.getLogger(JwtUtils.class); private static final String HEADER = "access-token"; + private static final String AUDIENCE = "Audience"; - private static final long EXPIRED_THRESHOLD = 10 * 60; - private static final String keyId = "3e79646c4dbc408383a9eed09f2b85ae"; - private static final String privateKeyStr = "{\"kty\":\"RSA\",\"kid\":\"3e79646c4dbc408383a9eed09f2b85ae\",\"alg\":\"RS256\",\"n\":\"gndmVdiOTSJ5et2HIeTM5f1m61x5ojLUi5HDfvr-jRrESQ5kbKuySGHVwR4QhwinpY1wQqBnwc80tx7cb_6SSqsTOoGln6T_l3k2Pb54ClVnGWiW_u1kmX78V2TZOsVmZmwtdZCMi-2zWIyAdIEXE-gncIehoAgEoq2VAhaCURbJWro_EwzzQwNmCTkDodLAx4npXRd_qSu0Ayp0txym9OFovBXBULRvk4DPiy3i_bPUmCDxzC46pTtFOe9p82uybTehZfULZtXXqRm85FL9n5zkrsTllPNAyEGhgb0RK9sE5nK1m_wNNysDyfLC4EFf1VXTrKm14XNVjc2vqLb7Mw\",\"e\":\"AQAB\",\"d\":\"ed7U_k3rJ4yTk70JtRSIfjKGiEb67BO1TabcymnljKO7RU8nage84zZYuSu_XpQsHk6P1f0Gzxkicghm_Er-FrfVn2pp70Xu52z3yRd6BJUgWLDFk97ngScIyw5OiULKU9SrZk2frDpftNCSUcIgb50F8m0QAnBa_CdPsQKbuuhLv8V8tBAV7F_lAwvSBgu56wRo3hPz5dWH8YeXM7XBfQ9viFMNEKd21sP_j5C7ueUnXT66nBxe3ZJEU3iuMYM6D6dB_KW2GfZC6WmTgvGhhxJD0h7aYmfjkD99MDleB7SkpbvoODOqiQ5Epb7Nyh6kv5u4KUv2CJYtATLZkUeMkQ\",\"p\":\"uBUjWPWtlGksmOqsqCNWksfqJvMcnP_8TDYN7e4-WnHL4N-9HjRuPDnp6kHvCIEi9SEfxm7gNxlRcWegvNQr3IZCz7TnCTexXc5NOklB9OavWFla6u-s3Thn6Tz45-EUjpJr0VJMxhO-KxGmuTwUXBBp4vN6K2qV6rQNFmgkWzk\",\"q\":\"tW_i7cCec56bHkhITL_79dXHz_PLC_f7xlynmlZJGU_d6mqOKmLBNBbTMLnYW8uAFiFzWxDeDHh1o5uF0mSQR-Z1Fg35OftnpbWpy0Cbc2la5WgXQjOwtG1eLYIY2BD3-wQ1VYDBCvowr4FDi-sngxwLqvwmrJ0xjhi99O-Gzcs\",\"dp\":\"q1d5jE85Hz_6M-eTh_lEluEf0NtPEc-vvhw-QO4V-cecNpbrCBdTWBmr4dE3NdpFeJc5ZVFEv-SACyei1MBEh0ItI_pFZi4BmMfy2ELh8ptaMMkTOESYyVy8U7veDq9RnBcr5i1Nqr0rsBkA77-9T6gzdvycBZdzLYAkAmwzEvk\",\"dq\":\"q29A2K08Crs-jmp2Bi8Q_8QzvIX6wSBbwZ4ir24AO-5_HNP56IrPS0yV2GCB0pqCOGb6_Hz_koDvhtuYoqdqvMVAtMoXR3YJBUaVXPt65p4RyNmFwIPe31zHs_BNUTsXVRMw4c16mci03-Af1sEm4HdLfxAp6sfM3xr5wcnhcek\",\"qi\":\"rHPgVTyHUHuYzcxfouyBfb1XAY8nshwn0ddo81o1BccD4Z7zo5It6SefDHjxCAbcmbiCcXBSooLcY-NF5FMv3fg19UE21VyLQltHcVjRRp2tRs4OHcM8yaXIU2x6N6Z6BP2tOksHb9MOBY1wAQzFOAKg_G4Sxev6-_6ud6RISuc\"}"; - private static final String publicKeyStr = "{\"kty\":\"RSA\",\"kid\":\"3e79646c4dbc408383a9eed09f2b85ae\",\"alg\":\"RS256\",\"n\":\"gndmVdiOTSJ5et2HIeTM5f1m61x5ojLUi5HDfvr-jRrESQ5kbKuySGHVwR4QhwinpY1wQqBnwc80tx7cb_6SSqsTOoGln6T_l3k2Pb54ClVnGWiW_u1kmX78V2TZOsVmZmwtdZCMi-2zWIyAdIEXE-gncIehoAgEoq2VAhaCURbJWro_EwzzQwNmCTkDodLAx4npXRd_qSu0Ayp0txym9OFovBXBULRvk4DPiy3i_bPUmCDxzC46pTtFOe9p82uybTehZfULZtXXqRm85FL9n5zkrsTllPNAyEGhgb0RK9sE5nK1m_wNNysDyfLC4EFf1VXTrKm14XNVjc2vqLb7Mw\",\"e\":\"AQAB\"}"; /** * token过期时间(分钟) */ public static final long expirationTime = 30 * 24 * 60; - public static String createToken(String username, String password, Integer roleId) { + private static RsaJsonWebKey rsaJsonWebKey; + + private static IUserService userService; + + @Resource + public void setUserService(IUserService userService) { + JwtUtils.userService = userService; + } + + @Override + public void afterPropertiesSet() { try { - /** + rsaJsonWebKey = generateRsaJsonWebKey(); + } catch (JoseException e) { + logger.error("生成RsaJsonWebKey报错。", e); + } + } + + /** + * 创建密钥对 + * @throws JoseException JoseException + */ + private RsaJsonWebKey generateRsaJsonWebKey() throws JoseException { + // 生成一个RSA密钥对,该密钥对将用于JWT的签名和验证,包装在JWK中 + RsaJsonWebKey rsaJsonWebKey = RsaJwkGenerator.generateJwk(2048); + // 给JWK一个密钥ID + rsaJsonWebKey.setKeyId(keyId); + return rsaJsonWebKey; + } + + public static String createToken(String username) { + try { + /* * “iss” (issuer) 发行人 - * * “sub” (subject) 主题 - * * “aud” (audience) 接收方 用户 - * * “exp” (expiration time) 到期时间 - * * “nbf” (not before) 在此之前不可用 - * * “iat” (issued at) jwt的签发时间 */ - //Payload JwtClaims claims = new JwtClaims(); claims.setGeneratedJwtId(); claims.setIssuedAtToNow(); @@ -62,9 +88,7 @@ public class JwtUtils { claims.setSubject("login"); claims.setAudience(AUDIENCE); //添加自定义参数,必须是字符串类型 - claims.setClaim("username", username); - claims.setClaim("password", password); - claims.setClaim("roleId", roleId); + claims.setClaim("userName", username); //jws JsonWebSignature jws = new JsonWebSignature(); @@ -73,12 +97,10 @@ public class JwtUtils { jws.setKeyIdHeaderValue(keyId); jws.setPayload(claims.toJson()); - PrivateKey privateKey = new RsaJsonWebKey(JsonUtil.parseJson(privateKeyStr)).getPrivateKey(); - jws.setKey(privateKey); + jws.setKey(rsaJsonWebKey.getPrivateKey()); //get token - String idToken = jws.getCompactSerialization(); - return idToken; + return jws.getCompactSerialization(); } catch (JoseException e) { logger.error("[Token生成失败]: {}", e.getMessage()); } @@ -90,7 +112,6 @@ public class JwtUtils { return HEADER; } - public static JwtUser verifyToken(String token) { JwtUser jwtUser = new JwtUser(); @@ -103,7 +124,7 @@ public class JwtUtils { .setRequireSubject() //.setExpectedIssuer("") .setExpectedAudience(AUDIENCE) - .setVerificationKey(new RsaJsonWebKey(JsonUtil.parseJson(publicKeyStr)).getPublicKey()) + .setVerificationKey(rsaJsonWebKey.getPublicKey()) .build(); JwtClaims claims = consumer.processToClaims(token); @@ -113,26 +134,26 @@ public class JwtUtils { long timeRemaining = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)) - expirationTime.getValue(); if (timeRemaining < 5 * 60) { jwtUser.setStatus(JwtUser.TokenStatus.EXPIRING_SOON); - }else { + } else { jwtUser.setStatus(JwtUser.TokenStatus.NORMAL); } - String username = (String) claims.getClaimValue("username"); - String password = (String) claims.getClaimValue("password"); - Long roleId = (Long) claims.getClaimValue("roleId"); + String username = (String) claims.getClaimValue("userName"); + User user = userService.getUserByUsername(username); + jwtUser.setUserName(username); - jwtUser.setPassword(password); - jwtUser.setRoleId(roleId.intValue()); + jwtUser.setPassword(user.getPassword()); + jwtUser.setRoleId(user.getRole().getId()); return jwtUser; } catch (InvalidJwtException e) { if (e.hasErrorCode(ErrorCodes.EXPIRED)) { jwtUser.setStatus(JwtUser.TokenStatus.EXPIRED); - }else { + } else { jwtUser.setStatus(JwtUser.TokenStatus.EXCEPTION); } return jwtUser; - }catch (Exception e) { + } catch (Exception e) { logger.error("[Token解析失败]: {}", e.getMessage()); jwtUser.setStatus(JwtUser.TokenStatus.EXPIRED); return jwtUser; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java index 5ffb02cb..b6f91832 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java @@ -57,7 +57,7 @@ public class UserController { if (user == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "用户名或密码错误"); }else { - String jwt = JwtUtils.createToken(username, password, user.getRole().getId()); + String jwt = JwtUtils.createToken(username); response.setHeader(JwtUtils.getHeader(), jwt); user.setAccessToken(jwt); } From d38ccc257c252e031363aef6c8fa19aff1a65692 Mon Sep 17 00:00:00 2001 From: chenzhangyue Date: Thu, 31 Aug 2023 17:36:57 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BF=AE=E5=A4=8D=EF=BC=8C=E8=BF=99=E9=87=8C?= =?UTF-8?q?update=E5=BA=94=E8=AF=A5=E4=B8=BA=E6=9F=A5=E5=87=BA=E6=9D=A5?= =?UTF-8?q?=E7=9A=84DO=EF=BC=8C=E4=B8=8D=E6=98=AF=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E7=9A=84DO=EF=BC=8C=E9=87=87=E7=94=A8=E6=9B=B4=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E7=9A=84redis=E7=AD=96=E7=95=A5=EF=BC=8C=E6=9B=B4?= =?UTF-8?q?=E6=96=B0DB=E5=88=A0=E9=99=A4=E7=BC=93=E5=AD=98=EF=BC=8C?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AE=BE=E5=A4=87=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/impl/DeviceServiceImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index 166b1922..1dc50f00 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -544,18 +544,19 @@ public class DeviceServiceImpl implements IDeviceService { if (deviceInStore.getGeoCoordSys() != null) { // 坐标系变化,需要重新计算GCJ02坐标和WGS84坐标 if (!deviceInStore.getGeoCoordSys().equals(device.getGeoCoordSys())) { - updateDeviceChannelGeoCoordSys(device); + deviceInStore.setGeoCoordSys(device.getGeoCoordSys()); + updateDeviceChannelGeoCoordSys(deviceInStore); } }else { - device.setGeoCoordSys("WGS84"); + deviceInStore.setGeoCoordSys("WGS84"); } if (device.getCharset() == null) { - device.setCharset("GB2312"); + deviceInStore.setCharset("GB2312"); } // 更新redis - redisCatchStorage.updateDevice(device); - deviceMapper.updateCustom(device); + deviceMapper.updateCustom(deviceInStore); + redisCatchStorage.removeDevice(deviceInStore.getDeviceId()); } @Override From bf8fbf4927d8ddec69893a6bebb79dadf1b4225d Mon Sep 17 00:00:00 2001 From: chenzhangyue Date: Fri, 1 Sep 2023 17:22:53 +0800 Subject: [PATCH 05/10] =?UTF-8?q?bugfix:=E8=BF=99=E9=87=8C=E5=BA=94?= =?UTF-8?q?=E8=AF=A5=E4=B8=8D=E5=AD=98=E5=9C=A8key=E6=89=8D=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/impl/MediaServerServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index f8c1ba18..6bbb4bc3 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -128,7 +128,7 @@ public class MediaServerServiceImpl implements IMediaServerService { continue; } // 更新 - if (ssrcFactory.hasMediaServerSSRC(mediaServerItem.getId())) { + if (!ssrcFactory.hasMediaServerSSRC(mediaServerItem.getId())) { ssrcFactory.initMediaServerSSRC(mediaServerItem.getId(), null); } // 查询redis是否存在此mediaServer @@ -229,7 +229,7 @@ public class MediaServerServiceImpl implements IMediaServerService { mediaServerMapper.update(mediaSerItem); MediaServerItem mediaServerItemInRedis = getOne(mediaSerItem.getId()); MediaServerItem mediaServerItemInDataBase = mediaServerMapper.queryOne(mediaSerItem.getId()); - if (mediaServerItemInRedis == null || ssrcFactory.hasMediaServerSSRC(mediaSerItem.getId())) { + if (mediaServerItemInRedis == null || !ssrcFactory.hasMediaServerSSRC(mediaSerItem.getId())) { ssrcFactory.initMediaServerSSRC(mediaServerItemInDataBase.getId(),null); } String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItemInDataBase.getId(); @@ -411,7 +411,7 @@ public class MediaServerServiceImpl implements IMediaServerService { } mediaServerMapper.update(serverItem); String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + zlmServerConfig.getGeneralMediaServerId(); - if (ssrcFactory.hasMediaServerSSRC(serverItem.getId())) { + if (!ssrcFactory.hasMediaServerSSRC(serverItem.getId())) { ssrcFactory.initMediaServerSSRC(zlmServerConfig.getGeneralMediaServerId(), null); } redisTemplate.opsForValue().set(key, serverItem); From 73f6f044a1aa58b9c422d19c30198bb515e7616d Mon Sep 17 00:00:00 2001 From: chenzhangyue Date: Fri, 1 Sep 2023 17:53:48 +0800 Subject: [PATCH 06/10] local dev --- src/main/resources/application-dev.yml | 24 ++++++++++++------------ src/main/resources/application.yml | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 504c9c66..e149886e 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -19,14 +19,14 @@ spring: # [可选] 数据库 DB database: 7 # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 - password: + password: luna # [可选] 超时时间 timeout: 10000 # mysql数据源 datasource: type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://127.0.0.1:3306/test_gb-89wulian?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true + url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true username: root password: root hikari: @@ -38,7 +38,7 @@ spring: max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位) #[可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 server: - port: 18978 + port: 8080 # [可选] HTTPS配置, 默认不开启 ssl: # [可选] 是否开启HTTPS访问 @@ -56,7 +56,7 @@ sip: # 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4 # 如果不明白,就使用0.0.0.0,大部分情况都是可以的 # 请不要使用127.0.0.1,任何包括localhost在内的域名都是不可以的。 - ip: 192.168.1.18 + ip: 172.19.128.50 # [可选] 28181服务监听的端口 port: 8116 # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) @@ -73,21 +73,21 @@ sip: #zlm 默认服务器配置 media: - id: 89wulian-one + id: zlmediakit-local # [必须修改] zlm服务器的内网IP - ip: 192.168.1.18 + ip: 172.19.128.50 # [必须修改] zlm服务器的http.port - http-port: 80 + http-port: 9092 # [可选] 返回流地址时的ip,置空使用 media.ip - stream-ip: 192.168.1.18 + stream-ip: 172.19.128.50 # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip - sdp-ip: 192.168.1.18 + sdp-ip: 172.19.128.50 # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip - hook-ip: 192.168.1.18 + hook-ip: 172.19.128.50 # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置 - http-ssl-port: 443 + http-ssl-port: 1443 # [可选] zlm服务器的hook.admin_params=secret - secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc + secret: 10000 # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 rtp: # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 3f478442..80de5efb 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -2,4 +2,4 @@ spring: application: name: wvp profiles: - active: local \ No newline at end of file + active: dev \ No newline at end of file From 7155680793e24ad2808eef5bdeaf5b66c875c102 Mon Sep 17 00:00:00 2001 From: chenzhangyue Date: Tue, 5 Sep 2023 17:35:46 +0800 Subject: [PATCH 07/10] fix VideoManagerConstants.SIP_SUBSCRIBE_PREFIX key set --- .../iot/vmp/gb28181/bean/SubscribeHolder.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java index ba905b50..d385d9af 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java @@ -2,12 +2,9 @@ package com.genersoft.iot.vmp.gb28181.bean; import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -24,6 +21,9 @@ public class SubscribeHolder { @Autowired private DynamicTask dynamicTask; + @Autowired + private UserSetting userSetting; + private final String taskOverduePrefix = "subscribe_overdue_"; private static ConcurrentHashMap catalogMap = new ConcurrentHashMap<>(); @@ -58,7 +58,7 @@ public class SubscribeHolder { public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo) { mobilePositionMap.put(platformId, subscribeInfo); - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + "MobilePosition_" + platformId; + String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId; // 添加任务处理GPS定时推送 dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(platformId), subscribeInfo.getGpsInterval() * 1000); @@ -76,7 +76,7 @@ public class SubscribeHolder { public void removeMobilePositionSubscribe(String platformId) { mobilePositionMap.remove(platformId); - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + "MobilePosition_" + platformId; + String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId; // 结束任务处理GPS定时推送 dynamicTask.stop(key); String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId; From 1d0c9c6a31cd8e15a5fc270d0a942807fd6187b9 Mon Sep 17 00:00:00 2001 From: chenzhangyue Date: Wed, 6 Sep 2023 09:49:50 +0800 Subject: [PATCH 08/10] fix set password --- .../com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index 1dc50f00..347e976f 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -511,6 +511,10 @@ public class DeviceServiceImpl implements IDeviceService { if (!ObjectUtils.isEmpty(device.getSdpIp())) { deviceInStore.setSdpIp(device.getSdpIp()); } + if (!ObjectUtils.isEmpty(device.getPassword())) { + deviceInStore.setPassword(device.getPassword()); + } + // 目录订阅相关的信息 if (device.getSubscribeCycleForCatalog() > 0) { From 33d4107d0c1776d730d84998c42b29933673525f Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 6 Sep 2023 10:21:42 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E6=97=B6=E5=A6=82=E6=9E=9C=E4=B8=8A=E6=9C=BA=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E8=BF=9E=E6=8E=A5=E7=9A=84=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E6=8C=81=E7=BB=AD=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java | 7 +++---- .../iot/vmp/service/impl/PlatformServiceImpl.java | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java index b58b91c5..7760bddf 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java @@ -14,9 +14,6 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; import java.util.List; /** @@ -61,8 +58,10 @@ public class SipPlatformRunner implements CommandLineRunner { sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{ platformService.login(parentPlatform); }); - } catch (InvalidArgumentException | ParseException | SipException e) { + } catch (Exception e) { logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage()); + platformService.offline(parentPlatform, true); + continue; } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java index 86ee0f4f..d295ed4c 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java @@ -276,7 +276,7 @@ public class PlatformServiceImpl implements IPlatformService { eventResult.statusCode, eventResult.msg); offline(parentPlatform, false); }, null); - } catch (InvalidArgumentException | ParseException | SipException e) { + } catch (Exception e) { logger.error("[命令发送失败] 国标级联定时注册: {}", e.getMessage()); } } From 18aff4b546d4f55da8bc8536d5be81e57897d61a Mon Sep 17 00:00:00 2001 From: davidche Date: Wed, 6 Sep 2023 10:30:20 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20#1058?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index 1dc50f00..6a44c3a5 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -553,7 +553,11 @@ public class DeviceServiceImpl implements IDeviceService { if (device.getCharset() == null) { deviceInStore.setCharset("GB2312"); } - + //SSRC校验 + deviceInStore.setSsrcCheck(device.isSsrcCheck()); + //作为消息通道 + deviceInStore.setAsMessageChannel(device.isAsMessageChannel()); + // 更新redis deviceMapper.updateCustom(deviceInStore); redisCatchStorage.removeDevice(deviceInStore.getDeviceId());