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