Skip to content

Commit

Permalink
add random ids!
Browse files Browse the repository at this point in the history
  • Loading branch information
ham1255 committed May 17, 2021
1 parent 4c1ffa2 commit 8df8d96
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId>
<version>0.6.1</version>
<version>0.6.2</version>

<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,13 @@ private void loadConfig() throws IOException, JedisConnectionException {
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;
Expand Down Expand Up @@ -475,7 +481,7 @@ public Void call() throws Exception {
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;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.net.InetAddress;
import java.util.List;
import java.util.UUID;

public class RedisBungeeConfiguration {
@Getter
Expand All @@ -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;
this.serverId = configuration.getString("server-id");
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");
Expand All @@ -33,4 +40,5 @@ public RedisBungeeConfiguration(JedisPool pool, Configuration configuration) {

this.exemptAddresses = addressBuilder.build();
}

}
4 changes: 4 additions & 0 deletions src/main/resources/example_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8df8d96

Please sign in to comment.