Commit 89956873d7ade2d1cc04c9fc691ad63812f196f7
1 parent
34469264
redis 增加配置控制是否调用config命令
Showing
6 changed files
with
45 additions
and
6 deletions
src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java
| ... | ... | @@ -27,6 +27,8 @@ public class UserSetup { |
| 27 | 27 | |
| 28 | 28 | private Boolean logInDatebase = Boolean.TRUE; |
| 29 | 29 | |
| 30 | + private Boolean redisConfig = Boolean.TRUE; | |
| 31 | + | |
| 30 | 32 | private String serverId = "000000"; |
| 31 | 33 | |
| 32 | 34 | private String thirdPartyGBIdReg = "[\\s\\S]*"; |
| ... | ... | @@ -124,4 +126,12 @@ public class UserSetup { |
| 124 | 126 | public void setThirdPartyGBIdReg(String thirdPartyGBIdReg) { |
| 125 | 127 | this.thirdPartyGBIdReg = thirdPartyGBIdReg; |
| 126 | 128 | } |
| 129 | + | |
| 130 | + public Boolean getRedisConfig() { | |
| 131 | + return redisConfig; | |
| 132 | + } | |
| 133 | + | |
| 134 | + public void setRedisConfig(Boolean redisConfig) { | |
| 135 | + this.redisConfig = redisConfig; | |
| 136 | + } | |
| 127 | 137 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java
| ... | ... | @@ -3,7 +3,9 @@ package com.genersoft.iot.vmp.gb28181.event.offline; |
| 3 | 3 | import com.genersoft.iot.vmp.conf.UserSetup; |
| 4 | 4 | import org.slf4j.Logger; |
| 5 | 5 | import org.slf4j.LoggerFactory; |
| 6 | +import org.springframework.beans.factory.InitializingBean; | |
| 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | +import org.springframework.context.annotation.DependsOn; | |
| 7 | 9 | import org.springframework.data.redis.connection.Message; |
| 8 | 10 | import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; |
| 9 | 11 | import org.springframework.data.redis.listener.RedisMessageListenerContainer; |
| ... | ... | @@ -28,10 +30,17 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa |
| 28 | 30 | @Autowired |
| 29 | 31 | private UserSetup userSetup; |
| 30 | 32 | |
| 33 | + @Override | |
| 34 | + public void init() { | |
| 35 | + if (!userSetup.getRedisConfig()) { | |
| 36 | + // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 | |
| 37 | + setKeyspaceNotificationsConfigParameter(""); | |
| 38 | + } | |
| 39 | + super.init(); | |
| 40 | + } | |
| 41 | + | |
| 31 | 42 | public KeepaliveTimeoutListenerForPlatform(RedisMessageListenerContainer listenerContainer) { |
| 32 | 43 | super(listenerContainer); |
| 33 | - // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 | |
| 34 | - setKeyspaceNotificationsConfigParameter(""); | |
| 35 | 44 | } |
| 36 | 45 | |
| 37 | 46 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java
| ... | ... | @@ -4,6 +4,8 @@ import com.genersoft.iot.vmp.conf.UserSetup; |
| 4 | 4 | import org.slf4j.Logger; |
| 5 | 5 | import org.slf4j.LoggerFactory; |
| 6 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | +import org.springframework.context.annotation.DependsOn; | |
| 8 | +import org.springframework.context.annotation.Lazy; | |
| 7 | 9 | import org.springframework.data.redis.connection.Message; |
| 8 | 10 | import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; |
| 9 | 11 | import org.springframework.data.redis.listener.RedisMessageListenerContainer; |
| ... | ... | @@ -28,10 +30,17 @@ public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener { |
| 28 | 30 | @Autowired |
| 29 | 31 | private UserSetup userSetup; |
| 30 | 32 | |
| 33 | + @Override | |
| 34 | + public void init() { | |
| 35 | + if (!userSetup.getRedisConfig()) { | |
| 36 | + // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 | |
| 37 | + setKeyspaceNotificationsConfigParameter(""); | |
| 38 | + } | |
| 39 | + super.init(); | |
| 40 | + } | |
| 41 | + | |
| 31 | 42 | public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) { |
| 32 | 43 | super(listenerContainer); |
| 33 | - // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 | |
| 34 | - setKeyspaceNotificationsConfigParameter(""); | |
| 35 | 44 | } |
| 36 | 45 | |
| 37 | 46 | /** | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java
| ... | ... | @@ -5,6 +5,8 @@ import org.slf4j.Logger; |
| 5 | 5 | import org.slf4j.LoggerFactory; |
| 6 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | 7 | import org.springframework.context.ApplicationListener; |
| 8 | +import org.springframework.context.annotation.DependsOn; | |
| 9 | +import org.springframework.context.annotation.Lazy; | |
| 8 | 10 | import org.springframework.stereotype.Component; |
| 9 | 11 | |
| 10 | 12 | import com.genersoft.iot.vmp.common.VideoManagerConstants; | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java
| ... | ... | @@ -37,10 +37,17 @@ public class ZLMKeepliveTimeoutListener extends KeyExpirationEventMessageListene |
| 37 | 37 | @Autowired |
| 38 | 38 | private IMediaServerService mediaServerService; |
| 39 | 39 | |
| 40 | + @Override | |
| 41 | + public void init() { | |
| 42 | + if (!userSetup.getRedisConfig()) { | |
| 43 | + // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 | |
| 44 | + setKeyspaceNotificationsConfigParameter(""); | |
| 45 | + } | |
| 46 | + super.init(); | |
| 47 | + } | |
| 48 | + | |
| 40 | 49 | public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) { |
| 41 | 50 | super(listenerContainer); |
| 42 | - // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 | |
| 43 | -// setKeyspaceNotificationsConfigParameter(""); | |
| 44 | 51 | } |
| 45 | 52 | |
| 46 | 53 | /** | ... | ... |
src/main/resources/all-application.yml
| ... | ... | @@ -156,6 +156,8 @@ user-settings: |
| 156 | 156 | wait-track: false |
| 157 | 157 | # 是否开启接口鉴权 |
| 158 | 158 | interface-authentication: true |
| 159 | + # 自动配置redis 可以过期事件 | |
| 160 | + redis-config: true | |
| 159 | 161 | # 接口鉴权例外的接口, 即不进行接口鉴权的接口,尽量详细书写,尽量不用/**,至少两级目录 |
| 160 | 162 | interface-authentication-excludes: |
| 161 | 163 | - /api/v1/** | ... | ... |