redis 增加配置控制是否调用config命令

This commit is contained in:
648540858 2021-12-20 15:14:34 +08:00
parent 5d88b97a7b
commit e5cdd60203
6 changed files with 45 additions and 6 deletions

View File

@ -27,6 +27,8 @@ public class UserSetup {
private Boolean logInDatebase = Boolean.TRUE; private Boolean logInDatebase = Boolean.TRUE;
private Boolean redisConfig = Boolean.TRUE;
private String serverId = "000000"; private String serverId = "000000";
private String thirdPartyGBIdReg = "[\\s\\S]*"; private String thirdPartyGBIdReg = "[\\s\\S]*";
@ -124,4 +126,12 @@ public class UserSetup {
public void setThirdPartyGBIdReg(String thirdPartyGBIdReg) { public void setThirdPartyGBIdReg(String thirdPartyGBIdReg) {
this.thirdPartyGBIdReg = thirdPartyGBIdReg; this.thirdPartyGBIdReg = thirdPartyGBIdReg;
} }
public Boolean getRedisConfig() {
return redisConfig;
}
public void setRedisConfig(Boolean redisConfig) {
this.redisConfig = redisConfig;
}
} }

View File

@ -3,7 +3,9 @@ package com.genersoft.iot.vmp.gb28181.event.offline;
import com.genersoft.iot.vmp.conf.UserSetup; import com.genersoft.iot.vmp.conf.UserSetup;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; 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.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.data.redis.listener.RedisMessageListenerContainer;
@ -28,11 +30,18 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa
@Autowired @Autowired
private UserSetup userSetup; private UserSetup userSetup;
public KeepaliveTimeoutListenerForPlatform(RedisMessageListenerContainer listenerContainer) { @Override
super(listenerContainer); public void init() {
if (!userSetup.getRedisConfig()) {
// 配置springboot默认Config为空即不让应用去修改redis的默认配置因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 // 配置springboot默认Config为空即不让应用去修改redis的默认配置因为Redis服务出于安全会禁用CONFIG命令给远程用户使用
setKeyspaceNotificationsConfigParameter(""); setKeyspaceNotificationsConfigParameter("");
} }
super.init();
}
public KeepaliveTimeoutListenerForPlatform(RedisMessageListenerContainer listenerContainer) {
super(listenerContainer);
}
/** /**

View File

@ -4,6 +4,8 @@ import com.genersoft.iot.vmp.conf.UserSetup;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.data.redis.listener.RedisMessageListenerContainer;
@ -28,11 +30,18 @@ public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener {
@Autowired @Autowired
private UserSetup userSetup; private UserSetup userSetup;
public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) { @Override
super(listenerContainer); public void init() {
if (!userSetup.getRedisConfig()) {
// 配置springboot默认Config为空即不让应用去修改redis的默认配置因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 // 配置springboot默认Config为空即不让应用去修改redis的默认配置因为Redis服务出于安全会禁用CONFIG命令给远程用户使用
setKeyspaceNotificationsConfigParameter(""); setKeyspaceNotificationsConfigParameter("");
} }
super.init();
}
public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) {
super(listenerContainer);
}
/** /**
* 监听失效的keykey格式为keeplive_deviceId * 监听失效的keykey格式为keeplive_deviceId

View File

@ -5,6 +5,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.common.VideoManagerConstants;

View File

@ -37,10 +37,17 @@ public class ZLMKeepliveTimeoutListener extends KeyExpirationEventMessageListene
@Autowired @Autowired
private IMediaServerService mediaServerService; private IMediaServerService mediaServerService;
@Override
public void init() {
if (!userSetup.getRedisConfig()) {
// 配置springboot默认Config为空即不让应用去修改redis的默认配置因为Redis服务出于安全会禁用CONFIG命令给远程用户使用
setKeyspaceNotificationsConfigParameter("");
}
super.init();
}
public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) { public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) {
super(listenerContainer); super(listenerContainer);
// 配置springboot默认Config为空即不让应用去修改redis的默认配置因为Redis服务出于安全会禁用CONFIG命令给远程用户使用
// setKeyspaceNotificationsConfigParameter("");
} }
/** /**

View File

@ -156,6 +156,8 @@ user-settings:
wait-track: false wait-track: false
# 是否开启接口鉴权 # 是否开启接口鉴权
interface-authentication: true interface-authentication: true
# 自动配置redis 可以过期事件
redis-config: true
# 接口鉴权例外的接口, 即不进行接口鉴权的接口,尽量详细书写,尽量不用/**,至少两级目录 # 接口鉴权例外的接口, 即不进行接口鉴权的接口,尽量详细书写,尽量不用/**,至少两级目录
interface-authentication-excludes: interface-authentication-excludes:
- /api/v1/** - /api/v1/**