mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-06-29 21:47:50 +08:00
Compare commits
5 Commits
f840ce91f5
...
bc3b648cdd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc3b648cdd | ||
|
|
bc1b5797e8 | ||
|
|
ef69a355fd | ||
|
|
03d36a9ac7 | ||
|
|
c011389c3f |
@ -22,6 +22,8 @@ public class MessageEvent<T> implements Delayed {
|
||||
|
||||
private String result;
|
||||
|
||||
private boolean keepAlive = false;
|
||||
|
||||
private T t;
|
||||
|
||||
private ErrorCallback<T> callback;
|
||||
|
||||
@ -3,15 +3,22 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.RequestEvent;
|
||||
import javax.sip.SipException;
|
||||
import javax.sip.message.Response;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* SIP命令类型: CANCEL请求
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CancelRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor {
|
||||
|
||||
@ -34,7 +41,11 @@ public class CancelRequestProcessor extends SIPRequestProcessorParent implements
|
||||
@Override
|
||||
public void process(RequestEvent evt) {
|
||||
// TODO 优先级99 Cancel Request消息实现,此消息一般为级联消息,上级给下级发送请求取消指令
|
||||
|
||||
try {
|
||||
responseAck((SIPRequest) evt.getRequest(), Response.OK);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -593,7 +593,12 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
playService.stopAudioBroadcast(device, deviceChannel);
|
||||
}
|
||||
} catch (SdpException e) {
|
||||
log.error("[SDP解析异常]", e);
|
||||
log.error("[语音通话] SDP解析异常", e);
|
||||
try {
|
||||
responseAck(request, Response.BAD_REQUEST);
|
||||
} catch (SipException | InvalidArgumentException | ParseException exception) {
|
||||
log.error("[命令发送失败] 来自设备的Invite请求非语音广播 FORBIDDEN: {}", exception.getMessage());
|
||||
}
|
||||
playService.stopAudioBroadcast(device, deviceChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,6 +63,11 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
|
||||
messageHandler.handForDevice(evt, device, element);
|
||||
}else {
|
||||
handMessageEvent(element, null);
|
||||
try {
|
||||
responseAck((SIPRequest) evt.getRequest(), Response.OK);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,6 +77,12 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
|
||||
IMessageHandler messageHandler = messageHandlerMap.get(cmd);
|
||||
if (messageHandler != null) {
|
||||
messageHandler.handForPlatform(evt, parentPlatform, element);
|
||||
}else {
|
||||
try {
|
||||
responseAck((SIPRequest) evt.getRequest(), Response.OK);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +98,9 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
|
||||
}else {
|
||||
subscribe.getCallback().run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), result);
|
||||
}
|
||||
messageSubscribe.removeSubscribe(cmd + sn);
|
||||
if (!subscribe.isKeepAlive()) {
|
||||
messageSubscribe.removeSubscribe(cmd + sn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
|
||||
}else { // 由于上面已经判断都为null则直接返回,所以这里device和parentPlatform必有一个不为null
|
||||
messageHandler.handForPlatform(evt, parentPlatform, rootElement);
|
||||
}
|
||||
responseAck(request, Response.OK);
|
||||
// 存在handler则由handler自行决定回复什么。
|
||||
}else {
|
||||
// 不支持的message
|
||||
// 不存在则回复415
|
||||
|
||||
@ -63,7 +63,11 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||
|
||||
@Override
|
||||
public void handForDevice(RequestEvent evt, Device device, Element element) {
|
||||
|
||||
try {
|
||||
responseAck((SIPRequest) evt.getRequest(), Response.OK);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -71,7 +71,11 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp
|
||||
|
||||
@Override
|
||||
public void handForDevice(RequestEvent evt, Device device, Element element) {
|
||||
|
||||
try {
|
||||
responseAck((SIPRequest) evt.getRequest(), Response.OK);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -34,7 +34,11 @@ public class AlarmQueryMessageHandler extends SIPRequestProcessorParent implemen
|
||||
|
||||
@Override
|
||||
public void handForDevice(RequestEvent evt, Device device, Element element) {
|
||||
|
||||
try {
|
||||
responseAck((SIPRequest) evt.getRequest(), Response.OK);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -55,7 +55,11 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp
|
||||
|
||||
@Override
|
||||
public void handForDevice(RequestEvent evt, Device device, Element rootElement) {
|
||||
|
||||
try {
|
||||
responseAck((SIPRequest) evt.getRequest(), Response.OK);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -46,7 +46,11 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i
|
||||
|
||||
@Override
|
||||
public void handForDevice(RequestEvent evt, Device device, Element element) {
|
||||
|
||||
try {
|
||||
responseAck((SIPRequest) evt.getRequest(), Response.OK);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -65,7 +65,11 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
|
||||
|
||||
@Override
|
||||
public void handForDevice(RequestEvent evt, Device device, Element element) {
|
||||
|
||||
try {
|
||||
responseAck((SIPRequest) evt.getRequest(), Response.OK);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -206,6 +206,21 @@ public class SipUtils {
|
||||
|
||||
public static Gb28181Sdp parseSDP(String sdpStr) throws SdpParseException {
|
||||
|
||||
// 校验:拦截空内容与注入攻击特征
|
||||
if (sdpStr == null || sdpStr.trim().isEmpty()) {
|
||||
throw new SdpParseException(0, 0, "SDP内容为空");
|
||||
}
|
||||
// 标准SDP每行格式固定为 "x=value",不存在SQL关键字;出现则视为注入攻击
|
||||
String sdpUpper = sdpStr.toUpperCase();
|
||||
if (sdpUpper.contains("' OR '") || sdpUpper.contains("' OR 1") || sdpUpper.contains(" OR 1=1")
|
||||
|| sdpUpper.contains("--") || sdpUpper.contains("/*") || sdpUpper.contains("*/")
|
||||
|| sdpUpper.contains("DROP ") || sdpUpper.contains("INSERT ") || sdpUpper.contains("UPDATE ")
|
||||
|| sdpUpper.contains("DELETE ") || sdpUpper.contains("UNION ") || sdpUpper.contains("SELECT ")) {
|
||||
log.error("[SDP注入攻击] 检测到非法SDP内容,已拒绝解析,内容长度: {}", sdpStr.length());
|
||||
throw new SdpParseException(0, 0, "非法SDP内容");
|
||||
}
|
||||
//校验结束
|
||||
|
||||
// jainSip不支持y= f=字段, 移除以解析。
|
||||
int ssrcIndex = sdpStr.indexOf("y=");
|
||||
int mediaDescriptionIndex = sdpStr.indexOf("f=");
|
||||
|
||||
@ -7,10 +7,7 @@ import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.BasicParam;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceConfigAware;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SyncStatus;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user