mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-12-23 02:28:01 +00:00
add ability to use redisbungee with acl username (#69)
This commit is contained in:
parent
c5040c9348
commit
73879640e5
@ -12,7 +12,6 @@ package com.imaginarycode.minecraft.redisbungee.api.config;
|
||||
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||
@ -54,6 +53,7 @@ public interface ConfigLoader {
|
||||
final boolean registerLegacyCommands = node.getNode("register-legacy-commands").getBoolean(false);
|
||||
final boolean restoreOldKickBehavior = node.getNode("disable-kick-when-online").getBoolean(false);
|
||||
String redisPassword = node.getNode("redis-password").getString("");
|
||||
String redisUsername = node.getNode("redis-username").getString("");
|
||||
String proxyId = node.getNode("proxy-id").getString("test-1");
|
||||
final int maxConnections = node.getNode("max-redis-connections").getInt(10);
|
||||
List<String> exemptAddresses;
|
||||
@ -68,6 +68,11 @@ public interface ConfigLoader {
|
||||
redisPassword = null;
|
||||
plugin.logWarn("password is empty");
|
||||
}
|
||||
if ((redisUsername.isEmpty() || redisUsername.equals("none"))) {
|
||||
redisUsername = null;
|
||||
plugin.logWarn("password is empty");
|
||||
}
|
||||
|
||||
if (useSSL) {
|
||||
plugin.logInfo("Using ssl");
|
||||
}
|
||||
@ -101,7 +106,7 @@ public interface ConfigLoader {
|
||||
if (hostAndPortSet.isEmpty()) {
|
||||
throw new RuntimeException("No redis cluster servers specified");
|
||||
}
|
||||
summoner = new JedisClusterSummoner(new ClusterConnectionProvider(hostAndPortSet, DefaultJedisClientConfig.builder().password(redisPassword).ssl(useSSL).socketTimeoutMillis(5000).timeoutMillis(10000).build(), poolConfig));
|
||||
summoner = new JedisClusterSummoner(new ClusterConnectionProvider(hostAndPortSet, DefaultJedisClientConfig.builder().user(redisUsername).password(redisPassword).ssl(useSSL).socketTimeoutMillis(5000).timeoutMillis(10000).build(), poolConfig));
|
||||
redisBungeeMode = RedisBungeeMode.CLUSTER;
|
||||
} else {
|
||||
plugin.logInfo("RedisBungee MODE: SINGLE");
|
||||
@ -115,13 +120,13 @@ public interface ConfigLoader {
|
||||
JedisPoolConfig config = new JedisPoolConfig();
|
||||
config.setMaxTotal(node.getNode("compatibility-max-connections").getInt(3));
|
||||
config.setBlockWhenExhausted(true);
|
||||
jedisPool = new JedisPool(config, redisServer, redisPort, 5000, redisPassword, useSSL);
|
||||
jedisPool = new JedisPool(config, redisServer, redisPort, 5000, redisUsername, redisPassword, useSSL);
|
||||
plugin.logInfo("Compatibility JedisPool was created");
|
||||
}
|
||||
GenericObjectPoolConfig<Connection> poolConfig = new GenericObjectPoolConfig<>();
|
||||
poolConfig.setMaxTotal(maxConnections);
|
||||
poolConfig.setBlockWhenExhausted(true);
|
||||
summoner = new JedisPooledSummoner(new PooledConnectionProvider(new ConnectionFactory(new HostAndPort(redisServer, redisPort), DefaultJedisClientConfig.builder().timeoutMillis(5000).ssl(useSSL).password(redisPassword).build()), poolConfig), jedisPool);
|
||||
summoner = new JedisPooledSummoner(new PooledConnectionProvider(new ConnectionFactory(new HostAndPort(redisServer, redisPort), DefaultJedisClientConfig.builder().user(redisUsername).timeoutMillis(5000).ssl(useSSL).password(redisPassword).build()), poolConfig), jedisPool);
|
||||
redisBungeeMode = RedisBungeeMode.SINGLE;
|
||||
}
|
||||
plugin.logInfo("Successfully connected to Redis.");
|
||||
|
@ -1,4 +1,5 @@
|
||||
# RedisBungee configuration file.
|
||||
# Get Redis from http://redis.io/
|
||||
|
||||
# Cluster Mode
|
||||
# enabling this option will enable cluster mode.
|
||||
@ -19,14 +20,18 @@ redis-cluster-servers:
|
||||
- host: 127.0.0.1
|
||||
port: 6379
|
||||
|
||||
# Get Redis from http://redis.io/
|
||||
# The Redis server you use.
|
||||
# these settings are ignored when cluster mode is enabled.
|
||||
redis-server: 127.0.0.1
|
||||
redis-port: 6379
|
||||
|
||||
# THIS FEATURE IS REDIS V6+
|
||||
# OPTIONAL: if your redis uses acl usernames set the username here. leave empty for no username.
|
||||
redis-username: ""
|
||||
|
||||
# OPTIONAL but recommended: If your Redis server uses AUTH, set the password required.
|
||||
redis-password: ""
|
||||
|
||||
# Maximum connections that will be maintained to the Redis server.
|
||||
# The default is 10. This setting should be left as-is unless you have some wildly
|
||||
# inefficient plugins or a lot of players.
|
||||
|
Loading…
Reference in New Issue
Block a user