From 89956873d7ade2d1cc04c9fc691ad63812f196f7 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 20 Dec 2021 15:14:34 +0800 Subject: [PATCH] =?UTF-8?q?redis=20=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E6=98=AF=E5=90=A6=E8=B0=83=E7=94=A8config?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/genersoft/iot/vmp/conf/UserSetup.java | 10 ++++++++++ .../KeepaliveTimeoutListenerForPlatform.java | 13 +++++++++++-- .../event/offline/KeepliveTimeoutListener.java | 13 +++++++++++-- .../gb28181/event/offline/OfflineEventListener.java | 2 ++ .../media/zlm/event/ZLMKeepliveTimeoutListener.java | 11 +++++++++-- src/main/resources/all-application.yml | 2 ++ 6 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java index 140295e8..8a4c021f 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java @@ -27,6 +27,8 @@ public class UserSetup { private Boolean logInDatebase = Boolean.TRUE; + private Boolean redisConfig = Boolean.TRUE; + private String serverId = "000000"; private String thirdPartyGBIdReg = "[\\s\\S]*"; @@ -124,4 +126,12 @@ public class UserSetup { public void setThirdPartyGBIdReg(String thirdPartyGBIdReg) { this.thirdPartyGBIdReg = thirdPartyGBIdReg; } + + public Boolean getRedisConfig() { + return redisConfig; + } + + public void setRedisConfig(Boolean redisConfig) { + this.redisConfig = redisConfig; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java index 08815682..8bbf03ee 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java @@ -3,7 +3,9 @@ package com.genersoft.iot.vmp.gb28181.event.offline; import com.genersoft.iot.vmp.conf.UserSetup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.DependsOn; import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; import org.springframework.data.redis.listener.RedisMessageListenerContainer; @@ -28,10 +30,17 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa @Autowired private UserSetup userSetup; + @Override + public void init() { + if (!userSetup.getRedisConfig()) { + // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 + setKeyspaceNotificationsConfigParameter(""); + } + super.init(); + } + public KeepaliveTimeoutListenerForPlatform(RedisMessageListenerContainer listenerContainer) { super(listenerContainer); - // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 - setKeyspaceNotificationsConfigParameter(""); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java index 95a8ba98..7b3cb589 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java @@ -4,6 +4,8 @@ import com.genersoft.iot.vmp.conf.UserSetup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.DependsOn; +import org.springframework.context.annotation.Lazy; import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; import org.springframework.data.redis.listener.RedisMessageListenerContainer; @@ -28,10 +30,17 @@ public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener { @Autowired private UserSetup userSetup; + @Override + public void init() { + if (!userSetup.getRedisConfig()) { + // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 + setKeyspaceNotificationsConfigParameter(""); + } + super.init(); + } + public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) { super(listenerContainer); - // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 - setKeyspaceNotificationsConfigParameter(""); } /** diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java index 0f5604c0..9751915e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java @@ -5,6 +5,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; +import org.springframework.context.annotation.DependsOn; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import com.genersoft.iot.vmp.common.VideoManagerConstants; diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java index eaf8bbbb..3fc6a3ca 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java @@ -37,10 +37,17 @@ public class ZLMKeepliveTimeoutListener extends KeyExpirationEventMessageListene @Autowired private IMediaServerService mediaServerService; + @Override + public void init() { + if (!userSetup.getRedisConfig()) { + // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 + setKeyspaceNotificationsConfigParameter(""); + } + super.init(); + } + public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) { super(listenerContainer); - // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 -// setKeyspaceNotificationsConfigParameter(""); } /** diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index 20587424..a9d7a080 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -156,6 +156,8 @@ user-settings: wait-track: false # 是否开启接口鉴权 interface-authentication: true + # 自动配置redis 可以过期事件 + redis-config: true # 接口鉴权例外的接口, 即不进行接口鉴权的接口,尽量详细书写,尽量不用/**,至少两级目录 interface-authentication-excludes: - /api/v1/**