Skip to content

Commit

Permalink
feat: able to create cluster from servers behind NAT (#1513)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinshine committed Aug 22, 2023
1 parent 8f2d9b6 commit 1ec9918
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion server-core/src/main/java/io/onedev/server/OneDev.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ public void start() {
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (thread == null)
return;

manualConfigs = checkData();
if (manualConfigs.isEmpty()) {
initStage = new InitStage("Please wait...");
Expand Down Expand Up @@ -200,12 +203,14 @@ public void start() {
@Sessional
@Override
public void postStart() {
if (thread == null)
return;
SecurityUtils.bindAsSystem();
initStage = null;
listenerRegistry.post(new SystemStarted());
clusterManager.postStart();
thread.start();
logger.info("Server is ready at " + guessServerUrl());
logger.info("Server is ready at " + guessServerUrl());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ public void start() {
hasLocalhost = true;
else
hasNonLocalhost = true;
config.getNetworkConfig().getJoin().getTcpIpConfig().addMember(server);
if (!server.equals(localServer))
config.getNetworkConfig().getJoin().getTcpIpConfig().addMember(server);
}
if (hasLocalhost && hasNonLocalhost)
throw new ExplicitException("Invalid servers detected in cluster: loopback address should not be used");

config.getNetworkConfig().setPublicAddress(localServer);
hazelcastInstance = Hazelcast.newHazelcastInstance(config);

hazelcastInstance.getCluster().addMembershipListener(new MembershipListener() {
@Override
public void memberAdded(MembershipEvent membershipEvent) {
Expand Down

0 comments on commit 1ec9918

Please sign in to comment.