2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-22 20:28:00 +00:00

add random ids!

This commit is contained in:
mohammed jasem alaajel 2021-05-17 22:42:57 +04:00 committed by GitHub
parent 4c1ffa2b01
commit 8df8d96ced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 5 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId>
<version>0.6.1</version>
<version>0.6.2</version>
<repositories>
<repository>

View File

@ -415,7 +415,13 @@ public final class RedisBungee extends Plugin {
final int redisPort = configuration.getInt("redis-port", 6379);
final boolean useSSL = configuration.getBoolean("useSSL");
String redisPassword = configuration.getString("redis-password");
String serverId = configuration.getString("server-id");
String serverId;
final String randomUUID = UUID.randomUUID().toString();
if (configuration.getBoolean("use-random-id-string", false)) {
serverId = configuration.getString("server-id") + "-" + randomUUID;
} else {
serverId = configuration.getString("server-id");
}
if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) {
redisPassword = null;
@ -475,7 +481,7 @@ public final class RedisBungee extends Plugin {
httpClient.setDispatcher(dispatcher);
NameFetcher.setHttpClient(httpClient);
UUIDFetcher.setHttpClient(httpClient);
RedisBungee.configuration = new RedisBungeeConfiguration(RedisBungee.this.getPool(), configuration);
RedisBungee.configuration = new RedisBungeeConfiguration(RedisBungee.this.getPool(), configuration, randomUUID);
return null;
}
});

View File

@ -8,6 +8,7 @@ import redis.clients.jedis.JedisPool;
import java.net.InetAddress;
import java.util.List;
import java.util.UUID;
public class RedisBungeeConfiguration {
@Getter
@ -19,9 +20,15 @@ public class RedisBungeeConfiguration {
@Getter
private final List<InetAddress> exemptAddresses;
public RedisBungeeConfiguration(JedisPool pool, Configuration configuration) {
public RedisBungeeConfiguration(JedisPool pool, Configuration configuration, String randomUUID) {
this.pool = pool;
if (configuration.getBoolean("use-random-id-string", false)) {
this.serverId = configuration.getString("server-id") + "-" + randomUUID;
} else {
this.serverId = configuration.getString("server-id");
}
this.registerBungeeCommands = configuration.getBoolean("register-bungee-commands", true);
List<String> stringified = configuration.getStringList("exempt-ip-addresses");
@ -33,4 +40,5 @@ public class RedisBungeeConfiguration {
this.exemptAddresses = addressBuilder.build();
}
}

View File

@ -16,8 +16,12 @@ max-redis-connections: 8
# you must disable this if redis version is under 6 you must disable this or connection wont work!!!
useSSL: false
# An identifier for this BungeeCord instance.
server-id: test1
# Should use random string? if enabled proxy id will be like this "test1-66cd2aeb-91f3-43a7-a106-e0307b098652"
# this great for servers who run replicas in Kubernetes or any auto deploying replica service
use-random-id-string: false
# Whether or not RedisBungee should install its version of regular BungeeCord commands.
# Often, the RedisBungee commands are desired, but in some cases someone may wish to